refactor: move mini mode name and remove unused mode description field
This commit is contained in:
parent
0ef553e4c6
commit
f67bfab5b7
18 changed files with 21 additions and 29 deletions
|
@ -10,13 +10,9 @@ const fmt = @import("std").fmt;
|
||||||
|
|
||||||
const Mode = @import("root.zig").Mode;
|
const Mode = @import("root.zig").Mode;
|
||||||
|
|
||||||
const name = "#goto";
|
|
||||||
|
|
||||||
pub fn create(_: Allocator) error{OutOfMemory}!Mode {
|
pub fn create(_: Allocator) error{OutOfMemory}!Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.static(@This()),
|
.handler = EventHandler.static(@This()),
|
||||||
.name = name,
|
|
||||||
.description = name,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@ pub const mode = struct {
|
||||||
|
|
||||||
pub const Mode = struct {
|
pub const Mode = struct {
|
||||||
handler: EventHandler,
|
handler: EventHandler,
|
||||||
name: []const u8,
|
name: []const u8 = "",
|
||||||
description: []const u8,
|
|
||||||
line_numbers: enum { absolute, relative } = .absolute,
|
line_numbers: enum { absolute, relative } = .absolute,
|
||||||
keybind_hints: ?*const KeybindHints = null,
|
keybind_hints: ?*const KeybindHints = null,
|
||||||
cursor_shape: renderer.CursorShape = .block,
|
cursor_shape: renderer.CursorShape = .block,
|
||||||
|
|
|
@ -31,7 +31,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = root.application_name,
|
.name = root.application_name,
|
||||||
.description = "default",
|
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = "INS",
|
.name = "INS",
|
||||||
.description = "helix",
|
|
||||||
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.cursor_shape = .beam,
|
.cursor_shape = .beam,
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = "NOR",
|
.name = "NOR",
|
||||||
.description = "helix",
|
|
||||||
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
.cursor_shape = .block,
|
.cursor_shape = .block,
|
||||||
|
|
|
@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = "SEL",
|
.name = "SEL",
|
||||||
.description = "helix",
|
|
||||||
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
.cursor_shape = .block,
|
.cursor_shape = .block,
|
||||||
|
|
|
@ -24,7 +24,6 @@ pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = root.application_name,
|
.name = root.application_name,
|
||||||
.description = "home",
|
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = "INSERT",
|
.name = "INSERT",
|
||||||
.description = "vim",
|
|
||||||
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.cursor_shape = .beam,
|
.cursor_shape = .beam,
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = "NORMAL",
|
.name = "NORMAL",
|
||||||
.description = "vim",
|
|
||||||
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
.cursor_shape = .block,
|
.cursor_shape = .block,
|
||||||
|
|
|
@ -33,7 +33,6 @@ pub fn create(allocator: Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = "VISUAL",
|
.name = "VISUAL",
|
||||||
.description = "vim",
|
|
||||||
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
.cursor_shape = .underline,
|
.cursor_shape = .underline,
|
||||||
|
|
|
@ -50,10 +50,10 @@ pub fn Create(options: type) type {
|
||||||
return .{
|
return .{
|
||||||
.{
|
.{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = options.name(self),
|
|
||||||
.description = options.name(self),
|
|
||||||
},
|
},
|
||||||
.{},
|
.{
|
||||||
|
.name = options.name(self),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,10 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
|
||||||
return .{
|
return .{
|
||||||
.{
|
.{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = name,
|
|
||||||
.description = name,
|
|
||||||
},
|
},
|
||||||
.{},
|
.{
|
||||||
|
.name = name,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
return error.NotFound;
|
return error.NotFound;
|
||||||
|
|
|
@ -39,10 +39,10 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
|
||||||
return .{
|
return .{
|
||||||
.{
|
.{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = name,
|
|
||||||
.description = name,
|
|
||||||
},
|
},
|
||||||
.{},
|
.{
|
||||||
|
.name = name,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return error.NotFound;
|
return error.NotFound;
|
||||||
|
|
|
@ -36,6 +36,7 @@ pub fn create(allocator: Allocator, _: command.Context) !struct { tui.Mode, tui.
|
||||||
try keybind.mode.mini.goto.create(allocator),
|
try keybind.mode.mini.goto.create(allocator),
|
||||||
.{
|
.{
|
||||||
.event_handler = EventHandler.to_owned(self),
|
.event_handler = EventHandler.to_owned(self),
|
||||||
|
.name = name,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,10 +42,10 @@ pub fn create(allocator: Allocator, ctx: command.Context) !struct { tui.Mode, tu
|
||||||
return .{
|
return .{
|
||||||
.{
|
.{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = self.name(),
|
|
||||||
.description = self.name(),
|
|
||||||
},
|
},
|
||||||
.{},
|
.{
|
||||||
|
.name = self.name(),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ pub fn create(allocator: std.mem.Allocator) !tui.Mode {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = " open recent",
|
.name = " open recent",
|
||||||
.description = "open recent",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,6 @@ pub fn Create(options: type) type {
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = options.name,
|
.name = options.name,
|
||||||
.description = options.description,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -758,6 +758,7 @@ const cmds = struct {
|
||||||
|
|
||||||
pub const MiniMode = struct {
|
pub const MiniMode = struct {
|
||||||
event_handler: ?EventHandler = null,
|
event_handler: ?EventHandler = null,
|
||||||
|
name: []const u8,
|
||||||
text: []const u8 = "",
|
text: []const u8 = "",
|
||||||
cursor: ?usize = null,
|
cursor: ?usize = null,
|
||||||
};
|
};
|
||||||
|
@ -776,7 +777,12 @@ fn context_check() void {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mode() []const u8 {
|
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 {
|
pub fn reset_drag_context() void {
|
||||||
|
|
Loading…
Add table
Reference in a new issue