From c2dd165ef0abdac5037b7025baeacbbfe5e93e42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Sun, 3 Mar 2024 11:57:51 +0100 Subject: [PATCH] Add non-canonical mode to the sim I want vim-esque modes to switch between schematics and commands. This is the first step, but it makes FET_sim unsuable as it is now, because input is not echoed back - one does not see what one enters. Function get_next_line is not really suitable for non-canonical mode, so an alternative (capable of parsing single char input, arrow keys etc.) needs to be implemented. --- TODO | 14 ++++++++++++++ src/terminal.c | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/TODO b/TODO index f80ad08..91dfe5c 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,14 @@ TODO +implement vim-esque modes and gdb-like split screen/window for commands and schematics (TUI?) + implement new method of input - echoing commands, moving cursor and more + implement "split screen" - one for commands, one for schematics (gdb like) + commands screen should work just similarly to normal terminal usage + schematics should use vim like controls + each is controllable from a "mode" (at least 2 modes necessary, more may be usefull later on) +make it possible to save schematics and use them again + use blocks to "condense" the schematics - similar to integrated parts + make blocks' schematics openable in another split screen (vim like split command?) + a block opened in another screen should show current simulation state as a part of the whole simulation (or maybe a switch between free mode and bound mode?) make build_graph not output rewrite command parsing (what I've created is just ugly) come up with better file structure @@ -11,6 +21,10 @@ optimize pass 42 norminette DONE +implement vim-esque modes and gdb-like split screen/window for commands and schematics (TUI?) + implement new method of input - echoing commands, moving cursor and more + use alternate screen + implement non-canonical mode rewrite t_fet and t_node to store indexes insted of pointers to connected parts - goal shifted a bit, nodes store their ID and FETs have no use for havind ID so far foundations of logic diff --git a/src/terminal.c b/src/terminal.c index d1252a6..1b97709 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1,18 +1,38 @@ #include "FET_sim.h" #include "libft.h" +#include +#include // for STDIN_FILENO +#include static const char alt_term_on[] = "\033[?1049h"; static const char alt_term_off[] = "\033[?1049l"; +static struct termios init_termios_set; + +static void termios_settings(void) +{ + struct termios termios_set; + + tcgetattr(STDIN_FILENO, &termios_set); + tcgetattr(STDIN_FILENO, &init_termios_set); + termios_set.c_lflag &= !ICANON; + termios_set.c_cc[VMIN] = 1; + termios_set.c_cc[VTIME] = 0; + tcsetattr(STDIN_FILENO, TCSANOW, &termios_set); + return ; +} + void setup_terminal(void) { ft_printf("%s", alt_term_on); ft_printf("\033[H"); + termios_settings(); return ; } void clean_terminal(void) { ft_printf("%s", alt_term_off); + tcsetattr(STDIN_FILENO, TCSANOW, &init_termios_set); return ; } -- 2.30.2