Skip to main content

KeyScope

Enum KeyScope 

Source
pub enum KeyScope {
    Global,
    Surface(String),
    System,
    Window(String),
    Panel(String),
}
Expand description

Where a binding listens. Each window dispatches its own keys and bubbles outwards: a surface holding the focus, then the window’s focused panel, then the window, then the whole application (KeyScope::tier); a binding of a narrower scope wins over one of a wider scope on the same keys.

Variants§

§

Global

Any window, whatever has the focus (a text input may keep the key, see Typing); a modal open in the window blocks it.

§

Surface(String)

Only while the surface (a focus scope of that name) holds the focus, shown with a focus ring or not.

§

System

Also while the application does not have the focus: the system delivers the keys (a global shortcut, registered by a plugin that reads Keymap::system_bindings). Inside the window it fires as a KeyScope::Global binding does.

§

Window(String)

Only in that application window (the context key appWindow: main for the main window and its detached panels).

§

Panel(String)

Only while that panel is the focused panel of the window the keys are pressed in (the context key focusedPanel, which each window keeps for itself): never from another window.

Implementations§

Source§

impl KeyScope

Source

pub fn surface(name: &str) -> KeyScope

Source

pub fn window(id: &str) -> KeyScope

Source

pub fn panel(id: &str) -> KeyScope

Source

pub fn parse(text: &str) -> Result<KeyScope, String>

As in files and traces: global, surface:<name>, system, window:<id>, panel:<id>.

Source

pub fn infer(when: &When) -> KeyScope

The scope a binding declared without one gets, from its clause: a clause requiring focusedPanel == '<id>' (alone or in a conjunction) is the panel’s (KeyScope::Panel); any other is KeyScope::Global. What keymaps written before scopes existed load as.

Source

pub fn infer_from(when: &str) -> KeyScope

KeyScope::infer from a clause’s text; a clause that does not parse is global.

Source

pub fn is_global(&self) -> bool

Whether it listens in every window (global, and system inside the window).

Source

pub fn is_system(&self) -> bool

Whether the system delivers it while the application is not focused.

Source

pub fn tier(&self) -> u8

Its place in the bubble order, nearer the focus higher: a surface 3, a panel 2, a window 1, global and system 0.

Trait Implementations§

Source§

impl Clone for KeyScope

Source§

fn clone(&self) -> KeyScope

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyScope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KeyScope

Source§

fn default() -> KeyScope

Returns the “default value” for a type. Read more
Source§

impl Display for KeyScope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for KeyScope

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for KeyScope

Source§

fn cmp(&self, other: &KeyScope) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for KeyScope

Source§

fn eq(&self, other: &KeyScope) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for KeyScope

Source§

fn partial_cmp(&self, other: &KeyScope) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for KeyScope

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for KeyScope

Source§

impl StructuralPartialEq for KeyScope

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.