summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 06:55:37 -0300
committerGabriel Schneider <[email protected]>2026-10-01 07:16:43 -0300
commitffe28cf8a9fbb483d576f52448dc1cd5269fd577 (patch)
treee6d417c410c223b394a7cf06a9c53a798c5b7244 /src/ninep/ctl.zig
parent4178fdf514b637cafde6325086e0ce66e2cafaa2 (diff)
downloadpardes-ffe28cf8a9fbb483d576f52448dc1cd5269fd577.tar.gz
pardes-ffe28cf8a9fbb483d576f52448dc1cd5269fd577.zip
Petscii, Palette, Ascii, PdfFit and PdfTint take the state their tag word names, set rather than flipped: `Petscii on`, `Palette terminal`, `PdfFit width`
Each could only flip, so a script had to read the tag to know which way a write would go. Each now takes an optional argument, the value its tag word shows (on|off for Petscii and Ascii, commodore|terminal for Palette, width|height for PdfFit, disabled|filtered|full for PdfTint), and sets it; bare, it flips as before. Anything else is refused with what it takes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index ad427cad..f4aff960 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -4188,3 +4188,28 @@ test "a second LookWord list look in a directory refills its +Search rather than
};
try testing.expectEqual(@as(usize, 1), searches);
}
+
+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 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);
+ }
+ _ = wr(p, ctl_node, "Petscii off\n");
+ try testing.expect(!doc.image.?.glyph_art);
+ _ = 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);
+ _ = wr(p, ctl_node, "Ascii off\n");
+ _ = wr(p, ctl_node, "Ascii off\n");
+ try testing.expect(!doc.image.?.ascii);
+ // Bare, each still flips.
+ _ = wr(p, ctl_node, "Ascii\n");
+ try testing.expect(doc.image.?.ascii);
+ _ = wr(p, ctl_node, "Petscii maybe\n");
+ try testing.expect(th.logHas(p, "Petscii takes on or off"));
+}