diff --git a/src/config.zig b/src/config.zig index 7c111ca90..df3ed1d15 100644 --- a/src/config.zig +++ b/src/config.zig @@ -97,13 +97,19 @@ pub const Config = struct { /// The color of the cursor. If this is not set, a default will be chosen. @"cursor-color": ?Color = null, - /// The style of the cursor. + /// The style of the cursor. This sets the default style. A running + /// programn can still request an explicit cursor style using escape + /// sequences (such as CSI q). Shell configurations will often request + /// specific cursor styles. /// /// Caveat: Shell integration currently defaults to always be a bar /// In order to fix it, we probably would want to add something similar to Kitty's /// shell integration options (no-cursor). For more information see: /// https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.shell_integration - @"cursor-style": terminal.CursorStyle = .default, + @"cursor-style": CursorStyle = .bar, + + /// Whether the cursor shall blink + @"cursor-style-blink": bool = true, /// The color of the text under the cursor. If this is not set, a default /// will be chosen. @@ -1455,6 +1461,22 @@ pub const ShellIntegration = enum { zsh, }; +/// Available options for `cursor-style`. Blinking is configured with +/// the `cursor-style-blink` option. +pub const CursorStyle = enum { + bar, + block, + underline, + + pub fn toTerminalCursorStyle(self: CursorStyle, blinks: bool) terminal.CursorStyle { + return switch (self) { + .bar => if (blinks) .blinking_bar else .steady_bar, + .block => if (blinks) .blinking_block else .steady_block, + .underline => if (blinks) .blinking_underline else .steady_underline, + }; + } +}; + // Wasm API. pub const Wasm = if (!builtin.target.isWasm()) struct {} else struct { const wasm = @import("os/wasm.zig"); diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 9851f195e..84c4b192e 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -137,7 +137,7 @@ pub const DerivedConfig = struct { else null, - .cursor_style = config.@"cursor-style", + .cursor_style = config.@"cursor-style".toTerminalCursorStyle(config.@"cursor-style-blink"), .cursor_text = if (config.@"cursor-text") |txt| txt.toTerminalRGB() else diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index cfdbf4118..b6e251711 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -266,7 +266,7 @@ pub const DerivedConfig = struct { else null, - .cursor_style = config.@"cursor-style", + .cursor_style = config.@"cursor-style".toTerminalCursorStyle(config.@"cursor-style-blink"), .cursor_text = if (config.@"cursor-text") |txt| txt.toTerminalRGB() else