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
//! # Pretext layout
//!
//! Two-phase text layout engine for terminal rendering, inspired by Cheng
//! Lou's [Pretext](https://github.com/chenglou/pretext) library for the
//! browser.
//!
//! ## Concept
//!
//! Measure text segments once using `unicode-width` and cache the results,
//! then compute line breaks and layout positions through pure arithmetic on
//! subsequent frames — no repeated measurement. This mirrors Pretext's
//! `prepare()` / `layout()` split, adapted for monospace terminal rendering.
//!
//! ## Targets
//!
//! - **Streaming AI output** — wrap positions are pre-computed before tokens
//! land, eliminating reflow stutter
//! - **Animated layouts** — text flows around moving ASCII shapes in real time
//! - **Masonry-style dashboards** — reflow cleanly as panel dimensions change
//!
//! ## Pairing with `PretextWidget`
//!
//! The [`crate::widgets::pretext::PretextWidget`] wraps this engine in a
//! ratatui [`StatefulWidget`](ratatui::widgets::StatefulWidget). Cache lives
//! on [`crate::widgets::pretext::PretextState`]; the widget itself is
//! zero-sized and cheap to construct each frame.
pub use ;
pub use ;
pub use PreparedText;
pub use ;
pub use ;