Skip to main content

EditorAction

Enum EditorAction 

Source
#[non_exhaustive]
pub enum EditorAction { Complete(CompletionStyle, CompletionType, CompletionDisplay), Cursor(CursorAction), Edit(Specifier<EditAction>, EditTarget), History(HistoryAction), InsertText(InsertTextAction), Mark(Specifier<Mark>), Selection(SelectionAction), }
Expand description

Actions for editing text within buffer.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Complete(CompletionStyle, CompletionType, CompletionDisplay)

Complete the text before the cursor group leader.

See the documentation for the CompletionStyle variants for how to construct all of the different EditorAction::Complete values using action.

§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};

let ct = CompletionType::Auto;
let style = CompletionStyle::Prefix;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct.clone(), display).into();

// All of these are equivalent:
assert_eq!(act, action!("complete -s prefix -T auto -D list"));
assert_eq!(act, action!("complete -s prefix -T {ct} -D list"));
assert_eq!(act, action!("complete -s prefix -D list"));
§

Cursor(CursorAction)

Modify the current cursor group.

See the documentation for the CursorAction variants for how to construct all of the different EditorAction::Cursor values using action.

§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, CursorAction};

let close: Action = action!("cursor close -t leader");
assert_eq!(close, CursorAction::Close(CursorCloseTarget::Leader).into());

let restore: Action = action!("cursor restore -s append");
assert_eq!(restore, CursorAction::Restore(CursorGroupCombineStyle::Append).into());
§

Edit(Specifier<EditAction>, EditTarget)

Perform the specified action on a target.

§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};

let ctx = Specifier::Contextual;
let target = EditTarget::CurrentPosition;
let act: Action = EditorAction::Edit(ctx, target.clone()).into();
assert_eq!(act, action!("edit -o ctx -t {target}"));
§

History(HistoryAction)

Perform a history operation.

See the documentation for the HistoryAction variants for how to construct all of the different EditorAction::History values using action.

use editor_types::prelude::*;
use editor_types::{action, Action, HistoryAction};

let undo: Action = action!("history undo");
assert_eq!(undo, HistoryAction::Undo(Count::Contextual).into());

let redo: Action = action!("history redo");
assert_eq!(redo, HistoryAction::Redo(Count::Contextual).into());
§

InsertText(InsertTextAction)

Insert text.

See the documentation for the InsertTextAction variants for how to construct all of the different EditorAction::InsertText values using action.

§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, InsertTextAction};

let paste: Action = action!("insert paste -s cursor -c 10");
assert_eq!(paste, InsertTextAction::Paste(PasteStyle::Cursor, 10.into()).into());
§

Mark(Specifier<Mark>)

Create a new Mark at the current leader position.

§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};

let mark = Mark::LastYankedBegin;
let set_mark: Action = action!("mark -m {}", mark.clone());
assert_eq!(set_mark, EditorAction::Mark(mark.into()).into());

let set_mark: Action = action!("mark -m ctx");
assert_eq!(set_mark, EditorAction::Mark(Specifier::Contextual).into());
§

Selection(SelectionAction)

Modify the current selection.

See the documentation for the SelectionAction variants for how to construct all of the different EditorAction::Selection values using action.

§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};

let act: Action = SelectionAction::Duplicate(MoveDir1D::Next, Count::Contextual).into();
assert_eq!(act, action!("selection duplicate -d next"));

Implementations§

Source§

impl EditorAction

Source

pub fn is_readonly(&self, ctx: &EditContext) -> bool

Indicates if this is a read-only action.

Source

pub fn is_edit_sequence( &self, motion: SequenceStatus, ctx: &EditContext, ) -> SequenceStatus

Indicates how an action gets included in RepeatType::EditSequence.

motion indicates what to do with EditAction::Motion.

Source

pub fn is_last_action(&self, _: &EditContext) -> SequenceStatus

Indicates how an action gets included in RepeatType::LastAction.

Source

pub fn is_last_selection(&self, ctx: &EditContext) -> SequenceStatus

Indicates how an action gets included in RepeatType::LastSelection.

Source

pub fn is_switchable(&self, ctx: &EditContext) -> bool

Returns true if this Action is allowed to trigger a WindowAction::Switch after an error.

Trait Implementations§

Source§

impl Clone for EditorAction

Source§

fn clone(&self) -> EditorAction

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 Debug for EditorAction

Source§

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

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

impl Eq for EditorAction

Source§

impl From<CursorAction> for EditorAction

Source§

fn from(act: CursorAction) -> Self

Converts to this type from the input type.
Source§

impl<I: ApplicationInfo> From<EditorAction> for Action<I>

Source§

fn from(act: EditorAction) -> Self

Converts to this type from the input type.
Source§

impl From<HistoryAction> for EditorAction

Source§

fn from(act: HistoryAction) -> Self

Converts to this type from the input type.
Source§

impl From<InsertTextAction> for EditorAction

Source§

fn from(act: InsertTextAction) -> Self

Converts to this type from the input type.
Source§

impl From<SelectionAction> for EditorAction

Source§

fn from(act: SelectionAction) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for EditorAction

Source§

fn eq(&self, other: &EditorAction) -> 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 EditorAction

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.