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
// Copyright (c) 2022-2025 R3BL LLC. Licensed under Apache License, Version 2.0.
//! Render operations type system for the TUI rendering pipeline.
//!
//! # You Are Here: **Type System Module** (Cross-Stage)
//!
//! This module defines the **core data types** that flow through all stages of the
//! rendering pipeline. These types are the "lingua franca" that all stages speak.
//!
//! ```text
//! render_op module ← YOU ARE HERE
//! (Defines RenderOpIR, RenderOpOutput, RenderOpCommon)
//! ```
//!
//! **Input**: Component code produces [`RenderOpIR`] operations
//! **Output**: These types are consumed by all downstream stages
//! **Role**: Define the contract between all layers
//!
//! <div class="warning">
//!
//! **For the complete 6-stage rendering pipeline with visual diagrams and stage
//! reference table**, see the [rendering pipeline overview].
//!
//! </div>
//!
//! [rendering pipeline overview]: mod@crate::terminal_lib_backends#rendering-pipeline-architecture
//!
//! ## What This Module Provides
//!
//! This module provides a type-safe, two-stage rendering system that separates
//! high-level component operations (IR) from low-level terminal operations (Output):
//!
//! - **[`RenderOpIR`]** - Operations with built-in clipping info (used by components)
//! - **[`RenderOpOutput`]** - Post-clipping operations (used by backend)
//! - **[`RenderOpCommon`]** - 27 shared operations available in both contexts
//! - **[`RenderOpsLocalData`]** - Optimization state to avoid redundant terminal commands
//! - **[`RenderOpCommonExt`]** - Ergonomic helper trait for creating common operations
//!
//! # Type Safety Benefits
//!
//! The split between [`RenderOpIR`] and [`RenderOpOutput`] provides compile-time
//! guarantees:
//!
//! - **Component code** uses [`RenderOpIR`] with clipping-aware operations
//! - **Backend code** uses [`RenderOpOutput`] with post-clipping operations
//! - **Impossible to mix** IR and Output operations incorrectly
//!
//! # Module Organization
//!
//! This module follows the **private modules with public re-exports** pattern for a clean
//! API:
//!
//! - `render_op_common` - 27 operations shared between IR and Output layers
//! - `render_op_ir` - Intermediate representation for component/app layer
//! - `render_op_output` - Terminal output operations for backend layer
//! - `render_op_common_ext` - Ergonomic helper trait for both IR and Output
//! - `render_op_local_data` - State tracking for render optimization
//! - `render_op_flush` - Terminal output flushing control
//!
//! All types are re-exported at the module level for ergonomic imports.
//!
//! # Architectural Patterns Used Across Submodules
//!
//! ## The "You Are Here" Diagram
//!
//! Each submodule includes a simplified "You Are Here" diagram showing where in the
//! rendering pipeline that module's types are used. This helps orient developers
//! when reading individual files. The complete diagram above shows the full context.
//!
//! ## Semantic Boundaries
//!
//! The design enforces critical architectural boundaries through the type system:
//!
//! - **[`RenderOpIR`] cannot be executed** - must flow through Compositor first
//! - **[`RenderOpOutput`] cannot be created by components** - only by backend converters
//! - **[`RenderOpsExec`] trait only on Output** - prevents bypassing the Compositor
//!
//! These boundaries ensure data flows correctly through the pipeline and guarantees
//! (like text clipping and style application) are maintained.
//!
//! ## Ergonomic Factory Methods
//!
//! The [`RenderOpCommonExt`] trait provides factory methods for common operations,
//! available on both IR and Output types. This avoids repetitive wrapping like
//! `RenderOpIR::Common(RenderOpCommon::MoveCursorPositionAbs(pos))` in favor of
//! `RenderOpIR::move_cursor(pos)`.
// Skip rustfmt for rest of file.
// https://stackoverflow.com/a/75910283/2085356
// Private modules - implementation details.
// Module is public only when building documentation or tests.
// This allows rustdoc links to work while keeping it private in release builds.
// Public re-exports - stable API surface.
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;