summaryrefslogtreecommitdiff
path: root/test/behaviour/keys.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 06:24:42 -0300
committerGabriel Schneider <[email protected]>2026-11-06 11:19:44 -0300
commitc1917b949b9580de8bf0977874a210f0266812da (patch)
tree447dd2235ea00634f662cd3becf4bceb8a895f41 /test/behaviour/keys.zig
parent76c55b5bce0f181b0b15b16596c900397dfef544 (diff)
downloadpardes-c1917b949b9580de8bf0977874a210f0266812da.tar.gz
pardes-c1917b949b9580de8bf0977874a210f0266812da.zip
kinds #14, the core's PDF code gone: pdf.zig and pdf_view.zig leave and every pdf_enabled branch with them; look, Jump, Recent, dumps (one from before the addon opens as its pane), the watch, mouse, keys, the rail and the tag go through Kind for any kind's pane; test/pdf.zig's behaviours are T1 cases over 9P (addons_pdf.zig) and pane cases (a Shadow over a replica, a file changed under it), the harnesses load pdf.so by path
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/keys.zig')
-rw-r--r--test/behaviour/keys.zig48
1 files changed, 28 insertions, 20 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig
index eeaacf7d..879ff441 100644
--- a/test/behaviour/keys.zig
+++ b/test/behaviour/keys.zig
@@ -136,28 +136,33 @@ test "keys: a count or a prefix a click or a change of pane cancels leaves nothi
}
}
-test "keys: a PDF shown as text turns pages for the moving keys, counted, and the editing keys do nothing" {
+test "keys: a PDF's moving keys scroll its strip, counted, gg G and ge go to pages, and the editing keys do nothing" {
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
const n = try s.lookFile("docs/design.pdf");
const pages = (try s.pdfPage(n))[1];
try std.testing.expect(pages > 3);
- // j k, Ctrl-d Ctrl-u, Ctrl-f Ctrl-b: a page each, counted.
- for ([_][]const u8{ "2j", "2k", "2\x04", "2\x15", "2\x06", "2\x02" }, 0..) |keys, i| {
- try s.keys(keys);
- try std.testing.expectEqual(@as(u32, if (i % 2 == 0) 3 else 1), (try s.pdfPage(n))[0]);
- }
- for ([_]struct { []const u8, u32 }{ .{ "ge", pages }, .{ "gg", 1 }, .{ "3gg", 3 }, .{ "2G", 2 } }) |step| {
+ for ([_]struct { []const u8, u32 }{ .{ "ge", pages }, .{ "gg", 1 }, .{ "3gg", 3 }, .{ "2G", 2 }, .{ "G", pages }, .{ "gg", 1 } }) |step| {
try s.keys(step[0]);
try std.testing.expectEqual(step[1], (try s.pdfPage(n))[0]);
}
+ // j a cell's pixels, Ctrl-f a window's: a count moves that many, so
+ // thirty windows down is past the first page (a window is a few rows
+ // of a page here), thirty back at the first, and k at the top stays.
+ try s.keys("k");
+ try std.testing.expectEqual(@as(u32, 1), (try s.pdfPage(n))[0]);
+ try s.keys("30\x06");
+ try std.testing.expect((try s.pdfPage(n))[0] > 1);
+ try s.keys("30\x02");
+ try std.testing.expectEqual(@as(u32, 1), (try s.pdfPage(n))[0]);
+ try s.keys("200j");
+ try std.testing.expect((try s.pdfPage(n))[0] > 1);
+ try s.keys("2G");
// Consumed, with their count: the page stays, no selection begins, and
- // the next j is one page.
- try s.keys("4dv|");
+ // no mode changes.
+ try s.keys("4dv|i");
try std.testing.expectEqual(@as(u32, 2), (try s.pdfPage(n))[0]);
try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal "));
- try s.keys("j");
- try std.testing.expectEqual(@as(u32, 3), (try s.pdfPage(n))[0]);
}
test "keys: SPC j n and SPC j p in plain text select its places, never a comment's slashes, round the end, opening nothing" {
@@ -334,23 +339,26 @@ test "keys: a PDF in normal mode keeps : (its tag and back), SPC (a leader, canc
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
const n = try s.lookFile("docs/design.pdf");
- const body = (try s.cursor()).?;
- const tag = (try s.where("docs/design.pdf [1/"))[1];
+ // A page has no text cursor: the body shows none.
+ try std.testing.expect(try s.cursor() == null);
+ _ = try s.pdfPage(n);
+ const tag = (try s.where("[1/"))[1];
try s.keys(":");
+ // On its tag, which runs to three rows (its path, the core's art words).
const on_tag = (try s.cursor()).?[1];
- try std.testing.expect(on_tag == tag or on_tag == tag + 1);
+ try std.testing.expect(on_tag >= tag and on_tag <= tag + 2);
try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal "));
try s.keys(":");
- try std.testing.expectEqual(body, (try s.cursor()).?);
- // The leader shows its keys at the row's end until one it has not.
+ try std.testing.expect(try s.cursor() == null);
+ // The leader shows its keys until one it has not.
try s.keys(" ");
- try std.testing.expect(std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC"));
+ try std.testing.expect(std.mem.indexOf(u8, try s.screen(), " SPC") != null);
try s.keys("!");
- try std.testing.expect(!std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC"));
+ try std.testing.expect(std.mem.indexOf(u8, try s.screen(), " SPC") == null);
try s.keys("/");
- try std.testing.expect(!std.meta.eql(body, (try s.cursor()).?));
+ try std.testing.expect(try s.cursor() != null);
try std.testing.expectEqual(n, try s.focused());
try s.keys("\x1b");
- try std.testing.expectEqual(body, (try s.cursor()).?);
+ try std.testing.expect(try s.cursor() == null);
try std.testing.expectEqual(n, try s.focused());
}