#[non_exhaustive]pub enum SelectionAction {
Duplicate(MoveDir1D, Count),
CursorSet(SelectionCursorChange),
Expand(SelectionBoundary, TargetShapeFilter),
Filter(MatchAction),
Join,
Resize(SelectionResizeStyle, EditTarget),
Split(SelectionSplitStyle, TargetShapeFilter),
Trim(SelectionBoundary, TargetShapeFilter),
}Expand description
Actions for manipulating text selections.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Duplicate(MoveDir1D, Count)
Duplicate selections n times to adjacent lines in MoveDir1D direction.
If the column positions are too large to fit on the adjacent lines, then the next line large enough to hold the selection is used instead.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};
let count = Count::Contextual;
let act: Action = SelectionAction::Duplicate(MoveDir1D::Next, count.clone()).into();
// All of these are equivalent:
assert_eq!(action!("selection duplicate -d next"), act);
assert_eq!(action!("selection duplicate -d next -c ctx"), act);
assert_eq!(action!("selection duplicate -d next -c {count}"), act);CursorSet(SelectionCursorChange)
Change the placement of the cursor and anchor of a visual selection.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};
let change = SelectionCursorChange::End;
let act: Action = action!("selection cursor-set -f end");
assert_eq!(act, SelectionAction::CursorSet(change).into());Expand(SelectionBoundary, TargetShapeFilter)
Expand a selection by repositioning its cursor and anchor such that they are placed on the specified boundary.
Be aware that since this repositions the start and end of the selection, this may not do what you want with TargetShape::BlockWise selections.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};
let style = SelectionBoundary::Line;
let split: Action = action!("selection expand -b line -t all");
assert_eq!(split, SelectionAction::Expand(style, TargetShapeFilter::ALL).into());Filter(MatchAction)
Filter selections using the last regular expression entered for CommandType::Search.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};
let act = SelectionAction::Filter(MatchAction::Keep);
let split: Action = action!("selection filter -F keep");
assert_eq!(split, act.into());Join
Join adjacent selections together.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};
let act: Action = SelectionAction::Join.into();
assert_eq!(act, action!("selection join"));Resize(SelectionResizeStyle, EditTarget)
Change the bounds of the current selection as described by the style and target.
If the context doesn’t specify a selection shape, then the selection will determine its shape from the EditTarget.
See the documentation for the SelectionResizeStyle variants for how to construct all of the possible values using action.
Split(SelectionSplitStyle, TargetShapeFilter)
Split matching selections into multiple selections line.
All of the new selections are of the same shape as the one they were split from.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};
let style = SelectionSplitStyle::Lines;
let split: Action = action!("selection split -s lines -F all");
assert_eq!(split, SelectionAction::Split(style, TargetShapeFilter::ALL).into());Trim(SelectionBoundary, TargetShapeFilter)
Shrink a selection by repositioning its cursor and anchor such that they are placed on the specified boundary.
Be aware that since this repositions the start and end of the selection, this may not do what you want with TargetShape::BlockWise selections.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, SelectionAction};
let style = SelectionBoundary::Line;
let split: Action = action!("selection trim -b line -t all");
assert_eq!(split, SelectionAction::Trim(style, TargetShapeFilter::ALL).into());Trait Implementations§
Source§impl Clone for SelectionAction
impl Clone for SelectionAction
Source§fn clone(&self) -> SelectionAction
fn clone(&self) -> SelectionAction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more