pub enum KeyBindingContextPredicate {
Identifier(SharedString),
Equal(SharedString, SharedString),
NotEqual(SharedString, SharedString),
Descendant(Box<KeyBindingContextPredicate>, Box<KeyBindingContextPredicate>),
Not(Box<KeyBindingContextPredicate>),
And(Box<KeyBindingContextPredicate>, Box<KeyBindingContextPredicate>),
Or(Box<KeyBindingContextPredicate>, Box<KeyBindingContextPredicate>),
}Expand description
A datastructure for resolving whether an action should be dispatched Representing a small language for describing which contexts correspond to which actions.
Variants§
Identifier(SharedString)
A predicate that will match a given identifier.
Equal(SharedString, SharedString)
A predicate that will match a given key-value pair.
NotEqual(SharedString, SharedString)
A predicate that will match a given key-value pair not being present.
Descendant(Box<KeyBindingContextPredicate>, Box<KeyBindingContextPredicate>)
A predicate that will match a given predicate appearing below another predicate. in the element tree
Not(Box<KeyBindingContextPredicate>)
Predicate that will invert another predicate.
And(Box<KeyBindingContextPredicate>, Box<KeyBindingContextPredicate>)
A predicate that will match if both of its children match.
Or(Box<KeyBindingContextPredicate>, Box<KeyBindingContextPredicate>)
A predicate that will match if either of its children match.
Implementations§
Source§impl KeyBindingContextPredicate
impl KeyBindingContextPredicate
Sourcepub fn parse(source: &str) -> Result<Self>
pub fn parse(source: &str) -> Result<Self>
Parse a string in the same format as the keymap’s context field.
A basic equivalence check against a set of identifiers can performed by simply writing a string:
StatusBar -> A predicate that will match a context with the identifier StatusBar
You can also specify a key-value pair:
mode == visible -> A predicate that will match a context with the key mode
with the value visible
And a logical operations combining these two checks:
StatusBar && mode == visible -> A predicate that will match a context with the
identifier StatusBar and the key mode
with the value visible
There is also a special child > operator that will match a predicate that is
below another predicate:
StatusBar > mode == visible -> A predicate that will match a context identifier StatusBar
and a child context that has the key mode with the
value visible
This syntax supports !=, || and && as logical operators.
You can also preface an operation or check with a ! to negate it.
Sourcepub fn depth_of(&self, contexts: &[KeyContext]) -> Option<usize>
pub fn depth_of(&self, contexts: &[KeyContext]) -> Option<usize>
Find the deepest depth at which the predicate matches.
Sourcepub fn eval_inner(
&self,
contexts: &[KeyContext],
all_contexts: &[KeyContext],
) -> bool
pub fn eval_inner( &self, contexts: &[KeyContext], all_contexts: &[KeyContext], ) -> bool
Eval a predicate against a set of contexts, arranged from lowest to highest.
Sourcepub fn is_superset(&self, other: &Self) -> bool
pub fn is_superset(&self, other: &Self) -> bool
Returns whether or not this predicate matches all possible contexts matched by the other predicate.
Trait Implementations§
Source§impl Clone for KeyBindingContextPredicate
impl Clone for KeyBindingContextPredicate
Source§fn clone(&self) -> KeyBindingContextPredicate
fn clone(&self) -> KeyBindingContextPredicate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KeyBindingContextPredicate
impl Debug for KeyBindingContextPredicate
Source§impl Display for KeyBindingContextPredicate
impl Display for KeyBindingContextPredicate
Source§impl Hash for KeyBindingContextPredicate
impl Hash for KeyBindingContextPredicate
impl Eq for KeyBindingContextPredicate
impl StructuralPartialEq for KeyBindingContextPredicate
Auto Trait Implementations§
impl Freeze for KeyBindingContextPredicate
impl RefUnwindSafe for KeyBindingContextPredicate
impl Send for KeyBindingContextPredicate
impl Sync for KeyBindingContextPredicate
impl Unpin for KeyBindingContextPredicate
impl UnwindSafe for KeyBindingContextPredicate
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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<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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more