feather_tui/lib.rs
1//! Feather-Tui is a simple terminal UI library designed to provide building blocks
2//! for text-based user interfaces. It started life as a small C library in my
3//! school management system project, aiming to offer an easy-to-use UI framework
4//! for terminal applications. Now, I’m rewriting it in Rust to learn the language
5//! and (hopefully) improve both performance and maintainability.
6//!
7//! # Features
8//!
9//! - `shorten_mod_name` shortened aliases for common modules to reduce verbosity.
10//! - `components` → `cpn`
11//! - `callback` → `cbk`
12//! - `trigger` → `trg`
13//! - `container` → `con`
14//! - `renderer` → `ren`
15//! - `input` → `inp`
16//! - `error` → `err`
17//!
18//! - `reduce_abstraction` flattens module paths to make the API more direct.
19//! - `feather_tui::components::Header` → `feather_tui::Header`
20//! - `feather_tui::renderer::Renderer` → `feather_tui::Renderer`
21//! - `feather_tui::input::key_char` → `feather_tui::key_char
22//! - ...
23
24/// Core building blocks for constructing user interfaces.
25pub mod components;
26/// A generic callback handler for executing functions with stored arguments.
27pub mod callback;
28/// A generic trigger handler for evaluating conditions based on stored arguments.
29pub mod trigger;
30/// Acts as a layout manager for the UI elements.
31pub mod container;
32pub mod list;
33/// Responsible for rendering the UI to the terminal.
34pub mod renderer;
35/// Handles user input, non-blocking key events, and key code conversions with crossterm.
36pub mod input;
37/// Provides custom error types and a result type alias for error handling in `Feather-TUI`.
38pub mod error;
39
40mod util;
41
42// Shorten modules name.
43
44#[cfg(feature = "shorten_mod_name")]
45pub use components as cpn;
46
47#[cfg(feature = "shorten_mod_name")]
48pub use callback as cbk;
49
50#[cfg(feature = "shorten_mod_name")]
51pub use trigger as trg;
52
53#[cfg(feature = "shorten_mod_name")]
54pub use container as con;
55
56#[cfg(feature = "shorten_mod_name")]
57pub use renderer as ren;
58
59#[cfg(feature = "shorten_mod_name")]
60pub use input as inp;
61
62#[cfg(feature = "shorten_mod_name")]
63pub use error as err;
64
65// Reducing abstraction.
66
67#[cfg(feature = "reduce_abstraction")]
68pub use components::{Header, Option, Text, TextFlags, Separator, SeparatorStyle, Selector};
69
70#[cfg(feature = "reduce_abstraction")]
71pub use callback::Callback;
72
73#[cfg(feature = "reduce_abstraction")]
74pub use trigger::Trigger;
75
76#[cfg(feature = "reduce_abstraction")]
77pub use container::{Container, ContainerBuilder};
78
79#[cfg(feature = "reduce_abstraction")]
80pub use list::{List, ListBuilder};
81
82#[cfg(feature = "reduce_abstraction")]
83pub use renderer::{ready, unready, Renderer};
84
85#[cfg(feature = "reduce_abstraction")]
86pub use input::{line, key, keycode_to_char, key_char};
87
88#[cfg(feature = "reduce_abstraction")]
89pub use error::{FtuiError, FtuiResult};