Add Quit2 action bound to Ctrl+C

This commit is contained in:
2026-03-12 16:30:54 +01:00
parent c3886ca0cf
commit ef271c0d87
3 changed files with 14 additions and 0 deletions
+1
View File
@@ -109,6 +109,7 @@ impl App {
if let Some(action) = event_to_action(&key_event) { if let Some(action) = event_to_action(&key_event) {
match action { match action {
Action::Quit => self.exit = true, Action::Quit => self.exit = true,
Action::Quit2 => self.exit = true,
Action::Esc => self.view = View::MainMenu, Action::Esc => self.view = View::MainMenu,
_ => (), _ => (),
} }
+12
View File
@@ -4,6 +4,7 @@ use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Action { pub enum Action {
Quit, Quit,
Quit2,
Up, Up,
Down, Down,
Space, Space,
@@ -50,6 +51,15 @@ pub static KEYBINDINGS: &[KeyBinding] = &[
symbol: "q", symbol: "q",
description: "Quit", description: "Quit",
}, },
KeyBinding {
action: Action::Quit2,
code: KeyCode::Char('c'),
kind: KeyEventKind::Press,
modifiers: KeyModifiers::CONTROL,
group: Group::Quit,
symbol: "Ctrl + c",
description: "Quit",
},
KeyBinding { KeyBinding {
action: Action::Up, action: Action::Up,
code: KeyCode::Up, code: KeyCode::Up,
@@ -106,9 +116,11 @@ pub fn binding_for_view(view: View) -> Vec<&'static KeyBinding> {
binding_for(Action::Down).unwrap(), binding_for(Action::Down).unwrap(),
binding_for(Action::Space).unwrap(), binding_for(Action::Space).unwrap(),
binding_for(Action::Quit).unwrap(), binding_for(Action::Quit).unwrap(),
binding_for(Action::Quit2).unwrap(),
], ],
_ => vec![ _ => vec![
binding_for(Action::Quit).unwrap(), binding_for(Action::Quit).unwrap(),
binding_for(Action::Quit2).unwrap(),
binding_for(Action::Esc).unwrap(), binding_for(Action::Esc).unwrap(),
], ],
} }
+1
View File
@@ -8,6 +8,7 @@ pub fn main_menu_keybindings(app: &mut App, event: &KeyEvent) {
if let Some(action) = event_to_action(&event) { if let Some(action) = event_to_action(&event) {
match action { match action {
Action::Quit => app.exit = true, Action::Quit => app.exit = true,
Action::Quit2 => app.exit = true,
Action::Up => { Action::Up => {
app.game_states.main_menu_state.selected_view = app app.game_states.main_menu_state.selected_view = app
.game_states .game_states