From fcf1537f82473abffbbd30733fe28eb8b4c85348 Mon Sep 17 00:00:00 2001 From: SoraTenshi Date: Mon, 28 Aug 2023 18:20:45 +0200 Subject: [PATCH 1/2] config: Add option for custom cursor style --- src/config.zig | 3 +++ src/renderer/Metal.zig | 6 +++++- src/renderer/OpenGL.zig | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/config.zig b/src/config.zig index 6f4544124..0f8eb97de 100644 --- a/src/config.zig +++ b/src/config.zig @@ -97,6 +97,9 @@ 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. + @"cursor-style": terminal.CursorStyle = .default, + /// The color of the text under the cursor. If this is not set, a default /// will be chosen. @"cursor-text": ?Color = null, diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 245ead92e..0b7d79c10 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -108,6 +108,7 @@ pub const DerivedConfig = struct { font_thicken: bool, font_features: std.ArrayList([]const u8), cursor_color: ?terminal.color.RGB, + cursor_style: terminal.CursorStyle, cursor_text: ?terminal.color.RGB, background: terminal.color.RGB, background_opacity: f64, @@ -136,6 +137,7 @@ pub const DerivedConfig = struct { else null, + .cursor_style = config.@"cursor-style", .cursor_text = if (config.@"cursor-text") |txt| txt.toTerminalRGB() else @@ -491,7 +493,9 @@ pub fn render( // If we aren't focused, we use a hollow box if (!self.focused) break :cursor_style .box_hollow; - break :cursor_style renderer.CursorStyle.fromTerminal(state.cursor.style) orelse .box; + const selected_cursor_style = if (state.cursor.style == .default) self.config.cursor_style else state.cursor.style; + + break :cursor_style renderer.CursorStyle.fromTerminal(selected_cursor_style) orelse .box; }; } diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index cbd529760..d7b5d6b5c 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -237,6 +237,7 @@ pub const DerivedConfig = struct { font_thicken: bool, font_features: std.ArrayList([]const u8), cursor_color: ?terminal.color.RGB, + cursor_style: terminal.CursorStyle, cursor_text: ?terminal.color.RGB, background: terminal.color.RGB, background_opacity: f64, @@ -265,6 +266,7 @@ pub const DerivedConfig = struct { else null, + .cursor_style = config.@"cursor-style", .cursor_text = if (config.@"cursor-text") |txt| txt.toTerminalRGB() else @@ -733,7 +735,9 @@ pub fn render( // If we aren't focused, we use a hollow box if (!self.focused) break :cursor_style .box_hollow; - break :cursor_style renderer.CursorStyle.fromTerminal(state.cursor.style) orelse .box; + const selected_cursor_style = if (state.cursor.style == .default) self.config.cursor_style else state.cursor.style; + + break :cursor_style renderer.CursorStyle.fromTerminal(selected_cursor_style) orelse .box; }; } From ead70eadae293464f5d7f5270d266d07d4aa9a98 Mon Sep 17 00:00:00 2001 From: SoraTenshi Date: Mon, 28 Aug 2023 19:44:01 +0200 Subject: [PATCH 2/2] Add Caveat information for shell integration --- src/config.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/config.zig b/src/config.zig index 0f8eb97de..891595aaf 100644 --- a/src/config.zig +++ b/src/config.zig @@ -98,6 +98,11 @@ pub const Config = struct { @"cursor-color": ?Color = null, /// The style of the cursor. + /// + /// 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, /// The color of the text under the cursor. If this is not set, a default