fix: Improve status bar dragging and commit message display
This commit is contained in:
parent
1bf45248bd
commit
f2a07737df
33
gtm
33
gtm
|
|
@ -845,10 +845,11 @@ def draw_status_bars(stdscr, state):
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Draw a blank second status bar
|
# Fill all remaining status bar lines with spaces
|
||||||
|
for y in range(status_bar_start + 1, state.height):
|
||||||
for x in range(state.width - 1):
|
for x in range(state.width - 1):
|
||||||
try:
|
try:
|
||||||
stdscr.addch(state.height - 1, x, ' ', curses.A_REVERSE)
|
stdscr.addch(y, x, ' ', curses.A_REVERSE)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -888,10 +889,10 @@ def draw_status_bars(stdscr, state):
|
||||||
status_attr = curses.A_NORMAL # Use terminal's default colors
|
status_attr = curses.A_NORMAL # Use terminal's default colors
|
||||||
|
|
||||||
# Fill all status bar lines with spaces using reverse video
|
# Fill all status bar lines with spaces using reverse video
|
||||||
for y in range(state.status_bar_height):
|
for y in range(status_bar_start, state.height):
|
||||||
for x in range(state.width - 1):
|
for x in range(state.width - 1):
|
||||||
try:
|
try:
|
||||||
stdscr.addch(state.height - state.status_bar_height + y, x, ' ', curses.A_REVERSE)
|
stdscr.addch(y, x, ' ', curses.A_REVERSE)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -933,10 +934,10 @@ def draw_status_bars(stdscr, state):
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# --- Second status bar (bottom) ---
|
# --- Second status bar and additional lines for commit details ---
|
||||||
# Draw the commit details in the second status bar
|
# Draw the commit details in the status bar area
|
||||||
|
|
||||||
# Draw the commit hash and message on the left
|
# Draw the commit hash and message
|
||||||
if state.commit_hash:
|
if state.commit_hash:
|
||||||
commit_info = f" {state.commit_hash} "
|
commit_info = f" {state.commit_hash} "
|
||||||
|
|
||||||
|
|
@ -952,7 +953,7 @@ def draw_status_bars(stdscr, state):
|
||||||
if not message_lines:
|
if not message_lines:
|
||||||
message_lines = [""]
|
message_lines = [""]
|
||||||
|
|
||||||
# Calculate how many message lines we can display
|
# Calculate how many message lines we can display (reserve 1 line for the main status bar)
|
||||||
available_message_lines = state.status_bar_height - 1
|
available_message_lines = state.status_bar_height - 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -968,13 +969,15 @@ def draw_status_bars(stdscr, state):
|
||||||
stdscr.addstr(bottom_line, right_x, author_branch_info, curses.A_REVERSE)
|
stdscr.addstr(bottom_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 on the same line as the hash
|
||||||
first_line = message_lines[0]
|
first_line = message_lines[0] if message_lines else ""
|
||||||
if len(first_line) > available_width:
|
if len(first_line) > available_width:
|
||||||
first_line = first_line[:available_width-3] + "..."
|
first_line = first_line[:available_width-3] + "..."
|
||||||
stdscr.addstr(bottom_line, len(commit_info), first_line, curses.A_REVERSE)
|
stdscr.addstr(bottom_line, len(commit_info), first_line, curses.A_REVERSE)
|
||||||
|
|
||||||
# Draw additional lines of the commit message if we have space
|
# Draw additional lines of the commit message if we have space and more lines
|
||||||
for i in range(1, min(available_message_lines, len(message_lines))):
|
for i in range(1, min(len(message_lines), available_message_lines + 1)):
|
||||||
|
if i >= len(message_lines):
|
||||||
|
break
|
||||||
line = message_lines[i]
|
line = message_lines[i]
|
||||||
# For continuation lines, we have more space since we don't need to show the hash
|
# 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
|
line_available_width = state.width - 4 # Leave some margin
|
||||||
|
|
@ -982,6 +985,7 @@ def draw_status_bars(stdscr, state):
|
||||||
line = line[:line_available_width-3] + "..."
|
line = line[:line_available_width-3] + "..."
|
||||||
# Draw the line with some indentation (going upward from the bottom line)
|
# Draw the line with some indentation (going upward from the bottom line)
|
||||||
line_y = bottom_line - i
|
line_y = bottom_line - i
|
||||||
|
if line_y >= status_bar_start: # Make sure we don't draw above the status bar area
|
||||||
stdscr.addstr(line_y, 4, line, curses.A_REVERSE)
|
stdscr.addstr(line_y, 4, line, curses.A_REVERSE)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
@ -1135,10 +1139,9 @@ def update_status_bar_height(state: AppState, my: int) -> AppState:
|
||||||
min_height = 2 # Minimum 2 lines for the status bar
|
min_height = 2 # Minimum 2 lines for the status bar
|
||||||
max_height = min(10, state.height // 2) # Maximum 10 lines or half the screen
|
max_height = min(10, state.height // 2) # Maximum 10 lines or half the screen
|
||||||
|
|
||||||
# Calculate the new height based on how far the user has dragged
|
# Calculate the new height based on mouse position
|
||||||
status_bar_start = state.height - state.status_bar_height
|
# When dragging up, we want to increase the status bar height
|
||||||
drag_distance = status_bar_start - my
|
new_height = state.height - my
|
||||||
new_height = state.status_bar_height + drag_distance
|
|
||||||
|
|
||||||
# Clamp to allowed range
|
# Clamp to allowed range
|
||||||
new_height = max(min_height, min(new_height, max_height))
|
new_height = max(min_height, min(new_height, max_height))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue