Module modalkit::actions

source ·
Expand description

§Editor Actions

§Overview

The types in this module provides a defunctionalized view of a text editor. Consumers of these types should map them into text manipulation or user interface actions.

The traits contained here can be implemented to indicate that an object is capable of processing the associated action.

§Examples

use modalkit::actions::{Action, EditAction, EditorAction};
use modalkit::prelude::*;

// Delete the current text selection.
let _: Action = EditorAction::Edit(EditAction::Delete.into(), EditTarget::Selection).into();

// Copy the next three lines.
let _: Action = EditorAction::Edit(EditAction::Yank.into(), EditTarget::Range(RangeType::Line, true, 3.into())).into();

// Make some contextually specified number of words lowercase.
let _: Action = EditorAction::Edit(
    EditAction::ChangeCase(Case::Lower).into(),
    EditTarget::Motion(MoveType::WordBegin(WordStyle::Big, MoveDir1D::Next), Count::Contextual)
).into();

// Scroll the viewport so that line 10 is at the top of the screen.
let _: Action = Action::Scroll(ScrollStyle::LinePos(MovePosition::Beginning, 10.into()));

Enums§

Traits§