From f2a07737dff3645a586a3c0f701f3a3af8e4a7a2 Mon Sep 17 00:00:00 2001 From: "n loewen (aider)" Date: Sun, 8 Jun 2025 09:08:50 +0100 Subject: [PATCH] fix: Improve status bar dragging and commit message display --- gtm | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/gtm b/gtm index 51d3ffc..ab223f7 100755 --- a/gtm +++ b/gtm @@ -845,12 +845,13 @@ def draw_status_bars(stdscr, state): except curses.error: pass - # Draw a blank second status bar - for x in range(state.width - 1): - try: - stdscr.addch(state.height - 1, x, ' ', curses.A_REVERSE) - except curses.error: - pass + # Fill all remaining status bar lines with spaces + for y in range(status_bar_start + 1, state.height): + for x in range(state.width - 1): + try: + stdscr.addch(y, x, ' ', curses.A_REVERSE) + except curses.error: + pass return @@ -888,10 +889,10 @@ def draw_status_bars(stdscr, state): status_attr = curses.A_NORMAL # Use terminal's default colors # Fill all status bar lines with spaces using reverse video - for y in range(state.status_bar_height): + for y in range(status_bar_start, state.height): for x in range(state.width - 1): try: - stdscr.addch(state.height - state.status_bar_height + y, x, ' ', curses.A_REVERSE) + stdscr.addch(y, x, ' ', curses.A_REVERSE) except curses.error: pass @@ -933,10 +934,10 @@ def draw_status_bars(stdscr, state): except curses.error: pass - # --- Second status bar (bottom) --- - # Draw the commit details in the second status bar + # --- Second status bar and additional lines for commit details --- + # Draw the commit details in the status bar area - # Draw the commit hash and message on the left + # Draw the commit hash and message if state.commit_hash: commit_info = f" {state.commit_hash} " @@ -952,7 +953,7 @@ def draw_status_bars(stdscr, state): if not message_lines: message_lines = [""] - # Calculate how many message lines we can display + # Calculate how many message lines we can display (reserve 1 line for the main status bar) available_message_lines = state.status_bar_height - 1 try: @@ -968,13 +969,15 @@ def draw_status_bars(stdscr, state): stdscr.addstr(bottom_line, right_x, author_branch_info, curses.A_REVERSE) # Draw the first line of the commit message on the same line as the hash - first_line = message_lines[0] + first_line = message_lines[0] if message_lines else "" if len(first_line) > available_width: first_line = first_line[:available_width-3] + "..." stdscr.addstr(bottom_line, len(commit_info), first_line, curses.A_REVERSE) - # Draw additional lines of the commit message if we have space - for i in range(1, min(available_message_lines, len(message_lines))): + # Draw additional lines of the commit message if we have space and more lines + for i in range(1, min(len(message_lines), available_message_lines + 1)): + if i >= len(message_lines): + break line = message_lines[i] # For continuation lines, we have more space since we don't need to show the hash line_available_width = state.width - 4 # Leave some margin @@ -982,7 +985,8 @@ def draw_status_bars(stdscr, state): line = line[:line_available_width-3] + "..." # Draw the line with some indentation (going upward from the bottom line) line_y = bottom_line - i - stdscr.addstr(line_y, 4, line, curses.A_REVERSE) + if line_y >= status_bar_start: # Make sure we don't draw above the status bar area + stdscr.addstr(line_y, 4, line, curses.A_REVERSE) except curses.error: pass @@ -1135,10 +1139,9 @@ def update_status_bar_height(state: AppState, my: int) -> AppState: min_height = 2 # Minimum 2 lines for the status bar max_height = min(10, state.height // 2) # Maximum 10 lines or half the screen - # Calculate the new height based on how far the user has dragged - status_bar_start = state.height - state.status_bar_height - drag_distance = status_bar_start - my - new_height = state.status_bar_height + drag_distance + # Calculate the new height based on mouse position + # When dragging up, we want to increase the status bar height + new_height = state.height - my # Clamp to allowed range new_height = max(min_height, min(new_height, max_height))