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
+16,
-0
jump to top
| ... | ... | @@ -117,6 +117,18 @@ fn writeColorOverrides(writer: *std.Io.Writer, term: *const ghostty_vt.Terminal) | |
| 117 | 117 | writeDynamicColor(writer, .cursor, colors.cursor); | |
| 118 | 118 | } | |
| 119 | 119 | ||
| 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 | + | ||
| 120 | 132 | pub fn serializeTerminalState(alloc: std.mem.Allocator, term: *ghostty_vt.Terminal) ?[]const u8 { | |
| 121 | 133 | var builder: std.Io.Writer.Allocating = .init(alloc); | |
| 122 | 134 | defer builder.deinit(); |
| ... | ... | @@ -236,6 +248,10 @@ pub fn serializeTerminalState(alloc: std.mem.Allocator, term: *ghostty_vt.Termin | |
| 236 | 248 | }; | |
| 237 | 249 | } | |
| 238 | 250 | ||
| 251 | + | writeCursorStyle(&builder.writer, term) catch |err| { | |
| 252 | + | std.log.warn("failed to restore cursor style err={s}", .{@errorName(err)}); | |
| 253 | + | }; | |
| 254 | + | ||
| 239 | 255 | const output = builder.writer.buffered(); | |
| 240 | 256 | if (output.len == 0) return null; | |
| 241 | 257 |