Split

Struct Split 

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

Splits the area in multiple parts and renders a UI that allows changing the sizes.

  • Can hide/show regions.
  • Resize
    • neighbours only
    • all regions
  • Horizontal / vertical split. Choose one.

The widget doesn’t hold references to the content widgets, instead it gives back the regions where the content can be rendered.

  1. Construct the Split.
  2. Call Split::into_widgets to create the actual widget and the layout of the regions.
  3. Render the content areas.
  4. Render the split widget last. There are options that will render above the widgets and use part of the content area.

Implementations§

Source§

impl<'a> Split<'a>

Source

pub fn new() -> Self

Create a new split.

To have any split-areas you must set a list of [constraints] for both the number and initial sizes of the areas.

Source

pub fn horizontal() -> Self

Horizontal split.

Source

pub fn vertical() -> Self

Vertical split

Source

pub fn constraints( self, constraints: impl IntoIterator<Item = Constraint>, ) -> Self

Set constraints for the initial area sizes. If the window is resized the current widths are used as constraints for recalculating.

The number of constraints determines the number of areas.

Source

pub fn resize_constraint(self, n: usize, constraint: ResizeConstraint) -> Self

Set the behaviour for each area when resizing the split-widget itself.

Source

pub fn direction(self, direction: Direction) -> Self

Layout direction of the widgets. Direction::Horizontal means the widgets are laid out left to right, with a vertical split area in between.

Source

pub fn split_type(self, split_type: SplitType) -> Self

Controls rendering of the splitter.

Source

pub fn resize(self, resize: SplitResize) -> Self

Controls resizing the split areas.

Source

pub fn join(self, border: BorderType) -> Self

Draw a join character between the split and the borders. This sets the border type used for the surrounding border.

Source

pub fn join_0(self, border: BorderType) -> Self

Draw a join character between the split and the border on the left/top side. This sets the border type used for the left/top border.

Source

pub fn join_1(self, border: BorderType) -> Self

Draw a join character between the split and the border on the right/bottom side. This sets the border type used for the right/bottom border.

Source

pub fn block(self, block: Block<'a>) -> Self

Outer block.

Source

pub fn styles(self, styles: SplitStyle) -> Self

Set all styles.

Source

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

Style for the split area.

Source

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

Style for the arrows.

Source

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

Style while dragging the splitter.

Source

pub fn mark_offset(self, offset: u16) -> Self

Offset for the split marker from the top/left.

Source

pub fn mark_0(self, mark: &'a str) -> Self

First marker char for the splitter.

Source

pub fn mark_1(self, mark: &'a str) -> Self

Second marker char for the splitter.

Source

pub fn into_widget(self, area: Rect, state: &mut SplitState) -> SplitWidget<'a>

👎Deprecated since 2.4.0: use into_widgets() instead

Constructs the widget for rendering.

Returns the SplitWidget that actually renders the split decorations.

Use SplitState::widget_areas to render your contents, and then render the SplitWidget. This allows it to render some decorations on top of your widgets.

Source

pub fn into_widget_layout( self, area: Rect, state: &mut SplitState, ) -> (SplitWidget<'a>, Vec<Rect>)

👎Deprecated since 2.4.0: use into_widgets() instead

Constructs the widgets for rendering.

Returns the SplitWidget that actually renders the split. Returns a Vec<Rect> with the regions for each split.

Render your content first, using the layout information. And the SplitWidget as last to allow rendering over the content widgets.

Source

pub fn into_widgets(self) -> (LayoutWidget<'a>, SplitWidget<'a>)

Constructs the widgets for rendering.

Returns the LayoutWidget that must run first. It doesn’t actually render anything, it just calculates the layout for the split regions.

Use the layout in SplitState::widget_areas to render your widgets.

The SplitWidget actually renders the split itself. Render it after you finished with the content.

Trait Implementations§

Source§

impl<'a> Clone for Split<'a>

Source§

fn clone(&self) -> Split<'a>

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<'a> Debug for Split<'a>

Source§

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

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

impl<'a> Default for Split<'a>

Source§

fn default() -> Split<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> StatefulWidget for &Split<'a>

Source§

type State = SplitState

State associated with the stateful widget. Read more
Source§

fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom stateful widget.
Source§

impl<'a> StatefulWidget for Split<'a>

Source§

type State = SplitState

State associated with the stateful widget. Read more
Source§

fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom stateful widget.

Auto Trait Implementations§

§

impl<'a> Freeze for Split<'a>

§

impl<'a> RefUnwindSafe for Split<'a>

§

impl<'a> Send for Split<'a>

§

impl<'a> Sync for Split<'a>

§

impl<'a> Unpin for Split<'a>

§

impl<'a> UnwindSafe for Split<'a>

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.