Skip to main content

Motion

Struct Motion 

Source
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

Source

pub const fn new(kind: MotionKind) -> Self

Creates an uncounted movement template with an effective count of one.

Source

pub const fn kind(self) -> MotionKind

Returns the operation.

Source

pub const fn count(self) -> usize

Returns the normalized count, which is always at least one.

Source

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.

Source

pub const fn target(self) -> Option<char>

Returns the character argument for find, till, delimiter, or method movement.

Source

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.

Source

pub const fn targeting(self, target: char) -> Self

Attaches a Unicode scalar character or delimiter argument.

Source

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.

Source

pub const fn is_repeated(self) -> bool

Reports whether this movement repeats a prior character search.

Trait Implementations§

Source§

impl Clone for Motion

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Motion

Source§

impl Debug for Motion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Motion

Source§

impl PartialEq for Motion

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Motion

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.