Skip to main content

Tree

Struct Tree 

Source
pub struct Tree { /* private fields */ }
Expand description

A tree of windows, with one of them focused.

Implementations§

Source§

impl Tree

Source

pub fn new(view: ViewId) -> Self

Source

pub fn focused(&self) -> ViewId

Source

pub fn focus_view(&mut self, view: ViewId) -> bool

Focus a named window, wherever it sits in the tree. false if it is not in this one.

Distinct from Tree::focus_direction, which asks “what is to the left of here” and needs a geometry to answer. A picker already knows exactly which window it means, so making it aim with direction keys would be the picker’s whole point thrown away.

Source

pub fn views(&self) -> Vec<ViewId>

Every view in the tree, left to right, top to bottom.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn split(&mut self, axis: Axis, view: ViewId)

Split the focused window, and focus the new one, as vim does.

Source

pub fn close(&mut self) -> bool

Close the focused window. Returns false when it is the only one, since a tab with no windows has nothing to draw.

Source

pub fn focus_direction(&mut self, dir: Direction, area: Rect) -> bool

Move focus geometrically, the way <C-w>hjkl does.

Geometric rather than tree-structural: the window to the right is the one that looks to the right, which is not always a sibling. Candidates must overlap this window across the direction’s axis, so pressing <C-w>j in a tall left-hand pane does not jump to something in a different column that happens to sit lower.

Returns false when there is nothing that way.

Source

pub fn resize(&mut self, dir: Direction, delta: i32) -> bool

Grow or shrink the focused window along dir by cells worth of weight.

Applied to the nearest ancestor that actually splits on that axis: asking a side-by-side split to get taller is meaningless, and silently doing nothing there would look like a broken key.

Source

pub fn equalize(&mut self)

Give every window in every split the same share, as <C-w>= does.

Source

pub fn layout(&self, area: Rect) -> Vec<Pane>

Where everything goes, given the space available.

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Tree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tree

Source§

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

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

impl Eq for Tree

Source§

impl PartialEq for Tree

Source§

fn eq(&self, other: &Tree) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Tree

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnsafeUnpin for Tree

§

impl UnwindSafe for Tree

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.