From f4de65055768b2492ab03c9026b0911f6ae3041d Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 22 Mar 2024 21:00:19 +0100 Subject: [PATCH] feat: add open recent command to home screen --- src/tui/home.zig | 4 ++-- src/tui/mode/input/home.zig | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tui/home.zig b/src/tui/home.zig index 025251d..9628145 100644 --- a/src/tui/home.zig +++ b/src/tui/home.zig @@ -38,7 +38,7 @@ pub fn create(a: std.mem.Allocator, parent: Widget) !Widget { try self.commands.init(self); try self.menu.add_item_with_handler("Help ······················· :h", menu_action_help); try self.menu.add_item_with_handler("Open file ·················· :o", menu_action_open_file); - try self.menu.add_item_with_handler("Open recent file ····(wip)·· :e", menu_action_open_recent_file); + try self.menu.add_item_with_handler("Open recent file ··········· :e", menu_action_open_recent_file); try self.menu.add_item_with_handler("Open recent project ·(wip)·· :r", menu_action_open_recent_project); try self.menu.add_item_with_handler("Show/Run commands ···(wip)·· :p", menu_action_show_commands); try self.menu.add_item_with_handler("Open config file ··········· :c", menu_action_open_config); @@ -122,7 +122,7 @@ fn menu_action_open_file(_: *Menu.State(*Self), _: *Button.State(*Menu.State(*Se } fn menu_action_open_recent_file(_: *Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void { - tp.self_pid().send(.{ "log", "home", "open recent file not implemented" }) catch {}; + command.executeName("enter_overlay_mode", command.fmt(.{"open_recent"})) catch {}; } fn menu_action_open_recent_project(_: *Menu.State(*Self), _: *Button.State(*Menu.State(*Self))) void { diff --git a/src/tui/mode/input/home.zig b/src/tui/mode/input/home.zig index e3cf9f5..26baedc 100644 --- a/src/tui/mode/input/home.zig +++ b/src/tui/mode/input/home.zig @@ -55,6 +55,7 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result { 'Q' => self.cmd("quit", .{}), 'W' => self.cmd("quit", .{}), 'O' => self.cmd("enter_open_file_mode", .{}), + 'E' => self.cmd("enter_overlay_mode", command.fmt(.{"open_recent"})), '/' => self.cmd("open_help", .{}), else => {}, }, @@ -77,7 +78,7 @@ fn mapPress(self: *Self, keypress: u32, modifiers: u32) tp.result { 0 => switch (keypress) { 'h' => self.cmd("open_help", .{}), 'o' => self.cmd("enter_open_file_mode", .{}), - 'e' => self.msg("open recent file not implemented"), + 'e' => self.cmd("enter_overlay_mode", command.fmt(.{"open_recent"})), 'r' => self.msg("open recent project not implemented"), 'p' => self.msg("open command palette not implemented"), 'c' => self.cmd("open_config", .{}),