Skip to main content

KeyDispatcher

Struct KeyDispatcher 

Source
pub struct KeyDispatcher<A> { /* private fields */ }
Expand description

Chord-aware dispatcher over a KeyMap.

Feed every key event through feed and call tick once per frame so pending chords and the Esc timer expire; every call returns the decisions to act on. See the module section header for the resolution rules.

Implementations§

Source§

impl<A: Clone> KeyDispatcher<A>

Source

pub fn new(map: KeyMap<A>) -> Self

A dispatcher over map with no active contexts.

Source

pub fn map(&self) -> &KeyMap<A>

The underlying map.

Source

pub fn map_mut(&mut self) -> &mut KeyMap<A>

Mutable access to the map (rebinding at runtime).

Source

pub fn set_active_contexts(&mut self, contexts: &[ContextId])

Replace the set of active contexts (focused widget, mode, …).

Source

pub fn active_contexts(&self) -> &[ContextId]

Currently active contexts.

Source

pub fn pending_prefix(&self) -> Option<Chord>

The chord prefix currently waiting for more keys.

Source

pub fn stats(&self) -> DispatchStats

Counters so far.

Source

pub fn reset(&mut self)

Drop any pending prefix and Esc state.

Source

pub fn feed(&mut self, key: &KeyEvent, now: Instant) -> Vec<Dispatch<A>>

Process one key event.

Source

pub fn tick(&mut self, now: Instant) -> Vec<Dispatch<A>>

Expire a pending prefix past the chord timeout and drive the Esc timer.

Trait Implementations§

Source§

impl<A: Debug> Debug for KeyDispatcher<A>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A> Freeze for KeyDispatcher<A>
where KeyMap<A>: Freeze,

§

impl<A> RefUnwindSafe for KeyDispatcher<A>

§

impl<A> Send for KeyDispatcher<A>
where KeyMap<A>: Send,

§

impl<A> Sync for KeyDispatcher<A>
where KeyMap<A>: Sync,

§

impl<A> Unpin for KeyDispatcher<A>
where KeyMap<A>: Unpin,

§

impl<A> UnsafeUnpin for KeyDispatcher<A>
where KeyMap<A>: UnsafeUnpin,

§

impl<A> UnwindSafe for KeyDispatcher<A>
where KeyMap<A>: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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