Skip to main content

Module terminal_model

Module terminal_model 

Source
Expand description

Terminal model for presenter validation.

This module provides a minimal terminal emulator that understands the subset of ANSI sequences we emit, enabling deterministic testing of the presenter without requiring actual terminal I/O.

§Scope

This is NOT a full VT emulator. It supports only:

  • Cursor positioning (CUP, relative moves)
  • SGR (style attributes)
  • Erase operations (EL, ED)
  • OSC 8 hyperlinks
  • DEC 2026 synchronized output (tracked but visual effects ignored)

§Usage

let mut model = TerminalModel::new(80, 24);
model.process(b"\x1b[1;1H"); // Move cursor to (0, 0)
model.process(b"\x1b[1mHello\x1b[0m"); // Write "Hello" in bold
assert_eq!(model.cursor(), (5, 0)); // Cursor advanced
assert_eq!(model.cell(0, 0).text, "H");

Structs§

ModeFlags
Mode flags tracked by the terminal model.
ModelCell
A single cell in the terminal model grid.
SgrState
Current SGR (style) state for the terminal model.
TerminalModel
A minimal terminal model for testing presenter output.