diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 04:00:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 04:00:32 -0300 |
| commit | 8dc84e6f9f1c3802f1d28de4d49907381cdf224b (patch) | |
| tree | 3ed7727a61de9ae4c473413d81de3ac95844af78 /src/main.zig | |
| parent | a4e17d350a7afdeee4916584c44c4770243c84e4 (diff) | |
| download | pardes-8dc84e6f9f1c3802f1d28de4d49907381cdf224b.tar.gz pardes-8dc84e6f9f1c3802f1d28de4d49907381cdf224b.zip | |
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 <dir>` 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 <[email protected]>
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 9 |
1 files changed, 5 insertions, 4 deletions
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 <dir>`, 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. |
