fix(tui): prevent cursor crash and status bar text bleed
This commit is contained in:
parent
315cd77639
commit
25c6fa3bdb
@ -35,7 +35,6 @@ class HendrikTUI:
|
||||
curses.wrapper(self._main)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
print("Exiting.")
|
||||
|
||||
def _main(self, stdscr):
|
||||
# Main loop: draw → getch → handle
|
||||
|
||||
@ -230,8 +230,8 @@ def draw_input(app, stdscr):
|
||||
except curses.error:
|
||||
pass
|
||||
|
||||
# Cursor position
|
||||
if line_is_active and not app.processing:
|
||||
# Cursor position — only on the visual chunk that contains the cursor
|
||||
if idx == cur_visual and not app.processing:
|
||||
col_on_visual = app.input_col - start
|
||||
cursor_yx = (y, 4 + min(col_on_visual, len(chunk)))
|
||||
|
||||
@ -248,7 +248,10 @@ def draw_input(app, stdscr):
|
||||
pass
|
||||
|
||||
if cursor_yx:
|
||||
try:
|
||||
stdscr.move(*cursor_yx)
|
||||
except curses.error:
|
||||
pass
|
||||
|
||||
|
||||
def draw_status(app, stdscr):
|
||||
@ -262,8 +265,8 @@ def draw_status(app, stdscr):
|
||||
if len(ws) > max_ws:
|
||||
ws = ".." + ws[-(max_ws - 2):]
|
||||
|
||||
status = f" {ws} \u2502{mode}\u2502{hints}"
|
||||
stdscr.addstr(y, 0, status[:w], curses.color_pair(C_STATUS_INFO))
|
||||
status = (f" {ws} \u2502{mode}\u2502{hints}").ljust(w)[:w]
|
||||
stdscr.addstr(y, 0, status, curses.color_pair(C_STATUS_INFO))
|
||||
|
||||
# Highlight mode dengan warna berbeda
|
||||
mode_start = len(f" {ws} \u2502")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user