diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pardes.zig | 36 | ||||
| -rw-r--r-- | src/tutor.txt | 4 |
2 files changed, 30 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. |
