diff options
| author | user <user@clank> | 2026-09-10 16:32:10 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-10 16:32:10 +0200 |
| commit | a2d08f4876226446c0052f033e8afea2f2ffbbf1 (patch) | |
| tree | ac77189b9c928939202adca4a43298730bccd8d2 /tests | |
| parent | sidebar: the new-tab button says what it is, given a row to say it on (diff) | |
| download | slosh-a2d08f4876226446c0052f033e8afea2f2ffbbf1.tar.gz slosh-a2d08f4876226446c0052f033e8afea2f2ffbbf1.tar.xz slosh-a2d08f4876226446c0052f033e8afea2f2ffbbf1.zip | |
sidebar: statuses wear italic instead of an indent, and can wear colour
Three columns of indent is a fifth of a sixteen-column sidebar, spent
saying 'this belongs to the row above'. The slant says it in none: a
status now starts in the same column its tab's name starts in, and is
set in italic. That also survives the monochrome themes in contrib,
where a colour-only distinction would have had nothing to spend.
tab_status_fg / tab_status_bg are there for themes that do have colour
to spend. The fg follows tab_count when a theme does not name it -- the
same declared/derived split apply_scrolled makes -- so the six themes
in contrib get coherent status rows without a line added to any of
them. The bg is unset by default, because a band is opt-in and 'none'
is what a translucent terminal wants; the row is padded so a band that
*is* set covers the row rather than the words on it.
Two things fell out. The padding loop existed three times and is now
pad_cells. And cb_color wrote #000000 for an unset colour, so
quietly pinned attach_bg -- 'gray
ink on the terminal's own background', says its comment -- to a black
band. Unset colours are now written commented out, the same trick the
states block uses for what it wants re-derived rather than pinned.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_dump_config.py | 11 | ||||
| -rw-r--r-- | tests/test_tab_bar.py | 57 |
2 files changed, 67 insertions, 1 deletions
diff --git a/tests/test_dump_config.py b/tests/test_dump_config.py index d6b3fd4..67679a1 100644 --- a/tests/test_dump_config.py +++ b/tests/test_dump_config.py @@ -106,7 +106,16 @@ def test_every_theme_colour_is_in_it(): src = open(SRC).read() colours = set(re.findall(r'\{"([a-z_]+)", offsetof\(config_t', src)) text = dump() - missing = sorted(c for c in colours if f" {c} " not in text) + # A colour that is *unset* is the terminal's own, and a theme block has no + # spelling for that -- parse_color takes #rrggbb and nothing else. Those + # are written commented out, so the dump still names the key while loading + # it back does not pin "none" to black. Same tolerance the settings check + # above already has. + missing = sorted( + c + for c in colours + if not re.search(r"^\s*(// )?%s[ \"]" % re.escape(c), text, re.M) + ) check( f"all {len(colours)} colours are rendered", not missing, diff --git a/tests/test_tab_bar.py b/tests/test_tab_bar.py index ce3ad9b..3fa3154 100644 --- a/tests/test_tab_bar.py +++ b/tests/test_tab_bar.py @@ -171,6 +171,60 @@ def test_status_rows_sit_under_their_tab(): ) +def test_status_rows_are_told_apart_by_the_slant_not_by_an_indent(): + with Session(SH, cols=90, rows=20, config=LEFT) as s: + s.settle(30) + _status(s, "building 3/7") + snap = s.snapshot() + label, status = _row(snap, Y0), _row(snap, Y0 + 1) + # One leading space each: a status starts in the column its tab's name + # starts in. Three columns of indent is a fifth of this sidebar. + check( + "a status is not indented under its label", + status.index("building") == label.index("1:"), + f"{status.index('building')} vs {label.index('1:')}", + ) + st = snap.style_at(CX + 1, Y0 + 1) + check("it is italic instead", "italic" in st["attrs"], str(st)) + check( + "...and the label above it is not", + "italic" not in snap.style_at(CX + 1, Y0)["attrs"], + str(snap.style_at(CX + 1, Y0)), + ) + + +def test_status_rows_take_their_own_theme_colours(): + themed = _cfg( + f'tab_bar_side "left"\ntab_bar_width {W}\n' + 'theme { tab_status_fg "#00ff88"\n tab_status_bg "#202030" }\n' + ) + with Session(SH, cols=90, rows=20, config=themed) as s: + s.settle(30) + _status(s, "building") + snap = s.snapshot() + st = snap.style_at(CX + 1, Y0 + 1) + check("the fg is the themed one", st["fg"] == "#00ff88", str(st)) + end = snap.style_at(CX + CW - 1, Y0 + 1) + check( + "and the band covers the row, not just the words", + end and end["bg"] == "#202030", + str(end), + ) + + +def test_an_old_theme_gets_coherent_status_colours_anyway(): + """A theme written before these rows existed names tab_count and nothing + about them; deriving from it beats one stock grey among its own greys.""" + old = _cfg( + f'tab_bar_side "left"\ntab_bar_width {W}\ntheme {{ tab_count "#ff8800" }}\n' + ) + with Session(SH, cols=90, rows=20, config=old) as s: + s.settle(30) + _status(s, "building") + st = s.snapshot().style_at(CX + 1, Y0 + 1) + check("the status follows tab_count", st["fg"] == "#ff8800", str(st)) + + def test_status_cap_spends_its_last_row_on_the_ellipsis(): capped = _cfg(f'tab_bar_side "left"\ntab_bar_width {W}\ntab_bar_status 1\n') with Session(SH, cols=90, rows=20, config=capped) as s: @@ -380,6 +434,9 @@ if __name__ == "__main__": test_right_sidebar_takes_the_other_edge() test_pad_pushes_the_list_down() test_status_rows_sit_under_their_tab() + test_status_rows_are_told_apart_by_the_slant_not_by_an_indent() + test_status_rows_take_their_own_theme_colours() + test_an_old_theme_gets_coherent_status_colours_anyway() test_status_cap_spends_its_last_row_on_the_ellipsis() test_a_long_status_is_cut_and_says_so() test_a_dead_pane_reports_its_exit_instead() |
