Skip to main content

Split

Struct Split 

Source
pub struct Split<'a, M> { /* private fields */ }
Expand description

Two children side by side (Split::horizontal) or one above the other (Split::vertical), with a border between them. The border drags with the mouse (#476’s preview border, generalised, #479) and moves with Alt+H/Alt+L (side by side) or Alt+K/Alt+J (stacked); each pane keeps its minimum size. Tab moves focus between the panes.

Implementations§

Source§

impl<'a, M> Split<'a, M>

Source

pub fn horizontal( left: impl Component<Output = M> + 'a, right: impl Component<Output = M> + 'a, ) -> Split<'a, M>

left and right, side by side.

Source

pub fn vertical( top: impl Component<Output = M> + 'a, bottom: impl Component<Output = M> + 'a, ) -> Split<'a, M>

top above bottom. The split takes the whole height.

Source

pub fn ratio(self, percent: u8) -> Self

The first pane’s share, in percent, until the border is moved (default 50).

Source

pub fn at(self, cells: usize) -> Self

Put the border after cells of the first pane, until moved.

Source

pub fn min(self, cells: usize) -> Self

Both panes at least cells along the axis (default 1).

Source

pub fn mins(self, first: usize, second: usize) -> Self

The first pane at least first cells and the second at least second.

Source

pub fn style(self, style: Style) -> Self

The border’s style (default: the theme’s, dim).

Source

pub fn on( self, action: &str, keys: impl IntoIterator<Item = Key>, description: &str, handler: impl FnMut() -> Flow<M> + 'a, ) -> Self

Run handler when one of keys bubbles up unused by the focused child: an action of yours, listed in the keymap under this container’s context.

Source

pub fn shortcut( self, action: &str, keys: impl IntoIterator<Item = Key>, description: &str, handler: impl FnMut() -> Flow<M> + 'a, ) -> Self

Run handler when one of keys is pressed, before the focused child sees it.

Source

pub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self

Make keys do this container’s action (focus-next, and the container’s own); no keys unbinds it.

Source

pub fn own_keymap(&self) -> &Keymap

This container’s own bindings, without its children’s.

Source

pub fn with_mouse(self, on: bool) -> Self

Report the mouse even when no child asks for it: for a click to focus a child, or a border to drag.

Source

pub fn axis(&self) -> Axis

Source

pub fn divider(&self) -> &Divider

The border: where it is, whether it is being dragged.

Source

pub fn first(&self) -> &(dyn Component<Output = M> + 'a)

Source

pub fn second(&self) -> &(dyn Component<Output = M> + 'a)

Source

pub fn first_mut(&mut self) -> &mut (dyn Component<Output = M> + 'a)

Source

pub fn second_mut(&mut self) -> &mut (dyn Component<Output = M> + 'a)

Source

pub fn focused(&self) -> Option<usize>

The focused pane: 0 or 1.

Source

pub fn focus(&mut self, index: usize) -> bool

Focus pane index (0 or 1), if it takes focus.

Source

pub fn layout(&self, context: &Context<'_>) -> [Rect; 2]

The two panes’ rectangles at context’s size.

Trait Implementations§

Source§

impl<M> Component for Split<'_, M>

Source§

type Output = M

Source§

fn start(&mut self, context: &Context<'_>) -> Flow<M>

Called once, before the component is first painted, with the terminal’s size: for work that needs it, such as rendering content at the width. Returning Done or Cancel finishes the component without waiting for an event. The default does nothing.
Source§

fn handle(&mut self, event: &Event, context: &Context<'_>) -> Flow<M>

Handle one event. Ctrl+C never arrives here: the event loop ends the component with Outcome::Interrupted.
Source§

fn render(&self, context: &Context<'_>) -> View

Render the current state.
Source§

fn tick(&self) -> Option<Duration>

How often the component wants Event::Tick, for a spinner or a countdown. None (the default): never.
Source§

fn mouse(&self) -> bool

Whether the component wants mouse events (#476): clicks, drags and the wheel. Off by default, since reporting the mouse takes text selection away from the terminal; a component turns it on when its caller opts in, and run then enables mouse reporting for the session.
Source§

fn keymap(&self) -> Keymap

The bindings this component has right now, for a help overlay, a shortcut list or status-bar hints to read (see keymap). A container’s include its focused child’s, before its own. The default declares none.
Source§

fn focusable(&self) -> bool

Whether the component takes focus in a container: Tab stops on it and keys go to it. The default: yes. A label, or a component that has finished, says no.
Source§

fn focus_step(&mut self, forward: bool) -> bool

Move focus to the next (forward) or previous focus stop inside this component, for Tab and Shift+Tab. false when there is none after the current one, so the container moves on to its next child. The default, for a component that is one stop: false.
Source§

fn focus_enter(&mut self, forward: bool) -> bool

Take focus from outside: at the first stop inside when forward, at the last otherwise. false when nothing in it can take focus. The default: whether the component is focusable.
Source§

fn default_value(&self) -> Option<Self::Output>

The value to return when the terminal is not interactive and the policy asks for defaults. None: there is none.
Source§

fn prompt( &mut self, io: &mut dyn LineIo, ) -> Result<Option<Self::Output>, NotInteractive>

Ask for the value line by line, for when the terminal is not interactive and the policy asks for a prompt. The default says the component has no line-based form. Read more

Auto Trait Implementations§

§

impl<'a, M> !RefUnwindSafe for Split<'a, M>

§

impl<'a, M> !Send for Split<'a, M>

§

impl<'a, M> !Sync for Split<'a, M>

§

impl<'a, M> !UnwindSafe for Split<'a, M>

§

impl<'a, M> Freeze for Split<'a, M>
where Group<'a, M>: Freeze, Bindings<'a, M>: Freeze,

§

impl<'a, M> Unpin for Split<'a, M>
where Group<'a, M>: Unpin, Bindings<'a, M>: Unpin,

§

impl<'a, M> UnsafeUnpin for Split<'a, M>
where Group<'a, M>: UnsafeUnpin, Bindings<'a, M>: UnsafeUnpin,

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<C> ComponentExt for C
where C: Component,

Source§

fn map<'a, M>( self, done: impl FnMut(Self::Output) -> Flow<M> + 'a, ) -> Map<'a, Self, M>
where Self: 'a,

Turn this component’s answer into M’s flow: Flow::Done(m) to finish the whole composition with m, Flow::Continue to carry on (the component stays, showing its answer, and focus moves past it). Cancelling cancels the composition unless on_cancel says otherwise.
Source§

fn with_overlays<'a>(self) -> Overlays<'a, Self::Output>
where Self: 'a, Self::Output: 'a,

Wrap this component in Overlays: a command palette, help and a shortcut sheet read from its keymap, and room for a status bar and breadcrumbs.
Source§

fn boxed<'a>(self) -> Child<'a, Self::Output>
where Self: 'a,

Box this component as a Child.
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, 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.