From 0025c4e437956cd121bf5ee7e2676f059bcf863f Mon Sep 17 00:00:00 2001 From: "n loewen (aider)" Date: Mon, 5 May 2025 09:22:39 +0100 Subject: [PATCH] feat: add colored status bars with focus-based highlighting --- git_time_machine.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/git_time_machine.py b/git_time_machine.py index 1ea828a..17df67e 100644 --- a/git_time_machine.py +++ b/git_time_machine.py @@ -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