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/exec.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/exec.zig') diff --git a/src/exec.zig b/src/exec.zig index e15ad12c..47484105 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -792,6 +792,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { if (panes.terminal.onAlternateScreen(pane)) panes.terminal.feedOutput(p, pane, "\x1b[?1049l"); panes.terminal.feedOutput(p, pane, "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?2004l\x1b[?25h\x1b[0m"); echoCommand(p, pane, line); + pane.command_from = winid(p, src); p.emitSpawn(id, pane.serial, pane.cwdSlice()); noteRun(p, pane, "run", line); return id; @@ -804,12 +805,20 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { p.reportError(from, "exec", err); return null; }; + pane.command_from = winid(p, src); echoCommand(p, pane, line); placeNew(p, from, from, free, .command); noteRun(p, pane, "run", line); return free; } +/// The serial a command's `$winid` names: the pane it was run from, none +/// (0) from a column's or the workspace's tag. +fn winid(p: *const Pardes, src: ?*Pane) u32 { + if (p.exec_header) return 0; + return if (src) |s| s.serial else 0; +} + /// `% line` above a command's output, every command, as a shell echoes /// what it was given; its newlines the terminal's, so a multi-line command /// does not staircase. -- cgit v1.3