pub struct Command { /* private fields */ }Expand description
A single command: its display name, category, underlying GPUI action, optional keybinding, and the handler invoked when it is executed.
Implementations§
Source§impl Command
impl Command
Sourcepub fn new(name: impl Into<SharedString>, action: impl Action) -> Self
pub fn new(name: impl Into<SharedString>, action: impl Action) -> Self
Start building a command. name is what appears in the palette;
action is the GPUI action this command wraps.
Sourcepub fn category(self, category: impl Into<SharedString>) -> Self
pub fn category(self, category: impl Into<SharedString>) -> Self
Set the category this command is grouped under in the palette.
Sourcepub fn keybinding(self, binding: impl Into<SharedString>) -> Self
pub fn keybinding(self, binding: impl Into<SharedString>) -> Self
Record a keybinding for this command, e.g. "cmd-s".
Sourcepub fn handler(self, f: impl Fn(&mut Window, &mut App) + 'static) -> Self
pub fn handler(self, f: impl Fn(&mut Window, &mut App) + 'static) -> Self
Set the handler invoked when this command is executed.
Sourcepub fn name(&self) -> &SharedString
pub fn name(&self) -> &SharedString
The display name shown in the palette.
Sourcepub fn category_name(&self) -> &SharedString
pub fn category_name(&self) -> &SharedString
The category this command is grouped under.
Sourcepub fn binding(&self) -> Option<&SharedString>
pub fn binding(&self) -> Option<&SharedString>
The bound keybinding, if any.
Auto Trait Implementations§
impl !RefUnwindSafe for Command
impl !Send for Command
impl !Sync for Command
impl !UnwindSafe for Command
impl Freeze for Command
impl Unpin for Command
impl UnsafeUnpin for Command
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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> 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> ⓘ
Converts
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> ⓘ
Converts
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