pub struct Binding {
pub context: String,
pub action: String,
pub keys: Vec<Key>,
pub description: String,
pub sequence: bool,
pub unavailable: Option<String>,
}Expand description
One thing a key does: an action, in a context, with a description.
Fields§
§context: StringWhich component or container it belongs to: select, split.
action: StringWhat it does, for code and configuration: down, focus-next.
keys: Vec<Key>The keys that do it, first the one to show.
description: StringWhat it does, for people: move down.
sequence: boolThe keys are pressed one after another (g g), rather than being
alternatives: a key sequence an app runs itself, listed in a help
or a palette. A keymap does not look these up.
Why it cannot be done now, when it cannot: a help or a palette lists it greyed, with the reason, and a palette does not run it.
Implementations§
Source§impl Binding
impl Binding
pub fn new( context: impl Into<String>, action: impl Into<String>, keys: impl IntoIterator<Item = Key>, description: impl Into<String>, ) -> Binding
Sourcepub fn sequence(
context: impl Into<String>,
action: impl Into<String>,
keys: impl IntoIterator<Item = Key>,
description: impl Into<String>,
) -> Binding
pub fn sequence( context: impl Into<String>, action: impl Into<String>, keys: impl IntoIterator<Item = Key>, description: impl Into<String>, ) -> Binding
A binding of keys pressed one after another (g then g), for a
help or a palette to list: shown as g g.
use rich_interact::keymap::{keys, Binding};
let top = Binding::sequence("files", "top", keys("g g"), "go to the top");
assert_eq!(top.keys_label(), "g g");Listed but not available now, saying reason (see
unavailable).
use rich_interact::keymap::{keys, Binding};
let save = Binding::new("editor", "save", keys("ctrl+s"), "save").unavailable("read-only");
assert_eq!(save.unavailable.as_deref(), Some("read-only"));Sourcepub fn keys_label(&self) -> String
pub fn keys_label(&self) -> String
The keys as people read them: up/ctrl+p, or g g for a
sequence.
Trait Implementations§
impl Eq for Binding
impl StructuralPartialEq for Binding
Auto Trait Implementations§
impl Freeze for Binding
impl RefUnwindSafe for Binding
impl Send for Binding
impl Sync for Binding
impl Unpin for Binding
impl UnsafeUnpin for Binding
impl UnwindSafe for Binding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more