pub struct Motion { /* private fields */ }Expand description
A completed Vim movement with its count and optional character argument.
Use crate::MotionState when counts and character arguments arrive as
separate key events. Constructing a Motion directly is useful when an
adapter has already resolved its command language. A target is meaningful
only to character find/till, unmatched-delimiter, and method motions; other
motions safely ignore it. Method motions use target 'M' for closing braces
([M/]M) and otherwise select opening braces ([m/]m).
Implementations§
Source§impl Motion
impl Motion
Sourcepub const fn new(kind: MotionKind) -> Self
pub const fn new(kind: MotionKind) -> Self
Creates an uncounted movement template with an effective count of one.
Sourcepub const fn kind(self) -> MotionKind
pub const fn kind(self) -> MotionKind
Returns the operation.
Sourcepub const fn has_explicit_count(self) -> bool
pub const fn has_explicit_count(self) -> bool
Reports whether the user supplied a count.
This is semantically distinct from Self::count: Vim interprets an
explicit 1G, 1%, or 1z command differently from its uncounted
form even though both carry the numeric value one.
Sourcepub const fn target(self) -> Option<char>
pub const fn target(self) -> Option<char>
Returns the character argument for find, till, delimiter, or method movement.
Sourcepub const fn counted(self, count: usize, source: CountSource) -> Self
pub const fn counted(self, count: usize, source: CountSource) -> Self
Attaches a normalized count and its explicit or implicit CountSource.
A zero count is normalized to one. Counts produced from decimal input
should normally come from crate::MotionState, which also saturates
overflow and applies Vim’s counted-command reinterpretations.
Sourcepub const fn targeting(self, target: char) -> Self
pub const fn targeting(self, target: char) -> Self
Attaches a Unicode scalar character or delimiter argument.
Sourcepub const fn repeating(self) -> Self
pub const fn repeating(self) -> Self
Marks a find/till movement as a ; or , repetition.
Repeated till motions have a Vim-specific adjacent-match exception;
callers should set this through crate::MotionState rather than
emulating it by issuing the original motion again.
Sourcepub const fn is_repeated(self) -> bool
pub const fn is_repeated(self) -> bool
Reports whether this movement repeats a prior character search.