admin panel keyindings

This commit is contained in:
filipriec
2025-03-23 11:28:39 +01:00
parent 49fe2aa793
commit 993febd204
4 changed files with 50 additions and 2 deletions

View File

@@ -28,6 +28,8 @@ pub struct ModeKeybindings {
#[serde(default)]
pub intro: HashMap<String, Vec<String>>,
#[serde(default)]
pub admin: HashMap<String, Vec<String>>,
#[serde(default)]
pub read_only: HashMap<String, Vec<String>>,
#[serde(default)]
pub edit: HashMap<String, Vec<String>>,
@@ -58,9 +60,11 @@ impl Config {
/// Gets an action for a key in Admin mode, checking common and global bindings
pub fn get_admin_action(&self, key: KeyCode, modifiers: KeyModifiers) -> Option<&str> {
self.get_action_for_key_in_mode(&self.keybindings.common, key, modifiers)
self.get_action_for_key_in_mode(&self.keybindings.admin, key, modifiers)
.or_else(|| self.get_action_for_key_in_mode(&self.keybindings.common, key, modifiers))
.or_else(|| self.get_action_for_key_in_mode(&self.keybindings.intro, key, modifiers))
.or_else(|| self.get_action_for_key_in_mode(&self.keybindings.global, key, modifiers))
}
}
/// Gets an action for a key in Read-Only mode, also checking common keybindings.
pub fn get_read_only_action_for_key(&self, key: KeyCode, modifiers: KeyModifiers) -> Option<&str> {