summaryrefslogtreecommitdiff
path: root/src/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/panes.zig')
-rw-r--r--src/panes.zig33
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");