Skip to main content

KeyPipeline

Struct KeyPipeline 

Source
pub struct KeyPipeline { /* private fields */ }
Expand description

The vim key layer lives in escriba_keymap::pipeline — one implementation every app drives. Re-exported so the gate in tests/operand_capture_order.rs keeps its spelling. The vim key layer: keymap + every piece of half-typed-gesture state.

See the module docs for the contract. Construct with KeyPipeline::default_vim (or KeyPipeline::new over a customised Keymap), then hand every key to KeyPipeline::feed.

Implementations§

Source§

impl KeyPipeline

Source

pub fn new(keymap: Keymap) -> KeyPipeline

A pipeline over keymap, with nothing half-typed.

Source

pub fn default_vim() -> KeyPipeline

A pipeline over Keymap::default_vim.

Source

pub const fn keymap(&self) -> &Keymap

Source

pub const fn keymap_mut(&mut self) -> &mut Keymap

The live keymap — rc / plugin binding application writes here.

Source

pub fn pending_keys(&self) -> &[Key]

The keys held for an in-progress multi-key sequence (empty when none). What a “showcmd” indicator renders.

Source

pub fn op_state(&self) -> &OpState

The operator machine’s state (Resting, Awaiting, AwaitingSearch).

Source

pub const fn last_find(&self) -> Option<FindSpec>

The last completed f/F/t/T — what ; / , (Motion::RepeatFind) resolve through. Resolving it needs the buffer, so that is the host’s job; recording it is the key layer’s.

Source

pub fn is_pending(&self) -> bool

True while a key sequence, an operator (including d/ with its search prompt open), an object, a find, a replace or a mark is half-typed.

A bare COUNT prefix is not included: it lives in ModalState (pending_count()), which the host already holds.

Source

pub fn reset(&mut self)

Abandon everything half-typed and disarm the operator machine. The keymap and Self::last_find are kept. The count prefix lives in the host’s ModalState; clear it there.

Source

pub fn feed(&mut self, modal: &mut ModalState, key: &Key) -> Vec<(Action, u32)>

Feed one key; get the fully composed steps to execute, in order.

Each (Action, u32) has passed the operator machine: 3d2w yields one ApplyOperator { Delete, WordStartNext } at count 6, ciw one ApplyOperatorObject, fx a Move(FindChar …), gg the resolved sequence. The count is a REPETITION count for most actions; an editor that treats some actions as absorbing their count (3p, 2dd as one operation) decides that itself.

Counts accumulate in modal; the pipeline never mutates text and never changes the mode — mode changes come back as actions.

This is Self::resolve_key followed by Self::compose on every unit. A host that must be able to refuse a unit before the operator machine sees it (see the module docs) calls those two itself.

Source

pub fn compose(&mut self, action: &Action, count: u32) -> Vec<(Action, u32)>

Run the operator machine over one resolved unit.

Also the entry for actions that did not come from a key — anything a host dispatches should pass here, so an armed d composes with it the same way it composes with a keyed motion.

| is folded in first: it is the one motion whose count is an ARGUMENT rather than a repetition (40| is column 40, not “column 1, forty times”). Folding it here keeps the machine at one rule — counts repeat — with the exception living where the exception is.

Source

pub fn resolve_key( &mut self, modal: &mut ModalState, key: &Key, ) -> Vec<(Action, u32)>

The key layer alone: captures, sequences, counts, keymap. Returns the units to hand to Self::compose, one at a time and in order.

A repeated sequence (3gg) and a counted object (2diw) come back as that many count-1 units rather than one counted unit, because that is how they meet the operator machine: each repetition is its own event (d3gg composes the first and runs the other two bare).

Trait Implementations§

Source§

impl Clone for KeyPipeline

Source§

fn clone(&self) -> KeyPipeline

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
Source§

impl Debug for KeyPipeline

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for KeyPipeline

Source§

fn default() -> KeyPipeline

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

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

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