diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 10:48:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 11:11:46 -0300 |
| commit | 159fc78fc8d350f0f40f7f2fcf344377034c8f2f (patch) | |
| tree | 8e86bbc10db85b9e7aa83af05c32dc1467292b36 /core/term/terminal.zig | |
| parent | 6d075524729cc81fb157a587bef5481d6c36cb0b (diff) | |
| download | pardes-159fc78fc8d350f0f40f7f2fcf344377034c8f2f.tar.gz pardes-159fc78fc8d350f0f40f7f2fcf344377034c8f2f.zip | |
term: the emulator's boundary written down and enforced (S1 on the one road, item 2 of pardes-term-join-8): abi/term.zig names `Ops` in two groups, `replicated` (what every side agrees on by construction, each emulator fed the same bytes in the tape's order, written only by a step or a load, read by a step as the digest covers it, or by a draw) and `local` (start, stop, gpa, due, cellPixels, echoCell, paint, images: this process's own), every entry in exactly one (a comptime check: a new entry fails to compile until it says which); the terminal's digest (core/term/terminal.zig `digest`) now covers what a step reads of it: its cols and rows, every mode bit (the alternate screen, the mouse's, focus reports, bracketed paste; `modes`), the mouse's event and format, and the OSC 133 cycle (`marksOf`, `prompt`'s), beside the view, the cursor, the reply buffer, whether it holds an image and the active area's text; NOT the history's text (its row count only: a step's read of it, a 9P read, a Save, a selection over a shell, is listed as not covered); the two tables of round 6 and pardes-image-loop are a test (core/Term.zig `calls`: every call of the core's into a terminal, by entry, file and count, with its rule: a WRITE outside the rollback copy and why no unit kept to replay makes it or how the copy puts it back, a READ by a step and whether the digest covers it, a LOCAL use and why no step's state reads it, PURE for the pager's; a new call fails until it is listed); the counted list, not a type, enforces that the digested paths call the replicated group (by type the digested code would need a handle of its own: every one of the 13 files that read `grid` and more, past the 200 lines the brief allows); core/root.zig's reasons that said a client's emulator is written by deltas, and that a terminal is in no digest, say what is true now; core-test 912/1069 (157 skipped: +1, the `calls` test), shell-test 1111/1114, term-test 15/15, pane-test 181/182, kitty-test 45/45, the soak's small run and `--echo` rc 0 (diverged 0, unequal 0)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/term/terminal.zig')
| -rw-r--r-- | core/term/terminal.zig | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/core/term/terminal.zig b/core/term/terminal.zig index f130d7b9..44038a18 100644 --- a/core/term/terminal.zig +++ b/core/term/terminal.zig @@ -211,10 +211,22 @@ pub fn digest(s: *const State, h: *std.hash.Wyhash, view: bool) void { const sb = screen.pages.scrollbar(); const cur = screen.cursor; const offset = if (view) sb.offset else 0; - // Whether it holds a kitty image: the tag says so (tagline.zig). - const facts = .{ sb.total, offset, sb.len, cur.x, cur.y, s.vt.modes.get(.cursor_visible), s.vt.screens.active_key, s.reply_dropped, hasImages(s) }; + // Everything a step reads of it (abi/term.zig `replicated`): its + // size, the view and the cursor, its modes (the alternate screen, + // the mouse's, focus reports, bracketed paste: `modes`), whether it + // holds a kitty image (the tag says so: tagline.zig), the reply + // buffer, the OSC 133 cycle (`prompt`), the active area's text. Not + // the history's text, only its length (a step's read of it: not + // covered; core/Term.zig `calls`). + const Modes = @TypeOf(s.vt.modes.values); + const mode_bits: @Int(.unsigned, @bitSizeOf(Modes)) = @bitCast(s.vt.modes.values); + const modes_word: @Int(.unsigned, (@bitSizeOf(Modes) + 7) / 8 * 8) = mode_bits; + const mouse_flags: [2]u8 = .{ @intCast(@intFromEnum(s.vt.flags.mouse_event)), @intCast(@intFromEnum(s.vt.flags.mouse_format)) }; + const facts = .{ s.vt.cols, s.vt.rows, sb.total, offset, sb.len, cur.x, cur.y, modes_word, s.vt.screens.active_key, mouse_flags, s.reply_dropped, hasImages(s) }; inline for (facts) |fact| h.update(std.mem.asBytes(&fact)); h.update(s.reply[0..s.reply_len]); + var marks: [marks_len]u8 = undefined; + h.update(marksOf(s, &marks)); var buf: [4096]u8 = undefined; var text: std.Io.Writer.Hashing(std.hash.Wyhash) = .initHasher(h.*, &buf); if (screen.pages.getBottomRight(.active)) |br| @@ -457,8 +469,7 @@ pub fn grid(state: ?*const State) Term.Grid { } /// What pardes made of a terminal's stream that its emulator does not hold -/// (the OSC 133 cycle, MarkedHandler), as bytes two terminals' compare by -/// (`expectSame`): phase u8, started, prompts, declined u32, continuation +/// (the OSC 133 cycle, MarkedHandler), as bytes its digest holds: phase u8, started, prompts, declined u32, continuation /// and lost u8, a finished command's seq u32 and status i32 (all ones: /// none; i32 min: no status). const marks_len = 1 + 4 * 3 + 2 + 4 + 4; |
