From 423440f25b4b23b56162008bba35218d438767fe Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 00:02:06 -0300 Subject: kinds #2, a pane of a kind is one slot and image is a kind compiled in: src/kinds/pardes_addon.h is the kinds' C ABI (the cell, the window a kind paints, placements and the tag prefix it hands back, keys, the mouse, pa_api of six functions over the pane's arena, words, the head and pa_ops of paint and sixteen optional functions), translated once by the build into the core's records, never mirrored; src/Kind.zig is the core's side: the kinds this process has (a registry with the checks a load makes: the head's size and abi major, a paint, a name, words, leaders and extensions none else has), a pane's Slot (the kind's state and arena, its path, the art bytes Petscii, Palette and Ascii set, its tick deadline and jobs) and the addon arm at the sites: Look and the initial file by extension, draw (cells into the grid, placements keyed by serial and the kind's key), the tag prefix from a paint over no cells, nextWake and the step (ticks, jobs' answers landing on the loop), close, Recent, paneDir, /index's kind word; a dump writes a slot by hand (kind name and version, path, where, art, the kind's own record) and loads it through the kind's open and load, or as a placeholder that keeps the record when the kind is not here; image.zig's pane is now a static pa_ops (open refuses what it cannot read, the decode a job whose answer lands at a step instead of a thread polled by draw, one placement fitted by the frontend, its record the file's bytes), Pane.image is Pane.addon, and the three art words act on the slot; no golden changes (images.snap and tagbottomimage.snap pass, the tag prefix and the placement key are the same bytes); tests: the image dump test, the Petscii/Palette/Ascii ctl tests, the image tag-prefix test and fs_namespace's decode test rewritten on the slot (the decode now lands at the step after the open), plus a registry test; gates: core-test 960/960 on both, unit-test 1487/1488 tui and 1531/1532 gui, behaviour-test 244/244, pane-test 171/172, snap all ok, process-test 0 of 37 failed on both Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/panes.zig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/panes.zig') diff --git a/src/panes.zig b/src/panes.zig index c4a32413..9f1ce036 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -37,7 +37,7 @@ pub const Pane = struct { .len = .{ .{ "msg", "msg_len" }, .{ "msg_older", "msg_older_len" }, .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } }, // A picture's and a PDF's memory is their own allocators' (a dump // loaded makes it there). - .alloc = .{ .{ "image", "image" }, .{ "pdf", "pdf" }, .{ "terminal", "terminal" } }, + .alloc = .{ .{ "addon", "image" }, .{ "pdf", "pdf" }, .{ "terminal", "terminal" } }, }; /// The words that throw unsaved text away (builtins.zig warnModified). pub const Discarding = enum { Exit, Restore, get, Del, Delcol }; @@ -201,7 +201,8 @@ pub const Pane = struct { /// (builtins.zig warnModified). discard_warned: ?struct { revision: u32, by: Discarding } = null, file: ?File.State = null, - image: ?Image.State = null, + /// A pane of a kind (Kind.zig): a picture, or one a library brought. + addon: ?*@import("Kind.zig").Slot = null, pdf: PdfSlot = if (Pdf.enabled) null else {}, prompt: Prompt = .none, /// The text an open prompt answers for: `s`/`S` select in it and `|` @@ -502,7 +503,7 @@ pub const Pane = struct { pub fn isTerminal(pane: *const Pane) bool { const no_pdf = if (comptime Pdf.enabled) pane.pdf == null else true; - return pane.file == null and pane.image == null and no_pdf; + return pane.file == null and pane.addon == null and no_pdf; } /// The one coloring choice keyed on what a pane IS, so the highlight @@ -736,6 +737,7 @@ test { _ = Dir; _ = mini; _ = Image; + _ = @import("Kind.zig"); _ = Pdf; _ = terminal; } @@ -803,9 +805,7 @@ pub fn teardownPane(p: *Pardes, pane: *Pane) void { panes.terminal.deinitPendingCommand(pane); if (pane.command) |line| p.gpa.free(line); if (pane.shell) |bin| p.gpa.free(bin); - if (pane.image) |*iv| { - iv.deinit(p.image_gpa); - } + @import("Kind.zig").close(p, pane); if (comptime pdf_enabled) if (pane.pdf) |pv| panes.Pdf.deinitPane(p, pane, pv); if (pane.file) |*file| panes.File.deinit(p, pane, file); if (pane.ovl) |o| p.gpa.free(o.text); @@ -1000,7 +1000,7 @@ pub fn paneDir(pane: *const Pane) []const u8 { if (pane.file) |f| return panes.Dir.ofName(f.path); if (comptime pdf_enabled) if (pane.pdf) |pv| return std.fs.path.dirname(pv.path) orelse "/"; - if (pane.image) |iv| return std.fs.path.dirname(iv.path) orelse "/"; + if (pane.addon) |k| if (k.path.len > 0) return std.fs.path.dirname(k.path) orelse "/"; return pane.cwdSlice(); } -- cgit v1.3