summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 09:57:16 -0300
committerGabriel Schneider <[email protected]>2026-11-20 11:35:33 -0300
commitfe0efce585bdd001d15db3b7fee7bf125af4168f (patch)
tree6568915dae435cf209770f92635f8c8e67161807
parent214839df238faa462de02274ef4322ea484cf383 (diff)
downloadpardes-fe0efce585bdd001d15db3b7fee7bf125af4168f.tar.gz
pardes-fe0efce585bdd001d15db3b7fee7bf125af4168f.zip
vaxis's parser (pardes's patch, build/patches.zig): an ESC read with a mouse report after it is the Escape key, then the report; the patch made an ESC before any CSI Alt on what followed, and on a mouse report, which has no Alt but in its button, it dropped the ESC: a busy session that read an Escape and the click after it in one read (or took the click within the 50 ms an ESC ending a longer read waits) kept the pane in insert mode (process-test exec-bigdrag's alive-ok: 3 of 9-21 runs at a load of 33-43, the pane's next i typed as text); dev/tui/tui.zig's test 'an Escape read with the click after it...' failed before (the mouse event came where the Escape was); after, pinned to one CPU: exec-bigdrag 0 of 30; the five together: tui core-test 859/1014, shell-test 1055/1058, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay, process-test 0 of 144 (cmdexit once, again alone), daemon.py in every mode, both soaks diverged 0 unequal 0, gui unit-test 1651/1655 (BaselineHarnessMismatch), the frame and perf gate against tree2 PASS
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
-rw-r--r--build/patches.zig5
-rw-r--r--dev/tui/tui.zig16
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;