Skip to main content

a3s_tui/
lib.rs

1//! A3S TUI - TEA (The Elm Architecture) framework for terminal user interfaces.
2//!
3//! This library provides a declarative way to build terminal applications using
4//! The Elm Architecture pattern, with Flexbox layout powered by Taffy and
5//! incremental rendering for optimal performance.
6//!
7//! # Quick Start
8//!
9//! ```rust,no_run
10//! use a3s_tui::{cmd, col, text, Element, ElementModel, ElementProgramBuilder};
11//! use a3s_tui::{Event, KeyCode, TextElement};
12//! use a3s_tui::style::Color;
13//!
14//! struct Counter { count: i64 }
15//!
16//! enum Msg {
17//!     Increment,
18//!     Decrement,
19//!     Quit,
20//! }
21//!
22//! impl From<Event> for Msg {
23//!     fn from(event: Event) -> Self {
24//!         match event {
25//!             Event::Key(key) if key.code == KeyCode::Up => Msg::Increment,
26//!             Event::Key(key) if key.code == KeyCode::Down => Msg::Decrement,
27//!             Event::Key(key) if key.code == KeyCode::Char('q') => Msg::Quit,
28//!             _ => Msg::Increment,
29//!         }
30//!     }
31//! }
32//!
33//! impl ElementModel for Counter {
34//!     type Msg = Msg;
35//!
36//!     fn update(&mut self, msg: Msg) -> Option<cmd::Cmd<Msg>> {
37//!         match msg {
38//!             Msg::Increment => { self.count += 1; None }
39//!             Msg::Decrement => { self.count -= 1; None }
40//!             Msg::Quit => Some(cmd::quit()),
41//!         }
42//!     }
43//!
44//!     fn view(&self) -> Element<Msg> {
45//!         col![
46//!             text!(""),
47//!             Element::Text(
48//!                 TextElement::new(format!("Counter: {}", self.count))
49//!                     .bold()
50//!                     .fg(Color::Cyan)
51//!             ),
52//!         ]
53//!     }
54//! }
55//!
56//! #[tokio::main]
57//! async fn main() -> std::io::Result<()> {
58//!     ElementProgramBuilder::new(Counter { count: 0 })
59//!         .with_alt_screen()
60//!         .with_fps(30)
61//!         .run()
62//!         .await
63//! }
64//! ```
65
66pub mod chrome;
67pub mod cmd;
68pub mod components;
69pub mod diff;
70pub mod element;
71pub mod element_program;
72pub mod event;
73pub mod focus;
74pub mod grid;
75pub mod input;
76pub mod interaction;
77pub mod key;
78pub mod keymap;
79pub mod layout;
80pub mod layout_engine;
81#[macro_use]
82pub mod macros;
83pub mod animation;
84#[cfg(feature = "markdown")]
85pub mod markdown;
86pub mod model;
87pub mod paint;
88pub mod prelude;
89pub mod program;
90pub mod renderer;
91#[cfg(feature = "markdown")]
92pub mod streaming;
93pub mod style;
94pub mod terminal;
95pub mod terminal_profile;
96pub mod theme;
97
98pub use animation::{Easing, FrameAnimation, Transition};
99pub use chrome::AgentChrome;
100pub use cmd::Cmd;
101pub use element::{
102    AlignItems, BorderStyle, BoxElement, BoxStyle, Dimension, Edges, Element, FlexDirection,
103    JustifyContent, Overflow, TextElement, TextStyle, TextWrap,
104};
105pub use element_program::{ElementProgram, ElementProgramBuilder};
106pub use event::{Event, KeyEvent, MouseEvent};
107pub use focus::{FocusId, FocusManager};
108pub use grid::{Cell, CellStyle, Grid};
109pub use input::{
110    InputCapture, InputCaptureMode, InputHelpEntry, InputRoute, InputRouter, InputScope,
111    RoutedInput,
112};
113pub use key::{KeyCode, KeyModifiers};
114pub use keymap::{KeyBinding, Keymap};
115pub use layout::{Constraint, Direction, Layout};
116pub use model::{ElementModel, Model};
117pub use program::{Program, ProgramBuilder};
118pub use style::{Align, Border, Color, Style};
119pub use terminal_profile::{
120    TerminalColorLevel, TerminalDisplayMode, TerminalFamily, TerminalMultiplexer, TerminalProfile,
121    TerminalSupport,
122};
123pub use theme::Theme;