FocusChange

Enum FocusChange 

Source
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

Source§

fn clone(&self) -> FocusChange

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 Debug for FocusChange

Source§

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

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

impl PartialEq for FocusChange

Source§

fn eq(&self, other: &FocusChange) -> 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 Eq for FocusChange

Source§

impl StructuralPartialEq for FocusChange

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.