mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
config: clean up cursor style configuration
This commit is contained in:

committed by
Mitchell Hashimoto

parent
26f589e3e0
commit
6faed268e0
@ -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");
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user