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 --- test/fs_namespace.zig | 15 ++++++++++----- test/mode.zig | 4 ++-- test/panes.zig | 13 +++++-------- 3 files changed, 17 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index d54eb9a2..ac638e41 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -1,5 +1,6 @@ const std = @import("std"); const pardes = @import("pardes"); +const image = pardes.image; const filesystem = pardes.filesystem; test "runtime Mount and Unmount copy command arguments and change Look resolution" { @@ -302,14 +303,18 @@ test "images decode through explicit filesystem mounts, and a dump reads one on defer p.deinit(); var arena = std.heap.ArenaAllocator.init(gpa); defer arena.deinit(); + // Its decode lands at the step after it (a job, run here at once). + p.update(.tick); _ = try p.render(arena.allocator()); - const pane = p.panes[0].?; - const state = pane.image.?; - try std.testing.expectEqual(@as(usize, 1), state.iw); - try std.testing.expectEqual(@as(usize, 1), state.ih); + const shown = p.surface.placements.items; + try std.testing.expectEqual(@as(usize, 1), shown.len); + try std.testing.expectEqual(@as(u32, 1), shown[0].raster.w); + try std.testing.expectEqual(@as(u32, 1), shown[0].raster.h); // The picture's bytes are in the dump: it comes back as it was shown. try pardes.dump.dumpState(p); const restored = try pardes.dump.initFromDump(gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); - try std.testing.expectEqualStrings(bytes, restored.panes[0].?.image.?.raw); + const slot = restored.panes[0].?.addon.?; + var kept: [64]u8 = undefined; + try std.testing.expectEqualStrings(bytes, kept[0..image.kind.dump.?(slot.st, &kept, kept.len)]); } diff --git a/test/mode.zig b/test/mode.zig index 6141d898..86de0488 100644 --- a/test/mode.zig +++ b/test/mode.zig @@ -92,9 +92,9 @@ test "Mode from actual tag Exec preserves parked file and output insert transact test "Mode leaves image and PDF document modes unchanged" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); - const picture = try panes.Image.create(p, 1, "/mode-test.png", &.{}); + const picture = try pardes.Kind.open(p, 1, &panes.Image.kind, "/mode-test.png", ""); try mode(p, 1, .normal); - try std.testing.expect(picture.image != null); + try std.testing.expect(picture.addon != null); if (comptime panes.Pdf.enabled) { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); diff --git a/test/panes.zig b/test/panes.zig index a6b6aecd..f51c2b27 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -2247,19 +2247,16 @@ const OutputTests = struct { }; const ImageTests = struct { - const State = panes.Image.State; - const tagPrefix = panes.Image.tagPrefix; - test "pane-local renderer choices are visible in the image tag" { - const state: State = .{ .path = @constCast("/tmp/picture.ppm"), .glyph_art = true, .pmode = .terminal, .ascii = false }; - const tag = try tagPrefix(std.testing.allocator, &state, state.glyph_art); - defer std.testing.allocator.free(tag); + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); + defer p.deinit(); + const pane = try pardes.Kind.open(p, p.freeSlot().?, &image.kind, "/tmp/picture.ppm", null); + pane.addon.?.art = .{ .glyph = true, .palette = .terminal, .ascii = false }; try std.testing.expectEqualStrings( config.tag_image ++ " petscii:on palette:terminal ascii:off /tmp/picture.ppm", - tag, + try pardes.tagline.tagPrefix(p, pane), ); } - }; const PdfTests = struct { -- cgit v1.3