pub struct Keymap { /* private fields */ }Implementations§
Source§impl Keymap
impl Keymap
pub fn new() -> Self
pub fn default_vim() -> Self
pub fn bind( &mut self, mode: Mode, key: Key, action: Action, desc: impl Into<String>, )
Sourcepub fn collisions(&self) -> &[Collision]
pub fn collisions(&self) -> &[Collision]
Every collision recorded while this keymap was built.
Read by --list-rc and reported at boot. An empty slice is the
claim “every binding escriba ships can actually fire”.
Sourcepub fn fatal_collisions(&self) -> impl Iterator<Item = &Collision>
pub fn fatal_collisions(&self) -> impl Iterator<Item = &Collision>
Collisions that mean a key can NEVER fire, as opposed to one that was deliberately overridden.
pub fn lookup(&self, mode: Mode, key: &Key) -> Option<&Binding>
Sourcepub fn leader(&self) -> &Key
pub fn leader(&self) -> &Key
The leader key — what <leader> resolves to when a sequence
binding is applied. Defaults to , (blnvim parity).
Sourcepub fn set_leader(&mut self, key: Key)
pub fn set_leader(&mut self, key: Key)
Override the leader key. Applied before sequence bindings so
<leader>-prefixed specs resolve against the chosen prefix.
Sourcepub fn bind_sequence(
&mut self,
mode: Mode,
keys: Vec<Key>,
action: Action,
desc: impl Into<String>,
)
pub fn bind_sequence( &mut self, mode: Mode, keys: Vec<Key>, action: Action, desc: impl Into<String>, )
Bind a multi-key SEQUENCE — <leader>ff →
[Char(','), Char('f'), Char('f')], gg →
[Char('g'), Char('g')]. A length-1 sequence delegates to
bind so callers never special-case it; an
empty sequence is a no-op.
Sourcepub fn lookup_sequence(&self, mode: Mode, keys: &[Key]) -> Option<&Binding>
pub fn lookup_sequence(&self, mode: Mode, keys: &[Key]) -> Option<&Binding>
Exact-match lookup for a full key sequence.
Sourcepub fn is_sequence_prefix(&self, mode: Mode, prefix: &[Key]) -> bool
pub fn is_sequence_prefix(&self, mode: Mode, prefix: &[Key]) -> bool
Does any bound sequence in mode STRICTLY extend prefix
(i.e. prefix is a proper prefix of a longer bound sequence)?
Drives the runtime’s pending-stroke state: a partial sequence
that is still a live prefix is held pending rather than
dispatched. Linear scan — fine at fleet sequence counts; a
trie is a later optimization if profiling ever asks for it.
Sourcepub fn sequences_extending(
&self,
mode: Mode,
prefix: &[Key],
) -> Vec<(&[Key], &Binding)>
pub fn sequences_extending( &self, mode: Mode, prefix: &[Key], ) -> Vec<(&[Key], &Binding)>
Every bound sequence in mode that STRICTLY extends prefix.
is_sequence_prefix answers the same
question with a bool and throws away the matches it just found. Two
consumers need those matches:
- a which-key popup, which must show what continues
<leader>; - a reserved-chord audit, which cannot check bindings it cannot
enumerate — and
sequencesis private, so from outside this crate the multi-key half of the keymap was invisible.
Same linear scan as is_sequence_prefix, so this costs nothing extra;
a trie is the same later optimization for both.
Pass an empty prefix for every sequence in the mode.
Sourcepub fn sequence_len(&self) -> usize
pub fn sequence_len(&self) -> usize
Count of bound multi-key sequences — for --keymap / doctor.