trying to make the intro and admin with general keybindings

This commit is contained in:
filipriec
2025-03-23 19:17:42 +01:00
parent 87b07db26a
commit fbcea1b270
3 changed files with 29 additions and 7 deletions

View File

@@ -56,6 +56,11 @@ impl Config {
.or_else(|| self.get_action_for_key_in_mode(&self.keybindings.global, key, modifiers))
}
/// Common actions for Edit/Read-only modes
pub fn get_common_action(&self, key: KeyCode, modifiers: KeyModifiers) -> Option<&str> {
self.get_action_for_key_in_mode(&self.keybindings.common, 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> {
self.get_action_for_key_in_mode(&self.keybindings.read_only, key, modifiers)
@@ -89,8 +94,12 @@ impl Config {
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),
_ => self.get_read_only_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))
// Add global bindings check for read-only mode
.or_else(|| self.get_action_for_key_in_mode(&self.keybindings.global, key, modifiers)),
}
}