From: Lukáš Jiřiště Date: Sat, 29 Mar 2025 21:06:34 +0000 (+0100) Subject: Add command "next" to schema X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=66dcb36e724a079be5e9b619887c7960804ae64a;p=FET_sim.git Add command "next" to schema --- 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); }