diff options
Diffstat (limited to 'src/ninep/pane.zig')
| -rw-r--r-- | src/ninep/pane.zig | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 92d28b99..704f1ac8 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -145,7 +145,6 @@ pub fn dirtyOf(pane: *const Pane) bool { /// The pane's name: its file, its document, or a terminal's directory. pub fn nameOf(p: *Pardes, pane: *const Pane) []const u8 { if (pane.file) |*f| return f.path; - if (pane.pdfPath()) |path| return path; if (pane.addon) |k| if (k.path.len > 0) return k.path; const cwd = pane.cwdSlice(); // A shell given no directory was started in the session's, and is @@ -155,7 +154,6 @@ pub fn nameOf(p: *Pardes, pane: *const Pane) []const u8 { pub fn kindOf(pane: *const Pane) []const u8 { if (pane.file != null) return "text"; - if (pane.pdfPath() != null) return "pdf"; if (pane.addon) |k| return k.nameOf(); // A command's pane is no shell to type into: a script choosing a // terminal by kind must not pick one. @@ -350,7 +348,7 @@ pub fn fileSize(p: *Pardes, id: usize, f: PaneFile) u64 { const pf = &pane.fs; return switch (f) { // A terminal's body reads its screen and history, as text. - .body => if (pane.file == null and pane.isTerminal()) panes.terminal.screenTextLen(pane) else if (pdfText(p, pane)) |t| t.len else bodyOf(pane).len, + .body => if (pane.file == null and pane.isTerminal()) panes.terminal.screenTextLen(pane) else if (kindText(p, pane)) |t| t.len else bodyOf(pane).len, // What addr selects, generated by each read: no length, as acme's // data and xdata have none. .data, .xdata => 0, @@ -452,14 +450,11 @@ fn readFlag(p: *Pardes, req: Req, on: bool) Reply { return tree.stagedReply(p, req); } -/// The text layer of the page a PDF pane shows (MuPDF's extraction, kept -/// with the page), null for any other pane. -/// A document's text, read-only: a PDF's text layer, a kind's `body`. -fn pdfText(p: *Pardes, pane: *Pane) ?[]const u8 { - if (pane.addon != null) return pardes.Kind.body(pane, p.scratch.allocator()) catch null; - if (comptime !pardes.pdf_enabled) return null; - const pv = pane.pdf orelse return null; - return pv.ensureText(p.pdf_gpa); +/// A kind's pane's text, read-only: its `body` (a PDF's: the text layer +/// of the page shown); null for any other pane. +fn kindText(p: *Pardes, pane: *Pane) ?[]const u8 { + if (pane.addon == null) return null; + return pardes.Kind.body(pane, p.scratch.allocator()) catch null; } fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { @@ -474,8 +469,8 @@ fn readBody(p: *Pardes, req: Req, id: usize, pane: *Pane) Reply { .len = clip(n), } } }; } - // A PDF's body is its text layer, the page shown's: read-only. - if (pdfText(p, pane)) |text| return tree.window(p, req, text); + // A kind's body is its text (a PDF's, the page shown's): read-only. + if (kindText(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); |
