repos / zmx

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

commit
85cda06
parent
230c637
author
Eric Bower
date
2025-10-14 12:31:08 -0400 EDT
feat: restore modes
1 files changed,  +64, -10
M src/daemon.zig
+64, -10
 1@@ -41,6 +41,60 @@ const VTHandler = struct {
 2         std.debug.print("Mode changed: {s} = {}\n", .{ @tagName(mode), enabled });
 3     }
 4 
 5+    // SGR attributes (colors, bold, italic, etc.)
 6+    pub fn setAttribute(self: *VTHandler, attr: ghostty.Attribute) !void {
 7+        try self.terminal.setAttribute(attr);
 8+    }
 9+
10+    // Cursor positioning
11+    pub fn setCursorPos(self: *VTHandler, row: usize, col: usize) !void {
12+        self.terminal.setCursorPos(row, col);
13+    }
14+
15+    pub fn setCursorRow(self: *VTHandler, row: usize) !void {
16+        self.terminal.setCursorPos(row, self.terminal.screen.cursor.x);
17+    }
18+
19+    pub fn setCursorCol(self: *VTHandler, col: usize) !void {
20+        self.terminal.setCursorPos(self.terminal.screen.cursor.y, col);
21+    }
22+
23+    // Screen/line erasing
24+    pub fn eraseDisplay(self: *VTHandler, mode: ghostty.EraseDisplay, protected: bool) !void {
25+        self.terminal.eraseDisplay(mode, protected);
26+    }
27+
28+    pub fn eraseLine(self: *VTHandler, mode: ghostty.EraseLine, protected: bool) !void {
29+        self.terminal.eraseLine(mode, protected);
30+    }
31+
32+    // Scroll regions
33+    pub fn setTopAndBottomMargin(self: *VTHandler, top: usize, bottom: usize) !void {
34+        self.terminal.setTopAndBottomMargin(top, bottom);
35+    }
36+
37+    // Cursor save/restore
38+    pub fn saveCursor(self: *VTHandler) !void {
39+        self.terminal.saveCursor();
40+    }
41+
42+    pub fn restoreCursor(self: *VTHandler) !void {
43+        try self.terminal.restoreCursor();
44+    }
45+
46+    // Tab stops
47+    pub fn tabSet(self: *VTHandler) !void {
48+        self.terminal.tabSet();
49+    }
50+
51+    pub fn tabClear(self: *VTHandler, cmd: ghostty.TabClear) !void {
52+        self.terminal.tabClear(cmd);
53+    }
54+
55+    pub fn tabReset(self: *VTHandler) !void {
56+        self.terminal.tabReset();
57+    }
58+
59     pub fn deviceAttributes(
60         self: *VTHandler,
61         req: ghostty.DeviceAttributeReq,
62@@ -747,16 +801,16 @@ fn renderTerminalSnapshot(session: *Session, allocator: std.mem.Allocator) ![]u8
63         const mode: ghostty.Mode = @field(ghostty.Mode, field.name);
64         const value = vt.modes.get(mode);
65         const tag: ghostty.modes.ModeTag = @bitCast(@as(ghostty.modes.ModeTag.Backing, field.value));
66-        // const mode_default = @field(vt.modes.default, field.name);
67-
68-        // if (value != mode_default) {
69-        std.debug.print("  {s}{d} {s} = {}\n", .{
70-            if (tag.ansi) "" else "?",
71-            tag.value,
72-            field.name,
73-            value,
74-        });
75-        // }
76+        const mode_default = @field(vt.modes.default, field.name);
77+
78+        if (value != mode_default) {
79+            std.debug.print("  {s}{d} {s} = {}\n", .{
80+                if (tag.ansi) "" else "?",
81+                tag.value,
82+                field.name,
83+                value,
84+            });
85+        }
86     }
87 
88     // Restore terminal modes by sending appropriate escape sequences