From dba40cbe8519015f6192afbbd4dc7f9a794faa07 Mon Sep 17 00:00:00 2001 From: "n loewen (aider)" Date: Sun, 8 Jun 2025 08:52:02 +0100 Subject: [PATCH] feat: Enhance status bar to display multi-line commit messages with resizable height --- gtm | 54 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/gtm b/gtm index 892ce8d..f7cdc53 100755 --- a/gtm +++ b/gtm @@ -931,12 +931,13 @@ def draw_status_bars(stdscr, state): # --- Second status bar (bottom) --- # Draw the commit details in the second status bar - # Fill the bottom status bar with spaces using reverse video - for x in range(state.width - 1): - try: - stdscr.addch(state.height - 1, x, ' ', curses.A_REVERSE) - except curses.error: - pass + # 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 if state.commit_hash: @@ -953,32 +954,45 @@ def draw_status_bars(stdscr, state): message_lines = commit_message.splitlines() if not message_lines: message_lines = [""] - - # Show the first line in the status bar - display_message = message_lines[0] - # Truncate message if needed - if len(display_message) > available_width: - display_message = display_message[:available_width-3] + "..." + # 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 try: - # Draw the commit hash with bold - stdscr.addstr(state.height - 1, 0, commit_info, curses.A_REVERSE | curses.A_BOLD) + # Draw the commit hash with bold on the first line of the status bar + stdscr.addstr(state.height - state.status_bar_height + 1, 0, commit_info, curses.A_REVERSE | curses.A_BOLD) - # Draw the commit message - stdscr.addstr(state.height - 1, len(commit_info), display_message, curses.A_REVERSE) - - # Draw the author and branch on the right + # Draw the author and branch on the right of the first line right_x = state.width - len(author_branch_info) if right_x >= 0: - stdscr.addstr(state.height - 1, right_x, author_branch_info, curses.A_REVERSE) + stdscr.addstr(state.height - state.status_bar_height + 1, 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] + if len(first_line) > available_width: + first_line = first_line[:available_width-3] + "..." + stdscr.addstr(state.height - state.status_bar_height + 1, 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))): + 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 + if len(line) > line_available_width: + line = line[:line_available_width-3] + "..." + # Draw the line with some indentation + stdscr.addstr(state.height - state.status_bar_height + 1 + i, 4, line, curses.A_REVERSE) except curses.error: pass # Draw a handle for resizing the status bar try: handle_char = "≡" if state.dragging_status_bar else "=" - stdscr.addstr(status_bar_start, state.width // 2 - 1, handle_char * 3, curses.A_REVERSE | curses.A_BOLD) + handle_text = handle_char * 3 + if state.status_bar_height > 2: + handle_text += f" ({state.status_bar_height} lines)" + stdscr.addstr(status_bar_start, state.width // 2 - len(handle_text) // 2, handle_text, curses.A_REVERSE | curses.A_BOLD) except curses.error: pass