pub struct Registry { /* private fields */ }Expand description
Every command of an app, shared by its menus, search, keys and agent (a cheap handle: clones share the same list).
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn new(commands: Vec<CommandSpec>) -> Self
pub fn new(commands: Vec<CommandSpec>) -> Self
A registry holding commands.
Sourcepub fn add(&self, command: CommandSpec)
pub fn add(&self, command: CommandSpec)
Adds a command, replacing one with the same id.
Sourcepub fn extend(&self, commands: impl IntoIterator<Item = CommandSpec>)
pub fn extend(&self, commands: impl IntoIterator<Item = CommandSpec>)
Adds several commands (Registry::add each).
Sourcepub fn get(&self, id: &str) -> Option<CommandSpec>
pub fn get(&self, id: &str) -> Option<CommandSpec>
The command id.
Sourcepub fn all(&self) -> Vec<CommandSpec>
pub fn all(&self) -> Vec<CommandSpec>
Every command, in the order added.
Sourcepub fn provide(
&self,
id: impl Into<SharedString>,
provider: impl Fn(&App) -> Vec<MenuItem> + 'static,
)
pub fn provide( &self, id: impl Into<SharedString>, provider: impl Fn(&App) -> Vec<MenuItem> + 'static, )
Registers the menu provider id (replacing one with the same id): a
MenuItem::Provided naming it shows the entries it makes when the menu opens.
Sourcepub fn provided(&self, id: &str, cx: &App) -> Vec<MenuItem>
pub fn provided(&self, id: &str, cx: &App) -> Vec<MenuItem>
The entries the provider id makes now (none when there is no such provider).
Sourcepub fn check(&self, id: &str, cx: &App) -> Result<(), String>
pub fn check(&self, id: &str, cx: &App) -> Result<(), String>
Whether id can run now (Err says why not, or that there is no such command).
Sourcepub fn run(
&self,
id: &str,
args: Value,
window: &mut Window,
cx: &mut App,
) -> Result<Value, String>
pub fn run( &self, id: &str, args: Value, window: &mut Window, cx: &mut App, ) -> Result<Value, String>
Runs id with args (null for none), when it can run now, as the person did.
Sourcepub fn run_as(
&self,
actor: Actor,
via: &str,
id: &str,
args: Value,
window: &mut Window,
cx: &mut App,
) -> Result<Value, String>
pub fn run_as( &self, actor: Actor, via: &str, id: &str, args: Value, window: &mut Window, cx: &mut App, ) -> Result<Value, String>
Runs id with args for actor, started from via (menu, key, search, title bar, agent),
and records it in the activity log (crate::activity), refused or not.
Sourcepub fn bind_keys(&self, context: Option<&str>, cx: &mut App) -> Vec<String>
pub fn bind_keys(&self, context: Option<&str>, cx: &mut App) -> Vec<String>
Binds every command’s key to RunCommand (globally; context limits them to a part of
the window, as GPUI’s key contexts do). A key that does not parse is skipped and named
in the result.
A ghost button titled as menu, opening its entries: each command with its icon, key
and check mark; a command that cannot run now is greyed with its reason under it.
Adds items to menu (as Registry::menu_button does).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Registry
impl !Send for Registry
impl !Sync for Registry
impl !UnwindSafe for Registry
impl Forget for Registry
impl Freeze for Registry
impl Move for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
Source§type NoneType = T
type NoneType = T
NoneValue::null_value produces.Source§fn null_value() -> T
fn null_value() -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().