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
//! Common patterns for TUI applications
//!
//! This module provides reusable patterns discovered while building multiple TUI apps
//! (jira-revue, jenkins-tui, sshfs-tui, todo-tui). These patterns follow Clean Code and
//! Single Responsibility Principle.
//!
//!
//! # Pattern Categories
//!
//! ## State Management Patterns
//!
//! | Pattern | Description | Use Case |
//! |---------|-------------|----------|
//! | [`MessageState`] | Auto-expiring messages | Toast notifications, status updates |
//! | [`ConfirmState`] | Confirmation dialogs | Destructive actions, confirmations |
//! | [`SearchState`] | Search/filter input | List filtering, query input |
//!
//! ## Async Patterns
//!
//! | Pattern | Description | Use Case |
//! |---------|-------------|----------|
//! | [`AsyncTask`] | Async polling with mpsc | API calls, file I/O, background work |
//! | [`ProgressiveLoader`] | Progressive data loading | Large datasets, pagination |
//!
//! ## Data Loading Patterns
//!
//! | Pattern | Description | Use Case |
//! |---------|-------------|----------|
//! | [`LazyData`] | On-demand data loading | Expensive computations, caching |
//! | [`LazySync`] | Synchronized lazy loading | Thread-safe lazy initialization |
//! | [`LazyReloadable`] | Reloadable data | Hot-reload, refreshable content |
//! | [`PagedData`] | Paginated data | Large lists, API pagination |
//!
//! ## Configuration Patterns
//!
//! | Pattern | Description | Use Case |
//! |---------|-------------|----------|
//! | [`AppConfig`] | TOML config loading | Application configuration |
//!
//! ## Interaction Patterns
//!
//! | Pattern | Description | Use Case |
//! |---------|-------------|----------|
//! | [`KeyHandler`] | Layered key handling | Modal UI, context-sensitive keys |
//! | [`FormState`] | Form field management | Multi-field input forms |
//! | [`NavigationState`] | Navigation stack | Breadcrumbs, route history |
//! | [`UndoStack`] | Generic undo/redo stack | Text editing, state history |
//!
//! ## UI Patterns
//!
//! | Pattern | Description | Use Case |
//! |---------|-------------|----------|
//! | [`colors`] | Color constants | Themed UIs |
//!
//! # Examples
//!
//! ## Message with Auto-Timeout
//!
//! ```ignore
//! use revue::patterns::MessageState;
//!
//! struct App {
//! message: MessageState,
//! }
//!
//! impl App {
//! fn show_status(&mut self, msg: String) {
//! self.message.set(msg); // Auto-clears after 3 seconds
//! }
//!
//! fn poll(&mut self) -> bool {
//! self.message.check_timeout() // Returns true if expired
//! }
//! }
//! ```
//!
//! ## Async Task with Spinner
//!
//! ```ignore
//! use revue::patterns::{AsyncTask, spinner_char};
//!
//! struct App {
//! task: Option<AsyncTask<Vec<Item>>>,
//! }
//!
//! impl App {
//! fn start_loading(&mut self) {
//! self.task = Some(AsyncTask::new(async {
//! // Expensive operation
//! fetch_items().await
//! }));
//! }
//!
//! fn poll(&mut self) -> bool {
//! if let Some(task) = &mut self.task {
//! match task.try_recv() {
//! Some(result) => {
//! self.items = result;
//! self.task = None;
//! true
//! }
//! None => {
//! // Show spinner
//! let frame = spinner_char();
//! self.draw_spinner(frame);
//! false
//! }
//! }
//! } else {
//! false
//! }
//! }
//! }
//! ```
//!
//! ## Form with Validation
//!
//! ```ignore
//! use revue::patterns::FormState;
//!
//! struct App {
//! form: FormState,
//! }
//!
//! impl App {
//! fn new() -> Self {
//! Self {
//! form: FormState::new()
//! .field("username", FieldType::Text)
//! .field("password", FieldType::Password)
//! .field("remember", FieldType::Checkbox),
//! }
//! }
//!
//! fn submit(&self) -> Result<(), Vec<ValidationError>> {
//! self.form.validate()
//! }
//! }
//! ```
// Re-export commonly used items
pub use ;
pub use *;
pub use ;
pub use ;
pub use ;
pub use ;
pub use MessageState;
pub use ;
pub use ;
pub use UndoStack;