feat: add configuration option default_cursor
This commit is contained in:
parent
deaafbefa0
commit
afca8a86bc
3 changed files with 8 additions and 4 deletions
|
@ -13,6 +13,7 @@ whitespace_mode: []const u8 = "none",
|
||||||
animation_min_lag: usize = 0, //milliseconds
|
animation_min_lag: usize = 0, //milliseconds
|
||||||
animation_max_lag: usize = 150, //milliseconds
|
animation_max_lag: usize = 150, //milliseconds
|
||||||
enable_format_on_save: bool = false,
|
enable_format_on_save: bool = false,
|
||||||
|
default_cursor: []const u8 = "default",
|
||||||
|
|
||||||
indent_size: usize = 4,
|
indent_size: usize = 4,
|
||||||
tab_width: usize = 8,
|
tab_width: usize = 8,
|
||||||
|
|
|
@ -78,7 +78,7 @@ pub const Mode = struct {
|
||||||
name: []const u8 = "",
|
name: []const u8 = "",
|
||||||
line_numbers: LineNumbers = .absolute,
|
line_numbers: LineNumbers = .absolute,
|
||||||
keybind_hints: *const KeybindHints,
|
keybind_hints: *const KeybindHints,
|
||||||
cursor_shape: CursorShape = .block,
|
cursor_shape: ?CursorShape = null,
|
||||||
|
|
||||||
pub fn deinit(self: *Mode) void {
|
pub fn deinit(self: *Mode) void {
|
||||||
self.allocator.free(self.mode);
|
self.allocator.free(self.mode);
|
||||||
|
@ -362,7 +362,7 @@ const BindingSet = struct {
|
||||||
on_match_failure: OnMatchFailure = .ignore,
|
on_match_failure: OnMatchFailure = .ignore,
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
line_numbers: LineNumbers = .absolute,
|
line_numbers: LineNumbers = .absolute,
|
||||||
cursor_shape: CursorShape = .block,
|
cursor_shape: ?CursorShape = null,
|
||||||
insert_command: []const u8 = "",
|
insert_command: []const u8 = "",
|
||||||
hints_map: KeybindHints = .{},
|
hints_map: KeybindHints = .{},
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ const BindingSet = struct {
|
||||||
on_match_failure: OnMatchFailure = .insert,
|
on_match_failure: OnMatchFailure = .insert,
|
||||||
name: ?[]const u8 = null,
|
name: ?[]const u8 = null,
|
||||||
line_numbers: LineNumbers = .absolute,
|
line_numbers: LineNumbers = .absolute,
|
||||||
cursor: CursorShape = .block,
|
cursor: ?CursorShape = null,
|
||||||
};
|
};
|
||||||
const parsed = try std.json.parseFromValue(JsonConfig, allocator, mode_bindings, .{
|
const parsed = try std.json.parseFromValue(JsonConfig, allocator, mode_bindings, .{
|
||||||
.ignore_unknown_fields = true,
|
.ignore_unknown_fields = true,
|
||||||
|
|
|
@ -52,6 +52,7 @@ final_exit: []const u8 = "normal",
|
||||||
render_pending: bool = false,
|
render_pending: bool = false,
|
||||||
keepalive_timer: ?tp.Cancellable = null,
|
keepalive_timer: ?tp.Cancellable = null,
|
||||||
mouse_idle_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 keepalive = std.time.us_per_day * 365; // one year
|
||||||
const idle_frames = 0;
|
const idle_frames = 0;
|
||||||
|
@ -118,6 +119,8 @@ fn init(allocator: Allocator) !*Self {
|
||||||
instance_ = self;
|
instance_ = self;
|
||||||
defer instance_ = null;
|
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.handler_ctx = self;
|
||||||
self.rdr.dispatch_input = dispatch_input;
|
self.rdr.dispatch_input = dispatch_input;
|
||||||
self.rdr.dispatch_mouse = dispatch_mouse;
|
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 {
|
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) {
|
return switch (shape) {
|
||||||
.default => .default,
|
.default => .default,
|
||||||
.block_blink => .block_blink,
|
.block_blink => .block_blink,
|
||||||
|
|
Loading…
Add table
Reference in a new issue