pub struct Keymap { /* private fields */ }Expand description
The bindings, by layer.
Implementations§
Source§impl Keymap
impl Keymap
pub fn new() -> Self
Sourcepub fn bind(
&mut self,
owner: &OwnerId,
layer: Layer,
keys: &str,
action: Action,
when: &str,
) -> Result<(), String>
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.
Sourcepub fn bind_with(
&mut self,
owner: &OwnerId,
layer: Layer,
keys: &str,
action: Action,
when: &str,
options: BindOptions,
) -> Result<(), String>
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.
Sourcepub fn set_dormant(
&mut self,
commands: impl IntoIterator<Item = CommandId>,
) -> bool
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.
Sourcepub fn is_dormant(&self, command: &CommandId) -> bool
pub fn is_dormant(&self, command: &CommandId) -> bool
Whether a command’s bindings are dormant.
Sourcepub fn dormant(&self) -> Vec<Binding>
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).
Sourcepub fn bindings(&self, layer: Layer) -> Vec<&Binding>
pub fn bindings(&self, layer: Layer) -> Vec<&Binding>
The bindings declared at a layer, in order (removals included).
Sourcepub fn clear(&mut self, layer: Layer)
pub fn clear(&mut self, layer: Layer)
Forgets every binding of a layer (before loading another profile).
Sourcepub fn remove_owner(&mut self, owner: &OwnerId) -> usize
pub fn remove_owner(&mut self, owner: &OwnerId) -> usize
Forgets an owner’s bindings; returns how many.
Sourcepub fn resolve(&self, keys: &Keys, cx: &WhenContext) -> Resolution
pub fn resolve(&self, keys: &Keys, cx: &WhenContext) -> Resolution
What pressing keys (the chords so far) does here.
Sourcepub fn resolve_traced(
&self,
keys: &Keys,
cx: &WhenContext,
) -> (Resolution, Trace)
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.
Sourcepub fn system_bindings(&self) -> Vec<Binding>
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.
Sourcepub fn pointer_bindings(&self) -> Vec<Binding>
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.
Sourcepub fn keys_for(&self, command: &CommandId) -> Vec<Keys>
pub fn keys_for(&self, command: &CommandId) -> Vec<Keys>
The keys bound to a command (what menus and tooltips show).
Sourcepub fn sources_for(&self, command: &CommandId) -> Vec<Binding>
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.
Sourcepub fn conflicts(&self) -> Vec<(Binding, Binding)>
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.
Sourcepub fn conflicts_by_scope(&self) -> BTreeMap<String, Vec<(Binding, Binding)>>
pub fn conflicts_by_scope(&self) -> BTreeMap<String, Vec<(Binding, Binding)>>
Keymap::conflicts, by scope (global, surface:<name>).
Sourcepub fn export_layer(&self, layer: Layer) -> KeymapDoc
pub fn export_layer(&self, layer: Layer) -> KeymapDoc
Every binding of a layer, whoever declared it, as saved.
Sourcepub fn remove_command(&mut self, owner: &OwnerId, command: &CommandId) -> usize
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.
Sourcepub fn rebind(
&mut self,
owner: &OwnerId,
layer: Layer,
command: &CommandId,
keys: Option<&str>,
) -> Result<(), String>
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.
Sourcepub fn rebind_all(
&mut self,
owner: &OwnerId,
layer: Layer,
command: &CommandId,
keys: &[&str],
) -> Result<(), String>
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).
Sourcepub fn reset(
&mut self,
owner: &OwnerId,
layer: Layer,
command: &CommandId,
) -> usize
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.
Sourcepub fn rebound(
&self,
owner: &OwnerId,
layer: Layer,
command: &CommandId,
) -> bool
pub fn rebound( &self, owner: &OwnerId, layer: Layer, command: &CommandId, ) -> bool
Whether the owner changed the command’s keys in layer.