refactor: Simplify warning message drawing and error handling in curses
This commit is contained in:
parent
6b84f1fc2b
commit
3b01821ed4
30
gtm
30
gtm
|
|
@ -911,27 +911,21 @@ def draw_warning_message(stdscr, state: AppState, layout: StatusBarLayout):
|
|||
if not state.warning_message:
|
||||
return
|
||||
|
||||
try:
|
||||
# Initialize color pair for warning if not already done
|
||||
if curses.has_colors():
|
||||
try:
|
||||
curses.init_pair(8, curses.COLOR_RED, -1) # Red text on default background
|
||||
except:
|
||||
pass # Silently fail if we can't set the color
|
||||
# Initialize color pair for warning if not already done
|
||||
if curses.has_colors():
|
||||
curses.init_pair(8, curses.COLOR_RED, -1) # Red text on default background
|
||||
|
||||
# Use red text with bold for warning
|
||||
warning_attr = curses.color_pair(8) | curses.A_BOLD
|
||||
# Use red text with bold for warning
|
||||
warning_attr = curses.color_pair(8) | curses.A_BOLD
|
||||
|
||||
# Draw the warning message and dismiss instruction all in red
|
||||
warning_text = f" WARNING: {state.warning_message} "
|
||||
stdscr.addstr(layout.main_status_y, 0, warning_text, warning_attr)
|
||||
# Draw the warning message and dismiss instruction all in red
|
||||
warning_text = f" WARNING: {state.warning_message} "
|
||||
stdscr.addstr(layout.main_status_y, 0, warning_text, warning_attr)
|
||||
|
||||
# Add instruction to dismiss, also in red
|
||||
dismiss_text = " (Press any key to dismiss) "
|
||||
if len(warning_text) + len(dismiss_text) < layout.screen_width:
|
||||
stdscr.addstr(layout.main_status_y, len(warning_text), dismiss_text, warning_attr)
|
||||
except curses.error:
|
||||
pass # Silently fail if we can't draw the warning
|
||||
# Add instruction to dismiss, also in red
|
||||
dismiss_text = " (Press any key to dismiss) "
|
||||
if len(warning_text) + len(dismiss_text) < layout.screen_width:
|
||||
stdscr.addstr(layout.main_status_y, len(warning_text), dismiss_text, warning_attr)
|
||||
|
||||
def draw_main_status_line(stdscr, state: AppState, layout: StatusBarLayout):
|
||||
"""Draw the main status line (percentages, indicators, etc.)"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue