summaryrefslogtreecommitdiff
path: root/src/ninep/screen.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:38:29 -0300
committerGabriel Schneider <[email protected]>2026-11-05 00:58:28 -0300
commit66c4095e140694376fd07c3afa0fee721558bdb3 (patch)
treee7ce443023bd305cb5707be56731985ad55a11c3 /src/ninep/screen.zig
parent4592c18aa80d61a87026ca5823232ce56837f1f7 (diff)
downloadpardes-66c4095e140694376fd07c3afa0fee721558bdb3.tar.gz
pardes-66c4095e140694376fd07c3afa0fee721558bdb3.zip
ninep: one tree.window answers a read with the part of a text its offset and size ask for, where ten places (a frozen listing, a stream's replay, README, /screen, the sources, a PDF's or a terminal's body, a tag, a column's) windowed by hand; /status, the root ctl, /commands and /listeners are each one text in the step's scratch, read and counted from it, so the xLen and readX pairs (statusLen, rootLen, commandsLen, readStatus, readRoot, readCommands, readPane, readListeners) go; tree.read asks openOf once
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep/screen.zig')
-rw-r--r--src/ninep/screen.zig30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig
index 22129546..c0251d80 100644
--- a/src/ninep/screen.zig
+++ b/src/ninep/screen.zig
@@ -49,32 +49,18 @@ pub fn readSnapshot(p: *Pardes, req: Req, pane: ?*Pane) Reply {
const terminal = pane orelse return Reply.fail(req.tag, E.INVAL);
snapshot.* = panes.terminal.screenTextAlloc(terminal, p.gpa) catch return Reply.fail(req.tag, E.NOMEM);
}
- const bytes = snapshot.*.?;
- const off = @min(req.off, bytes.len);
- const len = @min(bytes.len - off, req.size);
- const out = p.fs.stage(p.gpa);
- out.appendSlice(p.gpa, bytes[off..][0..len]) catch return Reply.fail(req.tag, E.NOMEM);
- return .{ .tag = req.tag, .payload = .{ .staged = @intCast(len) } };
+ return tree.window(p, req, snapshot.*.?);
}
-pub const listeners_cap = 512;
-
-pub fn listenersText(p: *Pardes, buf: []u8) []const u8 {
- var text = std.Io.Writer.fixed(buf);
- if (p.fs.socket_path.len != 0)
- text.print("unix!{s}\n", .{p.fs.socket_path}) catch return text.buffered();
+/// /listeners' text, a dial a line, in the step's scratch.
+pub fn listenersText(p: *Pardes) []const u8 {
+ var text: std.Io.Writer.Allocating = .init(p.scratch.allocator());
+ if (p.fs.socket_path.len != 0) text.writer.print("unix!{s}\n", .{p.fs.socket_path}) catch {};
if (p.fs.tcp_address) |address| switch (address) {
- .ip4 => |ip| text.print("tcp!{d}.{d}.{d}.{d}!{d}\n", .{ ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch {},
- .ip6 => |ip| text.print("tcp!{f}!{d}\n", .{ std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch {},
+ .ip4 => |ip| text.writer.print("tcp!{d}.{d}.{d}.{d}!{d}\n", .{ ip.bytes[0], ip.bytes[1], ip.bytes[2], ip.bytes[3], ip.port }) catch {},
+ .ip6 => |ip| text.writer.print("tcp!{f}!{d}\n", .{ std.Io.net.Ip6Address.Unresolved{ .bytes = ip.bytes, .interface_name = null }, ip.port }) catch {},
};
- return text.buffered();
-}
-
-pub fn readListeners(p: *Pardes, req: Req) Reply {
- var buf: [listeners_cap]u8 = undefined;
- const out = p.fs.stage(p.gpa);
- out.appendSlice(p.gpa, listenersText(p, &buf)) catch return Reply.fail(req.tag, E.NOMEM);
- return tree.stagedReply(p, req);
+ return text.written();
}
// ---- tests ----