diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 05:18:36 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 05:31:33 -0300 |
| commit | c22b57e13fec318ff4df96fb07b096ea53e31122 (patch) | |
| tree | 98174227327972821a2cd8623fc3a30b0e19b28c /test/process/window.zig | |
| parent | 61c40ab7cffc64a11cb5e874eec9568ed06ad95b (diff) | |
| download | pardes-c22b57e13fec318ff4df96fb07b096ea53e31122.tar.gz pardes-c22b57e13fec318ff4df96fb07b096ea53e31122.zip | |
tui, gui, test/process/window: Escape is the Escape key at once (walk UI P3 item 3, DESIGN D15, POLISH 16): MEASURED in a pty (.scratch/walkui/P3/esc/measure.py, the Debug tty on a legacy terminal, keys written as a terminal writes them, the body read over 9P after `i x Esc A y`): an Esc in a write of its own was taken at once (`xinitialy`); one that reached pardes glued after the key before it in one read (keys typed faster than read: a burst over a link) waited 50 ms for a sequence's rest, and `A` coming in those 50 ms joined it as Alt-A (`xyinitial`: Escape lost, insert mode kept); 100 ms later it was taken; with the kitty keyboard protocol Escape is `CSI 27 u`, never held; so a user of a legacy terminal (tmux, ssh) lost an Escape typed in a burst, never a lone one; THE CAUSE (dev/tui/tui.zig readInput): the ESC a wait saw more after was carried into the next read whatever that read held; THE FIX: carried so, it is the Escape key unless the next read goes on with a sequence's rest, its introducer (`[`, `O`, `]`, `P`, `_`, `^`, `\`) or another ESC: an ssh packet's cut after an ESC still joins (the test "terminal input split at every byte with a gap" unchanged), the key typed after Escape is its own; the 50 ms a glued ESC waits when nothing follows stays (its trade-off for those cuts); after it the pty measurement takes Escape in all three cases; AND the window's test stdin (dev/gui/gui.zig StdinFeed.pump, the screenshot kit's and the gui cases' keys, S's POLISH 16) held a read's trailing lone ESC as the possible start of its `ESC ]777;` events until the next write, with no timeout, so that write's first key came as Alt on it: a read that ends in a lone ESC ends in the Escape key now, as the tty's reader has a read of one; TESTS FIRST: tui.zig "an ESC that ends a read, a key read after it within the wait, is the Escape key and then that key" (on the base: Alt-A, `expected 27, found 65`), test/process/window.zig "a lone Esc written to its test stdin is the Escape key at once, the key written after it its own" (gui, run with the gui gates); shell-test 1281/1284 (3 skipped), core-test 1063/1233 (170 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'test/process/window.zig')
| -rw-r--r-- | test/process/window.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/process/window.zig b/test/process/window.zig index 2a1331ad..292e0e00 100644 --- a/test/process/window.zig +++ b/test/process/window.zig @@ -8,6 +8,7 @@ const process = @import("../process.zig"); pub const cases = .{ .{ "window: a monkey over the effects: random clicks, drags, wheels, keys, columns, looks and themes, then it settles, alive, with no crash record", monkey }, .{ "window: its frame corpus, every kept frame and its sha256 into PARDES_GUI_CORPUS, to compare two builds on one machine", corpus }, + .{ "window: a lone Esc written to its test stdin is the Escape key at once, the key written after it its own", loneEscape }, }; fn envOr(name: [*:0]const u8, default: []const u8) []const u8 { @@ -193,6 +194,25 @@ fn bodyHas(f: *process.Files, serial: u32, word: []const u8) !void { if (process.nowMs() > deadline) return error.NoOutput; } +/// A lone Esc a driver writes to the window's stdin, as its keys come: +/// the Escape key at once. Held for the next write (DESIGN D15, POLISH 16), +/// that write's `A` came as Alt-A and its `y` was typed where insert mode +/// still was. +fn loneEscape(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + try process.only(.gui); + var d = try process.Detached.start(gpa, exe, "loneesc", .{}); + defer d.deinit(); + const f = &d.files; + const pane = try paneWith(f, "loneesc.txt"); + try d.typeKeys("ix"); + try d.settle(gpa); + try d.typeKeys("\x1b"); + try d.settle(gpa); + try d.typeKeys("Ay"); + try d.settle(gpa); + try std.testing.expectEqualStrings("xinitialy\n", try f.read(f.at("/pane/{d}/body", .{pane}))); +} + extern "c" fn system(cmd: [*:0]const u8) c_int; extern "c" fn ioctl(fd: c_int, request: c_ulong, ...) c_int; |
