@@ -130,6 +130,7 @@ def show_status(self, message: str):
130130 self .status_message = message
131131 self .status_timeout = time .time () + 3.0
132132
133+
133134def curses_main (stdscr , node ):
134135 stdscr .nodelay (True )
135136 curses .curs_set (0 )
@@ -230,7 +231,8 @@ def curses_main(stdscr, node):
230231 if len (parts ) >= 1 :
231232 hz = float (parts [0 ])
232233 tolerance = float (parts [1 ]) if len (parts ) > 1 else 5.0
233- success , msg = node .ui_adaptor .set_expected_frequency (topic_name , hz , tolerance )
234+ success , msg = node .ui_adaptor .set_expected_frequency (
235+ topic_name , hz , tolerance )
234236 status_message = f"Set frequency for { topic_name } : { hz } Hz"
235237 if not success :
236238 status_message = f"Error: { msg } "
@@ -265,7 +267,8 @@ def curses_main(stdscr, node):
265267 elif key == curses .KEY_NPAGE : # Page Down
266268 visible_height = height - 5
267269 if len (node .visible_topics ) > 0 :
268- start_idx = min (len (node .visible_topics ) - visible_height , start_idx + visible_height )
270+ start_idx = min (len (node .visible_topics ) - visible_height ,
271+ start_idx + visible_height )
269272 selected_row = min (len (node .visible_topics ) - 1 , selected_row + visible_height )
270273 elif key == ord ('q' ) or key == ord ('Q' ):
271274 break
@@ -282,7 +285,8 @@ def curses_main(stdscr, node):
282285 elif key == ord ('c' ) or key == ord ('C' ):
283286 if 0 <= selected_row < len (node .visible_topics ):
284287 topic_name = node .visible_topics [selected_row ]
285- success , msg = node .ui_adaptor .set_expected_frequency (topic_name , clear = True )
288+ success , msg = node .ui_adaptor .set_expected_frequency (
289+ topic_name , clear = True )
286290 status_message = f"Cleared frequency for { topic_name } "
287291 if not success :
288292 status_message = f"Error: { msg } "
@@ -327,8 +331,11 @@ def curses_main(stdscr, node):
327331 if diag .status != '-' :
328332 is_monitored = True
329333 status_display = diag .status # Use actual diagnostic status
330- frame_rate_node = diag .pub_rate .ljust (FRAME_RATE_WIDTH ) if diag .pub_rate != '-' else 'N/A' .ljust (FRAME_RATE_WIDTH )
331- current_delay_from_realtime_ms = diag .latency .ljust (REALTIME_DELAY_WIDTH ) if diag .latency != '-' else 'N/A' .ljust (REALTIME_DELAY_WIDTH )
334+ frame_rate_node = (diag .pub_rate .ljust (FRAME_RATE_WIDTH )
335+ if diag .pub_rate != '-' else 'N/A' .ljust (FRAME_RATE_WIDTH ))
336+ current_delay_from_realtime_ms = (
337+ diag .latency .ljust (REALTIME_DELAY_WIDTH )
338+ if diag .latency != '-' else 'N/A' .ljust (REALTIME_DELAY_WIDTH ))
332339
333340 # Get expected frequency
334341 expected_hz , tolerance = node .ui_adaptor .get_expected_frequency (topic_name )
@@ -365,14 +372,16 @@ def curses_main(stdscr, node):
365372
366373 try :
367374 is_selected = (actual_idx == selected_row )
368- stdscr .addstr (idx + 2 , 0 , line , curses .A_REVERSE if is_selected else color_pair )
375+ stdscr .addstr (idx + 2 , 0 , line ,
376+ curses .A_REVERSE if is_selected else color_pair )
369377
370378 # Draw button
371379 button_text = ' [Remove] ' if is_monitored else ' [Add] '
372380 button_x = width - len (button_text ) - 1
373381
374382 if is_selected :
375- button_color = curses .color_pair (COLOR_ERROR ) if is_monitored else curses .color_pair (COLOR_BUTTON_ADD )
383+ button_color = (curses .color_pair (COLOR_ERROR ) if is_monitored
384+ else curses .color_pair (COLOR_BUTTON_ADD ))
376385 else :
377386 button_color = curses .color_pair (COLOR_WARN )
378387 stdscr .addstr (idx + 2 , button_x , button_text , button_color )
@@ -385,29 +394,33 @@ def curses_main(stdscr, node):
385394 if start_idx > 0 :
386395 stdscr .addstr (2 , width - BUTTON_WIDTH - 3 , '↑' )
387396 if start_idx + visible_height < len (visible_topics ):
388- stdscr .addstr (min (height - 3 , 2 + visible_height ), width - BUTTON_WIDTH - 3 , '↓' )
397+ stdscr .addstr (min (height - 3 , 2 + visible_height ),
398+ width - BUTTON_WIDTH - 3 , '↓' )
389399 except curses .error :
390400 pass
391401
392402 # Status message
393403 if current_time < status_timeout :
394404 try :
395- stdscr .addstr (height - 3 , 0 , status_message [:width - 1 ], curses .color_pair (COLOR_STATUS_MSG ))
405+ stdscr .addstr (height - 3 , 0 , status_message [:width - 1 ],
406+ curses .color_pair (COLOR_STATUS_MSG ))
396407 except curses .error :
397408 pass
398409
399410 # Show node status message
400411 if current_time < node .status_timeout :
401412 try :
402- stdscr .addstr (height - 3 , 0 , node .status_message [:width - 1 ], curses .color_pair (COLOR_STATUS_MSG ))
413+ stdscr .addstr (height - 3 , 0 , node .status_message [:width - 1 ],
414+ curses .color_pair (COLOR_STATUS_MSG ))
403415 except curses .error :
404416 pass
405417
406418 # Input prompt (if in input mode)
407419 if input_mode :
408420 try :
409421 prompt = f"Set frequency: { input_buffer } "
410- stdscr .addstr (height - 3 , 0 , prompt [:width - 1 ], curses .color_pair (COLOR_STATUS_MSG ))
422+ stdscr .addstr (height - 3 , 0 , prompt [:width - 1 ],
423+ curses .color_pair (COLOR_STATUS_MSG ))
411424 # Position cursor after the input
412425 cursor_x = len (prompt )
413426 if cursor_x < width - 1 :
@@ -421,12 +434,14 @@ def curses_main(stdscr, node):
421434 # Footer
422435 num_shown = min (start_idx + len (visible_topics_slice ), len (visible_topics ))
423436 if input_mode :
424- status_line = "Format: Hz [tolerance%] - Examples: '30' (30Hz±5% default) or '30 10' (30Hz±10%) - ESC=cancel, Enter=confirm"
437+ status_line = ("Format: Hz [tolerance%] - Examples: '30' (30Hz±5% default) "
438+ "or '30 10' (30Hz±10%) - ESC=cancel, Enter=confirm" )
425439 else :
426440 mode_text = "monitored only" if node .show_only_monitored else "all topics"
427441 status_line = (
428- f'Showing { start_idx + 1 } - { num_shown } of { len (visible_topics )} topics ({ mode_text } ). '
429- f'Enter=toggle, f=set freq, c=clear freq, h=hide unmonitored, q=quit' )
442+ f'Showing { start_idx + 1 } - { num_shown } of { len (visible_topics )} '
443+ f'topics ({ mode_text } ). Enter=toggle, f=set freq, c=clear freq, '
444+ f'h=hide unmonitored, q=quit' )
430445
431446 try :
432447 stdscr .addstr (height - 2 , 0 , status_line [:width - 1 ])
@@ -452,4 +467,4 @@ def main(args=None):
452467
453468
454469if __name__ == '__main__' :
455- main ()
470+ main ()
0 commit comments