From c8553032ef84aec74cbb5d07d07f934eecf3d4a9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 05:19:21 -0300 Subject: kinds #9, the core's image code gone: src/image.zig (558 lines) and the static table go, so no kind is compiled in (Registry.init, Kind.image, compiledIn, `static` in /addons and "is compiled in" with them) and a test of the core's side of a kind's pane opens Kind.test_kind (a picture of one pixel, no library); a placement's fit (NativeGeometry, containGeometry) moves to surface.zig and a PDF's fit modes to pdf_view.zig; a terminal's kitty PNG decodes in TerminalImages.zig through wuffs as before, its downscale through stb_image_resize, the one part of zstbi the core keeps (stb_image patched out of it, the wuffs_images option, tag_image and image_exts gone); the image cases load the built image.so by path: test/panes.zig's and fs_namespace's through Addon.perform, T1 through Addon load (a new behaviour case: PNG, JPEG and PPM through 9P, the art words, a refused corrupt PNG, a dump's placeholder and its picture back, which replaces the decode unit test and ctl.zig's corrupt-image case), the snapshot, process and image harnesses by linking it into each session's data directory; images.snap unchanged Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/Core.zig | 44 ++++---------------------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) (limited to 'src/Core.zig') diff --git a/src/Core.zig b/src/Core.zig index 4584e395..b1195ac2 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -64,7 +64,6 @@ const font_picker = pardes.font_picker; const fonts = pardes.fonts; const frame_ns = pardes.frame_ns; const host_io = pardes.host_io; -const image = pardes.image; const layout = pardes.layout; const limits = memory.limits; const locations = @import("locations.zig"); @@ -2499,7 +2498,7 @@ test "Filter is ordered after Del and toggles only its terminal or +Pager pane" try testing.expect(!first.tty_filter); const doc_id = p.freeSlot().?; - const doc = try pardes.Kind.open(p, doc_id, pardes.Kind.image, "/tmp/filter-inert.ppm", ""); + const doc = try pardes.Kind.open(p, doc_id, pardes.Kind.test_kind.of(p), "/tmp/filter-inert.ppm", ""); try testing.expect(!doc.tty_filter); try testing.expect(p.executeBuiltinLine(doc_id, "Filter")); try testing.expect(!doc.tty_filter); @@ -2669,7 +2668,7 @@ test "unknown Exec from a document runs as a command pane in its directory, type // A terminal free at a prompt in the same directory is not borrowed. p.setCwd(0, "/tmp/pardes-image-dir"); - const image_doc = try pardes.Kind.open(p, 1, pardes.Kind.image, "/tmp/pardes-image-dir/pic.ppm", null); + const image_doc = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pardes-image-dir/pic.ppm", null); try std.testing.expectEqualStrings("/tmp/pardes-image-dir", Pardes.paneDir(image_doc)); const dst = exec.execute(p, 1, "echo image-fallback") orelse return error.ExecFoundNowhereToRun; try std.testing.expect(dst != 0 and dst != 1); @@ -2723,7 +2722,7 @@ test "a command of several lines keeps its tag one row, and its echo does not st const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); defer p.deinit(); while (p.nextEffect()) |_| {} - _ = try pardes.Kind.open(p, 1, pardes.Kind.image, "/tmp/pic.ppm", null); + _ = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pic.ppm", null); const two = "def greet(name):\n return name\n\nprint(greet(\"x\"))\n"; const dst = exec.execute(p, 1, two) orelse return error.NoCommandPane; while (p.nextEffect()) |_| {} @@ -3071,7 +3070,7 @@ test "a command pane shows how its command ended, and the next command there run defer p.deinit(); while (p.nextEffect()) |_| {} p.setCwd(0, "/tmp/pardes-cmd"); - _ = try pardes.Kind.open(p, 1, pardes.Kind.image, "/tmp/pardes-cmd/pic.ppm", null); + _ = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pardes-cmd/pic.ppm", null); const dst = exec.execute(p, 1, "make -j8") orelse return error.NoCommandPane; while (p.nextEffect()) |_| {} @@ -3163,41 +3162,6 @@ test "a command pane shows how its command ended, and the next command there run try std.testing.expectEqual(@as(?usize, null), exec.execute(p, 1, long)); } -test "image dump restores source bytes renderer choices and exact custom tail" { - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{ .tty_only = true }); - defer p.deinit(); - try pardes.panes.deinitPane(p, p.panes[0].?); - p.panes[0] = null; - - const source = "\x00embedded image bytes\xff"; - const pane = try pardes.Kind.open(p, 0, pardes.Kind.image, "/missing/restored-image.ppm", source); - pane.addon.?.art = .{ .glyph = true, .palette = .terminal, .ascii = false }; - if (pane.tag.own) |own| p.gpa.free(own); - pane.tag.own = try p.gpa.dupe(u8, " Keep Del"); - try dump.dumpState(p); - - const restored = try dump.initFromDump(gpa, .{ .tty_only = true }, p.dump_out.?); - defer restored.deinit(); - const restored_pane = restored.panes[0].?; - const art = restored_pane.addon.?.art; - try std.testing.expect(art.glyph); - try std.testing.expectEqual(image.PaletteMode.terminal, art.palette); - try std.testing.expect(!art.ascii); - try std.testing.expect(restored_pane.tag.own != null); - try std.testing.expectEqualStrings(" Keep Del", tagline.curTail(restored_pane)); - var kept: [64]u8 = undefined; - const slot = restored_pane.addon.?; - try std.testing.expectEqualSlices(u8, source, kept[0..image.kind.dump.?(slot.st, &kept, kept.len)]); - - // And dumped again, its bytes still there. - try dump.dumpState(restored); - const again = try dump.load(gpa, .{ .tty_only = true }, restored.dump_out.?, null); - defer again.deinit(); - // Loaded as a replica loads it: a placeholder holding the record. - try std.testing.expectEqualSlices(u8, source, again.panes[0].?.addon.?.record.?); -} - test "a terminal its program gave back takes command lines again" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{}); -- cgit v1.3