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
//! `ratada`: a reusable ratatui widget toolkit.
//!
//! The toolkit owns the generic terminal, navigation, rendering and modal
//! building blocks over `ratatui`/`crossterm` (plus `unicode-width`,
//! `nucleo-matcher`, `chrono`, `log`) and never depends on any application
//! types. The [`theme`] layer supplies the framework-agnostic styling
//! vocabulary (a [`theme::Palette`], [`theme::Glyphs`] and [`theme::Mode`],
//! bundled into a [`theme::Skin`]); the host supplies lifecycle hooks (see
//! [`terminal::Tui::with_hooks`]). Theme colors are mapped to ratatui styles in
//! [`style`].
//!
//! # Example
//!
//! Implement [`Screen`] and hand it to [`run`], which owns the draw/input loop
//! inside a raw-mode [`Tui`] guard:
//!
//! ```no_run
//! use ratada::prelude::*;
//! use ratatui::{Frame, text::Line};
//! use crossterm::event::{KeyCode, KeyEvent};
//!
//! struct App {
//! count: u32,
//! }
//!
//! impl Screen for App {
//! type Error = std::io::Error;
//!
//! fn render(&self, frame: &mut Frame) {
//! frame.render_widget(Line::from(format!("count: {}", self.count)), frame.area());
//! }
//!
//! fn handle_key(&mut self, key: KeyEvent, _tui: &mut Tui) -> std::io::Result<Flow> {
//! match key.code {
//! KeyCode::Char('q') => Ok(Flow::Quit),
//! KeyCode::Char(' ') => {
//! self.count += 1;
//! Ok(Flow::Continue)
//! }
//! _ => Ok(Flow::Continue),
//! }
//! }
//! }
//!
//! let mut tui = Tui::new()?;
//! run(&mut tui, &mut App { count: 0 })?;
//! # Ok::<(), std::io::Error>(())
//! ```
// Terminal geometry mixes u16 (ratatui areas) and usize (indices/lengths); the
// conversions are bounded by the screen size, so these pedantic cast lints are
// allowed crate-wide rather than scattered per call.
// `#[must_use]` on every constructor/getter and a `# Errors` paragraph on every
// I/O wrapper add noise without catching real bugs; the meaningful public APIs
// already document their errors. Allowed crate-wide rather than per item.
pub use ;
pub use ModalSignal;
pub use ;
pub use ;
/// The common imports for building a TUI on `ratada`: the terminal guard, the
/// event-loop driver and the shared box decoration. Glob-import it with
/// `use ratada::prelude::*;`.