diff options
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")); } |
