pub struct Panel { /* private fields */ }Expand description
A bordered panel for wrapping content blocks with title/footer chrome.
For borderless stacking with cursor tracking, use Layout.
§Example
use tui::{Panel, Line, ViewContext};
let mut panel = Panel::new(tui::Color::Grey)
.title(" Settings ")
.footer("[Enter] Save [Esc] Cancel")
.gap(1);
panel.push(vec![Line::new("Name: Example")]);
panel.push(vec![Line::new("Value: 42")]);
let ctx = ViewContext::new((40, 20));
let lines = panel.render(&ctx);Implementations§
Source§impl Panel
impl Panel
pub fn new(border_color: Color) -> Self
pub fn title(self, title: impl Into<String>) -> Self
pub fn fill_height(self, h: usize) -> Self
pub fn gap(self, lines: usize) -> Self
pub fn push(&mut self, block: Vec<Line>)
Sourcepub fn inner_width(total_width: u16) -> u16
pub fn inner_width(total_width: u16) -> u16
Inner content width when borders are active.
Sourcepub fn render(&self, context: &ViewContext) -> Vec<Line>
pub fn render(&self, context: &ViewContext) -> Vec<Line>
Render blocks with borders/chrome.
Auto Trait Implementations§
impl Freeze for Panel
impl RefUnwindSafe for Panel
impl Send for Panel
impl Sync for Panel
impl Unpin for Panel
impl UnsafeUnpin for Panel
impl UnwindSafe for Panel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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