Extract keybinding handling to separate module

This commit is contained in:
2026-03-12 16:37:52 +01:00
parent ef271c0d87
commit 8b7c2c55ce
3 changed files with 28 additions and 19 deletions
+2 -19
View File
@@ -1,8 +1,5 @@
use crate::{
app::{
GameStates,
keybindings::{Action, event_to_action, main_menu_keybindings},
},
app::{GameStates, handle_keybindings},
cli::Cli,
};
use clap::ValueEnum;
@@ -103,21 +100,7 @@ impl App {
}
fn handle_key_event(&mut self, key_event: KeyEvent) -> Result<()> {
match self.view {
View::MainMenu => main_menu_keybindings(self, &key_event),
_ => {
if let Some(action) = event_to_action(&key_event) {
match action {
Action::Quit => self.exit = true,
Action::Quit2 => self.exit = true,
Action::Esc => self.view = View::MainMenu,
_ => (),
}
}
}
}
Ok(())
handle_keybindings(self, key_event)
}
}