- commit
- 5ef4207
- parent
- d4fdb99
- author
- Eric Bower
- date
- 2025-10-14 10:01:12 -0400 EDT
refactor: renderTerminalSnapshot
1 files changed,
+6,
-32
+6,
-32
1@@ -735,39 +735,13 @@ fn renderTerminalSnapshot(session: *Session, allocator: std.mem.Allocator) ![]u8
2
3 // Get the active screen from the terminal
4 const screen = &session.vt.screen;
5- const rows = screen.pages.rows;
6- const cols = screen.pages.cols;
7+ var it = screen.pages.pageIterator(.right_down, .{ .screen = .{} }, null);
8+ var page_index: usize = 0;
9
10- // Use cellIterator to walk through the visible viewport
11- const tl_pt: ghostty.point.Point = screen.pages.getTopLeft(tl);
12- const br_pt: ghostty.point.Point = screen.pages.getBottomRight(tl);
13-
14- var it = screen.pages.cellIterator(.right_down, tl_pt, br_pt);
15- var current_row: u16 = 0;
16-
17- while (it.next()) |pin| {
18- const cell_info = pin.rowAndCell();
19- const cell = cell_info.cell;
20-
21- // Check if we've moved to a new row
22- if (pin.y > current_row) {
23- try output.appendSlice(allocator, "\r\n");
24- current_row = pin.y;
25- }
26-
27- // Write the cell content
28- const cp = cell.content.codepoint;
29- if (cp == 0) {
30- try output.append(allocator, ' ');
31- } else {
32- var buf: [4]u8 = undefined;
33- const len = std.unicode.utf8Encode(cp, &buf) catch 0;
34- if (len == 0) {
35- try output.append(allocator, ' ');
36- } else {
37- try output.appendSlice(allocator, buf[0..len]);
38- }
39- }
40+ while (it.next()) |chunk| : (page_index += 1) {
41+ const page: *const ghostty.Page = &chunk.node.data;
42+ const start_y = chunk.start;
43+ const end_y = chunk.end;
44 }
45
46 // Add final newline if needed