refactor: move home keybindings to keybind module

This commit is contained in:
CJ van den Berg 2024-11-12 21:37:31 +01:00
parent 2a9e532340
commit 07a412c2b2
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 16 additions and 12 deletions

View file

@ -561,6 +561,14 @@ fn enter_overlay_mode(self: *Self, mode: type) command.Result {
self.refresh_hover();
}
fn static_mode(self: *Self, mode: anytype, name: []const u8) !Mode {
return .{
.input_handler = try mode.create(self.allocator),
.name = name,
.keybind_hints = &mode.hints,
};
}
const cmds = struct {
pub const Target = Self;
const Ctx = command.Context;
@ -662,7 +670,7 @@ const cmds = struct {
else if (std.mem.eql(u8, mode, "flow"))
try @import("mode/input/flow.zig").create(self.allocator)
else if (std.mem.eql(u8, mode, "home"))
try @import("mode/input/home.zig").create(self.allocator)
try self.static_mode(keybind.mode.input.home, "home")
else ret: {
self.logger.print("unknown mode {s}", .{mode});
break :ret try @import("mode/input/flow.zig").create(self.allocator);