feat: add colored status bars with focus-based highlighting

This commit is contained in:
n loewen (aider) 2025-05-05 09:22:39 +01:00
parent bc6ec6d847
commit 0025c4e437
1 changed files with 18 additions and 4 deletions

View File

@ -23,6 +23,8 @@ def main(stdscr, filename):
# Initialize colors if terminal supports them
if curses.has_colors():
curses.use_default_colors() # Use terminal's default colors
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) # Focused status bar
curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLUE) # Unfocused status bar
# Initialize key variable
key = 0
@ -109,10 +111,22 @@ def main(stdscr, filename):
left_percent = 0
left_status = f"{left_percent}%"
# Draw status bars
stdscr.addnstr(height - 1, 1, left_status, len(left_status), curses.A_REVERSE)
x = width - len(right_status) - 1
stdscr.addnstr(height - 1, x, right_status, len(right_status), curses.A_REVERSE)
# Draw status bars - full width with different colors based on focus
left_attr = curses.color_pair(1) if focus == "left" else curses.color_pair(2)
right_attr = curses.color_pair(1) if focus == "right" else curses.color_pair(2)
# Fill the entire bottom row for each pane
for x in range(divider_col):
stdscr.addch(height - 1, x, ' ', left_attr)
for x in range(divider_col + 1, width):
stdscr.addch(height - 1, x, ' ', right_attr)
# Add the percentage text
stdscr.addstr(height - 1, 1, left_status, left_attr)
stdscr.addstr(height - 1, width - len(right_status) - 1, right_status, right_attr)
# Add divider character at the bottom row
stdscr.addch(height - 1, divider_col, divider_char)
# Get input with a small timeout for smoother scrolling
stdscr.timeout(50) # 50ms timeout