diff options
| author | user <user@clank> | 2026-08-15 23:35:58 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-15 23:35:58 +0200 |
| commit | dabeb8eb2da8e87c52ad068173bf52204f3b76d6 (patch) | |
| tree | 5cadbd8d91ae5a21946080e030116c4d61f4eb0b /tests | |
| parent | sl0ppty: say what the config could not honour (diff) | |
| download | slosh-dabeb8eb2da8e87c52ad068173bf52204f3b76d6.tar.gz slosh-dabeb8eb2da8e87c52ad068173bf52204f3b76d6.tar.xz slosh-dabeb8eb2da8e87c52ad068173bf52204f3b76d6.zip | |
sl0ppty: one family of marks for the frame's buttons
⊟ ⊞ ⊠ away, bigger, gone
⊟ ⊡ ⊠ ...and while it is already filling the tab
`_ # x` said what they did only if you already knew, and `*` for a zoomed
pane was the weakest of the four: nothing about an asterisk says "put it
back". So there are four marks now instead of three and a half, with the
unzoom state getting one of its own.
ASCII was there for a reason, and the reason survives: the cells are
even, but a glyph that does not fill its own cell hands the slack to the
gap beside it, and how much it hands over depends on the font -- which is
why box-drawing and block characters were tried here and looked unevenly
spaced. Four copies of *the same box* answer that better than four
unrelated glyphs did: whatever a font does with the box, it does four
times, and only the interior changes. Minus for away, plus for bigger,
dot for back to normal, times for gone.
Single width, checked in a real frame rather than assumed -- the row
still closes on its corner and each button is still measured rather than
booked, so the hits land where the glyphs are. Not emoji, which many
terminals draw two columns wide while chrome here is booked as one.
Two tests were pinning the old glyphs by hand (`line.rindex("x")` for the
cheatsheet's close button, `"*" in line` for the zoom state). They read
them out of `sl0ppty --dump-config` now, which is generated from the
code: picking a nicer mark later cannot leave a test asserting a glyph
nothing draws.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_help.py | 21 | ||||
| -rw-r--r-- | tests/test_zoom.py | 22 |
2 files changed, 37 insertions, 6 deletions
diff --git a/tests/test_help.py b/tests/test_help.py index 69088c7..d4300bd 100644 --- a/tests/test_help.py +++ b/tests/test_help.py @@ -5,10 +5,12 @@ It is built from the bindings the config actually has, not from a list of what the defaults are — a cheatsheet that can disagree with the keyboard is worse than none, and it would disagree the first time somebody rebound a key. """ +import re +import subprocess import sys import tempfile -from harness import Session, check, report +from harness import BIN, Session, check, report SH = ["/bin/sh", "-c", 'printf "\\033]2;p\\007"; stty raw -echo; cat'] @@ -20,6 +22,19 @@ def cfg(text): return f.name +def close_mark(): + """The mark the close button is drawn with, read from the binary rather than + written down here: `--dump-config` is generated from the code, so changing + the default cannot leave this test asserting a glyph nothing draws.""" + out = subprocess.run([BIN, "--dump-config"], capture_output=True, + text=True).stdout + m = re.search(r'close_mark "(.+)"', out) + return m.group(1) if m else "x" + + +MARK = close_mark() + + def open_help(s): s.send(r"\x01?") s.settle() @@ -116,7 +131,7 @@ def test_the_close_button_can_be_seen_without_hovering_it(): snap = open_help(s) y, line = modal_top(snap) check("the modal has a top border", y is not None, snap.screen()) - x = line.rindex("x") + x = line.rindex(MARK) fg, bg = style(snap, x, y) check("the close button is not its own background", fg != bg, f"fg {fg} bg {bg}") @@ -129,7 +144,7 @@ def test_the_close_button_closes_it(): s.settle() snap = open_help(s) y, line = modal_top(snap) - s.click(line.rindex("x"), y) + s.click(line.rindex(MARK), y) s.settle() check("clicking the button puts it away", "split into columns" not in s.snapshot().screen()) diff --git a/tests/test_zoom.py b/tests/test_zoom.py index 285269d..d4dca17 100644 --- a/tests/test_zoom.py +++ b/tests/test_zoom.py @@ -7,14 +7,30 @@ layout being recomputed, that it cannot outlive the pane it names, and that it is per tab. """ import os +import re +import subprocess import sys import tempfile -from harness import Session, check, report +from harness import BIN, Session, check, report SH = ["/bin/sh", "-c", 'printf "\\033]2;p\\007"; stty raw -echo; cat'] +def mark(name): + """A chrome mark as the binary currently draws it. Read from + `--dump-config`, which is generated from the code, rather than written down + here -- a test that pins a glyph starts failing the day somebody picks a + nicer one, and says nothing useful when it does.""" + out = subprocess.run([BIN, "--dump-config"], capture_output=True, + text=True).stdout + m = re.search(name + r' "(.+)"', out) + return m.group(1) if m else "?" + + +ZOOM, ZOOM_ON = mark("zoom_mark"), mark("zoom_on_mark") + + def cfg(text): f = tempfile.NamedTemporaryFile("w", suffix=".kdl", delete=False) f.write(text) @@ -76,7 +92,7 @@ def test_the_button_toggles_and_says_which_way(): s.click(b["x"] + 1, b["y"]) s.settle(20) check("clicking it zooms", len(visible(s)) == 1, str(s.panes())) - check("and the mark says so", "*" in s.snapshot().line(2), + check("and the mark says so", ZOOM_ON in s.snapshot().line(2), repr(s.snapshot().line(2)[-14:])) # The button moved: the pane it belongs to just became the whole tab. @@ -85,7 +101,7 @@ def test_the_button_toggles_and_says_which_way(): s.settle(20) check("clicking it again puts it back", len(visible(s)) == 2, str(s.panes())) - check("and the mark goes back too", "#" in s.snapshot().line(2), + check("and the mark goes back too", ZOOM in s.snapshot().line(2), repr(s.snapshot().line(2)[-14:])) |
