flywheel/widget/mod.rs
1//! Widget System: Composable UI components for terminal applications.
2//!
3//! This module provides a collection of widgets that implement the [`Widget`] trait,
4//! allowing them to be composed into complex layouts and rendered to the terminal.
5//!
6//! # Available Widgets
7//!
8//! - [`StreamWidget`] - Scrolling text viewport for streaming content (LLM output)
9//! - [`TextInput`] - Single-line text input with cursor
10//! - [`StatusBar`] - Three-section status bar (left, center, right)
11//! - [`ProgressBar`] - Horizontal progress indicator
12//!
13//! # Widget Trait
14//!
15//! All widgets implement the [`Widget`] trait, which provides:
16//! - `bounds()` / `set_bounds()` - Layout management
17//! - `render(&mut Buffer)` - Draw to the buffer
18//! - `handle_input(&InputEvent) -> bool` - Input handling
19//! - `needs_redraw()` / `clear_redraw()` - Dirty tracking
20//!
21//! # Example
22//!
23//! ```rust,ignore
24//! use flywheel::widget::{Widget, TextInput, StatusBar};
25//! use flywheel::Rect;
26//!
27//! let mut input = TextInput::new(Rect::new(0, 23, 80, 1));
28//! let mut status = StatusBar::new(Rect::new(0, 0, 80, 1));
29//!
30//! status.set_all("Flywheel", "v0.1.0", "60 FPS");
31//! input.set_content("Hello, world!");
32//!
33//! // Render both widgets
34//! input.render(buffer);
35//! status.render(buffer);
36//! ```
37
38mod traits;
39mod stream;
40mod scroll_buffer;
41mod text_input;
42mod status_bar;
43mod progress_bar;
44mod terminal;
45
46pub use traits::Widget;
47pub use stream::{StreamWidget, StreamConfig, AppendResult};
48pub use scroll_buffer::ScrollBuffer;
49pub use text_input::{TextInput, TextInputConfig};
50pub use status_bar::{StatusBar, StatusBarConfig};
51pub use progress_bar::{ProgressBar, ProgressBarConfig, ProgressStyle};
52pub use terminal::Terminal;
53