diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-07 19:45:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-07 20:39:56 -0300 |
| commit | 4c134eaa5c7f84eba7091c9ccef86567f1434d49 (patch) | |
| tree | c6bd720bc8999887573e8d9112e553e19154f78b /test/behaviour/addons.zig | |
| parent | f2784acb88c98f33fed25dbf41f1a5af278c8e84 (diff) | |
| download | pardes-4c134eaa5c7f84eba7091c9ccef86567f1434d49.tar.gz pardes-4c134eaa5c7f84eba7091c9ccef86567f1434d49.zip | |
gui: a kind's pane (an image, a PDF) is watched again and shows its file as it is now: Kind.open and a restored kind's pane emit its watch, which kinds #14 dropped with pdf_view, and a reload counts into its pictures' keys, since its kind numbers them afresh from each open and a window keeps a texture by key; the T1 session watches files as a host does (Session.filesChanged) and two behaviour cases pin it
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/addons.zig')
| -rw-r--r-- | test/behaviour/addons.zig | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/behaviour/addons.zig b/test/behaviour/addons.zig index 3a53766a..9b96a3d6 100644 --- a/test/behaviour/addons.zig +++ b/test/behaviour/addons.zig @@ -331,3 +331,36 @@ test "addons: a Look at a file whose extension an addon claims opens a pane of i const help = try s.read(s.at("/pane/{d}/body", .{try s.focused()})); try std.testing.expect(has(help, "SPC z f Fake a fake pane, counting (addon fake)\n")); } + +test "addons: an image pane whose file changes on disk shows the new picture, under a new key: a window keeps a texture by its key" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + s.graphics(); + try load(&s, Session.image_addon); + defer unload(&s, "image"); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic.ppm", .data = "P6\n2 1\n255\n\x0d\x4d\xe7\x0d\x4d\xe7" }); + try s.write("/look", s.at("{s}/pic.ppm\n", .{dir})); + const n = try s.focused(); + const key = "\"key\":\""; + const before = try s.arena.allocator().dupe(u8, try s.read("/screen")); + try std.testing.expect(has(before, s.at("\"serial\":{d},", .{n})) and has(before, "\"src\":[0,0,2,1]")); + const old_key = before[std.mem.indexOf(u8, before, key).? + key.len ..][0..16]; + // The same size, other pixels: only its key tells a window it changed. + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic.ppm", .data = "P6\n2 1\n255\n\xe7\x4d\x0d\xe7\x4d\x0d" }); + try std.testing.expect(try s.filesChanged()); + const after = try s.read("/screen"); + try std.testing.expect(has(after, "\"src\":[0,0,2,1]")); + try std.testing.expect(!has(after, old_key)); + // Another size: the picture as it is now. + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pic.ppm", .data = "P6\n3 1\n255\n\xe7\x4d\x0d\xe7\x4d\x0d\xe7\x4d\x0d" }); + try std.testing.expect(try s.filesChanged()); + try std.testing.expect(has(try s.read("/screen"), "\"src\":[0,0,3,1]")); + // A second Look of it finds its pane, the new picture in it. + try s.write("/look", s.at("{s}/pic.ppm\n", .{dir})); + try std.testing.expectEqual(n, try s.focused()); + try std.testing.expect(has(try s.read("/screen"), "\"src\":[0,0,3,1]")); +} |
