on 2158366 help sign in
51 lines 1.6 kB history raw
1//! `widgets` is a collection of types that implement [`Widget`].
2//!
3//! All widgets are implemented using the builder pattern and are consumable objects. They are not
4//! meant to be stored but used as *commands* to draw common figures in the UI.
5//!
6//! The available widgets are:
7//! - [`Block`]
8// //! - [`List`]
9// //! - [`Table`]
10//! - [`Paragraph`]
12mod block;
13// mod list;
14mod paragraph;
15mod reflow;
16mod table;
18pub use self::block::{Block, BorderType};
19// pub use self::list::{List, ListItem, ListState};
20pub use self::paragraph::{Paragraph, Wrap};
21pub use self::table::{Cell, Row, Table, TableState};
23use crate::buffer::Buffer;
24use bitflags::bitflags;
26use helix_view::graphics::Rect;
28bitflags! {
29 /// Bitflags that can be composed to set the visible borders essentially on the block widget.
30 pub struct Borders: u32 {
31 /// Show no border (default)
32 const NONE = 0b0000_0001;
33 /// Show the top border
34 const TOP = 0b0000_0010;
35 /// Show the right border
36 const RIGHT = 0b0000_0100;
37 /// Show the bottom border
38 const BOTTOM = 0b000_1000;
39 /// Show the left border
40 const LEFT = 0b0001_0000;
41 /// Show all borders
42 const ALL = Self::TOP.bits | Self::RIGHT.bits | Self::BOTTOM.bits | Self::LEFT.bits;
43 }
46/// Base requirements for a Widget
47pub trait Widget {
48 /// Draws the current state of the widget in the given buffer. That the only method required to
49 /// implement a custom widget.
50 fn render(self, area: Rect, buf: &mut Buffer);