summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 05:19:21 -0300
committerGabriel Schneider <[email protected]>2026-11-06 05:55:49 -0300
commitc8553032ef84aec74cbb5d07d07f934eecf3d4a9 (patch)
treee47d3dd72b83e0b95d53271df9f5932dab389959 /src/ninep
parentde0447471febe1253b42a32fe9a1d6cdccc9d5b9 (diff)
downloadpardes-c8553032ef84aec74cbb5d07d07f934eecf3d4a9.tar.gz
pardes-c8553032ef84aec74cbb5d07d07f934eecf3d4a9.zip
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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig40
1 files changed, 8 insertions, 32 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 9b87d9aa..42d9f3bd 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1539,7 +1539,7 @@ test "an address looked at in an image pane names the image, never an empty subj
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const id = p.freeSlot().?;
- const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
_ = wr(p, Node.of(doc.serial, .look), ":/x/\n");
try testing.expect(th.logHas(p, "look: /tmp/pardes-pic.ppm is no text to address"));
}
@@ -1548,7 +1548,7 @@ test "Save and Save path on an image pane are refused with why, never a silent s
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
const id = p.freeSlot().?;
- const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
for ([_][]const u8{ "Save\n", "Save /tmp/pardes-copy.ppm\n" }) |line| {
const r = wr(p, Node.of(doc.serial, .ctl), line);
try testing.expectEqual(Status.err, r.reply.status);
@@ -1579,9 +1579,7 @@ test "a builtin for one kind of pane is refused on another, and still acts on it
};
const id = p.freeSlot().?;
// A picture shown: the core's art words follow the kind's prefix.
- pardes.image.start(testing.io, testing.allocator);
- defer pardes.image.stop();
- const doc = try pardes.Kind.open(p, id, pardes.Kind.image, "/tmp/pardes-pic.ppm", "P6\n1 1\n255\n\x01\x02\x03");
+ const doc = try pardes.Kind.open(p, id, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", "P6\n1 1\n255\n\x01\x02\x03");
while (p.nextEffect()) |e| p.perform(e);
pardes.exec.placeNew(p, 0, 0, id, .doc);
_ = try p.render(p.scratch.allocator());
@@ -2158,32 +2156,10 @@ test "a language server question that finds nothing, cannot be answered, or is a
try testing.expectEqual(@as(u16, 0), p.fs.late_failure_len);
// An image's body takes no write.
const slot = p.freeSlot().?;
- const img = try pardes.Kind.open(p, slot, pardes.Kind.image, "/tmp/pardes-no-such.png", "not a png");
+ const img = try pardes.Kind.open(p, slot, pardes.Kind.test_kind.of(p), "/tmp/pardes-no-such.png", "not a png");
try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno());
}
-test "a corrupt image fails its look with an err, and no pane is made" {
- pardes.image.start(testing.io, testing.allocator);
- defer pardes.image.stop();
- const p = try withFile(testing.allocator, "x\n");
- defer p.deinit();
- var tmp = testing.tmpDir(.{});
- defer tmp.cleanup();
- try tmp.dir.writeFile(testing.io, .{ .sub_path = "bad.png", .data = "\x89PNG not really" });
- var dir_buf: [4096]u8 = undefined;
- const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
- var line: [4200]u8 = undefined;
- var count: usize = 0;
- for (p.panes) |slot| count += @intFromBool(slot != null);
- const r = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/bad.png\n", .{dir}));
- try testing.expectEqual(E.IO, r.errno());
- try testing.expect(std.mem.endsWith(u8, r.reply.ename, "bad.png: not an image pardes can read"));
- p.sync();
- var after: usize = 0;
- for (p.panes) |slot| after += @intFromBool(slot != null);
- try testing.expectEqual(count, after);
-}
-
test "a truncated PDF fails its look with its path and why" {
if (comptime !pardes.pdf_enabled) return;
const p = try withFile(testing.allocator, "x\n");
@@ -2800,7 +2776,7 @@ test "a Save whose directory is missing because one above refuses says permissio
test "a body write to an image pane says its body takes none, not that terminals have no text" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
try testing.expectEqualStrings(pane_files.e_no_body, wr(p, Node.of(doc.serial, .body), "x").reply.ename);
}
@@ -2830,7 +2806,7 @@ test "a Rename that reaches other files previews them, says so, and is the pane
test "Edit on an image pane is refused as a data write there is, EINVAL, before it runs" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
const edit = wr(p, Node.of(doc.serial, .ctl), "Edit ,d\n");
const data = wr(p, Node.of(doc.serial, .data), "x");
try testing.expectEqual(E.INVAL, edit.errno());
@@ -2841,7 +2817,7 @@ test "Edit on an image pane is refused as a data write there is, EINVAL, before
test "Petscii, Palette and Ascii take the state their tag word names, set rather than flipped" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.image, "/tmp/pardes-pic.ppm", null);
+ const doc = try pardes.Kind.open(p, p.freeSlot().?, pardes.Kind.test_kind.of(p), "/tmp/pardes-pic.ppm", null);
const ctl_node = Node.of(doc.serial, .ctl);
for ([_][]const u8{ "Petscii on\n", "Petscii on\n" }) |line| {
try testing.expectEqual(Status.ok, wr(p, ctl_node, line).reply.status);
@@ -2851,7 +2827,7 @@ test "Petscii, Palette and Ascii take the state their tag word names, set rather
try testing.expect(!doc.addon.?.art.glyph);
_ = wr(p, ctl_node, "Palette terminal\n");
_ = wr(p, ctl_node, "Palette terminal\n");
- try testing.expectEqual(pardes.panes.Image.PaletteMode.terminal, doc.addon.?.art.palette);
+ try testing.expectEqual(pardes.Placement.Art.Palette.terminal, doc.addon.?.art.palette);
_ = wr(p, ctl_node, "Ascii off\n");
_ = wr(p, ctl_node, "Ascii off\n");
try testing.expect(!doc.addon.?.art.ascii);