feat: enter

This commit is contained in:
2025-05-26 17:47:52 +02:00
parent 726908bfbe
commit 426ce71be4
2 changed files with 9 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
pub fn handle_key(key: vaxis.Key, appState: *AppState, arena: std.mem.Allocator) !ActionResult {
if (key.matches(vaxis.Key.left, .{})) {
return try handle_action(Action.GoUp, appState, arena);
} else if (key.matches(vaxis.Key.right, .{})) {
return try handle_action(Action.Enter, appState, arena);
} else if (key.matches(vaxis.Key.up, .{})) {
return try handle_action(Action.SelectPrevious, appState, arena);
} else if (key.matches(vaxis.Key.down, .{})) {

View File

@@ -10,7 +10,13 @@ pub fn handle(action: Action, appState: *AppState, arena: std.mem.Allocator) !Ac
} else return error.NoParent;
} else return error.NoCurrentLocation;
},
.Enter => {},
.Enter => {
if (appState.currentTab.currentItem) |currentItem| {
const path = try arena.dupe(u8, currentItem.path);
try appState.currentTab.setCurrentLocation(.{ .path = path });
return ActionResult.Handled;
} else return error.NoCurrentLocation;
},
.SelectNext => {
return selectNextIndex(appState.currentTab, .Next);
},