summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 04:48:12 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit009e4ab8779bc7adc7b626814d36e62231d7a0ea (patch)
treed77c04f04b1d11c62aebb4985bce36208e17075c /src/exec.zig
parentbda5b5f621d0edd8e26f9700043ab21cae18f329 (diff)
downloadpardes-009e4ab8779bc7adc7b626814d36e62231d7a0ea.tar.gz
pardes-009e4ab8779bc7adc7b626814d36e62231d7a0ea.zip
A chorded exec an event reader holds is told its argument, and runs with it
With event open, a 2-1 chord's exec went out as one record with flag 8 and nothing after it: the argument was freed unsaid. As acme does (exec.c:150-190), two records follow it, the argument's text and where it came from (file:#q0,#q1, empty when not known), and the pane keeps the argument, so the record written back runs with it (acme's own write-back, xfid.c:842, passes none; the reader was told, so it runs as the click would have). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/exec.zig b/src/exec.zig
index d7a88ecc..73413910 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -217,6 +217,28 @@ pub fn heldSelection(p: *Pardes, first: usize) ?[]const u8 {
return null;
}
+/// Where the selection `heldSelection` would give is, as acme's argument
+/// location (exec.c:162, getbytearg): `path:#q0,#q1` of a file pane's dot.
+pub fn heldSelectionPlace(p: *Pardes, first: usize, buf: []u8) ?[]const u8 {
+ var k: usize = 0;
+ while (k < p.panes.len + 2) : (k += 1) {
+ const i = switch (k) {
+ 0 => first,
+ 1 => p.active,
+ else => k - 2,
+ };
+ if (k > 0 and (i == first or (k > 1 and i == p.active))) continue;
+ const t = p.panes[i] orelse continue;
+ if (t.sel[sel_slot].state == .done) return null; // a pointer selection: no byte range kept
+ if ((t.body.vsel.active and t.body.vsel.explicit) or t.body.msel.active) {
+ const f = t.file orelse return null;
+ const d = @import("ninep/pane.zig").dotOf(t);
+ return std.fmt.bufPrint(buf, "{s}:#{d},#{d}", .{ f.path, d.q0, d.q1 }) catch null;
+ }
+ }
+ return null;
+}
+
/// A clicked word and the selection held for it, as one command line.
pub fn withArg(p: *Pardes, txt: []const u8, arg: ?[]const u8) []const u8 {
const a = std.mem.trim(u8, arg orelse return txt, " \t\r\n");