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:
parent
b7fb970929
commit
12d6ddef16
4 changed files with 602 additions and 347 deletions
|
@ -1120,7 +1120,10 @@
|
||||||
"alt-ctrl-f": "keymap_editor::ToggleKeystrokeSearch",
|
"alt-ctrl-f": "keymap_editor::ToggleKeystrokeSearch",
|
||||||
"alt-c": "keymap_editor::ToggleConflictFilter",
|
"alt-c": "keymap_editor::ToggleConflictFilter",
|
||||||
"enter": "keymap_editor::EditBinding",
|
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1220,7 +1220,10 @@
|
||||||
"cmd-alt-f": "keymap_editor::ToggleKeystrokeSearch",
|
"cmd-alt-f": "keymap_editor::ToggleKeystrokeSearch",
|
||||||
"cmd-alt-c": "keymap_editor::ToggleConflictFilter",
|
"cmd-alt-c": "keymap_editor::ToggleConflictFilter",
|
||||||
"enter": "keymap_editor::EditBinding",
|
"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"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -959,19 +959,21 @@ impl<'a> KeybindUpdateTarget<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub enum KeybindSource {
|
pub enum KeybindSource {
|
||||||
User,
|
User,
|
||||||
Default,
|
|
||||||
Base,
|
|
||||||
Vim,
|
Vim,
|
||||||
|
Base,
|
||||||
|
#[default]
|
||||||
|
Default,
|
||||||
|
Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeybindSource {
|
impl KeybindSource {
|
||||||
const BASE: KeyBindingMetaIndex = KeyBindingMetaIndex(0);
|
const BASE: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::Base as u32);
|
||||||
const DEFAULT: KeyBindingMetaIndex = KeyBindingMetaIndex(1);
|
const DEFAULT: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::Default as u32);
|
||||||
const VIM: KeyBindingMetaIndex = KeyBindingMetaIndex(2);
|
const VIM: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::Vim as u32);
|
||||||
const USER: KeyBindingMetaIndex = KeyBindingMetaIndex(3);
|
const USER: KeyBindingMetaIndex = KeyBindingMetaIndex(KeybindSource::User as u32);
|
||||||
|
|
||||||
pub fn name(&self) -> &'static str {
|
pub fn name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
|
@ -979,6 +981,7 @@ impl KeybindSource {
|
||||||
KeybindSource::Default => "Default",
|
KeybindSource::Default => "Default",
|
||||||
KeybindSource::Base => "Base",
|
KeybindSource::Base => "Base",
|
||||||
KeybindSource::Vim => "Vim",
|
KeybindSource::Vim => "Vim",
|
||||||
|
KeybindSource::Unknown => "Unknown",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,21 +991,18 @@ impl KeybindSource {
|
||||||
KeybindSource::Default => Self::DEFAULT,
|
KeybindSource::Default => Self::DEFAULT,
|
||||||
KeybindSource::Base => Self::BASE,
|
KeybindSource::Base => Self::BASE,
|
||||||
KeybindSource::Vim => Self::VIM,
|
KeybindSource::Vim => Self::VIM,
|
||||||
|
KeybindSource::Unknown => KeyBindingMetaIndex(*self as u32),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_meta(index: KeyBindingMetaIndex) -> Self {
|
pub fn from_meta(index: KeyBindingMetaIndex) -> Self {
|
||||||
Self::try_from_meta(index).unwrap()
|
match index {
|
||||||
}
|
|
||||||
|
|
||||||
pub fn try_from_meta(index: KeyBindingMetaIndex) -> Result<Self> {
|
|
||||||
Ok(match index {
|
|
||||||
Self::USER => KeybindSource::User,
|
Self::USER => KeybindSource::User,
|
||||||
Self::BASE => KeybindSource::Base,
|
Self::BASE => KeybindSource::Base,
|
||||||
Self::DEFAULT => KeybindSource::Default,
|
Self::DEFAULT => KeybindSource::Default,
|
||||||
Self::VIM => KeybindSource::Vim,
|
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 {
|
impl From<KeybindSource> for KeyBindingMetaIndex {
|
||||||
fn from(source: KeybindSource) -> Self {
|
fn from(source: KeybindSource) -> Self {
|
||||||
return source.meta();
|
source.meta()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue