Action

Enum Action 

Source
#[non_exhaustive]
pub enum Action<I: ApplicationInfo = EmptyInfo> {
Show 17 variants NoOp, Editor(EditorAction), Macro(MacroAction), Jump(PositionList, MoveDir1D, Count), Repeat(RepeatType), Scroll(ScrollStyle), KeywordLookup(KeywordTarget), RedrawScreen, ShowInfoMessage(InfoMessage), Suspend, Search(MoveDirMod, Count), Command(CommandAction), CommandBar(CommandBarAction<I>), Prompt(PromptAction), Tab(TabAction<I>), Window(WindowAction<I>), Application(I::Action),
}
Expand description

The result of either pressing a complete keybinding sequence, or parsing a command.

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.
§

NoOp

Do nothing.

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

// All of these are equivalent:
let noop: Action = Action::NoOp;
assert_eq!(action!("nop"), noop);
assert_eq!(action!("noop"), noop);
assert_eq!(action!("no-op"), noop);
assert_eq!(Action::default(), noop);
§

Editor(EditorAction)

Perform an editor action.

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

§

Macro(MacroAction)

Perform a macro-related action.

See the documentation for the MacroAction variants for how to construct all of the different Action::Macro values using action.

§

Jump(PositionList, MoveDir1D, Count)

Navigate through the cursor positions in the specified list.

If the current window cannot satisfy the given Count, then this may jump to other windows.

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

let list = PositionList::JumpList;
let count = Count::Contextual;

let act: Action = Action::Jump(list, MoveDir1D::Next, count.clone());
assert_eq!(act, action!("jump -t jump-list -d next -c ctx"));

let act: Action = Action::Jump(list, MoveDir1D::Previous, count);
assert_eq!(act, action!("jump -t jump-list -d previous -c ctx"));
§

Repeat(RepeatType)

Repeat an action sequence with the current context.

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

let rep: Action = action!("repeat -s edit-sequence");
assert_eq!(rep, Action::Repeat(RepeatType::EditSequence));

See the RepeatType documentation for how to construct each of its variants.

§

Scroll(ScrollStyle)

Scroll the viewport in the specified manner.

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

let scroll: Action = Action::Scroll(
    ScrollStyle::LinePos(MovePosition::Beginning, 1.into()));
assert_eq!(scroll, action!("scroll -s (line-pos -p beginning -c 1)"));

See the ScrollStyle documentation for how to construct each of its variants.

§

KeywordLookup(KeywordTarget)

Lookup the keyword under the cursor.

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

let kw: Action = Action::KeywordLookup(KeywordTarget::Selection);
assert_eq!(kw, action!("keyword-lookup -t selection"));
§

RedrawScreen

Redraw the screen.

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

let redraw: Action = action!("redraw-screen");
assert_eq!(redraw, Action::RedrawScreen);
§

ShowInfoMessage(InfoMessage)

Show an InfoMessage.

§

Suspend

Suspend the process.

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

let suspend: Action = action!("suspend");
assert_eq!(suspend, Action::Suspend);
§

Search(MoveDirMod, Count)

Find the nth occurrence of the current application-level search.

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

let search: Action = action!("search -d same");
assert_eq!(search, Action::Search(MoveDirMod::Same, Count::Contextual));

See the documentation for MoveDirMod for how to construct all of its values using action.

§

Command(CommandAction)

Perform a command-related action.

See the documentation for the CommandAction variants for how to construct all of the different Action::Command values using action.

§

CommandBar(CommandBarAction<I>)

Perform a command bar-related action.

See the documentation for the CommandBarAction variants for how to construct all of the different Action::CommandBar values using action.

§

Prompt(PromptAction)

Perform a prompt-related action.

See the documentation for the PromptAction variants for how to construct all of the different Action::Prompt values using action.

§

Tab(TabAction<I>)

Perform a tab-related action.

See the documentation for the TabAction variants for how to construct all of the different Action::Tab values using action.

§

Window(WindowAction<I>)

Perform a window-related action.

See the documentation for the WindowAction variants for how to construct all of the different Action::Window values using action.

§

Application(I::Action)

Application-specific command.

Implementations§

Source§

impl<I: ApplicationInfo> Action<I>

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, ctx: &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<I: Clone + ApplicationInfo> Clone for Action<I>
where I::Action: Clone,

Source§

fn clone(&self) -> Action<I>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + ApplicationInfo> Debug for Action<I>
where I::Action: Debug,

Source§

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

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

impl<I: ApplicationInfo> Default for Action<I>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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

Source§

fn from(act: CommandAction) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(act: CommandBarAction<I>) -> Self

Converts to this type from the input type.
Source§

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

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<I: ApplicationInfo> From<HistoryAction> for Action<I>

Source§

fn from(act: HistoryAction) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(act: InsertTextAction) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(act: MacroAction) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(act: PromptAction) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(act: SelectionAction) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(act: TabAction<I>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(act: WindowAction<I>) -> Self

Converts to this type from the input type.
Source§

impl<I: PartialEq + ApplicationInfo> PartialEq for Action<I>
where I::Action: PartialEq,

Source§

fn eq(&self, other: &Action<I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I: Eq + ApplicationInfo> Eq for Action<I>
where I::Action: Eq,

Source§

impl<I: ApplicationInfo> StructuralPartialEq for Action<I>

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.