tui_popup

Struct Popup

Source
#[non_exhaustive]
pub struct Popup<'content, W: SizedWidgetRef> { pub body: W, pub title: Line<'content>, pub style: Style, pub borders: Borders, pub border_set: Set, pub border_style: Style, }
Expand description

Configuration for a popup.

This struct is used to configure a Popup. It can be created using Popup::new.

§Example

use ratatui::{prelude::*, symbols::border};
use tui_popup::Popup;

fn render_popup(frame: &mut Frame) {
    let popup = Popup::new("Press any key to exit")
        .title("tui-popup demo")
        .style(Style::new().white().on_blue())
        .border_set(border::ROUNDED)
        .border_style(Style::new().bold());
    frame.render_widget(&popup, frame.size());
}

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§body: W

The body of the popup.

§title: Line<'content>

The title of the popup.

§style: Style

The style to apply to the entire popup.

§borders: Borders

The borders of the popup.

§border_set: Set

The symbols used to render the border.

§border_style: Style

Border style

Implementations§

Source§

impl<'content, W: SizedWidgetRef> Popup<'content, W>

Source

pub fn title(self, value: impl Into<Line<'content>>) -> Self

Sets the title field of this struct.

Source

pub fn style(self, value: impl Into<Style>) -> Self

Sets the style field of this struct.

Source

pub fn borders(self, value: impl Into<Borders>) -> Self

Sets the borders field of this struct.

Source

pub fn border_set(self, value: impl Into<Set>) -> Self

Sets the border_set field of this struct.

Source

pub fn border_style(self, value: impl Into<Style>) -> Self

Sets the border_style field of this struct.

Source§

impl<'content, W: SizedWidgetRef> Popup<'content, W>

Source

pub fn new(body: W) -> Self

Create a new popup with the given title and body with all the borders.

§Parameters
  • body - The body of the popup. This can be any type that can be converted into a Text.
§Example
use tui_popup::Popup;

let popup = Popup::new("Press any key to exit").title("tui-popup demo");

Trait Implementations§

Source§

impl<'content, W: Debug + SizedWidgetRef> Debug for Popup<'content, W>

Source§

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

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

impl<W: SizedWidgetRef> StatefulWidgetRef for Popup<'_, W>

Source§

type State = PopupState

State associated with the stateful widget. Read more
Source§

fn render_ref(&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<W: SizedWidgetRef> WidgetRef for Popup<'_, W>

Source§

fn render_ref(&self, area: Rect, buf: &mut Buffer)

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

Auto Trait Implementations§

§

impl<'content, W> Freeze for Popup<'content, W>
where W: Freeze,

§

impl<'content, W> RefUnwindSafe for Popup<'content, W>
where W: RefUnwindSafe,

§

impl<'content, W> Send for Popup<'content, W>
where W: Send,

§

impl<'content, W> Sync for Popup<'content, W>
where W: Sync,

§

impl<'content, W> Unpin for Popup<'content, W>
where W: Unpin,

§

impl<'content, W> UnwindSafe for Popup<'content, W>
where W: UnwindSafe,

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