fix: Handle curses drawing errors in status bar rendering
This commit is contained in:
parent
90535bf156
commit
7db93d4af3
22
gtm2.py
22
gtm2.py
|
|
@ -361,8 +361,14 @@ def draw_status_bars(stdscr, state):
|
||||||
|
|
||||||
# Draw full-width status bar with commit message
|
# Draw full-width status bar with commit message
|
||||||
status_attr = curses.color_pair(5) # New color pair for status bar
|
status_attr = curses.color_pair(5) # New color pair for status bar
|
||||||
for x in range(state.width):
|
|
||||||
|
# Fill the status bar with spaces, avoiding the last character position
|
||||||
|
# which can cause curses errors on some terminals
|
||||||
|
for x in range(state.width - 1):
|
||||||
|
try:
|
||||||
stdscr.addch(state.height - 1, x, ' ', status_attr)
|
stdscr.addch(state.height - 1, x, ' ', status_attr)
|
||||||
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
# Add commit message centered in status bar
|
# Add commit message centered in status bar
|
||||||
if commit_message:
|
if commit_message:
|
||||||
|
|
@ -371,14 +377,26 @@ def draw_status_bars(stdscr, state):
|
||||||
commit_message = commit_message[:max_msg_width-3] + "..."
|
commit_message = commit_message[:max_msg_width-3] + "..."
|
||||||
|
|
||||||
msg_x = (state.width - len(commit_message)) // 2
|
msg_x = (state.width - len(commit_message)) // 2
|
||||||
|
try:
|
||||||
stdscr.addstr(state.height - 1, msg_x, commit_message, status_attr)
|
stdscr.addstr(state.height - 1, msg_x, commit_message, status_attr)
|
||||||
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
# Add percentage indicators on left and right sides
|
# Add percentage indicators on left and right sides
|
||||||
left_attr = status_attr | (curses.A_REVERSE if state.focus == "left" else 0)
|
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)
|
right_attr = status_attr | (curses.A_REVERSE if state.focus == "right" else 0)
|
||||||
|
|
||||||
|
try:
|
||||||
stdscr.addstr(state.height - 1, 1, left_status, left_attr)
|
stdscr.addstr(state.height - 1, 1, left_status, left_attr)
|
||||||
stdscr.addstr(state.height - 1, state.width - len(right_status) - 1, right_status, right_attr)
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
right_x = state.width - len(right_status) - 1
|
||||||
|
if right_x >= 0:
|
||||||
|
stdscr.addstr(state.height - 1, right_x, right_status, right_attr)
|
||||||
|
except curses.error:
|
||||||
|
pass
|
||||||
|
|
||||||
def draw_ui(stdscr, state):
|
def draw_ui(stdscr, state):
|
||||||
stdscr.erase()
|
stdscr.erase()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue