From 18a8d2b01d730f68c8098467dadd44e6ba97bc15 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 18 Aug 2024 15:01:03 -0700 Subject: [PATCH] Minor changes, mainly commenting to clarify some behaviors --- src/terminal/Screen.zig | 13 ++++++++++++- src/termio/stream_handler.zig | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 8b8941516..9d9db4b74 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -139,7 +139,18 @@ pub const Cursor = struct { /// The visual style of the cursor. Whether or not it blinks /// is determined by mode 12 (modes.zig). This mode is synchronized /// with CSI q, the same as xterm. -pub const CursorStyle = enum { bar, block, underline, block_hollow }; +pub const CursorStyle = enum { + bar, // DECSCUSR 5, 6 + block, // DECSCUSR 1, 2 + underline, // DECSCUSR 3, 4 + + /// The cursor styles below aren't known by DESCUSR and are custom + /// implemented in Ghostty. They are reported as some standard style + /// if requested, though. + /// Hollow block cursor. This is a block cursor with the center empty. + /// Reported as DECSCUSR 1 or 2 (block). + block_hollow, +}; /// Saved cursor state. pub const SavedCursor = struct { diff --git a/src/termio/stream_handler.zig b/src/termio/stream_handler.zig index 16e6d5880..7daf2b7a2 100644 --- a/src/termio/stream_handler.zig +++ b/src/termio/stream_handler.zig @@ -208,9 +208,12 @@ pub const StreamHandler = struct { const blink = self.terminal.modes.get(.cursor_blinking); const style: u8 = switch (self.terminal.screen.cursor.cursor_style) { .block => if (blink) 1 else 2, - .block_hollow => if (blink) 1 else 2, .underline => if (blink) 3 else 4, .bar => if (blink) 5 else 6, + + // Below here, the cursor styles aren't represented by + // DECSCUSR so we map it to some other style. + .block_hollow => if (blink) 1 else 2, }; try writer.print("{d} q", .{style}); },