feat: add colored status bars with focus-based highlighting
This commit is contained in:
parent
bc6ec6d847
commit
0025c4e437
|
|
@ -23,6 +23,8 @@ def main(stdscr, filename):
|
||||||
# Initialize colors if terminal supports them
|
# Initialize colors if terminal supports them
|
||||||
if curses.has_colors():
|
if curses.has_colors():
|
||||||
curses.use_default_colors() # Use terminal's default 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
|
# Initialize key variable
|
||||||
key = 0
|
key = 0
|
||||||
|
|
@ -109,10 +111,22 @@ def main(stdscr, filename):
|
||||||
left_percent = 0
|
left_percent = 0
|
||||||
left_status = f"{left_percent}%"
|
left_status = f"{left_percent}%"
|
||||||
|
|
||||||
# Draw status bars
|
# Draw status bars - full width with different colors based on focus
|
||||||
stdscr.addnstr(height - 1, 1, left_status, len(left_status), curses.A_REVERSE)
|
left_attr = curses.color_pair(1) if focus == "left" else curses.color_pair(2)
|
||||||
x = width - len(right_status) - 1
|
right_attr = curses.color_pair(1) if focus == "right" else curses.color_pair(2)
|
||||||
stdscr.addnstr(height - 1, x, right_status, len(right_status), curses.A_REVERSE)
|
|
||||||
|
# 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
|
# Get input with a small timeout for smoother scrolling
|
||||||
stdscr.timeout(50) # 50ms timeout
|
stdscr.timeout(50) # 50ms timeout
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue