diff options
Diffstat (limited to 'src/terminal.zig')
| -rw-r--r-- | src/terminal.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/terminal.zig b/src/terminal.zig index ce41bd95..0afbe43a 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -159,6 +159,30 @@ pub const State = struct { mouse_cell: if (enabled) ?ghostty_vt.Coordinate else void = if (enabled) null else {}, /// The kitty graphics its program placed, as drawn (TerminalImages.zig). images: TerminalImages = if (images_enabled) .{} else {}, + + /// The emulator as its program has made it, for the replay digest + /// (src/walk.zig): the active screen's text, how much history is above + /// it and where the view is, the cursor, the answers not yet written. + /// Not its pages (their addresses are its own), nor the history's text + /// (the screen's was all of it once, and a session's digest is taken + /// every step), nor the kitty images, whose media is read off the host: + /// a replica's terminal is the authority's screen state from phase 5 + /// on (docs/next-daemon.md). + pub fn digest(s: *const State, h: *pardes.walk.Hasher) void { + if (comptime !enabled) return; + const screen = s.vt.screens.active; + const sb = screen.pages.scrollbar(); + const cur = screen.cursor; + const facts = .{ sb.total, sb.offset, sb.len, cur.x, cur.y, s.vt.modes.get(.cursor_visible), s.vt.screens.active_key, s.reply_dropped }; + inline for (facts) |fact| h.update(std.mem.asBytes(&fact)); + h.update(s.reply[0..s.reply_len]); + var buf: [4096]u8 = undefined; + var text: std.Io.Writer.Hashing(pardes.walk.Hasher) = .initHasher(h.*, &buf); + if (screen.pages.getBottomRight(.active)) |br| + screen.dumpString(&text.writer, .{ .tl = screen.pages.getTopLeft(.active), .br = br, .unwrap = false }) catch {}; + text.writer.flush() catch {}; + h.* = text.hasher; + } }; const GColor = ghostty_vt.color; |
