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;
32/// Responsible for rendering the UI to the terminal.
33pub mod renderer;
34/// Handles user input, non-blocking key events, and key code conversions with crossterm.
35pub mod input;
36/// Provides custom error types and a result type alias for error handling in `Feather-TUI`.
37pub mod error;
38
39mod util;
40
41// Shorten modules name.
42
43#[cfg(feature = "shorten_mod_name")]
44pub use components as cpn;
45
46#[cfg(feature = "shorten_mod_name")]
47pub use callback as cbk;
48
49#[cfg(feature = "shorten_mod_name")]
50pub use trigger as trg;
51
52#[cfg(feature = "shorten_mod_name")]
53pub use container as con;
54
55#[cfg(feature = "shorten_mod_name")]
56pub use renderer as ren;
57
58#[cfg(feature = "shorten_mod_name")]
59pub use input as inp;
60
61#[cfg(feature = "shorten_mod_name")]
62pub use error as err;
63
64// Reducing abstraction.
65
66#[cfg(feature = "reduce_abstraction")]
67pub use components::{Header, Option, Text, TextFlags, Separator, SeparatorStyle, Selector};
68
69#[cfg(feature = "reduce_abstraction")]
70pub use callback::Callback;
71
72#[cfg(feature = "reduce_abstraction")]
73pub use trigger::Trigger;
74
75#[cfg(feature = "reduce_abstraction")]
76pub use container::{Container, ContainerBuilder};
77
78#[cfg(feature = "reduce_abstraction")]
79pub use renderer::{ready, unready, Renderer};
80
81#[cfg(feature = "reduce_abstraction")]
82pub use input::{line, key, keycode_to_char, key_char};
83
84#[cfg(feature = "reduce_abstraction")]
85pub use error::{FtuiError, FtuiResult};