WindowAction

Enum WindowAction 

Source
#[non_exhaustive]
pub enum WindowAction<I: ApplicationInfo> { Close(WindowTarget, CloseFlags), Exchange(FocusChange), Focus(FocusChange), MoveSide(MoveDir2D), Open(OpenTarget<I::WindowId>, Axis, MoveDir1D, Count), Rotate(MoveDir1D), Split(OpenTarget<I::WindowId>, Axis, MoveDir1D, Count), Switch(OpenTarget<I::WindowId>), ClearSizes, Resize(FocusChange, Axis, SizeChange), Write(WindowTarget, Option<String>, WriteFlags), ZoomToggle, }
Expand description

Actions for manipulating application windows.

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

Close(WindowTarget, CloseFlags)

Close the WindowTarget windows with CloseFlags options.

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

let fc = WindowTarget::Single(FocusChange::Current);
let flags = CloseFlags::NONE;
let extract: Action = WindowAction::Close(fc, flags).into();
assert_eq!(extract, action!("window close -t (single current) -F none"));
§

Exchange(FocusChange)

Exchange the currently focused window with the window targeted by FocusChange.

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

let fc = FocusChange::PreviouslyFocused;
let act: Action = WindowAction::Exchange(fc).into();
assert_eq!(act, action!("window exchange -f previously-focused"));
§

Focus(FocusChange)

Change the current focus to the window targeted by FocusChange.

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

let fc = FocusChange::PreviouslyFocused;
let act: Action = WindowAction::Focus(fc).into();
assert_eq!(act, action!("window focus -f previously-focused"));
§

MoveSide(MoveDir2D)

Move the currently focused window to the MoveDir2D side of the screen.

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

let act: Action = WindowAction::MoveSide(MoveDir2D::Left).into();
assert_eq!(act, action!("window move-side -d left"));
§

Open(OpenTarget<I::WindowId>, Axis, MoveDir1D, Count)

Open a new window that is n columns along an axis, positioned relative to the current window as indicated by MoveDir1D.

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

let target = OpenTarget::Unnamed;
let axis = Axis::Horizontal;
let dir = MoveDir1D::Next;
let count = Count::Contextual;
let act: Action = WindowAction::Open(target, axis, dir, count).into();

// All of these are equivalent:
assert_eq!(act, action!("window open -t unnamed -x horizontal -d next -c ctx"));
assert_eq!(act, action!("window open -t unnamed -x horizontal -d next"));
§

Rotate(MoveDir1D)

Visually rotate the windows in MoveDir2D direction.

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

let act: Action = WindowAction::Rotate(MoveDir1D::Next).into();
assert_eq!(act, action!("window rotate -d next"));
§

Split(OpenTarget<I::WindowId>, Axis, MoveDir1D, Count)

Split the currently focused window n times along an axis, moving the focus in MoveDir1D direction after performing the split.

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

let target = OpenTarget::Current;
let axis = Axis::Vertical;
let dir = MoveDir1D::Next;
let count = Count::Contextual;
let act: Action = WindowAction::Split(target, axis, dir, count).into();

// All of these are equivalent:
assert_eq!(act, action!("window split -t current -x vertical -d next -c ctx"));
assert_eq!(act, action!("window split -t current -x vertical -d next"));
§

Switch(OpenTarget<I::WindowId>)

Switch what content the window is currently showing.

If there are no currently open windows in the tab, then this behaves like WindowAction::Open.

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

let target = OpenTarget::Offset(MoveDir1D::Next, 5.into());
let switch: Action = WindowAction::Switch(target).into();
assert_eq!(switch, action!("window switch -t (offset -d next -c 5)"));
§

ClearSizes

Clear all of the explicitly set window sizes, and instead try to equally distribute available rows and columns.

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

let act: Action = WindowAction::ClearSizes.into();
assert_eq!(act, action!("window clear-sizes"));
§

Resize(FocusChange, Axis, SizeChange)

Resize the window targeted by FocusChange according to SizeChange.

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

let size = SizeChange::Equal;
let act: Action = WindowAction::Resize(FocusChange::Current, Axis::Vertical, size).into();
assert_eq!(act, action!("window resize -f current -x vertical -z equal"));
§

Write(WindowTarget, Option<String>, WriteFlags)

Write the contents of the windows targeted by WindowTarget.

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

let target = WindowTarget::All;
let flags = WriteFlags::NONE;
let act: Action = WindowAction::Write(target, None, flags).into();
assert_eq!(act, action!("window write -t all -F none"));
§

ZoomToggle

Zoom in on the currently focused window so that it takes up the whole screen. If there is already a zoomed-in window, then return to showing all windows.

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

let act: Action = WindowAction::ZoomToggle.into();
assert_eq!(act, action!("window zoom-toggle"));

Trait Implementations§

Source§

impl<I: Clone + ApplicationInfo> Clone for WindowAction<I>
where I::WindowId: Clone,

Source§

fn clone(&self) -> WindowAction<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 WindowAction<I>
where I::WindowId: Debug,

Source§

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

Formats the value using the given formatter. Read more
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 WindowAction<I>
where I::WindowId: PartialEq,

Source§

fn eq(&self, other: &WindowAction<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 WindowAction<I>
where I::WindowId: Eq,

Source§

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

Auto Trait Implementations§

§

impl<I> Freeze for WindowAction<I>

§

impl<I> RefUnwindSafe for WindowAction<I>

§

impl<I> Send for WindowAction<I>

§

impl<I> Sync for WindowAction<I>
where <I as ApplicationInfo>::WindowId: Sync,

§

impl<I> Unpin for WindowAction<I>

§

impl<I> UnwindSafe for WindowAction<I>

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.