refactor: Add pipe characters and align multi-line commit message details

This commit is contained in:
n loewen (aider) 2025-06-08 09:36:17 +01:00
parent 14f0f5ea9f
commit 6c02c2f6a9
1 changed files with 40 additions and 11 deletions

51
gtm
View File

@ -961,6 +961,11 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
# Calculate positions # Calculate positions
right_x = layout.screen_width - len(author_branch_info) right_x = layout.screen_width - len(author_branch_info)
# Calculate the message area boundaries
message_start_x = len(commit_info)
message_end_x = right_x - 1
message_width = message_end_x - message_start_x - 2 # -2 for the pipe characters
# Always draw the author/branch info (it should fit now) # Always draw the author/branch info (it should fit now)
if right_x >= len(commit_info): if right_x >= len(commit_info):
try: try:
@ -968,16 +973,27 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
except curses.error: except curses.error:
pass pass
# Draw left pipe character for message area
try:
stdscr.addstr(second_line, message_start_x, "|", curses.A_REVERSE)
except curses.error:
pass
# Draw the commit message in the remaining space # Draw the commit message in the remaining space
available_width = right_x - len(commit_info) - 1
first_line = message_lines[0] if message_lines else "" first_line = message_lines[0] if message_lines else ""
if available_width > 0: if message_width > 0:
if len(first_line) > available_width: if len(first_line) > message_width:
first_line = first_line[:available_width-3] + "..." first_line = first_line[:message_width-3] + "..."
try: try:
stdscr.addstr(second_line, len(commit_info), first_line, curses.A_REVERSE) stdscr.addstr(second_line, message_start_x + 1, first_line, curses.A_REVERSE)
except curses.error: except curses.error:
pass # Silently fail if we can't draw the message pass # Silently fail if we can't draw the message
# Draw right pipe character for message area
try:
stdscr.addstr(second_line, message_end_x, "|", curses.A_REVERSE)
except curses.error:
pass
# Draw additional lines of the commit message if we have more space # Draw additional lines of the commit message if we have more space
for i, line in enumerate(message_lines[1:], 1): for i, line in enumerate(message_lines[1:], 1):
@ -985,12 +1001,25 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
if line_y >= layout.start_y + layout.total_height: if line_y >= layout.start_y + layout.total_height:
break # No more space break # No more space
# For continuation lines, indent them # For continuation lines, align them with the first line of the message
line_available_width = layout.screen_width - 4 # Leave some margin # and add pipe characters on both sides
if len(line) > line_available_width: try:
line = line[:line_available_width-3] + "..." stdscr.addstr(line_y, message_start_x, "|", curses.A_REVERSE)
except curses.error:
stdscr.addstr(line_y, 4, line, curses.A_REVERSE) pass
if message_width > 0:
if len(line) > message_width:
line = line[:message_width-3] + "..."
try:
stdscr.addstr(line_y, message_start_x + 1, line, curses.A_REVERSE)
except curses.error:
pass
try:
stdscr.addstr(line_y, message_end_x, "|", curses.A_REVERSE)
except curses.error:
pass
def draw_search_mode(stdscr, state: AppState, layout: StatusBarLayout): def draw_search_mode(stdscr, state: AppState, layout: StatusBarLayout):
"""Draw search input interface""" """Draw search input interface"""