pub struct Overrides { /* private fields */ }Expand description
Keys rebound by context.action: what a configuration file sets.
Implementations§
Source§impl Overrides
impl Overrides
pub fn new() -> Overrides
Sourcepub fn set(
&mut self,
context: &str,
action: &str,
keys: impl IntoIterator<Item = Key>,
) -> &mut Self
pub fn set( &mut self, context: &str, action: &str, keys: impl IntoIterator<Item = Key>, ) -> &mut Self
Make keys do context.action. No keys unbinds it.
pub fn is_empty(&self) -> bool
Sourcepub fn from_pairs<I, A, K>(pairs: I) -> Result<Overrides, String>
pub fn from_pairs<I, A, K>(pairs: I) -> Result<Overrides, String>
(context.action, keys) pairs, as a configuration table holds them
("select.down" = "ctrl+n, down").
Sourcepub fn parse(text: &str) -> Result<Overrides, String>
pub fn parse(text: &str) -> Result<Overrides, String>
One context.action = key, key per line; blank lines are skipped,
and # at the start of a line or after a space starts a comment
(ctrl+# is a key). Quote a key that is a separator or a comment:
"#", ",". none unbinds the action; a line with no keys is an
error, so a stray # or , never unbinds one by accident.
use rich_interact::keymap::Overrides;
use rich_interact::Key;
let overrides = Overrides::parse("select.down = \"#\" j # keys\nselect.up = none").unwrap();
assert_eq!(overrides.get("select.down").unwrap(), [Key::char('#'), Key::char('j')]);
assert_eq!(overrides.get("select.up").unwrap(), []);
assert!(Overrides::parse("select.down = #").is_err());Trait Implementations§
impl Eq for Overrides
impl StructuralPartialEq for Overrides
Auto Trait Implementations§
impl Freeze for Overrides
impl RefUnwindSafe for Overrides
impl Send for Overrides
impl Sync for Overrides
impl Unpin for Overrides
impl UnsafeUnpin for Overrides
impl UnwindSafe for Overrides
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
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
Compare self to
key and return true if they are equal.