Skip to main content

KeyMap

Struct KeyMap 

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

A declarative binding map: chords to actions with priorities and contexts. Actions are any Clone type (usually an app enum).

Implementations§

Source§

impl<A> KeyMap<A>

Source

pub fn new() -> Self

An empty map with default timing.

Source

pub fn with_config(config: KeyMapConfig) -> Self

An empty map with the given timing.

Source

pub fn config(&self) -> &KeyMapConfig

Timing configuration.

Source

pub fn context(&mut self, name: &str) -> ContextId

Intern a context name; the same name always yields the same id.

Source

pub fn context_name(&self, id: ContextId) -> Option<&str>

Name of an interned context.

Source

pub fn bind(&mut self, chord: Chord, action: A) -> BindingId

Bind a chord at Priority::Global with no context.

Source

pub fn bind_in( &mut self, chord: Chord, action: A, priority: Priority, context: Option<ContextId>, ) -> BindingId

Bind a chord with an explicit priority and optional context.

Source

pub fn set_label(&mut self, id: BindingId, label: impl Into<String>) -> bool

Attach a label to a binding; false if the id is unknown.

Source

pub fn unbind(&mut self, id: BindingId) -> Option<Binding<A>>

Remove a binding.

Source

pub fn bindings(&self) -> &[Binding<A>]

All bindings in bind order.

Source

pub fn get(&self, id: BindingId) -> Option<&Binding<A>>

A binding by id.

Source

pub fn len(&self) -> usize

Number of bindings.

Source

pub fn is_empty(&self) -> bool

Whether the map has no bindings.

Source

pub fn lookup(&self, chord: &Chord, active: &[ContextId]) -> Lookup<'_, A>

Resolve chord against the bindings applicable under active contexts: the winning exact binding and how many longer bound chords start with it.

Source

pub fn conflicts(&self) -> ConflictReport

Report shadowed, duplicate, and prefix-colliding bindings.

Trait Implementations§

Source§

impl<A: Clone> Clone for KeyMap<A>

Source§

fn clone(&self) -> KeyMap<A>

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<A: Debug> Debug for KeyMap<A>

Source§

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

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

impl<A> Default for KeyMap<A>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<A> Freeze for KeyMap<A>
where Vec<Binding<A>>: Freeze,

§

impl<A> RefUnwindSafe for KeyMap<A>

§

impl<A> Send for KeyMap<A>
where Vec<Binding<A>>: Send,

§

impl<A> Sync for KeyMap<A>
where Vec<Binding<A>>: Sync,

§

impl<A> Unpin for KeyMap<A>
where Vec<Binding<A>>: Unpin,

§

impl<A> UnsafeUnpin for KeyMap<A>
where Vec<Binding<A>>: UnsafeUnpin,

§

impl<A> UnwindSafe for KeyMap<A>
where Vec<Binding<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> 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.

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.