From 8dc84e6f9f1c3802f1d28de4d49907381cdf224b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 04:00:32 -0300 Subject: pardes - asks /pager for its +Pager and reads the serial on the same open: another client's exec meanwhile can never take the text into its pane pardes - wrote `pager ` to /ctl, then read /exec on a fresh open, which answers the session's last answer: a client that exec'd in between had its pane overwritten by the paged text. /pager takes the directory and answers the +Pager's serial on the open that wrote it, as /pane/new answers its own open; the ctl verb is gone. Client.ask writes and reads on one open. The README's look recipe reads its answer on its own open too. Co-Authored-By: Claude Opus 5.5 --- src/main.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 1075b596..6c46b22c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -101,7 +101,7 @@ const help_text = ; /// `pardes -` inside a session: `text` into the directory's one +Pager -/// (root ctl `pager `, refilled when it is there), written into its +/// (/pager, refilled when it is there), written into its /// body through one open, as one undo step, and left clean. A text /// the session would not take is never lost: it goes to stderr, with why, /// and the exit is 1. @@ -125,9 +125,10 @@ fn pageInto(io: std.Io, gpa: std.mem.Allocator, dial: []const u8, text: []const if (c < ' ' or c == 0x7f) break false; } else true; var line_buf: [4200]u8 = undefined; - const ctl_line = std.fmt.bufPrint(&line_buf, "pager {s}\n", .{if (plain) cwd else ""}) catch "pager\n"; - ninep_io.Client.write(gpa, dial, "/ctl", ctl_line) catch |err| Fail.with(io, text, "no +Pager pane", err); - const answer = ninep_io.Client.read(gpa, dial, "/exec", "/exec") catch |err| Fail.with(io, text, "no +Pager pane", err); + const dir_line = std.fmt.bufPrint(&line_buf, "{s}\n", .{if (plain) cwd else ""}) catch "\n"; + // Its serial read back on the open that asked: another client's exec + // meanwhile can never send this text into that client's pane. + const answer = ninep_io.Client.ask(gpa, dial, "/pager", dir_line) catch |err| Fail.with(io, text, "no +Pager pane", err); const serial = std.fmt.parseInt(u32, std.mem.trim(u8, answer, " \n"), 10) catch |err| Fail.with(io, text, "no +Pager pane", err); // The whole text through one open of the body (truncated once, then // written at rising offsets): one undo step, and every byte of it. -- cgit v1.3