Minor changes, mainly commenting to clarify some behaviors

This commit is contained in:
Mitchell Hashimoto
2024-08-18 15:01:03 -07:00
parent 2e70ad20df
commit 18a8d2b01d
2 changed files with 16 additions and 2 deletions

View File

@ -139,7 +139,18 @@ pub const Cursor = struct {
/// The visual style of the cursor. Whether or not it blinks /// The visual style of the cursor. Whether or not it blinks
/// is determined by mode 12 (modes.zig). This mode is synchronized /// is determined by mode 12 (modes.zig). This mode is synchronized
/// with CSI q, the same as xterm. /// 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. /// Saved cursor state.
pub const SavedCursor = struct { pub const SavedCursor = struct {

View File

@ -208,9 +208,12 @@ pub const StreamHandler = struct {
const blink = self.terminal.modes.get(.cursor_blinking); const blink = self.terminal.modes.get(.cursor_blinking);
const style: u8 = switch (self.terminal.screen.cursor.cursor_style) { const style: u8 = switch (self.terminal.screen.cursor.cursor_style) {
.block => if (blink) 1 else 2, .block => if (blink) 1 else 2,
.block_hollow => if (blink) 1 else 2,
.underline => if (blink) 3 else 4, .underline => if (blink) 3 else 4,
.bar => if (blink) 5 else 6, .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}); try writer.print("{d} q", .{style});
}, },