Refactor keybinding handling and update widgets

- Remove the old `keybindings.rs` and stop re‑exporting its symbols.
- Add view‑specific handling: `App::handle_key_event` now delegates to
  `main_menu_keybindings` when the view is `MainMenu`.
- Update imports in `app.rs`, `widget.rs`, and widget modules to use the
  new `app::keybindings` path.
- Enhance `keybindings_widget` to display ↑, ↓ and “Space” for special
  keys.
- Change main menu layout percentages from 90/10 to 87/13.
- Reorder the `clap` import in `cli.rs` for consistency.
This commit is contained in:
2026-03-10 16:29:27 +01:00
parent de42569a51
commit ec1aa4fbe8
10 changed files with 112 additions and 65 deletions
+10 -8
View File
@@ -1,4 +1,4 @@
use crate::app::{Action, event_to_action};
use crate::app::keybindings::{Action, event_to_action, main_menu_keybindings};
use clap::ValueEnum;
use ratatui::{
DefaultTerminal, Frame,
@@ -59,13 +59,15 @@ impl App {
}
fn handle_key_event(&mut self, key_event: KeyEvent) -> Result<()> {
// if key_event.kind == KeyEventKind::Press && key_event.code == KeyCode::Char('q') {
// self.exit = true;
// }
if let Some(action) = event_to_action(&key_event) {
match action {
Action::Quit => self.exit = true,
match self.window {
View::MainMenu => main_menu_keybindings(self, &key_event),
_ => {
if let Some(action) = event_to_action(&key_event) {
match action {
Action::Quit => self.exit = true,
_ => (),
}
}
}
}