From 9917195fc4861d8ea682e9acd9782f2fd1745ca9 Mon Sep 17 00:00:00 2001 From: filipriec Date: Sun, 23 Mar 2025 20:07:47 +0100 Subject: [PATCH] disabling modes where they shouldnt be enabled BIG UPDATE --- client/src/config/binds/config.rs | 8 +++----- client/src/modes/handlers/event.rs | 10 ++++++---- client/src/state/state.rs | 2 -- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/client/src/config/binds/config.rs b/client/src/config/binds/config.rs index a6eb669..7231622 100644 --- a/client/src/config/binds/config.rs +++ b/client/src/config/binds/config.rs @@ -87,14 +87,12 @@ impl Config { &self, is_edit_mode: bool, command_mode: bool, - show_general_mode: bool, key: KeyCode, modifiers: KeyModifiers ) -> Option<&str> { - match (show_general_mode, command_mode, is_edit_mode) { - (true, _, _) => self.get_general_action(key, modifiers), - (_, true, _) => self.get_command_action_for_key(key, modifiers), - (_, _, true) => self.get_edit_action_for_key(key, modifiers) + match (command_mode, is_edit_mode) { + (true, _) => self.get_command_action_for_key(key, modifiers), + (_, true) => self.get_edit_action_for_key(key, modifiers) .or_else(|| self.get_common_action(key, modifiers)), _ => self.get_read_only_action_for_key(key, modifiers) .or_else(|| self.get_common_action(key, modifiers)) diff --git a/client/src/modes/handlers/event.rs b/client/src/modes/handlers/event.rs index fb26ed9..8a1bbef 100644 --- a/client/src/modes/handlers/event.rs +++ b/client/src/modes/handlers/event.rs @@ -55,7 +55,7 @@ impl EventHandler { let modifiers = key.modifiers; // Handle general mode (replaces intro and admin) - if app_state.ui.show_general_mode { + if app_state.ui.show_intro || app_state.ui.show_admin { if let Some(action) = config.get_general_action(key_code, modifiers) { match action { "move_up" => { @@ -75,8 +75,11 @@ impl EventHandler { return Ok((false, String::new())); } "select" => { - // Handle selection based on current view - app_state.ui.show_general_mode = false; + if app_state.ui.show_intro { + app_state.ui.show_intro = false; + } else if app_state.ui.show_admin { + app_state.ui.show_admin = false; + } return Ok((false, "Selected".to_string())); } "toggle_sidebar" => { @@ -179,7 +182,6 @@ impl EventHandler { let context_action = config.get_action_for_current_context( self.is_edit_mode, self.command_mode, - app_state.ui.show_general_mode, key_code, modifiers ); diff --git a/client/src/state/state.rs b/client/src/state/state.rs index 892017f..eb74fd7 100644 --- a/client/src/state/state.rs +++ b/client/src/state/state.rs @@ -8,7 +8,6 @@ pub struct UiState { pub is_saved: bool, pub show_intro: bool, pub show_admin: bool, - pub show_general_mode: bool, } pub struct GeneralState { @@ -65,7 +64,6 @@ impl Default for UiState { is_saved: false, show_intro: true, show_admin: false, - show_general_mode: false, } } }