pub struct CommandInvocation {
pub command: CommandId,
pub count: Option<Count>,
pub register: Option<Register>,
pub range: Option<Range>,
pub target: Option<Target>,
pub args: Args,
pub bang: bool,
}Expand description
One call of one command, with every grammar slot vim can fill: the
unified call type every front-end produces and
execute consumes (DESIGN.md §5.2.1).
A chord ("a3dw), a : line (:%s/a/b/g), a palette pick, a macro
replay and a plugin call all become one of these. The dispatcher looks
command up in the registry and routes by its CommandKind; each
kind reads the slots it understands and ignores the rest (a motion
ignores register, an action ignores range and target).
Build with Self::of plus the with_* builders. The value owns
everything it holds and borrows nothing, so it can outlive the keystroke
that produced it.
Fields§
§command: CommandIdThe command to run. Must have been minted by the registry the
invocation is dispatched against, or dispatch fails with
CommandError::UnknownCommand.
count: Option<Count>The count prefix, if one was typed. None and Some(Count(1))
differ: see Count.
register: Option<Register>The "x register prefix, if one was typed; None means the
unnamed register.
range: Option<Range>An explicit grammar range (:%, :1,5, the Visual selection).
When an operator has both, the range wins over Self::target.
target: Option<Target>What an operator acts on: a motion, text object or range. Unused by other kinds.
args: ArgsCommand-specific arguments: the char of f{char}, the path of
:w path, the parsed fields of :s/…/…/.
bang: boolTrailing ! on the ex-syntax form (:q!, :w!, :e!). Carried
out of the parser into the dispatcher; meaningless for non-ex
invocations and ignored by motion / operator / text-object
dispatch.
Implementations§
Source§impl CommandInvocation
impl CommandInvocation
Sourcepub fn of(command: CommandId) -> CommandInvocation
pub fn of(command: CommandId) -> CommandInvocation
A bare invocation of command: no count, register, range or
target; Args::None; no bang.
Sourcepub fn with_count(self, count: Count) -> CommandInvocation
pub fn with_count(self, count: Count) -> CommandInvocation
Set the count prefix.
Sourcepub fn with_register(self, register: Register) -> CommandInvocation
pub fn with_register(self, register: Register) -> CommandInvocation
Set the register prefix.
Sourcepub fn with_range(self, range: Range) -> CommandInvocation
pub fn with_range(self, range: Range) -> CommandInvocation
Set an explicit range.
Sourcepub fn with_target(self, target: Target) -> CommandInvocation
pub fn with_target(self, target: Target) -> CommandInvocation
Set the operator target.
Sourcepub fn with_args(self, args: Args) -> CommandInvocation
pub fn with_args(self, args: Args) -> CommandInvocation
Replace the arguments.
Sourcepub fn with_bang(self, bang: bool) -> CommandInvocation
pub fn with_bang(self, bang: bool) -> CommandInvocation
Set the trailing-! bit (ex-commands only).
Sourcepub fn count_or_default(&self) -> Count
pub fn count_or_default(&self) -> Count
The count, or Count::ONE when none was typed.
Sourcepub fn register_or_default(&self) -> Register
pub fn register_or_default(&self) -> Register
The register, or the unnamed register when none was typed.
Trait Implementations§
Source§impl Clone for CommandInvocation
impl Clone for CommandInvocation
Source§fn clone(&self) -> CommandInvocation
fn clone(&self) -> CommandInvocation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CommandInvocation
impl Debug for CommandInvocation
Source§impl<'de> Deserialize<'de> for CommandInvocation
impl<'de> Deserialize<'de> for CommandInvocation
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CommandInvocation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CommandInvocation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CommandInvocation
impl PartialEq for CommandInvocation
Source§impl Serialize for CommandInvocation
impl Serialize for CommandInvocation
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for CommandInvocation
Auto Trait Implementations§
impl Freeze for CommandInvocation
impl RefUnwindSafe for CommandInvocation
impl Send for CommandInvocation
impl Sync for CommandInvocation
impl Unpin for CommandInvocation
impl UnsafeUnpin for CommandInvocation
impl UnwindSafe for CommandInvocation
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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