refactor: Add pipe characters and align multi-line commit message details
This commit is contained in:
parent
14f0f5ea9f
commit
6c02c2f6a9
53
gtm
53
gtm
|
|
@ -961,6 +961,11 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
|
|||
# Calculate positions
|
||||
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)
|
||||
if right_x >= len(commit_info):
|
||||
try:
|
||||
|
|
@ -968,29 +973,53 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
|
|||
except curses.error:
|
||||
pass
|
||||
|
||||
# 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 ""
|
||||
if available_width > 0:
|
||||
if len(first_line) > available_width:
|
||||
first_line = first_line[:available_width-3] + "..."
|
||||
# Draw left pipe character for message area
|
||||
try:
|
||||
stdscr.addstr(second_line, len(commit_info), first_line, curses.A_REVERSE)
|
||||
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)
|
||||
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, indent them
|
||||
line_available_width = layout.screen_width - 4 # Leave some margin
|
||||
if len(line) > line_available_width:
|
||||
line = line[:line_available_width-3] + "..."
|
||||
# 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
|
||||
|
||||
stdscr.addstr(line_y, 4, line, curses.A_REVERSE)
|
||||
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):
|
||||
"""Draw search input interface"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue