From 66dcb36e724a079be5e9b619887c7960804ae64a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Sat, 29 Mar 2025 22:06:34 +0100 Subject: [PATCH] Add command "next" to schema --- src/c_next.c | 5 ++--- src/schema_mode.c | 11 +++++++++++ src/sim_main.c | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/c_next.c b/src/c_next.c index 2bf6a81..ef86bb6 100644 --- a/src/c_next.c +++ b/src/c_next.c @@ -7,15 +7,14 @@ int c_next(t_input input, t_vec *nodes, t_vec *mosfets) if (input.argc == 0) { - if (!sim_step(nodes, mosfets)) - return (0); + return (!sim_step(nodes, mosfets)); } else if (input.argc == 1 && input.argv[0].type == num) { i = 0; while (i < input.argv[0].val.num) { - if (!sim_step(nodes, mosfets)) + if (sim_step(nodes, mosfets)) return (0); ++i; } diff --git a/src/schema_mode.c b/src/schema_mode.c index fb66c2d..7e4d738 100644 --- a/src/schema_mode.c +++ b/src/schema_mode.c @@ -338,6 +338,15 @@ void schema_switch_mode(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, t_ return ; } +int schema_next(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, t_position pos) +{ + if (sim_step(nodes, mosfets)) + return (1); + refresh_schema_win(schematics_win, nodes, mosfets); + wmove(schematics_win, pos.y, pos.x); + return (0); +} + int handle_key_press(int ch, WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets) { t_position pos; @@ -357,6 +366,8 @@ int handle_key_press(int ch, WINDOW *schematics_win, t_vec *nodes, t_vec *mosfet schema_user_draw_node(schematics_win, nodes, mosfets, pos); else if (ch == 's') schema_switch_mode(schematics_win, nodes, mosfets, pos); + else if (ch == 'n') + schema_next(schematics_win, nodes, mosfets, pos); return (0); } diff --git a/src/sim_main.c b/src/sim_main.c index cb52bf1..a624dcf 100644 --- a/src/sim_main.c +++ b/src/sim_main.c @@ -29,5 +29,5 @@ int sim_step(t_vec *nodes, t_vec *mosfets) { update_mosfets(nodes, mosfets); update_nodes(nodes, mosfets); - return (1); + return (0); } -- 2.30.2