summaryrefslogtreecommitdiff
path: root/test/process/tty_images.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/process/tty_images.zig')
-rw-r--r--test/process/tty_images.zig66
1 files changed, 65 insertions, 1 deletions
diff --git a/test/process/tty_images.zig b/test/process/tty_images.zig
index 9cd67a40..dea9feef 100644
--- a/test/process/tty_images.zig
+++ b/test/process/tty_images.zig
@@ -1,3 +1,67 @@
//! The tty frontend's own cases (test/tty.zig), image panes drawn in a terminal (petscii glyph art).
+const std = @import("std");
+const Tty = @import("../tty.zig").Tty;
-pub const cases = .{};
+pub const cases = .{
+ .{ "tty images: images", images },
+};
+
+// image panes: right-click a .ppm opens petscii glyph art (no kitty in the
+// harness). The tag starts with the renderer's plain state fields followed by
+// its path and `Term Del`; the fields are display-only, while their toggles are
+// builtins under SPC t (the old clickable tag words sat past the pane's right
+// edge, so clicking them only ever hit the neighbouring shell's tag).
+fn images(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
+ var t = try Tty.init(gpa, exe, "images");
+ defer t.deinit();
+ try t.ppmDiag("pic.ppm");
+ try t.start(31, 150, &.{ "-n", "3" });
+ try t.wait(8000, "pic.ppm");
+ try t.stable(700, 20000);
+ try t.press("left", "5", 9);
+ try t.release("left", "5", 9);
+ try t.stable(400, 5000);
+ try t.key("i");
+ try t.send("pic.ppm");
+ try t.key("esc");
+ try t.settle(100);
+ try t.press("right", "6", 9);
+ try t.release("right", "6", 9);
+ try t.wait(10000, "img");
+ try t.stable(700, 20000);
+ try t.snap("img-open");
+ try t.style("img-open");
+ // SPC t l: the C64 Pepto palette gives way to the terminal's own 16 (the cells
+ // stop carrying truecolor and carry ansi indices instead)
+ try t.key("space");
+ try t.key("t");
+ try t.key("l");
+ try t.stable(700, 15000);
+ try t.style("term-palette");
+ // SPC t a: drop the printable-ASCII bitmaps from the matcher's glyph set, so
+ // the art is blocks and sextants only. Captured as TEXT — this toggle changes
+ // which glyph each cell picks, which a style capture cannot see (the reason
+ // the old click-at-x=57 version of this step proved nothing even when it hit).
+ try t.key("space");
+ try t.key("t");
+ try t.key("a");
+ try t.stable(700, 15000);
+ try t.snap("no-ascii");
+ // the tag takes an edit like any other pane's now — nothing live left in it to
+ // protect, so the image early-return in enterTagEdit is gone. The image-state
+ // prefix is wider than this source-local column, so widen the grid for this
+ // final assertion. (A column-border drag intentionally takes width from only
+ // one neighbour, which cannot expose this 82-column prefix.) Then click the
+ // visible tail itself, at its `Term`. This proves the image tag is an ordinary
+ // editor rather than accidentally typing at a clipped read-only path.
+ try t.resize(31, 400);
+ try t.stable(400, 5000);
+ try t.press("left", "@Term", 7);
+ try t.release("left", "@Term", 7);
+ try t.stable(400, 5000);
+ try t.key("i");
+ try t.send("Zork ");
+ try t.stable(400, 5000);
+ try t.snap("tag-edit");
+ try t.done();
+}