- commit
- 17988b5
- parent
- 7b22ead
- author
- Eric Bower
- date
- 2025-10-15 15:03:28 -0400 EDT
docs: render
1 files changed,
+23,
-0
+23,
-0
1@@ -2,6 +2,29 @@ const std = @import("std");
2 const ghostty = @import("ghostty-vt");
3 const sgr = @import("sgr.zig");
4
5+/// Terminal snapshot rendering for session persistence.
6+///
7+/// This module renders the current viewport state (text, colors, cursor position)
8+/// as a sequence of ANSI escape codes that can be sent to a client to restore
9+/// the visual terminal state when reattaching to a session.
10+///
11+/// Current implementation: Viewport-only rendering
12+/// - Renders only the visible active viewport (not full scrollback)
13+/// - Includes text content, SGR attributes (colors, bold, italic, etc.), and cursor position
14+/// - Handles single/multi-codepoint graphemes and wide characters correctly
15+///
16+/// Future work (see bd-10, bd-11):
17+/// - Full scrollback history rendering (see bd-10)
18+/// - Alternate screen buffer detection and handling (see bd-11)
19+/// - Mode restoration (bracketed paste, origin mode, etc.)
20+/// - Hyperlink reconstitution (OSC 8 sequences)
21+/// - Handling buffered/unprocessed PTY data (see bd-11)
22+///
23+/// Why viewport-only?
24+/// - Avoids payload bloat on reattach (megabytes for large scrollback)
25+/// - Prevents scrollback duplication in client terminal on multiple reattaches
26+/// - Faster rendering and simpler implementation
27+/// - Server owns the "true" scrollback, can add browsing features later
28 /// Extract UTF-8 text content from a cell, including multi-codepoint graphemes
29 fn extractCellText(pin: ghostty.Pin, cell: *const ghostty.Cell, buf: *std.ArrayList(u8), allocator: std.mem.Allocator) !void {
30 // Skip empty cells and spacer cells