refactor: Simplify commit details display by removing pipe characters and adjusting layout

This commit is contained in:
n loewen 2025-06-08 09:46:20 +01:00 committed by n loewen (aider)
parent 6c02c2f6a9
commit b50a2def03
1 changed files with 5 additions and 34 deletions

39
gtm
View File

@ -940,17 +940,13 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
# Draw on the second line of the status bar (layout.commit_detail_start_y)
second_line = layout.commit_detail_start_y
# Draw the commit hash with bold at the start
# Draw the commit hash at the start
commit_info = f" {state.commit_hash} "
stdscr.addstr(second_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
stdscr.addstr(second_line, 0, commit_info, curses.A_REVERSE) # | curses.A_BOLD)
# Calculate the author and branch info, ensuring it always fits
author_branch_info = f" {state.commit_author} [{state.commit_branch}] "
# Reserve space for author/branch info and ensure it fits
min_author_space = 20 # Minimum space to reserve for author info
max_author_width = max(min_author_space, len(author_branch_info))
# If the author info is too long, truncate it but keep the branch
if len(author_branch_info) > layout.screen_width // 3: # Don't let it take more than 1/3 of screen
max_author_name_width = (layout.screen_width // 3) - len(f" [{state.commit_branch}] ")
@ -964,60 +960,35 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
# 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
message_width = message_end_x - message_start_x
# Always draw the author/branch info (it should fit now)
if right_x >= len(commit_info):
try:
stdscr.addstr(second_line, right_x, author_branch_info, curses.A_REVERSE)
except curses.error:
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
first_line = message_lines[0] if message_lines else ""
if message_width > 0:
if len(first_line) > message_width:
first_line = first_line[:message_width-3] + "..."
try:
stdscr.addstr(second_line, message_start_x + 1, first_line, curses.A_REVERSE)
stdscr.addstr(second_line, message_start_x, first_line, curses.A_REVERSE)
except curses.error:
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
for i, line in enumerate(message_lines[1:], 1):
line_y = layout.commit_detail_start_y + i
if line_y >= layout.start_y + layout.total_height:
break # No more space
# For continuation lines, align them with the first line of the message
# and add pipe characters on both sides
try:
stdscr.addstr(line_y, message_start_x, "|", curses.A_REVERSE)
except curses.error:
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)
stdscr.addstr(line_y, message_start_x, line, curses.A_REVERSE)
except curses.error:
pass