pub struct Tree { /* private fields */ }Expand description
A tree of windows, with one of them focused.
Implementations§
Source§impl Tree
impl Tree
pub fn new(view: ViewId) -> Self
pub fn focused(&self) -> ViewId
Sourcepub fn focus_view(&mut self, view: ViewId) -> bool
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.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn split(&mut self, axis: Axis, view: ViewId)
pub fn split(&mut self, axis: Axis, view: ViewId)
Split the focused window, and focus the new one, as vim does.
Sourcepub fn close(&mut self) -> bool
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.
Sourcepub fn focus_direction(&mut self, dir: Direction, area: Rect) -> bool
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.
Sourcepub fn resize(&mut self, dir: Direction, delta: i32) -> bool
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.