Expand input area to 6 visible lines and fix scroll logic

This commit is contained in:
Dita Aji Pratama 2026-05-12 10:19:50 +07:00
parent 6f20e4b0b9
commit 2c2927751a

View File

@ -47,9 +47,9 @@ class HendrikTUI:
while self.running:
self.h, self.w = stdscr.getmaxyx()
if self.h < 8 or self.w < 40:
if self.h < 14 or self.w < 40:
stdscr.erase()
stdscr.addstr(0, 0, "Terminal too small (min 40x8)")
stdscr.addstr(0, 0, "Terminal too small (min 40x14)")
stdscr.refresh()
stdscr.getch()
continue
@ -94,7 +94,7 @@ class HendrikTUI:
def _draw_chat(self, stdscr):
chat_top = 1
chat_h = self.h - 6
chat_h = self.h - 10
if chat_h <= 0:
return
@ -145,11 +145,11 @@ class HendrikTUI:
# ---- input area -------------------------------------------------------
def _draw_input(self, stdscr):
iy = self.h - 4
iy = self.h - 8
for off, text in [
(0, "\u250c" + "\u2500" * (self.w - 2) + "\u2510"),
(3, "\u2514" + "\u2500" * (self.w - 2) + "\u2518"),
(7, "\u2514" + "\u2500" * (self.w - 2) + "\u2518"),
]:
try:
stdscr.addstr(iy + off, 0, text[:self.w])
@ -157,17 +157,13 @@ class HendrikTUI:
pass
total = len(self.input_buffer)
if total <= 2:
if total <= 6:
show = 0
elif self.input_line <= 1:
show = max(0, total - 2)
elif self.input_line >= total - 2:
show = total - 2
else:
show = self.input_line - 1
show = max(0, min(self.input_line - 3, total - 6))
cursor_yx = None
for i in range(2):
for i in range(6):
idx = show + i
y = iy + 1 + i
line = self.input_buffer[idx] if idx < total else ""
@ -191,7 +187,7 @@ class HendrikTUI:
# ---- status bar -------------------------------------------------------
def _draw_status(self, stdscr):
y = self.h - 5
y = self.h - 9
ws = os.getcwd()
mode = " PROCESSING " if self.processing else " READY "
hints = " ^D:send ^W:workspace ^C:exit "
@ -258,9 +254,9 @@ class HendrikTUI:
elif key == curses.KEY_END:
self.input_col = len(self.input_buffer[self.input_line])
elif key == curses.KEY_PPAGE:
self.scroll = max(0, self.scroll - (self.h - 6))
self.scroll = max(0, self.scroll - (self.h - 10))
elif key == curses.KEY_NPAGE:
self.scroll += self.h - 6
self.scroll += self.h - 10
elif key == curses.KEY_RESIZE:
pass
elif key == 9: