refactor: Move commit message to second line of status bar
This commit is contained in:
parent
c33866f12d
commit
35207ba7ab
31
gtm
31
gtm
|
|
@ -922,40 +922,39 @@ def draw_commit_details(stdscr, state: AppState, layout: StatusBarLayout):
|
|||
if not state.commit_hash or layout.total_height < 2:
|
||||
return
|
||||
|
||||
commit_info = f" {state.commit_hash} "
|
||||
author_branch_info = f" {state.commit_author} [{state.commit_branch}] "
|
||||
available_width = layout.screen_width - len(commit_info) - len(author_branch_info) - 1
|
||||
|
||||
# Get the commit message (potentially multi-line)
|
||||
message_lines = state.commit_message.splitlines()
|
||||
if not message_lines:
|
||||
message_lines = [""]
|
||||
|
||||
try:
|
||||
# Always draw the commit hash and first line of message on the bottom line
|
||||
bottom_line = layout.commit_detail_end_y
|
||||
# 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
|
||||
stdscr.addstr(bottom_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
|
||||
# Draw the commit hash with bold at the start
|
||||
commit_info = f" {state.commit_hash} "
|
||||
stdscr.addstr(second_line, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
|
||||
|
||||
# Draw the author and branch on the right of the bottom line
|
||||
# Draw the author and branch on the right
|
||||
author_branch_info = f" {state.commit_author} [{state.commit_branch}] "
|
||||
right_x = layout.screen_width - len(author_branch_info)
|
||||
if right_x >= 0:
|
||||
stdscr.addstr(bottom_line, right_x, author_branch_info, curses.A_REVERSE)
|
||||
stdscr.addstr(second_line, right_x, author_branch_info, curses.A_REVERSE)
|
||||
|
||||
# Draw the first line of the commit message on the same line as the hash
|
||||
# Draw the first line of the commit message in between
|
||||
available_width = layout.screen_width - len(commit_info) - len(author_branch_info) - 1
|
||||
first_line = message_lines[0] if message_lines else ""
|
||||
if len(first_line) > available_width:
|
||||
first_line = first_line[:available_width-3] + "..."
|
||||
stdscr.addstr(bottom_line, len(commit_info), first_line, curses.A_REVERSE)
|
||||
stdscr.addstr(second_line, len(commit_info), first_line, curses.A_REVERSE)
|
||||
|
||||
# Draw additional lines of the commit message if we have space and more lines
|
||||
# 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_end_y - i
|
||||
if line_y < layout.commit_detail_start_y:
|
||||
line_y = layout.commit_detail_start_y + i
|
||||
if line_y >= layout.start_y + layout.total_height:
|
||||
break # No more space
|
||||
|
||||
# For continuation lines, we have more space since we don't need to show the hash
|
||||
# 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] + "..."
|
||||
|
|
|
|||
Loading…
Reference in New Issue