diff options
| author | Gabriel Schneider <[email protected]> | 2026-07-08 04:22:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-01 15:02:07 -0300 |
| commit | b6b899b40a339441694ab7443b00967da8f0b100 (patch) | |
| tree | baadc7212b3c0de9cd673c9830d8f90a619f4672 | |
| parent | b13152f89b478466b860aecb2bada8d96f0e9e36 (diff) | |
| download | pardes-b6b899b40a339441694ab7443b00967da8f0b100.tar.gz pardes-b6b899b40a339441694ab7443b00967da8f0b100.zip | |
2-1 chord argument falls back to other panes' selections: when the middle-drag pane has no selection of its own (kept left sel, else explicit v/x n/N), the active pane is checked first (it holds the most recently made selection), then slot order. New selarg.snap covers borrowing a kept left selection and a v selection from another pane; tutor updated.
| -rw-r--r-- | src/pardes.zig | 36 | ||||
| -rw-r--r-- | src/tutor.txt | 4 | ||||
| -rw-r--r-- | test/snapshots/selarg.golden | 93 | ||||
| -rw-r--r-- | test/snapshots/selarg.snap | 58 |
4 files changed, 181 insertions, 10 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 4750fa0b..c6513392 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -3538,16 +3538,34 @@ pub const Pardes = struct { .left => switch (m.kind) { .press => { // middle+left chord: a left press during a middle select- - // drag captures the KEPT left selection as the execute's - // argument; the middle drag keeps running to its release. + // drag captures a selection as the execute's argument; the + // middle drag keeps running to its release. The drag pane's + // own selection wins; a pane with none borrows from the + // OTHER panes (acme: the chord argument is whatever text is + // selected, in any window) — the ACTIVE pane first (making + // a selection focuses its pane, so it holds the most + // recently made one), then slot order. Per pane a kept left + // selection wins, else an explicit modal (v/x, n/N) one. if (p.drag == .select and p.drag.select.button == .middle) { - if (p.panes[p.drag.select.id]) |t| { - const sl = t.sel[0]; - if (sl.state == .done) { - if (p.chord_arg) |old| p.gpa.free(old); - const txt = p.selectionText(t, sl) catch null; - p.chord_arg = if (txt) |tx| (p.gpa.dupe(u8, tx) catch null) else null; - } + const did = p.drag.select.id; + var txt: ?[]const u8 = null; + var k: usize = 0; + while (txt == null and k < p.panes.len + 2) : (k += 1) { + const i = switch (k) { + 0 => did, + 1 => p.active, + else => k - 2, + }; + if (k > 0 and (i == did or (k > 1 and i == p.active))) continue; + const t = p.panes[i] orelse continue; + if (t.sel[0].state == .done) + txt = p.selectionText(t, t.sel[0]) catch null + else if ((t.vsel.active and t.vsel.explicit) or t.msel.active) + txt = p.currentSelText(t); + } + if (txt) |tx| { + if (p.chord_arg) |old| p.gpa.free(old); + p.chord_arg = p.gpa.dupe(u8, tx) catch null; } return; } diff --git a/src/tutor.txt b/src/tutor.txt index f61ef8cc..0b78da72 100644 --- a/src/tutor.txt +++ b/src/tutor.txt @@ -80,7 +80,9 @@ SAME hold = copy (Snarf): the text comes back, the register keeps it. After a chord the left release is inert. 2-1 hold a MIDDLE drag over a command, tap LEFT: the kept left - selection rides along as the command's ARGUMENT. + selection rides along as the command's ARGUMENT. No selection + in that pane? The other panes' are searched (active pane first) + — a kept left selection or a v/x one, wherever it lives. 2-3 / 3-1 / 3-2 tapping the other button during a MIDDLE (execute) or RIGHT (look) drag CANCELS the gesture. diff --git a/test/snapshots/selarg.golden b/test/snapshots/selarg.golden new file mode 100644 index 00000000..664962a3 --- /dev/null +++ b/test/snapshots/selarg.golden @@ -0,0 +1,93 @@ +== snap kept grid=100x30 cursor=6,2 +|Kill Newcol Tutor Debug Colors NextColor Dump +| NOR /tmp/pardes-snap/selarg/cwd Del NOR /tmp/pardes-snap/selarg/cwd Del +| ZZARG ZZVEE ./c.sh +| +| +| +| +| +| +| +| +| +| +| +| +| +| NOR /tmp/pardes-snap/selarg/cwd Del +| +| s.txt +| +| +| +| +| +| +| +| +| +| +| +== snap crosspane grid=100x30 cursor=6,2 +|Kill Newcol Tutor Debug Colors NextColor Dump +| NOR /tmp/pardes-snap/selarg/cwd Del NOR /tmp/pardes-snap/selarg/cwd Del +| ZZARG ZZVEE ./c.sh +| +| CHORDARG:ZZARG +| +| +| +| +| +| +| +| +| +| +| +| NOR /tmp/pardes-snap/selarg/cwd Del +| +| s.txt +| +| +| +| +| +| +| +| +| +| +| +== snap vselarg grid=100x30 cursor=12,2 +|Kill Newcol Tutor Debug Colors NextColor Dump +| NOR /tmp/pardes-snap/selarg/cwd Del NOR /tmp/pardes-snap/selarg/cwd Del +| ZZARG ZZVEE ./c.sh +| +| CHORDARG:ZZARG +| +| CHORDARG:ZZVEE +| +| +| +| +| +| +| +| +| +| NOR /tmp/pardes-snap/selarg/cwd Del +| +| s.txt +| +| +| +| +| +| +| +| +| +| +| diff --git a/test/snapshots/selarg.snap b/test/snapshots/selarg.snap new file mode 100644 index 00000000..c7b09c33 --- /dev/null +++ b/test/snapshots/selarg.snap @@ -0,0 +1,58 @@ +# 2-1 chord borrows the argument selection from ANOTHER pane: pane A (left) +# holds the selection, pane B (right) middle-drags the command with no +# selection of its own — the chord's left tap finds A's kept left selection, +# and later A's explicit v selection, and rides it as the argument. +file s.txt x +start 30 100 -n 3 +wait 8000 s.txt +stable 700 20000 +# pane A (left, active at boot): print the two argument words +key c-b +stable 600 8000 +text clear; printf 'ZZARG ZZVEE\n' +key enter +wait 8000 ZZVEE +stable 700 15000 +key c-b +stable 600 8000 +# pane B (top right): create the arg-printing script and show its path +press left 60 5 +release left 60 5 +stable 400 5000 +key c-b +stable 600 8000 +text printf '#!/bin/sh\necho CHORDARG:"$1"\n' > c.sh; chmod +x c.sh; clear; printf './c.sh\n' +key enter +wait 10000 ./c.sh +stable 700 15000 +key c-b +stable 600 8000 +# keep a left selection over ZZARG in pane A (this also focuses A) +press left 3 3 +drag left 7 3 +release left 7 3 +stable 400 5000 +snap kept +# chord in pane B: middle on ./c.sh + left tap (B has NO selection: the +# argument comes from pane A's kept left selection) + middle release runs +press middle 55 3 +press left 55 3 +release middle 55 3 +release left 55 3 +wait 10000 CHORDARG:ZZARG +stable 700 10000 +snap crosspane +# now an explicit modal selection: plain-click ZZVEE in A (drops A's kept +# left selection), select it with v e, chord in B again +press left 9 3 +release left 9 3 +stable 400 5000 +text ve +stable 400 5000 +press middle 55 3 +press left 55 3 +release middle 55 3 +release left 55 3 +wait 10000 CHORDARG:ZZVEE +stable 700 10000 +snap vselarg |
