pub struct Binding { /* private fields */ }Expand description
A keybinding with associated help text.
Bindings can be enabled/disabled and contain zero or more key sequences that trigger the binding.
Implementations§
Source§impl Binding
impl Binding
Sourcepub fn keys(self, keys: &[&str]) -> Self
pub fn keys(self, keys: &[&str]) -> Self
Sets the keys for this binding.
§Example
use bubbles::key::Binding;
let binding = Binding::new().keys(&["k", "up", "ctrl+p"]);
assert_eq!(binding.get_keys(), &["k", "up", "ctrl+p"]);Sourcepub fn help(self, key: impl Into<String>, desc: impl Into<String>) -> Self
pub fn help(self, key: impl Into<String>, desc: impl Into<String>) -> Self
Sets the help text for this binding.
§Example
use bubbles::key::Binding;
let binding = Binding::new()
.keys(&["q"])
.help("q", "quit");
assert_eq!(binding.get_help().key, "q");
assert_eq!(binding.get_help().desc, "quit");Sourcepub fn set_help(&mut self, key: impl Into<String>, desc: impl Into<String>)
pub fn set_help(&mut self, key: impl Into<String>, desc: impl Into<String>)
Sets the help text for this binding (mutable version).
Sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Returns whether this binding is enabled.
A binding is enabled if it’s not explicitly disabled and has at least one key.
Sourcepub fn set_enabled(self, enabled: bool) -> Self
pub fn set_enabled(self, enabled: bool) -> Self
Enables or disables the binding (builder version).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Binding
impl RefUnwindSafe for Binding
impl Send for Binding
impl Sync for Binding
impl Unpin 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
Mutably borrows from an owned value. Read more