From fdeb97233061d0a30105ef01394a39298b500aa8 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:14:40 +0100 Subject: [PATCH] Add switch in reverse order to schema mode --- src/schema_mode.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/schema_mode.c b/src/schema_mode.c index 7e4d738..4b3f85e 100644 --- a/src/schema_mode.c +++ b/src/schema_mode.c @@ -321,7 +321,7 @@ void schema_user_draw_node(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, return ; } -void schema_switch_mode(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, t_position pos) +void schema_switch_node(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, t_position pos) { t_node *chosen_node; @@ -338,6 +338,23 @@ void schema_switch_mode(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, t_ return ; } +void schema_reverse_switch_node(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, t_position pos) +{ + t_node *chosen_node; + + chosen_node = find_node_at_pos(nodes, pos); + if (!chosen_node) + return ; + if (chosen_node->set_state == off) + chosen_node->set_state = unknown; + else + --chosen_node->set_state; + update_nodes(nodes, mosfets); + refresh_schema_win(schematics_win, nodes, mosfets); + wmove(schematics_win, pos.y, pos.x); + return ; +} + int schema_next(WINDOW *schematics_win, t_vec *nodes, t_vec *mosfets, t_position pos) { if (sim_step(nodes, mosfets)) @@ -365,7 +382,9 @@ int handle_key_press(int ch, WINDOW *schematics_win, t_vec *nodes, t_vec *mosfet else if (ch == 'c') schema_user_draw_node(schematics_win, nodes, mosfets, pos); else if (ch == 's') - schema_switch_mode(schematics_win, nodes, mosfets, pos); + schema_switch_node(schematics_win, nodes, mosfets, pos); + else if (ch == 'S') + schema_reverse_switch_node(schematics_win, nodes, mosfets, pos); else if (ch == 'n') schema_next(schematics_win, nodes, mosfets, pos); return (0); -- 2.30.2