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
//! Cell-diff renderer and terminal byte planner.
//!
//! The renderer turns a desired [`RenderBuffer`] into the shortest safe
//! sequence of terminal bytes it can produce for the configured
//! [`Optimizations`]. Most applications use it through
//! [`crate::screen::Screen`]; direct access is useful for lower-level
//! integrations and renderer-focused tests.
//!
//! ## Diff pipeline
//!
//! The renderer keeps a tracked current buffer (`cur_buf`) representing
//! what it believes is on the terminal. The buffer flow first syncs
//! touched desired cells into the renderer-owned staging buffer
//! (`back_buf`), filtering unchanged cells. Rendering then prepares the
//! frame, optionally applies scroll optimizations, transforms touched
//! rows, and finalizes the pen/cursor state.
//!
//! ```text
//! desired cells ─▶ sync_front ─▶ back_buf (actual changes)
//! │
//! ▼
//! cur_buf (tracked screen) ─────▶ row diff / scroll diff
//! │
//! ▼
//! cursor + pen planners ─▶ escape bytes
//! │
//! ▼
//! cur_buf updated to match terminal
//! ```
//!
//! ## Cursor movement planning
//!
//! Cursor movement is planned by byte cost before any bytes are
//! materialized. Absolute mode seeds CUP and, for local moves, lets
//! relative decompositions compete. Relative mode considers optional
//! prefixes (`none`, carriage return, and in absolute mode home), then
//! vertical and horizontal legs. Horizontal planning can use hardware
//! tabs, CHT/CBT, CUF/CUB, literal backspace, or re-emitting matching
//! cells as an overwrite advance. Forward tabs use the terminal's true
//! next tab stop, not a right-edge-clamped value, so a tab is never
//! chosen unless it lands at or before the target column.
//!
//! ```text
//! from ─▶ prefix? ─▶ vertical leg ─▶ horizontal leg ─▶ to
//! │ │ │
//! │ │ ├─ CUF/CUB, BS, tabs, CHT/CBT
//! │ └─ LF/CUD/CUU/RI/VPA
//! └─ none / CR / HOME (when eligible)
//! ```
//!
//! ## Pen and SGR state
//!
//! The renderer tracks the active style ("pen") alongside cursor
//! position. Before emitting a cell it writes only the style difference
//! needed from the current pen to the target cell style, including OSC 8
//! hyperlink open/close transitions. At frame end the pen is reset to
//! default only if the terminal state is not already default.
//!
//! ## Tab stops
//!
//! `TabStops` stores configurable horizontal tab stops and
//! precomputes previous, clamped-next, and unclamped-next lookup tables.
//! The unclamped next stop models the column a terminal tab would really
//! reach beyond the surface edge; cursor planning depends on that to
//! avoid over-counting forward tab moves near the right margin.
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub use RenderBuffer;
pub use Optimizations;
pub use Renderer;