1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//! # Radical TUI - Terminal User Interface Framework
//!
//! A reactive terminal UI framework inspired by React's virtual DOM architecture.
//! Provides a declarative API for building interactive terminal applications.
//!
//! ## Architecture Overview
//!
//! ```text
//! ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
//! │ Elements │────▶│ Node │────▶│ VDom │
//! │ Factory │ │ Tree │ │ State │
//! └─────────────┘ └─────────────┘ └─────────────┘
//! │ │ │
//! │ │ │
//! ▼ ▼ ▼
//! ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
//! │ Style │ │ Diff │────▶│ Render │
//! │ System │ │ Engine │ │ Engine │
//! └─────────────┘ └─────────────┘ └─────────────┘
//! │
//! ▼
//! ┌─────────────┐
//! │ Terminal │
//! │ Output │
//! └─────────────┘
//! ```
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use termtui::{Elements, ElementBuilder, Text, Node, Color, Direction, Spacing};
//!
//! // Create UI elements using the Elements factory
//! let ui = Elements::div()
//! .background(Color::Blue)
//! .padding(Spacing::all(2))
//! .children(vec![
//! Text::new("Hello, TUI!").color(Color::White).into(),
//! Elements::div()
//! .direction(Direction::Horizontal)
//! .children(vec![
//! Text::new("Left").into(),
//! Text::new("Right").into(),
//! ])
//! .into(),
//! ])
//! .into();
//! ```
//!
//! ## Key Components
//!
//! - **Node**: Virtual representation of UI elements (Element trait objects or Text)
//! - **Elements**: Factory for creating concrete element types (Div, etc.)
//! - **Element**: Trait for element data access (props, children)
//! - **ElementBuilder**: Trait providing fluent builder API for elements
//! - **VDom**: Manages the virtual DOM state and updates
//! - **Diff**: Calculates minimal changes between UI states
//! - **Render**: Translates virtual nodes to terminal output
//! - **App**: Main application lifecycle and event loop
//! - **Model**: Type-safe init-view-update architecture for stateful models
//--------------------------------------------------------------------------------------------------
// Modules: Core Components
//--------------------------------------------------------------------------------------------------
/// Prelude module for convenient imports
/// New component-based system (parallel implementation)
/// Node types for component tree (includes div, text, rich_text)
/// Virtual node types for the VDOM
//--------------------------------------------------------------------------------------------------
// Modules: Rendering
//--------------------------------------------------------------------------------------------------
/// Virtual DOM implementation for managing the UI state.
/// Maintains the current UI tree and applies patches from the diff engine.
/// Diffing algorithm for efficiently updating the UI.
/// Compares old and new virtual DOM trees to generate minimal change patches.
/// Rendering engine that converts virtual nodes into terminal output.
/// Handles the actual drawing of elements to the screen.
/// Double buffering and cell-level diffing for flicker-free rendering.
/// Maintains screen state to enable precise, minimal updates.
/// Optimized terminal renderer for applying cell updates.
/// Minimizes escape sequences and I/O operations for best performance.
//--------------------------------------------------------------------------------------------------
// Modules: Application
//--------------------------------------------------------------------------------------------------
/// Application framework for building terminal UIs.
/// Provides the main application lifecycle and event handling.
//--------------------------------------------------------------------------------------------------
// Modules: Styling & Layout
//--------------------------------------------------------------------------------------------------
/// Styling system for terminal UI components.
/// Defines colors, spacing, borders, and other visual properties.
/// Bounds and rectangle operations for dirty region tracking.
/// Provides types for tracking screen regions that need redrawing.
//--------------------------------------------------------------------------------------------------
// Modules: Input & Utilities
//--------------------------------------------------------------------------------------------------
/// Key representation for keyboard input.
/// Provides an enum for representing both characters and special keys.
/// Utilities for terminal rendering, Unicode width calculations, and text wrapping.
/// Provides helpers for display width, text manipulation, and wrapping algorithms.
//--------------------------------------------------------------------------------------------------
// Modules: Macros
//--------------------------------------------------------------------------------------------------
/// Macro-based DSL for building TUI components
/// Provides ergonomic macros for composing components with less boilerplate
//--------------------------------------------------------------------------------------------------
// Modules: Components
//--------------------------------------------------------------------------------------------------
/// Reusable UI components for building forms and interfaces
/// Provides pre-built components like TextInput, Button, etc.
//--------------------------------------------------------------------------------------------------
// Exports
//--------------------------------------------------------------------------------------------------
// Re-export the derive macro with the same name
pub use Component as ComponentMacro;
pub use ;
pub use Rect;
pub use ;
pub use TextInput;
pub use ;
pub use Key;
pub use ;
pub use RenderNode;
pub use ;
pub use wrap_text;
pub use VDom;
pub use VNode;
//--------------------------------------------------------------------------------------------------
// Tests
//--------------------------------------------------------------------------------------------------