From ffe28cf8a9fbb483d576f52448dc1cd5269fd577 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 06:55:37 -0300 Subject: 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 --- src/ninep/ctl.zig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/ninep') 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")); +} -- cgit v1.3