#[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
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
impl EditorAction
Sourcepub fn is_readonly(&self, ctx: &EditContext) -> bool
pub fn is_readonly(&self, ctx: &EditContext) -> bool
Indicates if this is a read-only action.
Sourcepub fn is_edit_sequence(
&self,
motion: SequenceStatus,
ctx: &EditContext,
) -> SequenceStatus
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.
Sourcepub fn is_last_action(&self, _: &EditContext) -> SequenceStatus
pub fn is_last_action(&self, _: &EditContext) -> SequenceStatus
Indicates how an action gets included in RepeatType::LastAction.
Sourcepub fn is_last_selection(&self, ctx: &EditContext) -> SequenceStatus
pub fn is_last_selection(&self, ctx: &EditContext) -> SequenceStatus
Indicates how an action gets included in RepeatType::LastSelection.
Sourcepub fn is_switchable(&self, ctx: &EditContext) -> bool
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
impl Clone for EditorAction
Source§fn clone(&self) -> EditorAction
fn clone(&self) -> EditorAction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more