diff options
| -rw-r--r-- | build/patches.zig | 5 | ||||
| -rw-r--r-- | dev/tui/tui.zig | 16 |
2 files changed, 19 insertions, 2 deletions
diff --git a/build/patches.zig b/build/patches.zig index 7c7b2d60..7d87b9f1 100644 --- a/build/patches.zig +++ b/build/patches.zig @@ -34,7 +34,8 @@ fn apply(b: *std.Build, patch: *std.Build.Step.Compile, dep: *std.Build.Dependen /// startup width queries' `CSI 1;1R` arrived as two F3s, which a shell /// pane took for text (build/patches/vaxis_parser.zig). /// - ESC before a CSI or SS3 key (rxvt's Alt+arrow) is Alt on that key, -/// not Alt+Escape followed by `[A` as text. +/// not Alt+Escape followed by `[A` as text; before anything else (a +/// mouse report: Alt is in its button) it is the Escape key. /// - An X10 mouse report and a kitty graphics reply cut short by a read /// wait for their rest: the first became three bytes of text, the /// second sliced past its input. @@ -56,7 +57,7 @@ const vaxis_parser = [_]Edit{ \\ if (inner.n == 0) return inner; \\ if (inner.event) |*event| switch (event.*) { \\ .key_press, .key_release => |*key| key.mods.alt = true, - \\ else => {}, + \\ else => return .{ .event = .{ .key_press = .{ .codepoint = Key.escape } }, .n = 1 }, \\ }; \\ inner.n += 1; \\ return inner; diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index 0157362a..e699745a 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -2446,6 +2446,22 @@ test "an ESC read by itself is the Escape key at once" { t.vx.caps.kitty_keyboard = false; } +test "an Escape read with the click after it is the Escape key, then the click" { + var t: TestInput = undefined; + try t.init(); + defer t.deinit(); + // A busy session reads them in one: no terminal sends Alt on a mouse + // report as an ESC before it (it is in the report's button). + var reader: TestReader = .{ .parts = &.{"\x1b\x1b[<1;105;9M"} }; + try readInput(&t.loop, &reader, &t.vx, &t.feed); + try std.testing.expectEqual(.winsize, std.meta.activeTag((try t.loop.tryEvent()).?)); + const escape = (try t.loop.tryEvent()).?.key_press; + try std.testing.expectEqual(vaxis.Key.escape, escape.codepoint); + try std.testing.expect(!escape.mods.alt); + try std.testing.expectEqual(.mouse, std.meta.activeTag((try t.loop.tryEvent()).?)); + try std.testing.expect(try t.loop.tryEvent() == null); +} + test "a frame's answer is taken wherever the reads cut it, and never typed" { const gpa = std.testing.allocator; var t: TestInput = undefined; |
