Skip to main content

eddacraft_tui/
lib.rs

1//! # eddacraft-tui
2//!
3//! Shared Ratatui component library for the `eddacraft` product family.
4//!
5//! Provides a consistent set of terminal UI building blocks — themed widgets,
6//! keyboard handling, shell chrome, and a surface abstraction — so that every
7//! `eddacraft` TUI application shares the same look and feel.
8//!
9//! ## Quick start
10//!
11//! ```rust,no_run
12//! use eddacraft_tui::prelude::*;
13//!
14//! let theme = EddaCraftTheme;
15//! // Use any widget with the theme:
16//! // let spinner = Spinner::new(&theme).eddacraft().label("Loading...");
17//! // render_shell(frame, area, ShellBranding::Anvil, "anvil", "Watch", "[q] quit", &theme, env!("CARGO_PKG_VERSION"));
18//! ```
19//!
20//! ## Modules
21//!
22//! | Module | Purpose |
23//! |--------|---------|
24//! | [`widgets`] | A growing suite of reusable Ratatui widgets (select, text input, progress, data table, tree, modal, toast, overlay, etc.) |
25//! | [`animation`] | Lightweight shims over the internal animation runtime |
26//! | [`pretext`] | Two-phase prepare/layout text engine — measure once, lay out cheaply |
27//! | [`theme`] | `Theme` trait + `EddaCraftTheme` implementation |
28//! | [`keyboard`] | `KeyHandler` mapping crossterm events to semantic `Action`s |
29//! | [`surface`] | `Surface` trait for multi-screen TUI applications |
30//! | [`shell`] | Branded header/footer chrome renderer |
31//! | [`compat`] | Terminal detection and minimum-size validation |
32//! | `test_utils` (feature `test-utils`) | Snapshot testing helpers for style-aware buffer serialisation |
33
34#![cfg_attr(docsrs, feature(doc_cfg))]
35
36pub mod animation;
37pub mod compat;
38pub mod keyboard;
39pub mod pretext;
40pub mod shell;
41pub mod surface;
42#[cfg(any(test, feature = "test-utils"))]
43pub mod test_utils;
44pub mod theme;
45pub mod widgets;
46
47pub mod prelude {
48    // Animation shim is owned by this crate so the underlying engine can be
49    // swapped without breaking the prelude API.
50    pub use crate::animation::{animate_tick, is_animating};
51    pub use crate::compat::{TerminalInfo, detect_terminal, validate_minimum_size};
52    pub use crate::keyboard::{Action, Binding, KeyHandler};
53    pub use crate::pretext::{ExclusionZone, LayoutResult, PositionedWord, PreparedText};
54    pub use crate::shell::{ShellBranding, render_shell};
55    pub use crate::surface::Surface;
56    pub use crate::theme::{EddaCraftTheme, Role, Theme};
57    pub use crate::widgets::confirm::{Confirm, ConfirmState};
58    pub use crate::widgets::container::{Container, ContainerVariant};
59    pub use crate::widgets::data_table::{DataTable, DataTableState, SortDirection, SortIndicator};
60    pub use crate::widgets::divider::{Divider, DividerVariant};
61    pub use crate::widgets::editor::{Editor, EditorState};
62    pub use crate::widgets::header::Header;
63    pub use crate::widgets::help_bar::HelpBar;
64    pub use crate::widgets::log_panel::{LogEntry, LogFilter, LogLevel, LogPanel, LogPanelState};
65    pub use crate::widgets::modal::Modal;
66    pub use crate::widgets::overlay::{Layer, OverlayStack, Placement};
67    pub use crate::widgets::parallel_progress::{
68        CheckProgress, CheckStatus, ParallelProgress, ParallelProgressState,
69    };
70    pub use crate::widgets::pretext::{PretextState, PretextWidget};
71    pub use crate::widgets::progress_bar::{ProgressBar, ProgressBarState};
72    pub use crate::widgets::select::{Select, SelectItem, SelectState};
73    pub use crate::widgets::spinner::{Spinner, SpinnerPreset, SpinnerState, anvil, eddacraft};
74    pub use crate::widgets::status_badge::{BadgeStatus, StatusBadge};
75    pub use crate::widgets::status_bar::StatusBar;
76    pub use crate::widgets::text_input::{TextInput, TextInputState};
77    pub use crate::widgets::toast::{Toast, ToastPlacement, ToastStack};
78    pub use crate::widgets::tree::{Tree, TreeNode, TreeState};
79    pub use crate::widgets::wrappers::{Disableable, Hideable, Padded};
80
81    #[cfg(feature = "big-text")]
82    #[cfg_attr(docsrs, doc(cfg(feature = "big-text")))]
83    pub use crate::widgets::big_banner::BigBanner;
84    #[cfg(feature = "image")]
85    #[cfg_attr(docsrs, doc(cfg(feature = "image")))]
86    pub use crate::widgets::image_pane::ImagePane;
87}