rustom 0.1.0

A library for building rich, stateful terminal user interfaces and dashboards.
Documentation
//! Built in widgets. Every widget implements [`Widget`], which consumes
//! `self` and draws into a region of a [`Buffer`](crate::buffer::Buffer).

mod barchart;
mod block;
mod gauge;
mod linegauge;
mod list;
mod paragraph;
mod scrollbar;
mod sparkline;
mod table;
mod tabs;

pub use barchart::{Bar, BarChart};
pub use block::{Block, BorderType, Borders};
pub use gauge::Gauge;
pub use linegauge::LineGauge;
pub use list::{List, ListItem, ListState};
pub use paragraph::{Paragraph, Wrap};
pub use scrollbar::{Scrollbar, ScrollbarOrientation, ScrollbarState};
pub use sparkline::Sparkline;
pub use table::{Cell as TableCell, Row, Table, TableState};
pub use tabs::Tabs;

use crate::buffer::Buffer;
use crate::layout::Rect;

/// A widget draws itself into a `Buffer` for a given `Rect`, consuming
/// itself in the process. Because rendering consumes `self`, widgets are
/// typically constructed fresh on every frame from application state,
/// rather than kept around and mutated.
pub trait Widget {
    fn render(self, area: Rect, buf: &mut Buffer);
}

/// A widget that also carries external, persistent state (such as a list's
/// current selection) which survives across frames.
pub trait StatefulWidget {
    type State;
    fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State);
}