diff options
| author | user <user@clank> | 2026-08-14 14:53:34 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-14 14:53:34 +0200 |
| commit | 7f9e2a5eb2607667eb46811b2f22aba8dff09834 (patch) | |
| tree | d300225f31a8485e2119478aaf23e991a748ad1f | |
| parent | sl0ppty: a floor under splitting, and an arrow saying which way (diff) | |
| download | slosh-7f9e2a5eb2607667eb46811b2f22aba8dff09834.tar.gz slosh-7f9e2a5eb2607667eb46811b2f22aba8dff09834.tar.xz slosh-7f9e2a5eb2607667eb46811b2f22aba8dff09834.zip | |
sl0ppty: the resize gap says it is a handle
The gap between two panes has always been draggable and has always looked
exactly like nothing. Resting on one now marks it dotted, and the mark doubles
and goes bold once you actually have hold of it — because "you could move
this" and "you are moving this" are different claims, and the second should
not have to be inferred from the panes changing size underneath you.
Dotted for a possibility, weight for a commitment: the same grammar the split
guide already uses, so there is one visual language to learn rather than two.
Vertical boundaries get vertical marks and horizontal ones horizontal, along
the axis the boundary actually runs.
It arms on dwell like the split guide, because crossing a gap on the way to
the pane on the other side is the most ordinary mouse movement there is, and a
pointer already carrying a pane is not shopping for a boundary — a title drag
passing over a gap arms nothing.
The hint is tested against the very rect registered as that gap's hit, in the
same loop iteration that registers it, so it cannot appear anywhere the click
would not land without having to trust a lookup to agree.
One thing that would have made this silently useless: app_next_timeout only
scheduled a repaint for hovers over `border:` and `title:`, so a hint that
arms on dwell over `edge:` would only have appeared when some unrelated event
happened to repaint the frame — visible when the session was busy and not when
it was idle, which is the worst way for it to be wrong. Everything that arms
on dwell has to be listed there, and now is.
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | src/app.c | 47 | ||||
| -rw-r--r-- | tests/test_drag.py | 103 |
3 files changed, 152 insertions, 2 deletions
@@ -62,7 +62,9 @@ worth having. Click a pane to focus it, a tab to switch, `+tab` to open one, a collapsed header to expand it, and a pane's own buttons to talk to the program inside it. **Drag a pane's title bar onto another pane to swap them, or drag the gap between two panes to move the -boundary.** While you drag, every *other* pane drains to grey and drops in +boundary.** Resting on a gap marks it dotted to say it is a handle, and +doubles the mark while you are actually moving it. While you drag a pane, +every *other* pane drains to grey and drops in brightness while its border turns dashed — they are all places the pane could land — and the one in your hand keeps its colour and a solid border, so it lifts off the page. Focus follows the pointer (`focus_follows_mouse`, on by @@ -246,9 +246,12 @@ int app_next_deadline_ms(app_t *a) { if (a->ptr_valid && a->painted) { int64_t due = a->ptr_still_since + CFG.hover_delay_ms; if (due > now_ms_()) { + /* Everything that arms on dwell has to be listed here, or it would only + * appear when some unrelated event happened to repaint the frame. */ const char *action = hit_test(&a->painted->hits, a->ptr_x, a->ptr_y); bool on_border = action && (strncmp(action, "border:", 7) == 0 || - strncmp(action, "title:", 6) == 0); + strncmp(action, "title:", 6) == 0 || + strncmp(action, "edge:", 5) == 0); if (on_border && (soonest < 0 || due < soonest)) soonest = due; } } @@ -1705,6 +1708,47 @@ static void draw_tab_strip(app_t *a, screen_t *s) { } } +/* The gap between two panes is a handle, and nothing about two blank columns + * says so. So it says it on hover — and says something else once you have hold + * of it, because "you could move this" and "you are moving this" are different + * claims and the second one should not have to be inferred from the panes + * changing size. + * + * Dotted while available, doubled and bold while engaged: the same grammar the + * split guide already uses, where dashes are a possibility and weight is a + * commitment. */ +static void draw_resize_hint(app_t *a, screen_t *s, node_t *split, size_t idx, + rect_t gapr) { + bool active = a->drag.kind == DRAG_EDGE && a->drag.src == split->id && + a->drag.edge == idx; + if (!active) { + /* A pointer busy with anything else is not shopping for a boundary. */ + if (a->drag.kind != DRAG_NONE || !a->ptr_valid) return; + /* Tested against the very rect just registered as this gap's hit, in the + * same loop iteration — so the hint cannot appear anywhere the click would + * not land, without having to trust a lookup to agree. */ + if (a->ptr_x < gapr.x || a->ptr_x >= gapr.x + gapr.w || a->ptr_y < gapr.y || + a->ptr_y >= gapr.y + gapr.h) + return; + /* Arm on dwell, like the split guide: crossing a gap on the way to a pane + * is the most ordinary mouse movement there is. */ + if (now_ms_() - a->ptr_still_since < CFG.hover_delay_ms) return; + } + + uint16_t attrs = active ? ATTR_BOLD : 0; + if (split->dir == SPLIT_COLS) { + uint16_t x = (uint16_t)(gapr.x + gapr.w / 2); + for (uint16_t y = gapr.y; y < gapr.y + gapr.h; y++) + screen_text(s, x, y, active ? "\u2551" : "\u250a", FRAME_FOCUS, NO_COLOR, + attrs); + } else { + uint16_t y = (uint16_t)(gapr.y + gapr.h / 2); + for (uint16_t x = gapr.x; x < gapr.x + gapr.w; x++) + screen_text(s, x, y, active ? "\u2550" : "\u2508", FRAME_FOCUS, NO_COLOR, + attrs); + } +} + static void draw_node(app_t *a, screen_t *s, node_t *n) { if (n->collapsed) { draw_collapsed(a, s, n); @@ -1735,6 +1779,7 @@ static void draw_node(app_t *a, screen_t *s, node_t *n) { char action[48]; snprintf(action, sizeof action, "edge:%u:%zu", n->id, i); hit_add(&s->hits, gapr.x, gapr.y, gapr.w, gapr.h, action); + draw_resize_hint(a, s, n, i, gapr); } for (size_t i = 0; i < n->nkids; i++) draw_node(a, s, n->kids[i]); diff --git a/tests/test_drag.py b/tests/test_drag.py index b392f3c..36fa83d 100644 --- a/tests/test_drag.py +++ b/tests/test_drag.py @@ -6,6 +6,7 @@ split is equal weights, and every layout pass is still the same pure function of the tree and the rect. """ import sys +import time from harness import Session, check, report @@ -212,6 +213,104 @@ def test_drop_target_is_visible(): s.send(rf"\e[<0;{right['x'] + 5};{right['y'] + 3}m") +# ---- the resize zone announces itself -------------------------------------- + +GRIP_V, GRAB_V = "\u250a", "\u2551" # dotted / doubled, vertical boundary +GRIP_H, GRAB_H = "\u2508", "\u2550" # dotted / doubled, horizontal boundary + + +def test_the_gap_says_it_is_a_handle(): + with Session(SH, cols=120, rows=26) as s: + s.settle() + s.key("\\\\") + s.settle(200) + left, right = s.panes() + gx, gy = left["x"] + left["w"], left["y"] + 3 + + check("an idle gap is blank", GRIP_V not in s.snapshot().screen(), "") + + # Crossing a gap on the way somewhere is the most ordinary mouse + # movement there is, so contact alone must not arm it. + s.send(rf"\e[<35;{gx + 1};{gy + 1}M") + s.settle(60) + check("contact alone does not arm it", + GRIP_V not in s.snapshot().screen(), "") + + time.sleep(0.35) + s.settle(60) + snap = s.snapshot() + check("resting on it says it can be moved", GRIP_V in snap.screen(), "") + check("and does not yet claim it is being moved", + GRAB_V not in snap.screen(), "") + + pos = snap.find(GRIP_V) + check("the hint is in the gap, not in either pane", + pos and left["x"] + left["w"] <= pos[0] < right["x"], str(pos)) + + +def test_the_hint_changes_while_resizing(): + with Session(SH, cols=120, rows=26) as s: + s.settle() + s.key("\\\\") + s.settle(200) + left, right = s.panes() + gx, gy = left["x"] + left["w"], left["y"] + 3 + before = left["w"] + + s.send(rf"\e[<0;{gx + 1};{gy + 1}M") + s.send(rf"\e[<32;{gx + 6};{gy + 1}M") + s.settle(80) + snap = s.snapshot() + check("a resize in progress reads differently from a hover", + GRAB_V in snap.screen() and GRIP_V not in snap.screen(), "") + + s.send(rf"\e[<0;{gx + 6};{gy + 1}m") + s.settle(150) + snap = s.snapshot() + check("and the boundary actually moved", + s.panes()[0]["w"] > before, f'{before} -> {s.panes()[0]["w"]}') + check("both hints are gone once it is dropped", + GRAB_V not in snap.screen() and GRIP_V not in snap.screen(), "") + + +def test_a_horizontal_boundary_uses_horizontal_marks(): + with Session(SH, cols=120, rows=26) as s: + s.settle() + s.key("-") # split into rows + s.settle(200) + top, bottom = s.panes() + gx, gy = top["x"] + 6, top["y"] + top["h"] + + s.send(rf"\e[<35;{gx + 1};{gy + 1}M") + time.sleep(0.35) + s.settle(60) + snap = s.snapshot() + check("a row boundary hints along its own axis", + GRIP_H in snap.screen() and GRIP_V not in snap.screen(), "") + pos = snap.find(GRIP_H) + check("in the gap between the two rows", + pos and top["y"] + top["h"] <= pos[1] < bottom["y"], str(pos)) + + +def test_no_resize_hint_during_another_drag(): + """A pointer already carrying a pane is not shopping for a boundary.""" + with Session(SH, cols=120, rows=26) as s: + s.settle() + s.key("\\\\") + s.settle(200) + left, right = s.panes() + gx, gy = left["x"] + left["w"], left["y"] + 3 + + s.send(rf"\e[<0;{left['x'] + 5};{left['y'] + 1}M") # grab the title + s.send(rf"\e[<32;{gx + 1};{gy + 1}M") # drag over the gap + time.sleep(0.35) + s.settle(80) + check("a title drag over a gap arms nothing", + GRIP_V not in s.snapshot().screen(), "") + s.send(rf"\e[<0;{gx + 1};{gy + 1}m") + s.settle(80) + + if __name__ == "__main__": test_keyboard_resize() test_vertical_resize() @@ -220,4 +319,8 @@ if __name__ == "__main__": test_title_drag_reorders() test_drag_edge_cases() test_drop_target_is_visible() + test_the_gap_says_it_is_a_handle() + test_the_hint_changes_while_resizing() + test_a_horizontal_boundary_uses_horizontal_marks() + test_no_resize_hint_during_another_drag() sys.exit(report()) |
