summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-08 04:22:29 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commitb6b899b40a339441694ab7443b00967da8f0b100 (patch)
treebaadc7212b3c0de9cd673c9830d8f90a619f4672 /src/pardes.zig
parentb13152f89b478466b860aecb2bada8d96f0e9e36 (diff)
downloadpardes-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.
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig36
1 files changed, 27 insertions, 9 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;
}