From 90535bf156add9cf62e6c076e6e1beb2c7066c9c Mon Sep 17 00:00:00 2001 From: "n loewen (aider)" Date: Sat, 7 Jun 2025 23:28:02 +0100 Subject: [PATCH] feat: Add full-width status bar with centered commit message --- gtm2.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/gtm2.py b/gtm2.py index 5512c7f..d277561 100755 --- a/gtm2.py +++ b/gtm2.py @@ -328,6 +328,14 @@ def draw_selection(stdscr, state): def draw_status_bars(stdscr, state): visible_height = state.height - 1 + # Get commit message for the selected commit + commit_message = "" + if state.commits and state.selected_commit_idx < len(state.commits): + commit_parts = state.commits[state.selected_commit_idx].split(' ', 2) + if len(commit_parts) >= 3: + commit_message = commit_parts[2] + + # Status bar percentages if len(state.file_lines) > 0: last_visible_line = state.right_scroll_offset + visible_height right_percent = int((last_visible_line / len(state.file_lines)) * 100) @@ -351,18 +359,26 @@ def draw_status_bars(stdscr, state): mouse_status += " SEL" left_status += mouse_status - left_attr = curses.color_pair(1) if state.focus == "left" else curses.color_pair(2) - right_attr = curses.color_pair(1) if state.focus == "right" else curses.color_pair(2) + # Draw full-width status bar with commit message + status_attr = curses.color_pair(5) # New color pair for status bar + for x in range(state.width): + stdscr.addch(state.height - 1, x, ' ', status_attr) - for x in range(state.divider_col): - stdscr.addch(state.height - 1, x, ' ', left_attr) - for x in range(state.divider_col + 1, state.width - 1): - stdscr.addch(state.height - 1, x, ' ', right_attr) + # Add commit message centered in status bar + if commit_message: + max_msg_width = state.width - 20 # Leave space for percentages + if len(commit_message) > max_msg_width: + commit_message = commit_message[:max_msg_width-3] + "..." + msg_x = (state.width - len(commit_message)) // 2 + stdscr.addstr(state.height - 1, msg_x, commit_message, status_attr) + + # Add percentage indicators on left and right sides + left_attr = status_attr | (curses.A_REVERSE if state.focus == "left" else 0) + right_attr = status_attr | (curses.A_REVERSE if state.focus == "right" else 0) + stdscr.addstr(state.height - 1, 1, left_status, left_attr) stdscr.addstr(state.height - 1, state.width - len(right_status) - 1, right_status, right_attr) - - stdscr.addch(state.height - 1, state.divider_col, "│") def draw_ui(stdscr, state): stdscr.erase() @@ -556,6 +572,7 @@ def main(stdscr, filename, show_diff, show_add, show_del, mouse): curses.init_pair(2, curses.COLOR_WHITE, 0) # Use black (0) instead of 8 curses.init_pair(3, curses.COLOR_GREEN, -1) curses.init_pair(4, curses.COLOR_RED, -1) + curses.init_pair(5, curses.COLOR_BLACK, 6) # Status bar color (cyan background) height, width = stdscr.getmaxyx() state = AppState(filename, width, height, show_diff, show_add, show_del, mouse)