diff --git a/src/config.zig b/src/config.zig index 81a01c7..4863397 100644 --- a/src/config.zig +++ b/src/config.zig @@ -13,6 +13,7 @@ whitespace_mode: []const u8 = "none", animation_min_lag: usize = 0, //milliseconds animation_max_lag: usize = 150, //milliseconds enable_format_on_save: bool = false, +default_cursor: []const u8 = "default", indent_size: usize = 4, tab_width: usize = 8, diff --git a/src/keybind/keybind.zig b/src/keybind/keybind.zig index c60f363..aa50215 100644 --- a/src/keybind/keybind.zig +++ b/src/keybind/keybind.zig @@ -78,7 +78,7 @@ pub const Mode = struct { name: []const u8 = "", line_numbers: LineNumbers = .absolute, keybind_hints: *const KeybindHints, - cursor_shape: CursorShape = .block, + cursor_shape: ?CursorShape = null, pub fn deinit(self: *Mode) void { self.allocator.free(self.mode); @@ -362,7 +362,7 @@ const BindingSet = struct { on_match_failure: OnMatchFailure = .ignore, name: []const u8, line_numbers: LineNumbers = .absolute, - cursor_shape: CursorShape = .block, + cursor_shape: ?CursorShape = null, insert_command: []const u8 = "", hints_map: KeybindHints = .{}, @@ -379,7 +379,7 @@ const BindingSet = struct { on_match_failure: OnMatchFailure = .insert, name: ?[]const u8 = null, line_numbers: LineNumbers = .absolute, - cursor: CursorShape = .block, + cursor: ?CursorShape = null, }; const parsed = try std.json.parseFromValue(JsonConfig, allocator, mode_bindings, .{ .ignore_unknown_fields = true, diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 63e8e28..5b23a05 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -52,6 +52,7 @@ final_exit: []const u8 = "normal", render_pending: bool = false, keepalive_timer: ?tp.Cancellable = null, mouse_idle_timer: ?tp.Cancellable = null, +default_cursor: keybind.CursorShape = .default, const keepalive = std.time.us_per_day * 365; // one year const idle_frames = 0; @@ -118,6 +119,8 @@ fn init(allocator: Allocator) !*Self { instance_ = self; defer instance_ = null; + self.default_cursor = std.meta.stringToEnum(keybind.CursorShape, conf.default_cursor) orelse .default; + self.config.default_cursor = @tagName(self.default_cursor); self.rdr.handler_ctx = self; self.rdr.dispatch_input = dispatch_input; self.rdr.dispatch_mouse = dispatch_mouse; @@ -1097,7 +1100,7 @@ fn set_terminal_style(self: *Self) void { } pub fn get_cursor_shape(self: *Self) renderer.CursorShape { - const shape = if (self.input_mode) |mode| mode.cursor_shape else .block; + const shape = if (self.input_mode) |mode| mode.cursor_shape orelse self.default_cursor else self.default_cursor; return switch (shape) { .default => .default, .block_blink => .block_blink,