summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 05:48:20 -0300
committerGabriel Schneider <[email protected]>2026-11-10 05:52:38 -0300
commit3eb166e287ec5afbd54b03a86711610e1b5269b6 (patch)
tree3d0577ada14499c3dcad84926ab52b6c6f54c6f1 /src/exec.zig
parent8903d352237919455996831047017ae57f2a83ef (diff)
downloadpardes-3eb166e287ec5afbd54b03a86711610e1b5269b6.tar.gz
pardes-3eb166e287ec5afbd54b03a86711610e1b5269b6.zip
panes: exec.noteRun and exec.commandDone become Pane methods (pane.noteRun, pane.commandDone) at the end of the Pane struct, beside the command_* fields they keep, since they act on one command pane; commandDone takes the pane its two callers in Core already hold, with its id for the close and the report, in place of looking it up again
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig38
1 files changed, 2 insertions, 36 deletions
diff --git a/src/exec.zig b/src/exec.zig
index d0bee0e9..96902889 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -771,7 +771,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
echoCommand(p, pane, line);
pane.command_from = winid(p, src);
p.emitSpawn(id, pane.serial, pane.cwdSlice());
- noteRun(p, pane, "run", line);
+ pane.noteRun(p, "run", line);
return id;
}
const free = p.freeSlot() orelse {
@@ -789,7 +789,7 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
p.reportError(from, "exec", error.NoPaneRoom);
return null;
}
- noteRun(p, pane, "run", line);
+ pane.noteRun(p, "run", line);
return free;
}
@@ -824,40 +824,6 @@ fn echoCommand(p: *Pardes, pane: *Pane, line: []const u8) void {
panes.terminal.feedOutput(p, pane, w.buffered());
}
-/// `run <serial> <word>` or `exit <serial> <N|?>` in the log.
-/// The whole line, one record as `msg` carries its text: its control
-/// characters, a newline too, become spaces (events.pushLog). A new pane is
-/// announced first, so `new` comes before the `run` in it.
-pub fn noteRun(p: *Pardes, pane: *Pane, what: []const u8, said: []const u8) void {
- pardes.ctlfs.events.announce(p);
- var buf: pardes.Kind.Buf(command_max + 16) = .{};
- pardes.ctlfs.events.notePath(p, what, buf.print("{d} {s}", .{ pane.serial, std.mem.trim(u8, said, " \t\r\n") }));
-}
-
-/// A command pane's child is gone: the pane stays, showing what it said
-/// and how it ended, and is the next command's for its directory.
-pub fn commandDone(p: *Pardes, id: usize, status: ?u8) void {
- const pane = p.panes[id] orelse return;
- pane.command_done = true;
- // A REPL it was is gone with its command; the pane's next is not one.
- pane.repl = null;
- pane.command_status = status;
- pane.body.mode = .normal;
- // Look's `git show`: its output went to a +Pager, the +Diff now; only a
- // failure is worth the pane.
- if (pane.command_pages) {
- pane.command_pages = false;
- if (status == 0) return p.removePane(id, null) catch |err| p.reportError(id, "close", err);
- }
- var buf: [16]u8 = undefined;
- const code = if (status) |n| std.fmt.bufPrint(&buf, "{d}", .{n}) catch unreachable else "?"; // an exit status fits 16
- var said: pardes.Kind.Buf(32) = .{};
- const lead = if (panes.terminal.gridCursor(pane).x != 0) "\r\n" else "";
- panes.terminal.feedOutput(p, pane, said.print("{s}exit {s}\r\n", .{ lead, code }));
- noteRun(p, pane, "exit", code);
- p.needs_frame = true;
-}
-
/// Trim and unwrap clickable command-word notation once for every command
/// consumer, so startup lines and interactive Exec speak the same syntax.
pub fn commandText(txt: []const u8) []const u8 {