@@ -35,16 +35,19 @@ def read_serial(ser, log_lines, log_lock):
3535 log_lines .append (f"[Serial Error] { e } " )
3636 time .sleep (0.05 )
3737
38- def curses_main (stdscr , port , baudrate ):
38+ def curses_main (stdscr , port , baudrate , filter_start = None ):
3939 global stop_thread
4040 curses .curs_set (1 )
4141 stdscr .nodelay (True )
4242 stdscr .timeout (100 )
4343
44+ if filter_start is None :
45+ filter_start = ["SET;POS" ]
46+
4447 log_lines = []
4548 log_lock = threading .Lock ()
4649 cmd_history = []
47- history_index = - 1 # For navigating command history
50+ history_index = - 1
4851
4952 with serial .Serial (port , baudrate , timeout = 1 ) as ser :
5053 time .sleep (2 )
@@ -57,24 +60,36 @@ def curses_main(stdscr, port, baudrate):
5760 stdscr .clear ()
5861 h , w = stdscr .getmaxyx ()
5962
60- # Split screen horizontally (70% logs, 30% command history)
61- split_x = int (w * 0.7 )
63+ # --- Split into 3 vertical columns ---
64+ col_width = w // 3
65+ col1_x = 0
66+ col2_x = col_width
67+ col3_x = 2 * col_width
68+
6269 log_height = h - 2
6370
64- # --- Left panel: logs ---
71+ # --- Separate logs into filtered and others ---
6572 with log_lock :
66- visible_logs = log_lines [- log_height :]
67- for i , line in enumerate (visible_logs ):
68- stdscr .addnstr (i , 0 , line , split_x - 1 )
69-
70- # --- Right panel: command history ---
71- stdscr .vline (0 , split_x , "|" , log_height )
72- history_start_x = split_x + 2
73- stdscr .addstr (0 , history_start_x , "Command History:" )
74-
75- visible_history = cmd_history [- (log_height - 2 ):]
73+ filtered_logs = [line for line in log_lines if any (line .startswith (p ) for p in filter_start )]
74+ other_logs = [line for line in log_lines if not any (line .startswith (p ) for p in filter_start )]
75+ visible_filtered = filtered_logs [- log_height :]
76+ visible_other = other_logs [- log_height :]
77+ visible_history = cmd_history [- log_height :]
78+
79+ # --- Column 1: Filtered serial output ---
80+ stdscr .addstr (0 , col1_x , f"Filtered ({ ', ' .join (filter_start )} ):" )
81+ for i , line in enumerate (visible_filtered ):
82+ stdscr .addnstr (i + 1 , col1_x , line , col_width - 1 )
83+
84+ # --- Column 2: Other serial output ---
85+ stdscr .addstr (0 , col2_x , "Other Logs:" )
86+ for i , line in enumerate (visible_other ):
87+ stdscr .addnstr (i + 1 , col2_x , line , col_width - 1 )
88+
89+ # --- Column 3: Command history ---
90+ stdscr .addstr (0 , col3_x , "Command History:" )
7691 for i , cmd in enumerate (visible_history ):
77- stdscr .addnstr (i + 1 , history_start_x , cmd , w - history_start_x - 1 )
92+ stdscr .addnstr (i + 1 , col3_x , cmd , col_width - 1 )
7893
7994 # --- Input line ---
8095 stdscr .addstr (log_height , 0 , "-" * (w - 1 ))
0 commit comments