Fix input box border rendering and layout math
This commit is contained in:
parent
9c7e34409e
commit
18bbb07737
@ -146,7 +146,6 @@ class HendrikTUI:
|
||||
|
||||
def _draw_input(self, stdscr):
|
||||
iy = self.h - 4
|
||||
blank = " " * (self.w - 2)
|
||||
|
||||
for off, text in [
|
||||
(0, "\u250c" + "\u2500" * (self.w - 2) + "\u2510"),
|
||||
@ -170,15 +169,20 @@ class HendrikTUI:
|
||||
for i in range(2):
|
||||
idx = show + i
|
||||
y = iy + 1 + i
|
||||
prefix = "> " if idx < total else " "
|
||||
line = self.input_buffer[idx] if idx < total else ""
|
||||
vis = prefix + line
|
||||
if len(vis) > self.w - 2:
|
||||
vis = vis[: self.w - 2]
|
||||
fmt = "\u2502 " + vis + blank[len(vis):] + "\u2502"
|
||||
max_text = self.w - 6
|
||||
if len(line) > max_text:
|
||||
line = line[:max_text]
|
||||
if idx < total:
|
||||
fmt = "\u2502 > " + line + " " * (max_text + 1 - len(line)) + "\u2502"
|
||||
else:
|
||||
fmt = "\u2502 " + " " * (self.w - 5) + "\u2502"
|
||||
try:
|
||||
stdscr.addstr(y, 0, fmt, curses.color_pair(self.C_INPUT))
|
||||
except curses.error:
|
||||
pass
|
||||
if idx == self.input_line and not self.processing:
|
||||
col = min(2 + self.input_col, self.w - 3)
|
||||
col = 4 + min(self.input_col, max_text)
|
||||
stdscr.move(y, col)
|
||||
|
||||
# ---- status bar -------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user