Skip to main content

Keymap

Struct Keymap 

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

The bindings, by layer.

Implementations§

Source§

impl Keymap

Source

pub fn new() -> Self

Source

pub fn bind( &mut self, owner: &OwnerId, layer: Layer, keys: &str, action: Action, when: &str, ) -> Result<(), String>

Adds a binding, its scope inferred from its clause (see Keymap::bind_with); its keys and clause must parse.

Source

pub fn bind_with( &mut self, owner: &OwnerId, layer: Layer, keys: &str, action: Action, when: &str, options: BindOptions, ) -> Result<(), String>

Adds a binding with its scope and typing rule. A global scope is narrowed to the panel its clause requires (KeyScope::infer: focusedPanel == '<id>'), which fires exactly where the clause holds and wins over the wider scopes.

Source

pub fn set_dormant( &mut self, commands: impl IntoIterator<Item = CommandId>, ) -> bool

Makes the bindings running these commands dormant, and those of every other command live: the commands that went with a disconnected plugin (ADR 0028). Whether the set changed.

Source

pub fn is_dormant(&self, command: &CommandId) -> bool

Whether a command’s bindings are dormant.

Source

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

The dormant bindings, in declaration order: those running a command of Keymap::set_dormant that no higher layer removed (what a shortcuts editor lists apart, with the plugin’s name).

Source

pub fn bindings(&self, layer: Layer) -> Vec<&Binding>

The bindings declared at a layer, in order (removals included).

Source

pub fn all(&self) -> impl Iterator<Item = &Binding>

Every binding, in declaration order.

Source

pub fn clear(&mut self, layer: Layer)

Forgets every binding of a layer (before loading another profile).

Source

pub fn remove_owner(&mut self, owner: &OwnerId) -> usize

Forgets an owner’s bindings; returns how many.

Source

pub fn resolve(&self, keys: &Keys, cx: &WhenContext) -> Resolution

What pressing keys (the chords so far) does here.

Source

pub fn resolve_traced( &self, keys: &Keys, cx: &WhenContext, ) -> (Resolution, Trace)

Resolves and says why: every binding of these keys or starting with them, with its verdict.

Source

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

The live bindings in the KeyScope::System scope: what a plugin registers with the system as global shortcuts, each command once per keys.

Source

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

The live bindings of pointer gestures (Pointer), one per scope and gesture: the winner among those of the same keys in the same scope by layer, then the clause testing more keys, then the last declared (the order Keymap::conflicts reports). Clauses are not evaluated: a canvas reads this table once per change of the keymap.

Source

pub fn keys_for(&self, command: &CommandId) -> Vec<Keys>

The keys bound to a command (what menus and tooltips show).

Source

pub fn sources_for(&self, command: &CommandId) -> Vec<Binding>

The live bindings running a command, with the layer each comes from (what a shortcuts editor shows as their source), by keys.

Source

pub fn conflicts(&self) -> Vec<(Binding, Binding)>

Bindings sharing keys with another of the same or a higher layer that wins over them (ignoring focus depth, which only the moment decides): what a shortcuts editor shows as conflicts. Two whose when clauses can never both hold (When::excludes) are none.

Source

pub fn conflicts_by_scope(&self) -> BTreeMap<String, Vec<(Binding, Binding)>>

Keymap::conflicts, by scope (global, surface:<name>).

Source

pub fn export_layer(&self, layer: Layer) -> KeymapDoc

Every binding of a layer, whoever declared it, as saved.

Source

pub fn remove_command(&mut self, owner: &OwnerId, command: &CommandId) -> usize

Removes an owner’s bindings running a command, in every layer; returns how many.

Source

pub fn rebind( &mut self, owner: &OwnerId, layer: Layer, command: &CommandId, keys: Option<&str>, ) -> Result<(), String>

Gives a command new keys in layer (the user’s, from a shortcuts editor): the owner’s earlier rules there about the command go, the command’s bindings in the layers below are removed (a removal with no keys), and keys (none: no key at all) run it, typing decided by the keys, in the scope of the binding it replaces (the highest layer’s below; global when the command had none): a system shortcut stays one.

Source

pub fn rebind_all( &mut self, owner: &OwnerId, layer: Layer, command: &CommandId, keys: &[&str], ) -> Result<(), String>

Keymap::rebind with several keys at once (none: no key at all): what a pointer gesture keeps when one of its gestures is added or taken away (Wheel, Ctrl+Scroll, Pinch all zoom).

Source

pub fn reset( &mut self, owner: &OwnerId, layer: Layer, command: &CommandId, ) -> usize

Takes back what Keymap::rebind did: the owner’s rules in layer running or removing the command go. Returns how many.

Source

pub fn rebound( &self, owner: &OwnerId, layer: Layer, command: &CommandId, ) -> bool

Whether the owner changed the command’s keys in layer.

Source

pub fn load( &mut self, owner: &OwnerId, layer: Layer, doc: &KeymapDoc, ) -> Diagnostics

Loads a saved keymap into a layer, owned by owner, replacing that owner’s bindings there. Entries that do not parse are skipped and reported.

Source

pub fn export(&self, owner: &OwnerId, layer: Layer) -> KeymapDoc

An owner’s bindings of a layer, as saved.

Trait Implementations§

Source§

impl Clone for Keymap

Source§

fn clone(&self) -> Keymap

Returns a duplicate of the value. Read more
1.0.0 · 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() -> Keymap

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