summaryrefslogtreecommitdiff
path: root/src/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core.zig')
-rw-r--r--src/Core.zig44
1 files changed, 4 insertions, 40 deletions
diff --git a/src/Core.zig b/src/Core.zig
index 4584e395..b1195ac2 100644
--- a/src/Core.zig
+++ b/src/Core.zig
@@ -64,7 +64,6 @@ const font_picker = pardes.font_picker;
const fonts = pardes.fonts;
const frame_ns = pardes.frame_ns;
const host_io = pardes.host_io;
-const image = pardes.image;
const layout = pardes.layout;
const limits = memory.limits;
const locations = @import("locations.zig");
@@ -2499,7 +2498,7 @@ test "Filter is ordered after Del and toggles only its terminal or +Pager pane"
try testing.expect(!first.tty_filter);
const doc_id = p.freeSlot().?;
- const doc = try pardes.Kind.open(p, doc_id, pardes.Kind.image, "/tmp/filter-inert.ppm", "");
+ const doc = try pardes.Kind.open(p, doc_id, pardes.Kind.test_kind.of(p), "/tmp/filter-inert.ppm", "");
try testing.expect(!doc.tty_filter);
try testing.expect(p.executeBuiltinLine(doc_id, "Filter"));
try testing.expect(!doc.tty_filter);
@@ -2669,7 +2668,7 @@ test "unknown Exec from a document runs as a command pane in its directory, type
// A terminal free at a prompt in the same directory is not borrowed.
p.setCwd(0, "/tmp/pardes-image-dir");
- const image_doc = try pardes.Kind.open(p, 1, pardes.Kind.image, "/tmp/pardes-image-dir/pic.ppm", null);
+ const image_doc = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pardes-image-dir/pic.ppm", null);
try std.testing.expectEqualStrings("/tmp/pardes-image-dir", Pardes.paneDir(image_doc));
const dst = exec.execute(p, 1, "echo image-fallback") orelse return error.ExecFoundNowhereToRun;
try std.testing.expect(dst != 0 and dst != 1);
@@ -2723,7 +2722,7 @@ test "a command of several lines keeps its tag one row, and its echo does not st
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
while (p.nextEffect()) |_| {}
- _ = try pardes.Kind.open(p, 1, pardes.Kind.image, "/tmp/pic.ppm", null);
+ _ = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pic.ppm", null);
const two = "def greet(name):\n return name\n\nprint(greet(\"x\"))\n";
const dst = exec.execute(p, 1, two) orelse return error.NoCommandPane;
while (p.nextEffect()) |_| {}
@@ -3071,7 +3070,7 @@ test "a command pane shows how its command ended, and the next command there run
defer p.deinit();
while (p.nextEffect()) |_| {}
p.setCwd(0, "/tmp/pardes-cmd");
- _ = try pardes.Kind.open(p, 1, pardes.Kind.image, "/tmp/pardes-cmd/pic.ppm", null);
+ _ = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pardes-cmd/pic.ppm", null);
const dst = exec.execute(p, 1, "make -j8") orelse return error.NoCommandPane;
while (p.nextEffect()) |_| {}
@@ -3163,41 +3162,6 @@ test "a command pane shows how its command ended, and the next command there run
try std.testing.expectEqual(@as(?usize, null), exec.execute(p, 1, long));
}
-test "image dump restores source bytes renderer choices and exact custom tail" {
- const gpa = std.testing.allocator;
- const p = try Pardes.init(gpa, .{ .tty_only = true });
- defer p.deinit();
- try pardes.panes.deinitPane(p, p.panes[0].?);
- p.panes[0] = null;
-
- const source = "\x00embedded image bytes\xff";
- const pane = try pardes.Kind.open(p, 0, pardes.Kind.image, "/missing/restored-image.ppm", source);
- pane.addon.?.art = .{ .glyph = true, .palette = .terminal, .ascii = false };
- if (pane.tag.own) |own| p.gpa.free(own);
- pane.tag.own = try p.gpa.dupe(u8, " Keep Del");
- try dump.dumpState(p);
-
- const restored = try dump.initFromDump(gpa, .{ .tty_only = true }, p.dump_out.?);
- defer restored.deinit();
- const restored_pane = restored.panes[0].?;
- const art = restored_pane.addon.?.art;
- try std.testing.expect(art.glyph);
- try std.testing.expectEqual(image.PaletteMode.terminal, art.palette);
- try std.testing.expect(!art.ascii);
- try std.testing.expect(restored_pane.tag.own != null);
- try std.testing.expectEqualStrings(" Keep Del", tagline.curTail(restored_pane));
- var kept: [64]u8 = undefined;
- const slot = restored_pane.addon.?;
- try std.testing.expectEqualSlices(u8, source, kept[0..image.kind.dump.?(slot.st, &kept, kept.len)]);
-
- // And dumped again, its bytes still there.
- try dump.dumpState(restored);
- const again = try dump.load(gpa, .{ .tty_only = true }, restored.dump_out.?, null);
- defer again.deinit();
- // Loaded as a replica loads it: a placeholder holding the record.
- try std.testing.expectEqualSlices(u8, source, again.panes[0].?.addon.?.record.?);
-}
-
test "a terminal its program gave back takes command lines again" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{});