pub enum FocusChange {
Current,
Offset(Count, bool),
Position(MovePosition),
PreviouslyFocused,
Direction1D(MoveDir1D, Count, bool),
Direction2D(MoveDir2D, Count),
}Expand description
This represents what UI element is targeted during an Action.
Variants§
Current
Target the currently focused UI element.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, TabAction};
let fc = FocusChange::Current;
let act: Action = TabAction::Focus(fc).into();
assert_eq!(act, action!("tab focus -f current"));Offset(Count, bool)
Target the nth element from the beginning. The first element is numbered 1.
If the specified n is greater than the number of elements, and bool is true, target
the last element. Otherwise, do nothing.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, TabAction};
let fc = FocusChange::Offset(2.into(), false);
let act: Action = TabAction::Focus(fc).into();
assert_eq!(act, action!("tab focus -f (offset -c 2 -l false)"));Position(MovePosition)
Target the element at MovePosition in the element list.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, TabAction};
// All of these are equivalent:
let fc = FocusChange::Position(MovePosition::End);
let act: Action = TabAction::Focus(fc).into();
assert_eq!(act, action!("tab focus -f (pos -p end)"));
assert_eq!(act, action!("tab focus -f (position -p end)"));See the documentation for MovePosition for how to construct each of its variants with action.
PreviouslyFocused
Target the previously focused element.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, TabAction};
// All of these are equivalent:
let fc = FocusChange::PreviouslyFocused;
let act: Action = TabAction::Focus(fc).into();
assert_eq!(act, action!("tab focus -f previously-focused"));
assert_eq!(act, action!("tab focus -f previous"));
assert_eq!(act, action!("tab focus -f prev"));Direction1D(MoveDir1D, Count, bool)
Target the element n times away in MoveDir1D direction.
If moving n times would go past the first or last element, and bool is true, wrap
around to the other end of the element list and continue from there. Otherwise, do nothing.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, TabAction};
// All of these are equivalent:
let fc = FocusChange::Direction1D(MoveDir1D::Next, 4.into(), true);
let act: Action = TabAction::Focus(fc).into();
assert_eq!(act, action!("tab focus -f (dir1d -d next -c 4 -w true)"));Direction2D(MoveDir2D, Count)
Target the element n times away in MoveDir2D direction.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, TabAction};
// All of these are equivalent:
let fc = FocusChange::Direction2D(MoveDir2D::Up, 3.into());
let act: Action = TabAction::Focus(fc).into();
assert_eq!(act, action!("tab focus -f (dir2d -d up -c 3)"));Trait Implementations§
Source§impl Clone for FocusChange
impl Clone for FocusChange
Source§fn clone(&self) -> FocusChange
fn clone(&self) -> FocusChange
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more