diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 11:19:29 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 11:20:50 -0300 |
| commit | 49ed5492dec8275ace22e37003f4de548b2d2fc5 (patch) | |
| tree | 92fd6c3750da7a558b4ab8ee4ec09cd3f477e830 /test/behaviour/keys.zig | |
| parent | a5504e6e808c5b147e114d43b5c165bbe714f3c3 (diff) | |
| download | pardes-49ed5492dec8275ace22e37003f4de548b2d2fc5.tar.gz pardes-49ed5492dec8275ace22e37003f4de548b2d2fc5.zip | |
test: test/pdf.zig's PDF normal-mode keys through the 9P tree alone, in test/behaviour/keys.zig: in a PDF, : giving its tag the keyboard in normal mode and : again the body back, SPC a leader (its keys shown at the row's end) that a key it has not cancels, and / a search prompt that Esc closes, the PDF keeping the keyboard; each checked to fail against a break (a PDF's : doing nothing, its / doing nothing, its SPC not starting the leader)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/keys.zig')
| -rw-r--r-- | test/behaviour/keys.zig | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index e659b369..b6fe1e83 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -274,3 +274,35 @@ test "keys: SPC j n and SPC j p walk on from the place a Look's +Search listing try std.testing.expectEqual(results, try s.focused()); try s.expect(sel, "look-owner.txt:1:7-12"); } + +/// Screen row `row` as drawn. +fn screenRow(s: *Session, row: usize) ![]const u8 { + var rows = std.mem.splitScalar(u8, try s.screen(), '\n'); + for (0..row) |_| _ = rows.next(); + return rows.next().?; +} + +test "keys: a PDF in normal mode keeps : (its tag and back), SPC (a leader, cancelled by a key it has not) and / (a search prompt, Esc closing it)" { + 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]; + try s.keys(":"); + const on_tag = (try s.cursor()).?[1]; + try std.testing.expect(on_tag == tag or on_tag == tag + 1); + 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 s.keys(" "); + try std.testing.expect(std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC")); + try s.keys("!"); + try std.testing.expect(!std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC")); + try s.keys("/"); + try std.testing.expect(!std.meta.eql(body, (try s.cursor()).?)); + try std.testing.expectEqual(n, try s.focused()); + try s.keys("\x1b"); + try std.testing.expectEqual(body, (try s.cursor()).?); + try std.testing.expectEqual(n, try s.focused()); +} |
