feat: Enhance status bar to display multi-line commit messages with resizable height
This commit is contained in:
parent
c945c89b74
commit
dba40cbe85
54
gtm
54
gtm
|
|
@ -931,12 +931,13 @@ def draw_status_bars(stdscr, state):
|
||||||
# --- Second status bar (bottom) ---
|
# --- Second status bar (bottom) ---
|
||||||
# Draw the commit details in the second status bar
|
# Draw the commit details in the second status bar
|
||||||
|
|
||||||
# Fill the bottom status bar with spaces using reverse video
|
# Fill all status bar lines with spaces using reverse video
|
||||||
for x in range(state.width - 1):
|
for y in range(state.status_bar_height):
|
||||||
try:
|
for x in range(state.width - 1):
|
||||||
stdscr.addch(state.height - 1, x, ' ', curses.A_REVERSE)
|
try:
|
||||||
except curses.error:
|
stdscr.addch(state.height - state.status_bar_height + y, x, ' ', curses.A_REVERSE)
|
||||||
pass
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
# Draw the commit hash and message on the left
|
# Draw the commit hash and message on the left
|
||||||
if state.commit_hash:
|
if state.commit_hash:
|
||||||
|
|
@ -953,32 +954,45 @@ def draw_status_bars(stdscr, state):
|
||||||
message_lines = commit_message.splitlines()
|
message_lines = commit_message.splitlines()
|
||||||
if not message_lines:
|
if not message_lines:
|
||||||
message_lines = [""]
|
message_lines = [""]
|
||||||
|
|
||||||
# Show the first line in the status bar
|
|
||||||
display_message = message_lines[0]
|
|
||||||
|
|
||||||
# Truncate message if needed
|
# Calculate how many message lines we can display
|
||||||
if len(display_message) > available_width:
|
# We need at least one line for the status bar with hash and author
|
||||||
display_message = display_message[:available_width-3] + "..."
|
available_message_lines = state.status_bar_height - 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Draw the commit hash with bold
|
# Draw the commit hash with bold on the first line of the status bar
|
||||||
stdscr.addstr(state.height - 1, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
|
stdscr.addstr(state.height - state.status_bar_height + 1, 0, commit_info, curses.A_REVERSE | curses.A_BOLD)
|
||||||
|
|
||||||
# Draw the commit message
|
# Draw the author and branch on the right of the first line
|
||||||
stdscr.addstr(state.height - 1, len(commit_info), display_message, curses.A_REVERSE)
|
|
||||||
|
|
||||||
# Draw the author and branch on the right
|
|
||||||
right_x = state.width - len(author_branch_info)
|
right_x = state.width - len(author_branch_info)
|
||||||
if right_x >= 0:
|
if right_x >= 0:
|
||||||
stdscr.addstr(state.height - 1, right_x, author_branch_info, curses.A_REVERSE)
|
stdscr.addstr(state.height - state.status_bar_height + 1, right_x, author_branch_info, curses.A_REVERSE)
|
||||||
|
|
||||||
|
# Draw the first line of the commit message on the same line as the hash
|
||||||
|
first_line = message_lines[0]
|
||||||
|
if len(first_line) > available_width:
|
||||||
|
first_line = first_line[:available_width-3] + "..."
|
||||||
|
stdscr.addstr(state.height - state.status_bar_height + 1, len(commit_info), first_line, curses.A_REVERSE)
|
||||||
|
|
||||||
|
# Draw additional lines of the commit message if we have space
|
||||||
|
for i in range(1, min(available_message_lines, len(message_lines))):
|
||||||
|
line = message_lines[i]
|
||||||
|
# For continuation lines, we have more space since we don't need to show the hash
|
||||||
|
line_available_width = state.width - 4 # Leave some margin
|
||||||
|
if len(line) > line_available_width:
|
||||||
|
line = line[:line_available_width-3] + "..."
|
||||||
|
# Draw the line with some indentation
|
||||||
|
stdscr.addstr(state.height - state.status_bar_height + 1 + i, 4, line, curses.A_REVERSE)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Draw a handle for resizing the status bar
|
# Draw a handle for resizing the status bar
|
||||||
try:
|
try:
|
||||||
handle_char = "≡" if state.dragging_status_bar else "="
|
handle_char = "≡" if state.dragging_status_bar else "="
|
||||||
stdscr.addstr(status_bar_start, state.width // 2 - 1, handle_char * 3, curses.A_REVERSE | curses.A_BOLD)
|
handle_text = handle_char * 3
|
||||||
|
if state.status_bar_height > 2:
|
||||||
|
handle_text += f" ({state.status_bar_height} lines)"
|
||||||
|
stdscr.addstr(status_bar_start, state.width // 2 - len(handle_text) // 2, handle_text, curses.A_REVERSE | curses.A_BOLD)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue