summaryrefslogtreecommitdiff
path: root/test/behaviour/other_files.zig
blob: b97affc472fe63f66286fcea02101cfdeecca194 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! docs/typ/reference.typ, Other files <other-files>.
const std = @import("std");
const Session = @import("session").Session;

test "other-files: kbdin types at the pane with the keyboard and mousein clicks, each done before its write is answered" {
    var s = try Session.initFile(std.testing.allocator, "x\n");
    defer s.deinit();
    const body = try std.fmt.allocPrint(s.arena.allocator(), "/pane/{d}/body", .{try s.focused()});
    try s.keys("ihello \x1b");
    try s.expect(body, "hello x\n");
    // Plan 9's Khome rune, then text before it.
    try s.keys("A!\x1b\u{F00D}i>\x1b");
    try s.expect(body, ">hello x!\n");
    // A left click on the second l, then text there.
    try s.click(">hello", 4, 1);
    try s.keys("i#\x1b");
    try s.expect(body, ">hel#lo x!\n");
    // Refused, in words, as rio and devmouse refuse.
    try std.testing.expectEqual(@as(u16, 22), try s.refused("/mousein", "m 1 2\n"));
    try std.testing.expectEqual(@as(u16, 22), try s.refused("/mousein", "x 1 2 0\n"));
    try std.testing.expectEqual(@as(u16, 22), try s.refused("/kbdin", "\xff"));
    try std.testing.expectError(error.Refused, s.read("/kbdin"));
}