pub struct Keymap { /* private fields */ }Implementations§
Source§impl Keymap
impl Keymap
Sourcepub fn conflicts(&self) -> Vec<KeymapConflict>
pub fn conflicts(&self) -> Vec<KeymapConflict>
Returns keymap conflicts, defined as multiple bindings sharing the same
(platform, when, sequence) tuple (ADR 0021 section 7).
This is intended for diagnostics and future UI reporting.
Source§impl Keymap
impl Keymap
Sourcepub fn shortcut_for_command(
&self,
ctx: &InputContext,
command: &CommandId,
) -> Option<KeyChord>
pub fn shortcut_for_command( &self, ctx: &InputContext, command: &CommandId, ) -> Option<KeyChord>
Best-effort reverse lookup for UI display (command palette / menus).
This applies the same platform + when matching rules as resolve, then finds any chord
whose effective command equals command under the provided context.
pub fn shortcut_for_command_sequence( &self, ctx: &InputContext, command: &CommandId, ) -> Option<Vec<KeyChord>>
pub fn shortcut_for_command_sequence_with_key_contexts( &self, ctx: &InputContext, key_contexts: &[Arc<str>], command: &CommandId, ) -> Option<Vec<KeyChord>>
Sourcepub fn display_shortcut_for_command(
&self,
base: &InputContext,
command: &CommandId,
) -> Option<KeyChord>
pub fn display_shortcut_for_command( &self, base: &InputContext, command: &CommandId, ) -> Option<KeyChord>
Best-effort reverse lookup for UI display that is intentionally stable across focus changes.
This is intended for menu bar / command palette shortcut labels, where displaying different
shortcuts as focus moves is confusing. Instead of using the live focus state, we evaluate
bindings against a small set of “default” contexts derived from base:
- non-modal + not text input
- non-modal + text input
- modal + not text input
- modal + text input
Candidate sequences are ranked by:
- first matching default context (earlier is preferred),
- shorter sequences (single-chord preferred),
- later-defined bindings (user/project overrides preferred).
pub fn display_shortcut_for_command_sequence( &self, base: &InputContext, command: &CommandId, ) -> Option<Vec<KeyChord>>
pub fn display_shortcut_for_command_sequence_with_key_contexts( &self, base: &InputContext, key_contexts: &[Arc<str>], command: &CommandId, ) -> Option<Vec<KeyChord>>
Source§impl Keymap
impl Keymap
pub fn from_bytes(bytes: &[u8]) -> Result<Self, KeymapError>
pub fn from_bytes_with_options( bytes: &[u8], options: KeymapLoadOptions, ) -> Result<Self, KeymapError>
pub fn from_v1(file: KeymapFileV1) -> Result<Self, KeymapError>
pub fn from_v1_with_options( file: KeymapFileV1, options: KeymapLoadOptions, ) -> Result<Self, KeymapError>
Source§impl Keymap
impl Keymap
pub fn empty() -> Self
pub fn push_binding(&mut self, binding: Binding)
Sourcepub fn resolve(&self, ctx: &InputContext, chord: KeyChord) -> Option<CommandId>
pub fn resolve(&self, ctx: &InputContext, chord: KeyChord) -> Option<CommandId>
Last-wins resolution. If a later binding matches and its command is None, the key is
explicitly unbound and resolution stops.
Sourcepub fn resolve_with_key_contexts(
&self,
ctx: &InputContext,
key_contexts: &[Arc<str>],
chord: KeyChord,
) -> Option<CommandId>
pub fn resolve_with_key_contexts( &self, ctx: &InputContext, key_contexts: &[Arc<str>], chord: KeyChord, ) -> Option<CommandId>
Like Self::resolve, but evaluates when expressions with a key-context stack.
Sourcepub fn match_sequence(
&self,
ctx: &InputContext,
sequence: &[KeyChord],
) -> SequenceMatch
pub fn match_sequence( &self, ctx: &InputContext, sequence: &[KeyChord], ) -> SequenceMatch
Sequence matching helper used by pending multi-stroke bindings (ADR 0043).
Sourcepub fn match_sequence_with_key_contexts(
&self,
ctx: &InputContext,
key_contexts: &[Arc<str>],
sequence: &[KeyChord],
) -> SequenceMatch
pub fn match_sequence_with_key_contexts( &self, ctx: &InputContext, key_contexts: &[Arc<str>], sequence: &[KeyChord], ) -> SequenceMatch
Like Self::match_sequence, but evaluates when expressions with a key-context stack.
Sourcepub fn continuations(
&self,
ctx: &InputContext,
prefix: &[KeyChord],
) -> Vec<KeymapContinuation>
pub fn continuations( &self, ctx: &InputContext, prefix: &[KeyChord], ) -> Vec<KeymapContinuation>
Lists the valid “next” keystrokes that can follow the provided prefix under the given input context.
This is intended for UI hint overlays (e.g. a leader-key popup): it enumerates candidate
next chords from the configured bindings, then uses match_sequence to filter down to
chords that either execute a command or have further continuations.
Sourcepub fn continuations_with_key_contexts(
&self,
ctx: &InputContext,
key_contexts: &[Arc<str>],
prefix: &[KeyChord],
) -> Vec<KeymapContinuation>
pub fn continuations_with_key_contexts( &self, ctx: &InputContext, key_contexts: &[Arc<str>], prefix: &[KeyChord], ) -> Vec<KeymapContinuation>
Like Self::continuations, but evaluates when expressions with a key-context stack.