Struct KeymapBinding
pub struct KeymapBinding {
pub mode: BindingMode,
pub chords: Vec<ChordPattern>,
pub command: CommandInvocation,
pub source: SourceLocation,
pub doc: Option<&'static str>,
pub fall_through: bool,
}Expand description
One mode-contributed keymap binding.
Declarative: the host calls lattice_mode::Mode::keymap once at
registration time and translates each binding into a
BoundCommand inserted at KeymapLayer::MinorMode(mode.id()).
Re-translation only happens on dynamic
ModeRegistry::register after boot.
source is captured at the binding’s own file!() +
line!() (via [SourceLocation::builtin_file]) so
:describe-key can name the contributing crate without
the host having to track provenance separately.
Fields§
§mode: BindingModeBinding-mode the chord resolves in (Normal, Insert, …).
chords: Vec<ChordPattern>Registration path – one [ChordPattern] per chord
in the sequence (gd -> two Literal chords, 'a ->
one Literal + one CharLiteral for the mark name).
command: CommandInvocationTyped invocation the dispatcher fires on match. Same shape host-registered bindings carry, so the matcher engine treats mode-contributed and host-registered bindings identically once translated.
source: SourceLocationWhere this binding was registered. Surfaces in
:describe-key and the upcoming :keymap listing.
doc: Option<&'static str>Human-readable one-line doc surfaced by :describe-key
and the :keymap listing. K.2.4.A.0.2: populated when
the binding originates from a keymap_entry!-driven
entry (every entry carries a doc) and translated by the
host pass into a KeymapBinding. None when the
binding came via bind_chord (the terse chain form,
optimized for ergonomics) or via KeymapBinding::new
directly. Plugin and runtime :bind callers can attach
docs via Self::with_doc.
fall_through: boolSN.3c.2b: :map-style augment-and-continue, carried from the
owning KeymapEntry::fall_through through to the
[crate::BoundCommand] the registry stores. false by default;
see [crate::BoundCommand::fall_through] for the semantics.
Implementations§
§impl KeymapBinding
impl KeymapBinding
pub fn new(
mode: BindingMode,
chords: Vec<ChordPattern>,
command: CommandInvocation,
source: SourceLocation,
) -> KeymapBinding
pub fn new( mode: BindingMode, chords: Vec<ChordPattern>, command: CommandInvocation, source: SourceLocation, ) -> KeymapBinding
Construct one mode-contributed binding. Modes use the
lattice_grammar::SourceLocation::builtin_file(file!(), line!()) idiom for source so provenance points at
the binding declaration’s own file:line. doc
defaults to None; attach a doc string via
Self::with_doc.
pub fn with_doc(self, doc: &'static str) -> KeymapBinding
pub fn with_doc(self, doc: &'static str) -> KeymapBinding
Attach a human-readable one-line doc. Returned via
:describe-key and :keymap. Builder shape so call
sites can chain KeymapBinding::new(...).with_doc("...").
pub fn with_fall_through(self, fall_through: bool) -> KeymapBinding
pub fn with_fall_through(self, fall_through: bool) -> KeymapBinding
SN.3c.2b: set the augment-and-continue flag (see
[crate::BoundCommand::fall_through]). Builder shape so the
table-form translation can chain it off the entry.
Trait Implementations§
§impl Clone for KeymapBinding
impl Clone for KeymapBinding
§fn clone(&self) -> KeymapBinding
fn clone(&self) -> KeymapBinding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more