diff options
| author | user <user@clank> | 2026-08-14 14:45:49 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-14 14:45:49 +0200 |
| commit | 037c3550f075ff78e680e5a1f1508d4c292ffcb1 (patch) | |
| tree | 18c085806ac40d1e5ff9b49e6cee668732152fde /tests/test_split_ux.py | |
| parent | sl0ppty: pane states are a table, not three hardcoded knobs (diff) | |
| download | slosh-037c3550f075ff78e680e5a1f1508d4c292ffcb1.tar.gz slosh-037c3550f075ff78e680e5a1f1508d4c292ffcb1.tar.xz slosh-037c3550f075ff78e680e5a1f1508d4c292ffcb1.zip | |
sl0ppty: a floor under splitting, and an arrow saying which way
Two changes to the same affordance.
A border stops being a button below `min_split cols=32 rows=8`. This is a
different question from min_pane, which is where the layout gives up and
collapses a pane: two twenty-five column panes technically fit and are not
worth having, so the number that decides whether to *offer* a split is larger
than the one that decides whether a pane can survive. It is clamped to never
go below min_pane, because refusing to offer what the layout would collapse
anyway is the floor under the floor.
The test is the layout's own arithmetic rather than an approximation of it:
the same floor, the same gap, and the same child count the split would create
— which is one more sibling when the parent already splits that way and two
when it does not. The guide's standing claim is that drawing and the layout
cannot disagree, and a guide promising a split that immediately collapsed
would be exactly that.
The keyboard obeys the same floor, with a toast. A rule only the mouse
followed would mean the same session splits or refuses depending on how you
asked, and whether there is room cannot depend on that. The control API and
layout files are *not* bound by it: a script asking for a pane is declaring
what it wants rather than being offered something, and D6's responsive
collapse is what catches it there. That distinction was not free — app_split_pane
went through the same helper as the keybinding, so the API was silently bound
too until a test noticed, and the interactive path is now its own function.
The guide also gained an arrow on the dashed line, pointing at the half the
new pane will take. The line already said where the boundary lands and left
which side to be inferred from which border you happened to be touching.
Pointers for left and right rather than the matching triangles: U+25C0 and
U+25B6 carry emoji presentation and are widely rendered double-width, while
screen_text books every chrome glyph as exactly one cell — so one that drew as
two would shift the rest of the row. U+25B2 is already the scroll indicator,
so the vertical pair is known good here.
Raising a floor invalidates every test that quietly relied on the old one, and
nine of them did: sessions sized for a world where a sixty-column terminal
could be split into columns. They are sized for the rule now, and the two that
were really about *layout* collapse rather than the affordance now split over
the API, which is the path that still means "do it anyway".
Diffstat (limited to 'tests/test_split_ux.py')
| -rw-r--r-- | tests/test_split_ux.py | 128 |
1 files changed, 120 insertions, 8 deletions
diff --git a/tests/test_split_ux.py b/tests/test_split_ux.py index 17f368a..faa1341 100644 --- a/tests/test_split_ux.py +++ b/tests/test_split_ux.py @@ -5,11 +5,20 @@ The old per-pane `+` was one glyph for a verb that has four directions, and it taxed every frame three columns forever. A border encodes the direction by being on that side, costs nothing when idle, and shows a preview on hover. """ +import os import sys +import tempfile import time from harness import Session, check, report + +def cfg(text): + f = tempfile.NamedTemporaryFile("w", suffix=".kdl", delete=False) + f.write(text) + f.close() + return f.name + SH = ["/bin/sh", "-c", 'printf "\\033]2;shell\\007"; stty raw -echo; cat'] @@ -48,7 +57,7 @@ def test_each_border_splits_toward_itself(): ("bottom", lambda p: (p["x"] + 4, p["y"] + p["h"] - 1), "below"), ("top", lambda p: (p["x"] + 4, p["y"]), "above"), ]: - with Session(SH, cols=70, rows=18) as s: + with Session(SH, cols=80, rows=26) as s: s.settle() before = s.pane() x, y = cell(before) @@ -81,7 +90,7 @@ def test_each_border_splits_toward_itself(): def test_the_guide(): - with Session(SH, cols=60, rows=14) as s: + with Session(SH, cols=80, rows=26) as s: s.settle() p = s.pane() snap = s.snapshot() @@ -118,7 +127,7 @@ def test_guide_follows_the_new_layout(): until the mouse moved and corrected it. It is derived during the paint now, from the rects that paint registered. """ - with Session(SH, cols=54, rows=12) as s: + with Session(SH, cols=120, rows=26) as s: s.settle() p = s.pane() edge_x, edge_y = p["x"] + p["w"] - 1, p["y"] + 3 @@ -146,7 +155,7 @@ def test_guide_follows_the_new_layout(): def test_the_guide_waits_for_a_rest(): """A pointer crossing a border on its way elsewhere must not flash it.""" - with Session(SH, cols=54, rows=12) as s: + with Session(SH, cols=80, rows=26) as s: s.settle() p = s.pane() left, right = p["x"], p["x"] + p["w"] - 1 @@ -179,7 +188,7 @@ def test_the_guide_waits_for_a_rest(): def test_press_skips_the_wait(): - with Session(SH, cols=54, rows=12) as s: + with Session(SH, cols=80, rows=26) as s: s.settle() p = s.pane() x, y = p["x"] + p["w"] - 1, p["y"] + 3 @@ -195,7 +204,7 @@ def test_delay_is_configurable(): f = tempfile.NamedTemporaryFile("w", suffix=".kdl", delete=False) f.write("hover_delay_ms 0\n") f.close() - with Session(SH, cols=54, rows=12, config=f.name) as s: + with Session(SH, cols=80, rows=26, config=f.name) as s: s.settle() p = s.pane() hover(s, p["x"], p["y"] + 3) @@ -206,7 +215,7 @@ def test_delay_is_configurable(): def test_guide_is_per_pane(): - with Session(SH, cols=90, rows=14) as s: + with Session(SH, cols=150, rows=26) as s: s.settle() s.key("\\\\") s.settle() @@ -222,7 +231,7 @@ def test_guide_is_per_pane(): def test_drag_still_moves(): """The top border does double duty: click splits, drag moves.""" - with Session(SH, cols=90, rows=16) as s: + with Session(SH, cols=90, rows=26) as s: s.settle() s.key("\\\\") s.settle() @@ -262,6 +271,104 @@ def test_tiny_panes_have_no_targets(): and h["w"] < 4) for h in snap.hits), str(snap.hits)) +# ---- the floor: a split that is not worth making is not offered ------------ + +ARROWS = {"l": "\u25c4", "r": "\u25ba", "t": "\u25b2", "b": "\u25bc"} + + +def edge_of(pane, side): + if side == "l": + return pane["x"], pane["y"] + 2 + if side == "r": + return pane["x"] + pane["w"] - 1, pane["y"] + 2 + if side == "t": + return pane["x"] + 4, pane["y"] + return pane["x"] + 4, pane["y"] + pane["h"] - 1 + + +def test_a_split_below_the_floor_is_not_offered(): + """min_split is a usability floor, not the physical one: the pane below + would still *fit* by min_pane, and is refused anyway.""" + conf = cfg("min_pane cols=10 rows=3\nmin_split cols=40 rows=14\n") + with Session(SH, cols=80, rows=26, config=conf) as s: + s.settle() + p = s.pane() + for side in ("l", "r", "t", "b"): + x, y = edge_of(p, side) + rest(s, x, y) + snap = s.snapshot() + body = snap.screen() + check(f"resting on the {side} border arms nothing below the floor", + "\u2503" not in body and "\u2501" not in body, repr(body[:80])) + click(s, x, y) + s.settle(80) + check(f"and clicking the {side} border splits nothing", + len(s.panes()) == 1, str(len(s.panes()))) + os.unlink(conf) + + +def test_the_floor_is_configurable_in_both_axes(): + # Wide enough for columns, too short for rows. + conf = cfg("min_split cols=20 rows=40\n") + with Session(SH, cols=90, rows=26, config=conf) as s: + s.settle() + p = s.pane() + x, y = edge_of(p, "b") + click(s, x, y) + s.settle(80) + check("a row split below the row floor is refused", + len(s.panes()) == 1, str(len(s.panes()))) + x, y = edge_of(p, "r") + click(s, x, y) + s.settle(80) + check("while a column split above the column floor still happens", + len(s.panes()) == 2, str(len(s.panes()))) + os.unlink(conf) + + +def test_the_keyboard_obeys_the_same_floor(): + conf = cfg("min_split cols=40 rows=14\n") + with Session(SH, cols=80, rows=26, config=conf) as s: + s.settle() + s.key("\\\\") + s.settle(80) + check("the keyboard will not split below the floor either", + len(s.panes()) == 1, str(len(s.panes()))) + # ...but a script asking for a pane is declaring, not being offered. + s.api("split", dir="cols") + s.settle(80) + check("the control API is not bound by it", len(s.panes()) == 2, + str(len(s.panes()))) + os.unlink(conf) + + +def test_the_guide_says_which_way_it_goes(): + with Session(SH, cols=120, rows=26) as s: + s.settle() + p = s.pane() + for side in ("l", "r", "t", "b"): + x, y = edge_of(p, side) + rest(s, x, y) + body = s.snapshot().screen() + check(f"the {side} guide carries its own arrow", + ARROWS[side] in body, repr(ARROWS[side])) + others = [a for k, a in ARROWS.items() if k != side] + check(f"and only that one", not any(o in body for o in others), + repr(body[:80])) + + +def test_the_arrow_sits_on_the_new_boundary(): + with Session(SH, cols=120, rows=26) as s: + s.settle() + p = s.pane() + x, y = edge_of(p, "r") + rest(s, x, y) + snap = s.snapshot() + pos = snap.find(ARROWS["r"]) + check("the arrow is on the dashed line, not the border", + pos is not None and pos[0] == p["x"] + p["w"] // 2, str(pos)) + + if __name__ == "__main__": test_no_more_plus() test_each_border_splits_toward_itself() @@ -273,4 +380,9 @@ if __name__ == "__main__": test_guide_is_per_pane() test_drag_still_moves() test_tiny_panes_have_no_targets() + test_a_split_below_the_floor_is_not_offered() + test_the_floor_is_configurable_in_both_axes() + test_the_keyboard_obeys_the_same_floor() + test_the_guide_says_which_way_it_goes() + test_the_arrow_sits_on_the_new_boundary() sys.exit(report()) |
