From 48c129a701d60abdb836bbb400d949cc61ed2820 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 23:32:31 -0300 Subject: A command run from a pane gets acme's $winid, the serial of the pane it was run from; one from a column's or the workspace's tag gets none PARDES_PANE names the command pane itself, so a script a click ran had no way to address the pane it was run in, as acme's win scripts do with $winid. The command pane now remembers that pane and its child gets winid set to it; a header tag's command, which no pane owns, gets winid unset. PARDES_PANE is unchanged. Co-Authored-By: Claude Opus 5.5 --- src/host_io.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/host_io.zig') diff --git a/src/host_io.zig b/src/host_io.zig index 1fab3729..8ddb0c90 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -1351,6 +1351,14 @@ test "the child environment replaces the launcher's terminal identity exactly on extern "c" fn unsetenv(name: [*:0]const u8) c_int; +fn exportWinid(serial: u32) void { + var buf: [16]u8 = undefined; + if (serial != 0) if (std.fmt.bufPrintSentinel(&buf, "{d}", .{serial}, 0)) |text| { + if (Shell.setenv("winid", text, 1) == 0) return; + } else |_| {}; + _ = unsetenv("winid"); +} + /// The longest line a command pane runs (exec.zig refuses a longer one). pub const exec_command_max = pardes.exec.command_max; @@ -1418,6 +1426,9 @@ pub fn forkShell( if (core) |c| (if (c.panes[pane]) |pn| pn.serial else 0) else 0, if (core) |c| !c.opts.nested else false, ); + // acme's `$winid`: the pane a command was run from, so a script it runs + // can address that pane; unset for a shell and a header tag's command. + exportWinid(if (core) |c| (if (c.panes[pane]) |pn| (if (pn.command != null) pn.command_from else 0) else 0) else 0); if (helper) |path| { const c = core.?; const pn = c.panes[pane].?; -- cgit v1.3