pub struct TerminalModel { /* private fields */ }Expand description
A minimal terminal model for testing presenter output.
Tracks grid state, cursor position, SGR state, and hyperlinks. Processes a subset of ANSI sequences that we emit.
Implementations§
Source§impl TerminalModel
impl TerminalModel
Sourcepub fn new(width: usize, height: usize) -> Self
pub fn new(width: usize, height: usize) -> Self
Create a new terminal model with the given dimensions.
Dimensions are clamped to a minimum of 1×1 to prevent arithmetic underflows in cursor-positioning and diff helpers.
Sourcepub fn cell(&self, x: usize, y: usize) -> Option<&ModelCell>
pub fn cell(&self, x: usize, y: usize) -> Option<&ModelCell>
Get the cell at (x, y). Returns None if out of bounds.
Sourcepub fn current_cell(&self) -> Option<&ModelCell>
pub fn current_cell(&self) -> Option<&ModelCell>
Get the current cell under the cursor.
Sourcepub fn row_text(&self, y: usize) -> Option<String>
pub fn row_text(&self, y: usize) -> Option<String>
Extract the text content of a row as a string (trimmed of trailing spaces).
Sourcepub fn has_dangling_link(&self) -> bool
pub fn has_dangling_link(&self) -> bool
Check if the terminal has a dangling hyperlink (active link after processing).
Sourcepub fn sync_output_balanced(&self) -> bool
pub fn sync_output_balanced(&self) -> bool
Check if synchronized output is properly balanced.
Sourcepub fn diff_grid(&self, expected: &[ModelCell]) -> Option<String>
pub fn diff_grid(&self, expected: &[ModelCell]) -> Option<String>
Compare two grids and return a diff description for debugging.
Sourcepub fn dump_sequences(bytes: &[u8]) -> String
pub fn dump_sequences(bytes: &[u8]) -> String
Dump the escape sequences in a human-readable format (for debugging test failures).