diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 10:49:58 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 11:05:39 -0300 |
| commit | 9cfebaeca67301a8925eaa44c71859b42b676e59 (patch) | |
| tree | 9f3e221ac895d9b006031470098d83135e61d7cb /test/behaviour/keys.zig | |
| parent | ff0b8a382de7a1994a6912dc71ba28a8ecdaf474 (diff) | |
| download | pardes-9cfebaeca67301a8925eaa44c71859b42b676e59.tar.gz pardes-9cfebaeca67301a8925eaa44c71859b42b676e59.zip | |
test: a tag's file-name tint and Back and Forward through the 9P tree alone: in test/behaviour/tags.zig a file pane's tag tinting its name (界file.zig) and not its directory, dirty marker or words, the tag at the top or the bottom (Session.styles); in keys.zig Ctrl-o and Ctrl-i (Kctl o, i) jumping between line 60 and line 1 made by 60G1G, dot empty where the jump lands and no B1 sweep drawn after either, a wrapped Unicode and tab sweep included, swept either way; each checked to fail against a break (the tint starting at the last slash, focusPaneLine not moving the caret; clearNavigationSelection returning at once is not caught, the key's own path dropping the sweep too); test/panes.zig's two one-pane jump tests deleted, the tint test trimmed to its search pane (fillResults), the cross-pane jump test kept (it seeds held selections)
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 | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index 989489d7..0c2c0a43 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -240,3 +240,60 @@ test "keys: Save's prompt on a scratch starts from the scratch's directory, one try s.keys("\x1b"); } } + +/// A B1 sweep from cell (x0, y0) to (x1, y1). +fn sweep(s: *Session, x0: usize, y0: usize, x1: usize, y1: usize) !void { + try s.write("/mousein", s.at("m {d} {d} 1\nm {d} {d} 1\nm {d} {d} 0\n", .{ x0, y0, x1, y1, x1, y1 })); +} + +/// Whether any cell /screen draws is in `style`. +fn drawsIn(s: *Session, style: []const u8) !bool { + for (try s.styles()) |cell| if (std.mem.eql(u8, cell, style)) return true; + return false; +} + +test "keys: Ctrl-o and Ctrl-i jump back and forth, leaving no sweep drawn, a wrapped Unicode and tab one included" { + const ctl = "\u{F017}"; + for ([_]struct { []const u8, []const u8, bool }{ + .{ "alpha\nbravo\n", "alpha", false }, + .{ "界\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n", "界", true }, + }) |c| for ([_]bool{ false, true }) |reverse| { + const prefix, const first, const wrap = c; + var buf: [4096]u8 = undefined; + @memcpy(buf[0..prefix.len], prefix); + for (0..80) |i| @memcpy(buf[prefix.len + i * 27 ..][0..27], "unrelated destination text\n"); + var s = try Session.initFile(std.testing.allocator, buf[0 .. prefix.len + 80 * 27]); + defer s.deinit(); + const n = try s.focused(); + s.detach(); + try s.write("/ctl", "size 34 10\n"); + try s.write("/ctl", if (wrap) "Wrap on\n" else "Wrap off\n"); + const dot = s.at("/pane/{d}/dot", .{n}); + const addr = s.at("/pane/{d}/addr", .{n}); + // Two places in the jump list: line 60, then line 1. + try s.keys("60G1G"); + const x, const y = try s.where(first); + const plain = (try s.styles())[0]; + if (reverse) try sweep(&s, x + 3, y + 1, x + 1, y) else try sweep(&s, x + 1, y, x + 3, y + 1); + const screen = try s.screen(); + const cols = try std.unicode.utf8CountCodepoints(screen[0..std.mem.indexOfScalar(u8, screen, '\n').?]); + const swept = (try s.styles())[(y + 1) * cols + x]; + try std.testing.expect(!std.mem.eql(u8, swept, plain)); + try s.keys(ctl ++ "o"); + try s.write(addr, "60"); + const line60 = (try s.range(addr))[0]; + try std.testing.expectEqual(.{ line60, line60 }, try s.range(dot)); + try std.testing.expectError(error.NotOnScreen, s.where(first)); + try std.testing.expect(!try drawsIn(&s, swept)); + // A sweep made after Back is gone after Forward. + const x2, const y2 = try s.where("unrelated"); + try sweep(&s, x2 + 1, y2, x2 + 3, y2 + 1); + try std.testing.expect(try drawsIn(&s, swept)); + try s.keys(ctl ++ "i"); + // Back where the sweep left the caret, nothing selected. + const q0, const q1 = try s.range(dot); + try std.testing.expect(q0 == q1 and q1 < line60); + _ = try s.where(first); + try std.testing.expect(!try drawsIn(&s, swept)); + }; +} |
