feat(core): appstate
This commit is contained in:
4
src/core/action/action.zig
Normal file
4
src/core/action/action.zig
Normal file
@@ -0,0 +1,4 @@
|
||||
pub const Action = union(enum) {
|
||||
GoUp,
|
||||
Enter,
|
||||
};
|
||||
17
src/core/action/action_handler.zig
Normal file
17
src/core/action/action_handler.zig
Normal file
@@ -0,0 +1,17 @@
|
||||
pub fn handle(action: Action, appState: *AppState) !void {
|
||||
switch (action) {
|
||||
.GoUp => {
|
||||
if (appState.currentTab.currentLocation) |currentLocation| {
|
||||
const parent = currentLocation.item.parent;
|
||||
if (parent) |p| {
|
||||
try appState.currentTab.setCurrentLocation(.{ .path = p.path.path });
|
||||
} else return error.NoParent;
|
||||
} else return error.NoCurrentLocation;
|
||||
},
|
||||
.Enter => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
const Action = @import("action.zig").Action;
|
||||
const AppState = @import("../app_state.zig").AppState;
|
||||
const RootProvider = @import("../provider/root.zig").RootProvider;
|
||||
Reference in New Issue
Block a user