repos / zmx

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

commit
fced2b8
parent
536bad4
author
Eric Bower
date
2025-10-14 15:44:20 -0400 EDT
fix: need clrf
1 files changed,  +13, -3
M src/daemon.zig
+13, -3
 1@@ -916,10 +916,20 @@ fn renderTerminalSnapshot(session: *Session, allocator: std.mem.Allocator) ![]u8
 2     try output.appendSlice(allocator, "\x1b[?6l"); // Disable origin mode temporarily
 3     try output.appendSlice(allocator, "\x1b[2J\x1b[H"); // Clear and home
 4 
 5-    // Step 2: Print terminal content
 6-    const content = try session.vt.plainString(allocator);
 7+    // Step 2: Print terminal content with CRLF translation
 8+    // In raw mode (no ONLCR), we need explicit CR with each LF
 9+    const content = try session.vt.plainStringUnwrapped(allocator);
10     defer allocator.free(content);
11-    try output.appendSlice(allocator, content);
12+    var prev: u8 = 0;
13+    for (content) |b| {
14+        if (b == '\n' and prev != '\r') {
15+            try output.append(allocator, '\r');
16+            try output.append(allocator, '\n');
17+        } else {
18+            try output.append(allocator, b);
19+        }
20+        prev = b;
21+    }
22 
23     // Step 3: Restore scroll regions (if non-default)
24     const default_top: u16 = 0;