Skip to main content

Keymap

Struct Keymap 

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

A component’s bindings, and the keys rebound on it.

Implementations§

Source§

impl Keymap

Source

pub fn new(context: impl Into<String>) -> Keymap

An empty keymap whose bindings are in context.

Source

pub fn context(&self) -> &str

The context bind puts bindings in.

Source

pub fn bind( self, action: impl Into<String>, keys: impl IntoIterator<Item = Key>, description: impl Into<String>, ) -> Keymap

Declare that keys do action, described as description.

Source

pub fn add(&mut self, binding: Binding)

Add a binding, in whatever context it has. A binding for an action already declared in that context replaces it.

Source

pub fn extend(&mut self, other: Keymap)

Add every binding of other after this one’s, keeping what other rebound: how a container lists its focused child’s keys with its own.

Source

pub fn rebind(&mut self, action: &str, keys: impl IntoIterator<Item = Key>)

Make keys do action (in this keymap’s context) instead of what was declared or installed. No keys unbinds it.

Source

pub fn rebound( self, action: &str, keys: impl IntoIterator<Item = Key>, ) -> Keymap

Builder form of rebind.

Source

pub fn apply(&mut self, overrides: &Overrides)

Apply overrides on this keymap only, over anything installed.

Source

pub fn lookup(&self, key: Key) -> Option<Binding>

The binding key triggers, if any: see action.

Source

pub fn action(&self, key: Key) -> Option<&str>

The action key triggers, if any: a binding whose keys were rebound (or installed) wins over one with its declared keys, so a key moved onto an action does it even when an earlier action declared it; otherwise the first declared.

Source

pub fn is(&self, key: Key, action: &str) -> bool

Whether key triggers action.

Source

pub fn keys(&self, action: &str) -> Vec<Key>

The keys that trigger action (in any context) now.

Source

pub fn key(&self, action: &str) -> Option<Key>

The first key for action, to show in a hint.

Source

pub fn bindings(&self) -> Vec<Binding>

Every binding, with the keys that do it now.

Source

pub fn declared(&self) -> &[Binding]

Every binding as declared, before rebinding.

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Trait Implementations§

Source§

impl Clone for Keymap

Source§

fn clone(&self) -> Self

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 Keymap

Source§

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

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

impl Default for Keymap

Source§

fn default() -> Self

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