Documentation
¶
Overview ¶
Package emu holds the VT emulator adapter used by tuitest. It defines a narrow Emulator interface and a single implementation backed by the copied vt package (which itself sits on top of charmbracelet/ultraviolet). Keeping this internal means the emulator choice is not part of tuitest's public contract and can be swapped without a breaking change.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Emulator ¶
type Emulator interface {
// Write feeds output bytes (from the child PTY) into the emulator.
Write(p []byte) (int, error)
// TakeResponses removes and returns the bytes the emulator wants to send
// back to the program, the answers to queries it made: cursor position
// reports, foreground and background colour queries, device attributes,
// and keyboard protocol probes. A real terminal answers these, so the
// harness must too, or any program that probes before drawing hangs on a
// retry loop and paints nothing. Callers drain after each Write and
// forward the result to the PTY. It must not block, and returns nil when
// nothing is queued.
TakeResponses() []byte
// Resize changes the emulator's grid size in cells.
Resize(cols, rows int)
// Size returns the current grid size in cells.
Size() (cols, rows int)
// CellAt returns the cell at the given zero-based column and row, or nil
// when out of bounds.
CellAt(col, row int) *uv.Cell
// Cursor returns the cursor position (zero-based) and whether it is visible.
Cursor() (col, row int, visible bool)
// PromptCount returns how many OSC 133 prompt-start (A) markers have been
// seen, used to detect a newly drawn shell prompt.
PromptCount() int
// CommandFinishedCount returns how many OSC 133 command-finished (D) markers
// have been seen, used to detect a command completing.
CommandFinishedCount() int
// LastCommandExit returns the exit code from the most recent command-finished
// marker, and whether any such marker exists.
LastCommandExit() (code int, ok bool)
// Modes reports the private modes currently set, keyed by mode number
// (1049 alt screen, 1000/1002/1003 mouse tracking, 2004 bracketed paste,
// and so on). Only modes that are set appear in the map. It exists so
// callers can tell whether a program restored the terminal on exit.
Modes() map[int]bool
}
Emulator is the minimal surface tuitest needs from a VT interpreter: feed it bytes, resize it, and read back the cell grid, cursor, and (optionally) OSC 133 semantic markers. Everything above this interface in tuitest is written against it, so the concrete emulator is replaceable.