keymap_ui: Dim keybinds that are overridden by other keybinds (#34952)

This change dims rows in the keymap editor for which the corresponding
keybind is overridden by other keybinds coming from higher priority
sources.

Release Notes:

- N/A
This commit is contained in:
Finn Evers 2025-07-23 18:03:04 +02:00 committed by Joseph T. Lyons
parent b7fb970929
commit 12d6ddef16
4 changed files with 602 additions and 347 deletions

View file

@ -1120,7 +1120,10 @@
"alt-ctrl-f": "keymap_editor::ToggleKeystrokeSearch",
"alt-c": "keymap_editor::ToggleConflictFilter",
"enter": "keymap_editor::EditBinding",
"alt-enter": "keymap_editor::CreateBinding"
"alt-enter": "keymap_editor::CreateBinding",
"ctrl-c": "keymap_editor::CopyAction",
"ctrl-shift-c": "keymap_editor::CopyContext",
"ctrl-t": "keymap_editor::ShowMatchingKeybinds"
}
},
{

View file

@ -1220,7 +1220,10 @@
"cmd-alt-f": "keymap_editor::ToggleKeystrokeSearch",
"cmd-alt-c": "keymap_editor::ToggleConflictFilter",
"enter": "keymap_editor::EditBinding",
"alt-enter": "keymap_editor::CreateBinding"
"alt-enter": "keymap_editor::CreateBinding",
"cmd-c": "keymap_editor::CopyAction",
"cmd-shift-c": "keymap_editor::CopyContext",
"cmd-t": "keymap_editor::ShowMatchingKeybinds"
}
},
{

View file

@ -959,19 +959,21 @@ impl<'a> KeybindUpdateTarget<'a> {
}
}
#[derive(Clone, Copy, PartialEq, Eq)]
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord)]
pub enum KeybindSource {
User,
Default,
Base,
Vim,
Base,
#[default]
Default,
Unknown,
}
impl KeybindSource {
const BASE: KeyBindingMetaIndex = KeyBindingMetaIndex(0);
const DEFAULT: KeyBindingMetaIndex = KeyBindingMetaIndex(1);
const VIM: KeyBindingMetaIndex = KeyBindingMetaIndex(2);
const USER: KeyBindingMetaIndex = KeyBindingMetaIndex(3);
const BASE: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::Base as u32);
const DEFAULT: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::Default as u32);
const VIM: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::Vim as u32);
const USER: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::User as u32);
pub fn name(&self) -> &'static str {
match self {
@ -979,6 +981,7 @@ impl KeybindSource {
KeybindSource::Default => "Default",
KeybindSource::Base => "Base",
KeybindSource::Vim => "Vim",
KeybindSource::Unknown => "Unknown",
}
}
@ -988,21 +991,18 @@ impl KeybindSource {
KeybindSource::Default => Self::DEFAULT,
KeybindSource::Base => Self::BASE,
KeybindSource::Vim => Self::VIM,
KeybindSource::Unknown => KeyBindingMetaIndex(*self as u32),
}
}
pub fn from_meta(index: KeyBindingMetaIndex) -> Self {
Self::try_from_meta(index).unwrap()
}
pub fn try_from_meta(index: KeyBindingMetaIndex) -> Result<Self> {
Ok(match index {
match index {
Self::USER => KeybindSource::User,
Self::BASE => KeybindSource::Base,
Self::DEFAULT => KeybindSource::Default,
Self::VIM => KeybindSource::Vim,
_ => anyhow::bail!("Invalid keybind source {:?}", index),
})
_ => KeybindSource::Unknown,
}
}
}
@ -1014,7 +1014,7 @@ impl From<KeyBindingMetaIndex> for KeybindSource {
impl From<KeybindSource> for KeyBindingMetaIndex {
fn from(source: KeybindSource) -> Self {
return source.meta();
source.meta()
}
}

File diff suppressed because it is too large Load diff