aboutsummaryrefslogtreecommitdiff
path: root/helix-tui/src/widgets/mod.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-09 08:52:55 +0000
committerBlaž Hrastnik2021-05-09 08:52:55 +0000
commit35606a3daa7ee273845a12f3e03728e0ae23928e (patch)
tree643684eaff6627dbebc4156d33fdb541bf87bbd9 /helix-tui/src/widgets/mod.rs
parent6c705f09e88a4b63c4ed854bc9e956b0539ca8af (diff)
Inline tui as helix-tui fork.
We only rely on some of the rendering primitives and implement our Cursive-style compositor on top.
Diffstat (limited to 'helix-tui/src/widgets/mod.rs')
-rw-r--r--helix-tui/src/widgets/mod.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/helix-tui/src/widgets/mod.rs b/helix-tui/src/widgets/mod.rs
new file mode 100644
index 00000000..76eb73c1
--- /dev/null
+++ b/helix-tui/src/widgets/mod.rs
@@ -0,0 +1,53 @@
+//! `widgets` is a collection of types that implement [`Widget`] or [`StatefulWidget`] or both.
+//!
+//! All widgets are implemented using the builder pattern and are consumable objects. They are not
+//! meant to be stored but used as *commands* to draw common figures in the UI.
+//!
+//! The available widgets are:
+//! - [`Block`]
+//! - [`Tabs`]
+//! - [`List`]
+//! - [`Table`]
+//! - [`Paragraph`]
+//! - [`Clear`]
+
+mod block;
+mod clear;
+// mod list;
+mod paragraph;
+mod reflow;
+// mod table;
+
+pub use self::block::{Block, BorderType};
+pub use self::clear::Clear;
+// pub use self::list::{List, ListItem, ListState};
+pub use self::paragraph::{Paragraph, Wrap};
+// pub use self::table::{Cell, Row, Table, TableState};
+
+use crate::{buffer::Buffer, layout::Rect};
+use bitflags::bitflags;
+
+bitflags! {
+ /// Bitflags that can be composed to set the visible borders essentially on the block widget.
+ pub struct Borders: u32 {
+ /// Show no border (default)
+ const NONE = 0b0000_0001;
+ /// Show the top border
+ const TOP = 0b0000_0010;
+ /// Show the right border
+ const RIGHT = 0b0000_0100;
+ /// Show the bottom border
+ const BOTTOM = 0b000_1000;
+ /// Show the left border
+ const LEFT = 0b0001_0000;
+ /// Show all borders
+ const ALL = Self::TOP.bits | Self::RIGHT.bits | Self::BOTTOM.bits | Self::LEFT.bits;
+ }
+}
+
+/// Base requirements for a Widget
+pub trait Widget {
+ /// Draws the current state of the widget in the given buffer. That the only method required to
+ /// implement a custom widget.
+ fn render(self, area: Rect, buf: &mut Buffer);
+}