refactor: move mini mode name and remove unused mode description field

This commit is contained in:
CJ van den Berg 2024-10-26 16:33:59 +02:00
parent 0ef553e4c6
commit f67bfab5b7
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
18 changed files with 21 additions and 29 deletions

View file

@ -10,13 +10,9 @@ const fmt = @import("std").fmt;
const Mode = @import("root.zig").Mode;
const name = "goto";
pub fn create(_: Allocator) error{OutOfMemory}!Mode {
return .{
.handler = EventHandler.static(@This()),
.name = name,
.description = name,
};
}

View file

@ -6,8 +6,7 @@ pub const mode = struct {
pub const Mode = struct {
handler: EventHandler,
name: []const u8,
description: []const u8,
name: []const u8 = "",
line_numbers: enum { absolute, relative } = .absolute,
keybind_hints: ?*const KeybindHints = null,
cursor_shape: renderer.CursorShape = .block,

View file

@ -31,7 +31,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = root.application_name,
.description = "default",
.keybind_hints = &hints,
};
}

View file

@ -32,7 +32,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = "INS",
.description = "helix",
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
.cursor_shape = .beam,
};

View file

@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = "NOR",
.description = "helix",
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
.keybind_hints = &hints,
.cursor_shape = .block,

View file

@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = "SEL",
.description = "helix",
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
.keybind_hints = &hints,
.cursor_shape = .block,

View file

@ -24,7 +24,6 @@ pub fn create(allocator: std.mem.Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = root.application_name,
.description = "home",
.keybind_hints = &hints,
};
}

View file

@ -41,7 +41,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = "INSERT",
.description = "vim",
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
.cursor_shape = .beam,
};

View file

@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = "NORMAL",
.description = "vim",
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
.keybind_hints = &hints,
.cursor_shape = .block,

View file

@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = "VISUAL",
.description = "vim",
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
.keybind_hints = &hints,
.cursor_shape = .underline,

View file

@ -50,10 +50,10 @@ pub fn Create(options: type) type {
return .{
.{
.handler = EventHandler.to_owned(self),
.name = options.name(self),
.description = options.name(self),
},
.{},
.{
.name = options.name(self),
},
};
}

View file

@ -45,10 +45,10 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
return .{
.{
.handler = EventHandler.to_owned(self),
.name = name,
.description = name,
},
.{},
.{
.name = name,
},
};
};
return error.NotFound;

View file

@ -39,10 +39,10 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
return .{
.{
.handler = EventHandler.to_owned(self),
.name = name,
.description = name,
},
.{},
.{
.name = name,
},
};
}
return error.NotFound;

View file

@ -36,6 +36,7 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
try keybind.mode.mini.goto.create(allocator),
.{
.event_handler = EventHandler.to_owned(self),
.name = name,
},
};
};

View file

@ -42,10 +42,10 @@ pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tu
return .{
.{
.handler = EventHandler.to_owned(self),
.name = self.name(),
.description = self.name(),
},
.{},
.{
.name = self.name(),
},
};
}

View file

@ -64,7 +64,6 @@ pub fn create(allocator: std.mem.Allocator) !tui.Mode {
return .{
.handler = EventHandler.to_owned(self),
.name = "󰈞 open recent",
.description = "open recent",
};
}

View file

@ -86,7 +86,6 @@ pub fn Create(options: type) type {
return .{
.handler = EventHandler.to_owned(self),
.name = options.name,
.description = options.description,
};
}

View file

@ -758,6 +758,7 @@ const cmds = struct {
pub const MiniMode = struct {
event_handler: ?EventHandler = null,
name: []const u8,
text: []const u8 = "",
cursor: ?usize = null,
};
@ -776,7 +777,12 @@ fn context_check() void {
}
pub fn get_mode() []const u8 {
return if (current().input_mode) |m| m.name else "INI";
return if (current().mini_mode) |m|
m.name
else if (current().input_mode) |m|
m.name
else
"INI";
}
pub fn reset_drag_context() void {