fix: Improve status bar rendering and commit message display

This commit is contained in:
n loewen (aider) 2025-06-08 08:57:50 +01:00
parent a804ebe85a
commit c2c678b8b3
1 changed files with 10 additions and 18 deletions

18
gtm
View File

@ -883,10 +883,11 @@ def draw_status_bars(stdscr, state):
# Use terminal's default colors for the status bar # Use terminal's default colors for the status bar
status_attr = curses.A_NORMAL # Use terminal's default colors status_attr = curses.A_NORMAL # Use terminal's default colors
# Fill the top status bar with spaces using reverse video # Fill all status bar lines with spaces using reverse video
for y in range(state.status_bar_height):
for x in range(state.width - 1): for x in range(state.width - 1):
try: try:
stdscr.addch(status_bar_start, x, ' ', curses.A_REVERSE) stdscr.addch(state.height - state.status_bar_height + y, x, ' ', curses.A_REVERSE)
except curses.error: except curses.error:
pass pass
@ -931,14 +932,6 @@ def draw_status_bars(stdscr, state):
# --- Second status bar (bottom) --- # --- Second status bar (bottom) ---
# Draw the commit details in the second status bar # Draw the commit details in the second status bar
# Fill all status bar lines with spaces using reverse video
for y in range(state.status_bar_height):
for x in range(state.width - 1):
try:
stdscr.addch(state.height - state.status_bar_height + y, x, ' ', curses.A_REVERSE)
except curses.error:
pass
# Draw the commit hash and message on the left # Draw the commit hash and message on the left
if state.commit_hash: if state.commit_hash:
commit_info = f" {state.commit_hash} " commit_info = f" {state.commit_hash} "
@ -956,11 +949,10 @@ def draw_status_bars(stdscr, state):
message_lines = [""] message_lines = [""]
# Calculate how many message lines we can display # Calculate how many message lines we can display
# We need at least one line for the status bar with hash and author
available_message_lines = state.status_bar_height - 1 available_message_lines = state.status_bar_height - 1
try: try:
# Draw the commit hash with bold on the bottom line of the status bar # Always draw the commit hash and first line of message on the bottom line
bottom_line = state.height - 1 bottom_line = state.height - 1
stdscr.addstr(bottom_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD) stdscr.addstr(bottom_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
@ -982,7 +974,7 @@ def draw_status_bars(stdscr, state):
line_available_width = state.width - 4 # Leave some margin line_available_width = state.width - 4 # Leave some margin
if len(line) > line_available_width: if len(line) > line_available_width:
line = line[:line_available_width-3] + "..." line = line[:line_available_width-3] + "..."
# Draw the line with some indentation # Draw the line with some indentation (going upward from the bottom line)
line_y = bottom_line - i line_y = bottom_line - i
stdscr.addstr(line_y, 4, line, curses.A_REVERSE) stdscr.addstr(line_y, 4, line, curses.A_REVERSE)
except curses.error: except curses.error: