repos / zmx

session persistence for terminal processes
git clone https://github.com/neurosnap/zmx.git

commit
83c8c35
parent
cca1a8a
author
Eric Bower
date
2025-10-16 13:42:07 -0400 EDT
shore: fix cursor error
1 files changed,  +6, -2
M src/terminal_snapshot.zig
+6, -2
 1@@ -216,12 +216,16 @@ pub fn render(vt: *ghostty.Terminal, allocator: std.mem.Allocator) ![]u8 {
 2     // TODO: Restore left/right margins if enabled (need to check modes for left_right_margins)
 3 
 4     // Compute cursor position (may be relative to scroll margins if origin mode is on)
 5+    // Note: The terminal stores cursor.y as absolute coordinates (0-based from top of screen)
 6+    // When origin mode is enabled, the CSI H (cursor position) escape code expects coordinates
 7+    // relative to the scroll region, so we need to subtract the top margin offset
 8     var final_cursor_row = cursor_row;
 9     const final_cursor_col = cursor_col;
10 
11-    // If origin mode is on, cursor is relative to the top margin
12+    // If origin mode is on, cursor coordinates must be relative to the top/left margins
13     if (origin and !is_full_tb) {
14-        final_cursor_row = cursor_row - scroll.top;
15+        final_cursor_row = (cursor_row -| (scroll.top + 1)) + 1;
16+        // TODO: Also handle left/right margins if left_right_margins mode is enabled
17     }
18 
19     try std.fmt.format(output.writer(allocator), "\x1b[{d};{d}H", .{ final_cursor_row, final_cursor_col });