summaryrefslogtreecommitdiff
path: root/src/tty
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 14:29:44 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit8262f315538b70ab8a123ef1e9346f25b25ec939 (patch)
tree7e0058b229bcf974758f748cbca5b7730aef856c /src/tty
parent505d15e238e4e9c5020a8e567d700bdbf67a8528 (diff)
downloadpardes-8262f315538b70ab8a123ef1e9346f25b25ec939.tar.gz
pardes-8262f315538b70ab8a123ef1e9346f25b25ec939.zip
The window's F1-F24, Insert, Print Screen, Scroll Lock, Pause and Menu keys reach a terminal's program, which they never did; every key a program gets follows its cursor keys' mode and kitty keyboard flags, pinned for both shells
The keys went through ghostty's encoder already (DECCKM, the kitty flags); the GUI's native key map simply dropped the function and editing keys it did not name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tty')
-rw-r--r--src/tty/tty.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig
index 67807cd5..0a9d65c4 100644
--- a/src/tty/tty.zig
+++ b/src/tty/tty.zig
@@ -2211,6 +2211,44 @@ test "a terminal pane gets function keys as their sequences and lone modifiers n
try std.testing.expectEqualStrings("\x1bOR\x1b[15~\x1b[2~\x1bOR\x1b[Ah", written.written());
}
+test "the terminal's keys reach a program as its cursor keys' mode and keyboard flags say" {
+ const gpa = std.testing.allocator;
+ const core = try pardes.Pardes.init(gpa, .{ .tty_only = true });
+ defer core.deinit();
+ core.panes[0].?.body.mode = .tty;
+ while (core.nextEffect()) |_| {}
+ var written: std.Io.Writer.Allocating = .init(gpa);
+ defer written.deinit();
+ // What the outer terminal sends, what the program asked for, and what
+ // it should read.
+ const Case = struct { modes: []const u8, in: []const u8, sent: []const u8 };
+ const cases = [_]Case{
+ .{ .modes = "", .in = "\x1b[A\x1b[H\x1bOP\x1b[15~", .sent = "\x1b[A\x1b[H\x1bOP\x1b[15~" },
+ .{ .modes = "\x1b[?1h", .in = "\x1b[A\x1b[F\x1b[1;5D", .sent = "\x1bOA\x1bOF\x1b[1;5D" },
+ .{ .modes = "\x1b[?1l\x1b[>7u", .in = "\x1b[99;5u\x1b[97;3u\x1b[A", .sent = "\x1b[99;5u\x1b[97;3u\x1b[1;1:1A" },
+ };
+ for (cases) |case| {
+ core.update(.{ .output = .{ .pane = 0, .bytes = case.modes } });
+ while (core.nextEffect()) |_| {}
+ var parser: vaxis.Parser = .{};
+ var bytes = case.in;
+ while (bytes.len > 0) {
+ const result = try parser.parse(bytes, gpa);
+ if (result.n == 0) break;
+ bytes = bytes[result.n..];
+ if (result.event) |event| switch (event) {
+ .key_press => |key| core.update(vaxis_input.keyEvent(key)),
+ else => {},
+ };
+ }
+ written.clearRetainingCapacity();
+ while (core.nextEffect()) |effect| {
+ if (effect == .write) try written.writer.writeAll(effect.write.bytes.slice());
+ }
+ try std.testing.expectEqualStrings(case.sent, written.written());
+ }
+}
+
test "keypad Enter matches Return for editor input terminal writes and paste" {
for ([_]u21{ vaxis.Key.enter, vaxis.Key.kp_enter }) |codepoint| {
const key: vaxis.Key = .{ .codepoint = codepoint };