From c1917b949b9580de8bf0977874a210f0266812da Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 06:24:42 -0300 Subject: kinds #14, the core's PDF code gone: pdf.zig and pdf_view.zig leave and every pdf_enabled branch with them; look, Jump, Recent, dumps (one from before the addon opens as its pane), the watch, mouse, keys, the rail and the tag go through Kind for any kind's pane; test/pdf.zig's behaviours are T1 cases over 9P (addons_pdf.zig) and pane cases (a Shadow over a replica, a file changed under it), the harnesses load pdf.so by path Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/builtins.zig | 59 ++++++++------------------------------------------------ 1 file changed, 8 insertions(+), 51 deletions(-) (limited to 'src/builtins.zig') diff --git a/src/builtins.zig b/src/builtins.zig index 68730166..e5c7753d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -59,7 +59,6 @@ pub fn viewPlatform(p: *const Pardes) []const u8 { /// The kinds of pane a builtin may be for alone (registry.needs). pub const PaneKind = enum { terminal, - pdf, image, /// An image pane, or a terminal, whose program's kitty graphics are /// pictures too. @@ -72,7 +71,6 @@ pub const PaneKind = enum { pub fn has(kind: PaneKind, pane: *const panes.Pane) bool { return switch (kind) { .terminal => pane.isTerminal(), - .pdf => pane.hasPdf(), .image => pane.addon != null, .picture => pane.addon != null or pane.isTerminal(), .program_colors => pane.isTerminal() or (pane.file != null and pane.file.?.pager), @@ -84,7 +82,6 @@ pub const PaneKind = enum { pub fn noun(kind: PaneKind) []const u8 { return switch (kind) { .terminal => "a terminal", - .pdf => "a PDF", .image => "an image", .picture => "an image or a terminal", .program_colors => "a terminal or a +Pager", @@ -946,49 +943,6 @@ fn stateArg(c: Ctx, comptime T: type, comptime builtin_word: []const u8, comptim const OnOff = enum { on, off }; -/// Fit the PDF page to the pane by width or by height, flipping between them -/// (or to the one named, `width|height`). -pub const PdfFit = struct { - pub const needs: PaneKind = .pdf; - pub const enabled = pardes.pdf_enabled; - pub const takes_arg = true; - pub fn run(c: Ctx) void { - const state = c.pane.pdf orelse return; - if (c.arg != null) { - const want = stateArg(c, panes.Pdf.FitMode, "PdfFit", "width or height") orelse return; - if (want == state.fit) return; - } - panes.Pdf.toggleFit(c.pane); - } -}; - -/// Tint the PDF page to the theme, or show it as printed, stepping through -/// them (or to the one named, `disabled|filtered|full`). -pub const PdfTint = struct { - pub const needs: PaneKind = .pdf; - pub const enabled = pardes.pdf_enabled; - pub const takes_arg = true; - pub fn run(c: Ctx) void { - const state = c.pane.pdf orelse return; - if (c.arg != null) { - const want = stateArg(c, panes.Pdf.TintMode, "PdfTint", "disabled, filtered or full") orelse return; - while (state.tint != want) panes.Pdf.toggleTint(c.pane); - return; - } - panes.Pdf.toggleTint(c.pane); - } -}; - -/// List the PDF's sections in a pane, each a place to go. -pub const PdfSections = struct { - pub const needs: PaneKind = .pdf; - pub const output: OutputTraits = .{ .name = config.pdf_sections_buffer, .steps = true, .locations = true }; - pub const enabled = pardes.pdf_enabled; - pub fn run(c: Ctx) void { - panes.Pdf.openSections(c.p, c.id); - } -}; - /// Addons, the libraries that bring kinds of pane: `Addon load `, /// `Addon unload `, `Addon reload `; bare, the kinds here. pub const Addon = struct { @@ -1211,11 +1165,14 @@ pub const Zerox = struct { pub const Save = struct { pub const takes_arg = true; pub fn run(c: Ctx) void { - // A PDF or an image shows a file it does not hold as text: there - // is nothing of its own to write, bare or to a path. Said, never a - // silent success. - if (c.pane.file == null and !c.pane.isTerminal()) - return c.p.reportFailure(c.id, if (c.pane.hasPdf()) "Save: a PDF pane has no text to save" else "Save: an image pane has no text to save"); + // A kind's pane (an image, a PDF) shows a file it does not hold as + // text: there is nothing of its own to write, bare or to a path. + // Said, never a silent success. + if (c.pane.file == null and !c.pane.isTerminal()) { + const kind = if (c.pane.addon) |k| k.nameOf() else ""; + var said: [64]u8 = undefined; + return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Save: a{s} {s} pane has no text to save", .{ if (kind.len > 0 and std.mem.indexOfScalar(u8, "aeiou", kind[0]) != null) "n" else "", kind }) catch "Save: no text to save"); + } // A directory's listing is no file to write, bare or to a path, as // acme's Put does nothing in a directory window. if (c.pane.file) |file| if (file.listing != null) { -- cgit v1.3