refactor: clean-up and simplify home screen keys

This commit is contained in:
CJ van den Berg 2024-03-01 23:00:29 +01:00
parent 9537c54962
commit 1d418db9b4
2 changed files with 19 additions and 6 deletions

View file

@ -89,12 +89,13 @@ pub fn render(self: *Self, theme: *const Widget.Theme) bool {
fn render_hints(self: *Self, style_base: Widget.Theme.Style, style_text: Widget.Theme.Style, style_keybind: Widget.Theme.Style) void {
const hint_text: [:0]const u8 =
\\Help ······················· :F1 / C-?
\\Open file ·················· :C-o
\\Open recent file ··(wip)···· :C-e / C-r
\\Show/Run commands ·(wip)···· :C-p / C-S-p
\\Open config file ··········· :F6
\\Quit/Close ················· :C-q, C-w
\\Help ······················· :h
\\Open file ·················· :o
\\Open recent file ··(wip)···· :e
\\Open recent project ··(wip)· :r
\\Show/Run commands ·(wip)···· :p
\\Open config file ··········· :c
\\Quit/Close ················· :q
\\
;

View file

@ -75,6 +75,14 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result {
else => {},
},
0 => switch (keypress) {
'h' => self.cmd("open_help", .{}),
'o' => self.cmd("enter_open_file_mode", .{}),
'e' => self.msg("open recent file not implemented"),
'r' => self.msg("open recent project not implemented"),
'p' => self.msg("open command palette not implemented"),
'c' => self.cmd("open_config", .{}),
'q' => self.cmd("quit", .{}),
nc.key.F01 => self.cmd("open_help", .{}),
nc.key.F06 => self.cmd("open_config", .{}),
nc.key.F09 => self.cmd("theme_prev", .{}),
@ -91,6 +99,10 @@ fn cmd(_: *Self, name_: []const u8, ctx: command.Context) tp.result {
try command.executeName(name_, ctx);
}
fn msg(_: *Self, text: []const u8) tp.result {
return tp.self_pid().send(.{ "log", "home", text });
}
fn cmd_async(_: *Self, name_: []const u8) tp.result {
return tp.self_pid().send(.{ "cmd", name_ });
}