aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-25 14:52:30 -0400
committerhistoria <historiavg@proton.me>2026-08-25 14:52:30 -0400
commitfca3431721a55277f139efc83df2438207917448 (patch)
tree1d64aec465db7fa1d5098bc56c11ea70ab6b682d /app
parent061406b608c5a77b33259506648e0166367b2b9f (diff)
downloadtts-audiobook-generator-fca3431721a55277f139efc83df2438207917448.tar.gz
feat: clearer colors for buttons
Diffstat (limited to 'app')
-rw-r--r--app/tests/test_tui.py13
-rw-r--r--app/ui/tui.py8
2 files changed, 16 insertions, 5 deletions
diff --git a/app/tests/test_tui.py b/app/tests/test_tui.py
index 030b668..964f983 100644
--- a/app/tests/test_tui.py
+++ b/app/tests/test_tui.py
@@ -58,6 +58,7 @@ class FakeCurses:
def __init__(self):
self.pairs = {} # pair number -> (fg, bg)
self.colors = True
+ self.COLORS = 256
def has_colors(self):
return self.colors
@@ -167,6 +168,14 @@ class ThemeTests(TuiTestCase):
self.assertEqual((fg, bg),
(FakeCurses.COLOR_BLACK, FakeCurses.COLOR_GREEN))
+ def test_inactive_button_is_white_on_dark_gray(self):
+ frame = tui.Frame(self.screen, "Title", "footer")
+ theme, pairs = frame.theme, self.curses.pairs
+ fg, bg = pairs[theme["btn_off"] >> 8]
+ self.assertEqual((fg, bg),
+ (FakeCurses.COLOR_WHITE, 236))
+ self.assertFalse(theme["btn_off"] & FakeCurses.A_BOLD)
+
def test_without_colors_theme_uses_plain_attributes(self):
self.curses.colors = False
frame = tui.Frame(self.screen, "Title", "footer")
@@ -261,7 +270,7 @@ class MenuTests(TuiTestCase):
screen = FakeScreen(keys=[10])
tui.menu(screen, "Pick", self.OPTIONS)
x0, _ = self.dialog_box(screen)
- arrow_x = x0 + 1 + tui.Frame.LIST_MARGIN - 1
+ arrow_x = x0 + 1 + tui.Frame.LIST_MARGIN - 2
arrows = [(y, x) for y, x, ch, _ in screen.chars
if ch == FakeCurses.ACS_RARROW]
y_first = next(y for y, _, text, _ in screen.strings
@@ -273,7 +282,7 @@ class MenuTests(TuiTestCase):
screen = FakeScreen(keys=[FakeCurses.KEY_DOWN, 10])
tui.menu(screen, "Pick", self.OPTIONS)
x0, _ = self.dialog_box(screen)
- arrow_x = x0 + 1 + tui.Frame.LIST_MARGIN - 1
+ arrow_x = x0 + 1 + tui.Frame.LIST_MARGIN - 2
arrows = [y for y, x, ch, _ in screen.chars
if ch == FakeCurses.ACS_RARROW and x == arrow_x]
y_first = next(y for y, _, text, _ in screen.strings
diff --git a/app/ui/tui.py b/app/ui/tui.py
index 34c9a3e..663df0a 100644
--- a/app/ui/tui.py
+++ b/app/ui/tui.py
@@ -178,7 +178,7 @@ def _ensure_theme(curses) -> dict:
"input": curses.A_BOLD,
"bar": curses.A_REVERSE,
"btn_on": curses.A_REVERSE | curses.A_BOLD,
- "btn_off": curses.A_DIM,
+ "btn_off": curses.A_BOLD,
"check": curses.A_BOLD,
"accent": curses.A_BOLD,
}
@@ -186,6 +186,7 @@ def _ensure_theme(curses) -> dict:
try:
curses.start_color()
black = curses.COLOR_BLACK
+ gray = 236 if getattr(curses, "COLORS", 0) >= 256 else black
pairs = {
"desktop": (curses.COLOR_WHITE, black),
"border": (curses.COLOR_CYAN, black),
@@ -197,6 +198,7 @@ def _ensure_theme(curses) -> dict:
"input": (curses.COLOR_WHITE, black),
"bar": (curses.COLOR_BLACK, curses.COLOR_CYAN),
"btn_on": (curses.COLOR_BLACK, curses.COLOR_GREEN),
+ "btn_off": (curses.COLOR_WHITE, gray),
"check": (curses.COLOR_GREEN, black),
"accent": (curses.COLOR_CYAN, black),
}
@@ -205,7 +207,7 @@ def _ensure_theme(curses) -> dict:
theme[name] = curses.color_pair(number)
theme["dim"] = curses.A_DIM | theme["desktop"]
theme["body"] = theme["desktop"]
- theme["btn_off"] = curses.A_DIM | theme["desktop"]
+
for name in ("title", "ok", "warn", "err", "check", "accent",
"input"):
theme[name] |= curses.A_BOLD
@@ -450,7 +452,7 @@ class Frame:
if selected:
_addstr(scr, y, inner_x, " " * inner_w, theme["bar"])
if row["align"] == "left":
- _addch(scr, y, inner_x + self.LIST_MARGIN - 1,
+ _addch(scr, y, inner_x + self.LIST_MARGIN - 2,
self.curses.ACS_RARROW, theme["bar"])
if row["segments"] is not None:
self._draw_segments_row(y, row, inner_x, inner_w, selected)