Skip to main content

KeymapBinding

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: BindingMode

Binding-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: CommandInvocation

Typed 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: SourceLocation

Where 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: bool

SN.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

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

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

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

§

fn clone(&self) -> KeymapBinding

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for KeymapBinding

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl PartialEq for KeymapBinding

§

fn eq(&self, other: &KeymapBinding) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl StructuralPartialEq for KeymapBinding

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more