generated from GarandPLG/rust-flake-template
Add Settings view, widget, and keybindings
Introduce Settings view handling in key events and widgets. Add `Enter` action with its keybinding. Refactor keybinding lookup to use `Option<&KeyBinding>` for missing entries. Update view option generation to safely filter possible values. Export `settings_keybindings` and `settings_widget` from their modules.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
use crate::app::{
|
||||
App, View,
|
||||
keybindings::{Action, event_to_action},
|
||||
};
|
||||
use ratatui::crossterm::event::KeyEvent;
|
||||
|
||||
pub fn settings_keybindings(app: &mut App, key_event: &KeyEvent) {
|
||||
if let Some(action) = event_to_action(&key_event) {
|
||||
match action {
|
||||
Action::Quit => app.exit = true,
|
||||
Action::Quit2 => app.exit = true,
|
||||
Action::Esc => app.view = View::MainMenu,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user