diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 05:48:20 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 05:52:38 -0300 |
| commit | 3eb166e287ec5afbd54b03a86711610e1b5269b6 (patch) | |
| tree | 3d0577ada14499c3dcad84926ab52b6c6f54c6f1 /src/panes.zig | |
| parent | 8903d352237919455996831047017ae57f2a83ef (diff) | |
| download | pardes-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/panes.zig')
| -rw-r--r-- | src/panes.zig | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/panes.zig b/src/panes.zig index 3bac74ab..99652b04 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -680,6 +680,39 @@ pub const Pane = struct { } pane.body.cur_pinned = true; } + + /// `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(pane: *Pane, p: *Pardes, what: []const u8, said: []const u8) void { + pardes.ctlfs.events.announce(p); + var buf: pardes.Kind.Buf(exec.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(pane: *Pane, p: *Pardes, id: usize, status: ?u8) void { + 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 })); + pane.noteRun(p, "exit", code); + p.needs_frame = true; + } }; pub const Text = @import("Text.zig"); |
