diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 00:02:06 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 01:21:34 -0300 |
| commit | 423440f25b4b23b56162008bba35218d438767fe (patch) | |
| tree | a7b06a88c7a55308e7e906ff49fa264a1fd147cf /src/ninep/ctl.zig | |
| parent | 94ca47f225632fefc8f688c0c0822d25d6a5db1e (diff) | |
| download | pardes-423440f25b4b23b56162008bba35218d438767fe.tar.gz pardes-423440f25b4b23b56162008bba35218d438767fe.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 81ccd6ea..68fefbc5 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1521,8 +1521,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 p.newDocPane(id); - doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") }; + const doc = try pardes.Kind.open(p, id, &pardes.image.kind, "/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")); } @@ -1531,8 +1530,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 p.newDocPane(id); - doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") }; + const doc = try pardes.Kind.open(p, id, &pardes.image.kind, "/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); @@ -1562,17 +1560,16 @@ test "a builtin for one kind of pane is refused on another, and still acts on it try testing.expectEqual(Status.err, wr(p, Node.of(serial, .ctl), line).reply.status); }; const id = p.freeSlot().?; - const doc = try p.newDocPane(id); - doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") }; + const doc = try pardes.Kind.open(p, id, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); const r = wr(p, Node.of(doc.serial, .ctl), "Mode\n"); try testing.expectEqualStrings("Mode: only a text or terminal pane has modes", r.reply.ename); - const glyphs = doc.image.?.glyph_art; + const glyphs = doc.addon.?.art.glyph; try testing.expectEqual(Status.ok, wr(p, Node.of(doc.serial, .ctl), "Petscii\n").reply.status); - try testing.expect(doc.image.?.glyph_art != glyphs); + try testing.expect(doc.addon.?.art.glyph != glyphs); // Its tag says what is drawn: with no graphics, glyph art whatever // Petscii chose; with them, what it chose. for ([_]bool{ false, true }) |art| { - doc.image.?.glyph_art = art; + doc.addon.?.art.glyph = art; p.frontend.native_images = false; try testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(p, doc), " petscii:on ") != null); p.frontend.native_images = true; @@ -2137,7 +2134,7 @@ 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.panes.Image.create(p, slot, "/tmp/pardes-no-such.png", try p.image_gpa.dupe(u8, "not a png")); + const img = try pardes.Kind.open(p, slot, &pardes.image.kind, "/tmp/pardes-no-such.png", "not a png"); try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno()); } @@ -2779,8 +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 p.newDocPane(p.freeSlot().?); - doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") }; + const doc = try pardes.Kind.open(p, p.freeSlot().?, &pardes.image.kind, "/tmp/pardes-pic.ppm", null); try testing.expectEqualStrings(pane_files.e_no_body, wr(p, Node.of(doc.serial, .body), "x").reply.ename); } @@ -2810,8 +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 p.newDocPane(p.freeSlot().?); - doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") }; + const doc = try pardes.Kind.open(p, p.freeSlot().?, &pardes.image.kind, "/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()); @@ -2822,24 +2817,23 @@ 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 p.newDocPane(p.freeSlot().?); - doc.image = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-pic.ppm") }; + const doc = try pardes.Kind.open(p, p.freeSlot().?, &pardes.image.kind, "/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); - try testing.expect(doc.image.?.glyph_art); + try testing.expect(doc.addon.?.art.glyph); } _ = wr(p, ctl_node, "Petscii off\n"); - try testing.expect(!doc.image.?.glyph_art); + 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.image.?.pmode); + try testing.expectEqual(pardes.panes.Image.PaletteMode.terminal, doc.addon.?.art.palette); _ = wr(p, ctl_node, "Ascii off\n"); _ = wr(p, ctl_node, "Ascii off\n"); - try testing.expect(!doc.image.?.ascii); + try testing.expect(!doc.addon.?.art.ascii); // Bare, each still flips. _ = wr(p, ctl_node, "Ascii\n"); - try testing.expect(doc.image.?.ascii); + try testing.expect(doc.addon.?.art.ascii); _ = wr(p, ctl_node, "Petscii maybe\n"); try testing.expect(th.logHas(p, "Petscii takes on or off")); } |
