feat(tui): gray ^D:send when processing, black-on-bright-green READY, fix chat truncation + right margin
This commit is contained in:
parent
f3c3d8d1ad
commit
02f5ce345b
@ -19,6 +19,7 @@ C_SEP = 7 # separator line: magenta
|
|||||||
C_ERROR = 8 # error message: merah
|
C_ERROR = 8 # error message: merah
|
||||||
C_INPUT_BORDER = 9 # border input box: biru
|
C_INPUT_BORDER = 9 # border input box: biru
|
||||||
C_STATUS_INFO = 12 # status info (workspace/hints): putih
|
C_STATUS_INFO = 12 # status info (workspace/hints): putih
|
||||||
|
C_HINT_DISABLED = 13 # hint disabled (abu-abu)
|
||||||
|
|
||||||
|
|
||||||
def init_colors():
|
def init_colors():
|
||||||
@ -30,12 +31,13 @@ def init_colors():
|
|||||||
curses.init_pair(C_SYSTEM, curses.COLOR_YELLOW, -1)
|
curses.init_pair(C_SYSTEM, curses.COLOR_YELLOW, -1)
|
||||||
curses.init_pair(C_INPUT, curses.COLOR_WHITE, -1)
|
curses.init_pair(C_INPUT, curses.COLOR_WHITE, -1)
|
||||||
curses.init_pair(C_STATUS, curses.COLOR_BLACK, curses.COLOR_YELLOW)
|
curses.init_pair(C_STATUS, curses.COLOR_BLACK, curses.COLOR_YELLOW)
|
||||||
curses.init_pair(C_STATUS_READY, curses.COLOR_WHITE, curses.COLOR_GREEN)
|
curses.init_pair(C_STATUS_READY, curses.COLOR_BLACK, curses.COLOR_GREEN + 8)
|
||||||
curses.init_pair(C_STATUS_PROC, curses.COLOR_BLACK, curses.COLOR_YELLOW)
|
curses.init_pair(C_STATUS_PROC, curses.COLOR_BLACK, curses.COLOR_YELLOW)
|
||||||
curses.init_pair(C_STATUS_INFO, curses.COLOR_WHITE, -1)
|
curses.init_pair(C_STATUS_INFO, curses.COLOR_WHITE, -1)
|
||||||
curses.init_pair(C_SEP, curses.COLOR_MAGENTA, -1)
|
curses.init_pair(C_SEP, curses.COLOR_MAGENTA, -1)
|
||||||
curses.init_pair(C_ERROR, curses.COLOR_RED, -1)
|
curses.init_pair(C_ERROR, curses.COLOR_RED, -1)
|
||||||
curses.init_pair(C_INPUT_BORDER, curses.COLOR_BLUE, -1)
|
curses.init_pair(C_INPUT_BORDER, curses.COLOR_BLUE, -1)
|
||||||
|
curses.init_pair(C_HINT_DISABLED, 8, -1) # abu-abu di atas bg default
|
||||||
|
|
||||||
|
|
||||||
def draw(app, stdscr):
|
def draw(app, stdscr):
|
||||||
@ -75,7 +77,7 @@ def draw_chat(app, stdscr):
|
|||||||
rendered = []
|
rendered = []
|
||||||
|
|
||||||
def _wrap_render(text, indent=0, color=C_INPUT):
|
def _wrap_render(text, indent=0, color=C_INPUT):
|
||||||
available = w - indent
|
available = w - indent - 1 # sisakan 1 kolom margin kanan
|
||||||
if available <= 0:
|
if available <= 0:
|
||||||
rendered.append((color, " " * indent))
|
rendered.append((color, " " * indent))
|
||||||
return
|
return
|
||||||
@ -147,8 +149,8 @@ def draw_chat(app, stdscr):
|
|||||||
for i in range(app.scroll, min(app.scroll + chat_h, total)):
|
for i in range(app.scroll, min(app.scroll + chat_h, total)):
|
||||||
color, text = rendered[i]
|
color, text = rendered[i]
|
||||||
attr = curses.color_pair(color) | curses.A_BOLD if color else curses.A_NORMAL
|
attr = curses.color_pair(color) | curses.A_BOLD if color else curses.A_NORMAL
|
||||||
if len(text) >= w:
|
if len(text) > w:
|
||||||
text = text[: w - 1]
|
text = text[:w]
|
||||||
try:
|
try:
|
||||||
stdscr.addstr(y, 0, text, attr)
|
stdscr.addstr(y, 0, text, attr)
|
||||||
except curses.error:
|
except curses.error:
|
||||||
@ -273,3 +275,9 @@ def draw_status(app, stdscr):
|
|||||||
mode_end = mode_start + len(mode)
|
mode_end = mode_start + len(mode)
|
||||||
mode_attr = curses.color_pair(C_STATUS_READY) if not app.processing else curses.color_pair(C_STATUS_PROC)
|
mode_attr = curses.color_pair(C_STATUS_READY) if not app.processing else curses.color_pair(C_STATUS_PROC)
|
||||||
stdscr.addstr(y, mode_start, mode, mode_attr | curses.A_BOLD)
|
stdscr.addstr(y, mode_start, mode, mode_attr | curses.A_BOLD)
|
||||||
|
|
||||||
|
# ^D:send — abu-abu saat processing, bold putih saat idle
|
||||||
|
if app.processing:
|
||||||
|
stdscr.addstr(y, mode_end + 2, "^D:send", curses.color_pair(C_HINT_DISABLED))
|
||||||
|
else:
|
||||||
|
stdscr.addstr(y, mode_end + 2, "^D:send", curses.color_pair(C_STATUS_INFO) | curses.A_BOLD)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user