feat: Add new status bar below existing panes with commit message
This commit is contained in:
parent
7db93d4af3
commit
4053001591
83
gtm2.py
83
gtm2.py
|
|
@ -205,10 +205,10 @@ class AppState:
|
||||||
def draw_left_pane(stdscr, state):
|
def draw_left_pane(stdscr, state):
|
||||||
if state.selected_commit_idx < state.left_scroll_offset:
|
if state.selected_commit_idx < state.left_scroll_offset:
|
||||||
state.left_scroll_offset = state.selected_commit_idx
|
state.left_scroll_offset = state.selected_commit_idx
|
||||||
elif state.selected_commit_idx >= state.left_scroll_offset + state.height - 1:
|
elif state.selected_commit_idx >= state.left_scroll_offset + state.height - 2:
|
||||||
state.left_scroll_offset = state.selected_commit_idx - (state.height - 2)
|
state.left_scroll_offset = state.selected_commit_idx - (state.height - 3)
|
||||||
|
|
||||||
visible_commits = state.commits[state.left_scroll_offset:state.left_scroll_offset + state.height - 1]
|
visible_commits = state.commits[state.left_scroll_offset:state.left_scroll_offset + state.height - 2]
|
||||||
for i, line in enumerate(visible_commits):
|
for i, line in enumerate(visible_commits):
|
||||||
display_index = i + state.left_scroll_offset
|
display_index = i + state.left_scroll_offset
|
||||||
if display_index == state.selected_commit_idx:
|
if display_index == state.selected_commit_idx:
|
||||||
|
|
@ -220,10 +220,10 @@ def draw_left_pane(stdscr, state):
|
||||||
def draw_right_pane(stdscr, state):
|
def draw_right_pane(stdscr, state):
|
||||||
right_width = state.width - state.divider_col - 3
|
right_width = state.width - state.divider_col - 3
|
||||||
|
|
||||||
max_scroll = max(0, len(state.file_lines) - (state.height - 1))
|
max_scroll = max(0, len(state.file_lines) - (state.height - 2))
|
||||||
state.right_scroll_offset = min(state.right_scroll_offset, max_scroll)
|
state.right_scroll_offset = min(state.right_scroll_offset, max_scroll)
|
||||||
|
|
||||||
visible_lines = state.file_lines[state.right_scroll_offset:state.right_scroll_offset + state.height - 1]
|
visible_lines = state.file_lines[state.right_scroll_offset:state.right_scroll_offset + state.height - 2]
|
||||||
|
|
||||||
display_lines = []
|
display_lines = []
|
||||||
deleted_line_map = {}
|
deleted_line_map = {}
|
||||||
|
|
@ -250,7 +250,7 @@ def draw_right_pane(stdscr, state):
|
||||||
|
|
||||||
display_row = 0
|
display_row = 0
|
||||||
for line_info in display_lines:
|
for line_info in display_lines:
|
||||||
if display_row >= state.height - 1:
|
if display_row >= state.height - 2:
|
||||||
break
|
break
|
||||||
|
|
||||||
line_type = line_info['type']
|
line_type = line_info['type']
|
||||||
|
|
@ -274,7 +274,7 @@ def draw_right_pane(stdscr, state):
|
||||||
|
|
||||||
def draw_divider(stdscr, state):
|
def draw_divider(stdscr, state):
|
||||||
divider_char = "║" if state.dragging_divider else "│"
|
divider_char = "║" if state.dragging_divider else "│"
|
||||||
for y in range(state.height):
|
for y in range(state.height - 1): # Don't draw through the commit message bar
|
||||||
try:
|
try:
|
||||||
stdscr.addch(y, state.divider_col, divider_char)
|
stdscr.addch(y, state.divider_col, divider_char)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
|
|
@ -326,7 +326,8 @@ def draw_selection(stdscr, state):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def draw_status_bars(stdscr, state):
|
def draw_status_bars(stdscr, state):
|
||||||
visible_height = state.height - 1
|
# We'll use height-2 for the original status bars and height-1 for the commit message bar
|
||||||
|
visible_height = state.height - 2
|
||||||
|
|
||||||
# Get commit message for the selected commit
|
# Get commit message for the selected commit
|
||||||
commit_message = ""
|
commit_message = ""
|
||||||
|
|
@ -359,42 +360,60 @@ def draw_status_bars(stdscr, state):
|
||||||
mouse_status += " SEL"
|
mouse_status += " SEL"
|
||||||
left_status += mouse_status
|
left_status += mouse_status
|
||||||
|
|
||||||
# Draw full-width status bar with commit message
|
# Draw original status bars for left and right panes
|
||||||
status_attr = curses.color_pair(5) # New color pair for status bar
|
left_attr = curses.color_pair(1) if state.focus == "left" else curses.color_pair(2)
|
||||||
|
right_attr = curses.color_pair(1) if state.focus == "right" else curses.color_pair(2)
|
||||||
|
|
||||||
# Fill the status bar with spaces, avoiding the last character position
|
# Fill the original status bar with spaces
|
||||||
# which can cause curses errors on some terminals
|
for x in range(state.divider_col):
|
||||||
for x in range(state.width - 1):
|
|
||||||
try:
|
try:
|
||||||
stdscr.addch(state.height - 1, x, ' ', status_attr)
|
stdscr.addch(state.height - 2, x, ' ', left_attr)
|
||||||
|
except curses.error:
|
||||||
|
pass
|
||||||
|
for x in range(state.divider_col + 1, state.width - 1):
|
||||||
|
try:
|
||||||
|
stdscr.addch(state.height - 2, x, ' ', right_attr)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Add commit message centered in status bar
|
# Add percentage indicators on left and right sides of original status bar
|
||||||
if commit_message:
|
|
||||||
max_msg_width = state.width - 20 # Leave space for percentages
|
|
||||||
if len(commit_message) > max_msg_width:
|
|
||||||
commit_message = commit_message[:max_msg_width-3] + "..."
|
|
||||||
|
|
||||||
msg_x = (state.width - len(commit_message)) // 2
|
|
||||||
try:
|
try:
|
||||||
stdscr.addstr(state.height - 1, msg_x, commit_message, status_attr)
|
stdscr.addstr(state.height - 2, 1, left_status, left_attr)
|
||||||
except curses.error:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Add percentage indicators on left and right sides
|
|
||||||
left_attr = status_attr | (curses.A_REVERSE if state.focus == "left" else 0)
|
|
||||||
right_attr = status_attr | (curses.A_REVERSE if state.focus == "right" else 0)
|
|
||||||
|
|
||||||
try:
|
|
||||||
stdscr.addstr(state.height - 1, 1, left_status, left_attr)
|
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
right_x = state.width - len(right_status) - 1
|
right_x = state.width - len(right_status) - 1
|
||||||
if right_x >= 0:
|
if right_x >= 0:
|
||||||
stdscr.addstr(state.height - 1, right_x, right_status, right_attr)
|
stdscr.addstr(state.height - 2, right_x, right_status, right_attr)
|
||||||
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Draw divider in status bar
|
||||||
|
try:
|
||||||
|
stdscr.addch(state.height - 2, state.divider_col, "│")
|
||||||
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Draw new full-width status bar with commit message below the original status bars
|
||||||
|
status_attr = curses.color_pair(5) # Color pair for commit message bar
|
||||||
|
|
||||||
|
# Fill the commit message bar with spaces
|
||||||
|
for x in range(state.width - 1):
|
||||||
|
try:
|
||||||
|
stdscr.addch(state.height - 1, x, ' ', status_attr)
|
||||||
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Add commit message centered in the commit message bar
|
||||||
|
if commit_message:
|
||||||
|
max_msg_width = state.width - 4 # Leave a small margin
|
||||||
|
if len(commit_message) > max_msg_width:
|
||||||
|
commit_message = commit_message[:max_msg_width-3] + "..."
|
||||||
|
|
||||||
|
msg_x = (state.width - len(commit_message)) // 2
|
||||||
|
try:
|
||||||
|
stdscr.addstr(state.height - 1, msg_x, commit_message, status_attr)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue