diff options
| author | user <user@clank> | 2026-09-22 15:38:08 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-22 15:38:08 +0200 |
| commit | 1cbfb4474ca31c61254be8d5f3ec046967bd1ff3 (patch) | |
| tree | 3e8184674e330ce24ebef23dd13594fa38f45fa2 /tests | |
| parent | sidebar: room for the spinner, by default (tab_bar_padding 0 1 0 2) (diff) | |
| download | slosh-1cbfb4474ca31c61254be8d5f3ec046967bd1ff3.tar.gz slosh-1cbfb4474ca31c61254be8d5f3ec046967bd1ff3.tar.xz slosh-1cbfb4474ca31c61254be8d5f3ec046967bd1ff3.zip | |
theme: the busy spinner is its own colour (tab_status_spinner)
It was drawn in tab_status_busy, the colour of the words it sits beside, which
made one decision out of two. The words have to stay readable at a glance and
a mark does not: a theme may well want the glyph loud and the text calm -- or
the text in the accent and the mark a quiet dot -- and with one entry neither
is available without moving both.
Unset it follows tab_status_busy, derived after it and from whatever that
resolved to, named or derived, so nothing changes for anyone who does not ask
and no theme in contrib needs a line. `--dump-theme` writes both, like every
other colour the compositor draws.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_tab_bar.py | 60 | ||||
| -rw-r--r-- | tests/test_themes.py | 8 |
2 files changed, 66 insertions, 2 deletions
diff --git a/tests/test_tab_bar.py b/tests/test_tab_bar.py index ad523ad..6a1a0a5 100644 --- a/tests/test_tab_bar.py +++ b/tests/test_tab_bar.py @@ -648,8 +648,64 @@ def test_the_busy_colour_is_the_themes_own(): _status(s, "make test") _busy(s) s.settle(30) - st = s.snapshot().style_at(CX + 1, Y0 + 1) + snap = s.snapshot() + st = snap.style_at(CX + 2, Y0 + 1) check("named, it wins", st["fg"] == "#ff00ff", str(st)) + check( + "and the mark follows the words it marks", + (snap.style_at(CX, Y0 + 1) or {}).get("fg") == "#ff00ff", + str(snap.style_at(CX, Y0 + 1)), + ) + + +def test_the_spinner_can_be_coloured_on_its_own(): + """Its own entry because it is its own decision: the words have to stay + readable and a mark does not, so a theme can shout with the glyph and keep + the text calm.""" + themed = _cfg( + f'tab_bar_side "left"\ntab_bar_width {W}\n' + 'theme { tab_status_busy "#8888ff"\n tab_status_spinner "#ffcc00" }\n' + ) + with Session(SH, cols=90, rows=20, config=themed) as s: + s.settle(30) + _status(s, "make test") + _busy(s) + s.settle(30) + snap = s.snapshot() + check( + "the mark takes its own colour", + (snap.style_at(CX, Y0 + 1) or {}).get("fg") == "#ffcc00", + str(snap.style_at(CX, Y0 + 1)), + ) + check( + "...and the words keep theirs", + (snap.style_at(CX + 2, Y0 + 1) or {}).get("fg") == "#8888ff", + str(snap.style_at(CX + 2, Y0 + 1)), + ) + + +def test_an_old_theme_gets_a_spinner_colour_anyway(): + """Neither colour is in any theme in contrib, so both are mixed from what a + theme does define -- the same bargain the other status colours make.""" + old = _cfg( + f'tab_bar_side "left"\ntab_bar_width {W}\ntheme {{ tab_hover "#00ff88" }}\n' + ) + with Session(SH, cols=90, rows=20, config=old) as s: + s.settle(30) + _status(s, "make test") + _busy(s) + s.settle(30) + snap = s.snapshot() + check( + "the row is the theme's accent", + (snap.style_at(CX + 2, Y0 + 1) or {}).get("fg") == "#00ff88", + str(snap.style_at(CX + 2, Y0 + 1)), + ) + check( + "...and so is the mark", + (snap.style_at(CX, Y0 + 1) or {}).get("fg") == "#00ff88", + str(snap.style_at(CX, Y0 + 1)), + ) def test_status_rows_take_their_own_theme_colours(): @@ -1272,6 +1328,8 @@ if __name__ == "__main__": test_a_spinner_costs_a_frame_clock_and_a_mark_does_not() test_no_busy_mark_leaves_the_colour_to_say_it() test_the_busy_colour_is_the_themes_own() + test_the_spinner_can_be_coloured_on_its_own() + test_an_old_theme_gets_a_spinner_colour_anyway() test_status_rows_take_their_own_theme_colours() test_an_old_theme_gets_coherent_status_colours_anyway() test_a_monochrome_theme_stays_monochrome() diff --git a/tests/test_themes.py b/tests/test_themes.py index d9c67b0..e9f5495 100644 --- a/tests/test_themes.py +++ b/tests/test_themes.py @@ -26,7 +26,13 @@ THEMES = sorted(glob.glob(os.path.join(THEMEDIR, "*.kdl"))) # from colours the theme does define (so a theme gets them in its own family # without a line), and the opt-in ones are unset on purpose, because a band # behind a row takes a translucent terminal's own background away. -DERIVED = {"tab_status_fg", "tab_status_stripe", "tab_status_busy", "tab_idle_bg"} +DERIVED = { + "tab_status_fg", + "tab_status_stripe", + "tab_status_busy", + "tab_status_spinner", + "tab_idle_bg", +} OPT_IN = {"tab_status_bg", "attach_bg"} # The scrollback search tints: one theme in contrib names them and the rest # take the compiled-in pair, which reads the same on every palette here. |
