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) -> Self
pub fn of(command: CommandId) -> Self
A bare invocation of command: no count, register, range or
target; Args::None; no bang.
Sourcepub fn with_count(self, count: Count) -> Self
pub fn with_count(self, count: Count) -> Self
Set the count prefix.
Sourcepub fn with_register(self, register: Register) -> Self
pub fn with_register(self, register: Register) -> Self
Set the register prefix.
Sourcepub fn with_range(self, range: Range) -> Self
pub fn with_range(self, range: Range) -> Self
Set an explicit range.
Sourcepub fn with_target(self, target: Target) -> Self
pub fn with_target(self, target: Target) -> Self
Set the operator target.
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 more