diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 19:02:34 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 19:02:34 -0300 |
| commit | 486f347adeed5bac6aaabe8be34e6a69bf323a62 (patch) | |
| tree | da8b333b4033889aa2fd16ab7f5a4bef35b0401d /test/tty.zig | |
| parent | 4053e62a2aabd794db9075d93ebe57eec3f432a6 (diff) | |
| parent | 06f6c72583faf8256190a0ae195a8085e7cd7f32 (diff) | |
| download | pardes-486f347adeed5bac6aaabe8be34e6a69bf323a62.tar.gz pardes-486f347adeed5bac6aaabe8be34e6a69bf323a62.zip | |
integration: six small faults on a hang-up as a close: pardes-faults-6 (a hang-up with no daemon kills the language servers' children; the daemon's reader hands a note under a lock; a retried Edit write answered from the listener's hold; the cursor hidden when a frame has no caret; syntax-test deleted and the grammar tiers' tests skipping; the tty harness's Esc after what came before is read) and pardes-merge41, merged without a textual conflict; tui core-test 874/1031 (157 skipped), shell-test 1073/1076, term-test 17/17, both soaks diverged 0, unequal 0, unlisted 0, the window builds; the coordinator's gate in the ledger (reorg/merge42)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/tty.zig')
| -rw-r--r-- | test/tty.zig | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/test/tty.zig b/test/tty.zig index a6e37c6c..f26328ca 100644 --- a/test/tty.zig +++ b/test/tty.zig @@ -263,11 +263,28 @@ pub const Tty = struct { } /// Keys by name, space-separated: enter esc tab bs space up down left - /// right home end pgup pgdn, a character, c-<ch> and a-<ch>. After esc, - /// settle: vaxis reads the next byte in the same batch as alt-<ch>. + /// right home end pgup pgdn, a character, c-<ch> and a-<ch>. An esc is + /// read alone: sent once the app has read what came before it, and + /// read before anything after it is sent (a read that ends in ESC waits + /// for more, and `ESC h` is alt-h). pub fn key(t: *Tty, names: []const u8) !void { var it = std.mem.tokenizeScalar(u8, names, ' '); - while (it.next()) |name| try t.live().send(keyBytes(name) orelse return error.BadKey); + while (it.next()) |name| { + const esc = std.mem.eql(u8, name, "esc"); + if (esc) try t.allRead(); + try t.live().send(keyBytes(name) orelse return error.BadKey); + if (esc) try t.allRead(); + } + } + + /// Pump until the app has read every byte typed (10 s at most). + fn allRead(t: *Tty) !void { + const h = t.live(); + const until = eh.nowMs() + 10_000; + while (h.unread() > 0) { + if (eh.nowMs() > until) return error.InputNeverRead; + _ = try h.pumpOnce(2); + } } /// An SGR mouse press, release or drag (motion with it held) of @@ -567,7 +584,7 @@ fn stateKey(h: *eh.Harness) ![]u8 { styles.update("\x00"); } } - return std.fmt.allocPrint(h.gpa, "{d},{d},{x}\n{s}", .{ c.x, c.y, styles.final(), text }); + return std.fmt.allocPrint(h.gpa, "{d},{d},{},{x}\n{s}", .{ c.x, c.y, c.shown, styles.final(), text }); } /// A mouse column: either a screen column, or `@Word` / `@Word#2` - the column @@ -797,7 +814,8 @@ fn snap9pText(arena: std.mem.Allocator, h: *eh.Harness, label: []const u8, prev: return out.items; } -/// `== snap <label> grid=CxR cursor=X,Y` then either the whole screen as +/// `== snap <label> grid=CxR cursor=X,Y` (`cursor=hidden` when the app +/// hides it: where a hidden cursor was left is no one's) then either the whole screen as /// `|<row text>` (first capture of a case, or after a resize) or just the /// rows that changed as `|<n>: <row text>`. An indexed row is a patch against /// the previous capture; an unindexed one is a frame. @@ -810,9 +828,8 @@ fn snapText(arena: std.mem.Allocator, h: *eh.Harness, label: []const u8, prev: * for (rows) |*r| r.* = try arena.dupe(u8, std.mem.trimEnd(u8, it.next() orelse "", " ")); var out: std.ArrayList(u8) = .empty; - try out.appendSlice(arena, try std.fmt.allocPrint(arena, "== snap {s} grid={d}x{d} cursor={d},{d}\n", .{ - label, h.cols, h.rows, c.x, c.y, - })); + try out.appendSlice(arena, try std.fmt.allocPrint(arena, "== snap {s} grid={d}x{d} cursor=", .{ label, h.cols, h.rows })); + try out.appendSlice(arena, if (c.shown) try std.fmt.allocPrint(arena, "{d},{d}\n", .{ c.x, c.y }) else "hidden\n"); if (prev.snap.len == rows.len and prev.snap_cols == h.cols) { for (rows, prev.snap, 0..) |now, was, i| { if (std.mem.eql(u8, now, was)) continue; |
