Commit 770eb5f

Barrett Ruth  ·  2026-10-22 23:32:55 -0400 EDT
parent 213390b
fix: replay the cursor style on re-attach (#283)
1 files changed,  +16, -0
+16, -0
jump to top
......@@ -117,6 +117,18 @@ fn writeColorOverrides(writer: *std.Io.Writer, term: *const ghostty_vt.Terminal)
117117 writeDynamicColor(writer, .cursor, colors.cursor);
118118 }
119119
120+/// The VT formatter does not emit the cursor shape (DECSCUSR).
121+fn writeCursorStyle(writer: *std.Io.Writer, term: *ghostty_vt.Terminal) !void {
122+ if (term.cursor.is_default) return writer.writeAll("\x1b[0 q");
123+ const blink = term.modes.get(.cursor_blinking);
124+ const style: u8 = switch (term.screens.active.cursor.cursor_style) {
125+ .block, .block_hollow => if (blink) 1 else 2,
126+ .underline => if (blink) 3 else 4,
127+ .bar => if (blink) 5 else 6,
128+ };
129+ try writer.print("\x1b[{d} q", .{style});
130+}
131+
120132 pub fn serializeTerminalState(alloc: std.mem.Allocator, term: *ghostty_vt.Terminal) ?[]const u8 {
121133 var builder: std.Io.Writer.Allocating = .init(alloc);
122134 defer builder.deinit();
......@@ -236,6 +248,10 @@ pub fn serializeTerminalState(alloc: std.mem.Allocator, term: *ghostty_vt.Termin
236248 };
237249 }
238250
251+ writeCursorStyle(&builder.writer, term) catch |err| {
252+ std.log.warn("failed to restore cursor style err={s}", .{@errorName(err)});
253+ };
254+
239255 const output = builder.writer.buffered();
240256 if (output.len == 0) return null;
241257