From 66c4095e140694376fd07c3afa0fee721558bdb3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:38:29 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/ninep/pane.zig | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/ninep/pane.zig') diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index c12b2e80..48095c46 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -413,11 +413,12 @@ pub fn read(p: *Pardes, req: Req, id: usize, pane: *Pane, file: PaneFile) Reply .body => readBody(p, req, id, pane), .tag => tag: { applyTagTruncation(p, pane); - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, tagOf(p, pane)) catch {}; - break :tag tree.stagedReply(p, req); + break :tag tree.window(p, req, tagOf(p, pane)); + }, + .ctl => ctl: { + var buf: [ctl.pane_text_cap]u8 = undefined; + break :ctl tree.window(p, req, ctl.paneText(p, pane, &buf)); }, - .ctl => ctl.readPane(p, req, pane), // A failed address reads empty, as an unset limit does: there is // none. data and xdata are what refuse. .addr => readRange(p, req, if (pf.addr_failed) null else addr: { @@ -477,17 +478,12 @@ fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { } } }; } // A PDF's body is its text layer, the page shown's: read-only. - if (pdfText(p, pane)) |text| { - p.fs.stage(p.gpa).appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); - return tree.stagedReply(p, req); - } + if (pdfText(p, pane)) |text| return tree.window(p, req, text); if (req.handle != 0 and pane.isTerminal()) return screen.readSnapshot(p, req, pane); const text = panes.terminal.screenTextAlloc(pane, p.gpa) catch return Reply.fail(req.tag, E.NOMEM); defer p.gpa.free(text); - const out = p.fs.stage(p.gpa); - out.appendSlice(p.gpa, text) catch return Reply.fail(req.tag, E.NOMEM); - return tree.stagedReply(p, req); + return tree.window(p, req, text); } fn readData(req: Req, id: usize, pane: *Pane, pf: *State, stop_at_end: bool) Reply { -- cgit v1.3