diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-31 06:28:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-31 06:28:48 -0300 |
| commit | a479792a1ab2b593642d7f648194bfa23ce01dba (patch) | |
| tree | 96ddee7d879a9084daa07db43b0b7910b072a785 /src/ninep/pty.zig | |
| parent | e179cc44fe5060c76a5b00c41e53f11209f5acd9 (diff) | |
| parent | 4c761893e5b3fdae422622cfa02104ab36633045 (diff) | |
| download | pardes-a479792a1ab2b593642d7f648194bfa23ce01dba.tar.gz pardes-a479792a1ab2b593642d7f648194bfa23ce01dba.zip | |
Merge the upstream daemon and replicated client/server refactor
Diffstat (limited to 'src/ninep/pty.zig')
| -rw-r--r-- | src/ninep/pty.zig | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index d80f7175..ee8c618e 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -86,7 +86,7 @@ pub fn writeCtl(p: *Pardes, req: Req, id: usize) Reply { if (comptime pardes.hosted) if (!apply and std.mem.eql(u8, line, "exec")) if (p.panes[id]) |pane| { const bin = pane.shell orelse p.shellBin(); var why: [320]u8 = undefined; - if (@import("../host_io.zig").Shell.refusal(bin[0..@min(bin.len, 200)], &why)) |refused| + if (pardes.tape.value(.shell, @import("../host_io.zig").Shell.refusal, .{ bin[0..@min(bin.len, 200)], &why })) |refused| return tree.failText(req.tag, E.NOENT, std.fmt.bufPrint(&p.fs.ename, "exec: {s}", .{refused}) catch "exec: no such shell"); }; if (!verb(p, id, line, apply)) return tree.failText(req.tag, E.INVAL, if (tooFewRows(line)) e_winsize_rows else if (outOfRange(line)) e_winsize_range else e_bad_pty_ctl); @@ -378,9 +378,11 @@ pub fn noteMarks(p: *Pardes, id: usize, pane: *Pane) void { /// Answers a run whose command ended with `status`: the header and the /// output it printed. fn finish(p: *Pardes, slot: *Run, pane: *Pane, status_code: ?i32) void { - const printed = pardes.panes.terminal.commandOutput(pane, p.gpa, output_rows) catch + // As the authority's emulator has it (taped): a screen-state replica's + // is its deltas', which a lagging client's can be states behind, its + // pins in pages it never had (ghostty's leftWrap overflowed on one). + const printed = pardes.tape.value(.prompt, printedBy, .{ pane, p.scratch.allocator() }) orelse return answer(p, slot, "error out of memory", .{}); - defer p.gpa.free(printed.text); // Keep the tail, cut at a line start so the first line kept is whole. var keep: []const u8 = printed.text; if (keep.len > output_cap) { @@ -409,6 +411,14 @@ fn finish(p: *Pardes, slot: *Run, pane: *Pane, status_code: ?i32) void { answer(p, slot, "exit {s}", .{status}); } +pub const Printed = struct { text: []const u8, whole: bool }; + +/// What pane `pane`'s command printed (terminal.commandOutput), in `arena`. +fn printedBy(pane: *Pane, arena: std.mem.Allocator) ?Printed { + const out = pardes.panes.terminal.commandOutput(pane, arena, output_rows) catch return null; + return .{ .text = out.text, .whole = out.whole }; +} + /// The shell itself exited (a run's `exit 3`, or one typed): a run waiting /// on the command it ran answers with the shell's status and what it /// printed, and the log says `exit` before the pane's `del`. Unknown, the |
