libvt.terminal¶
Sans-I/O virtual terminal state machine, immutable snapshots, and formatters.
Bases:
objectBounded raw-byte ring buffer capturing recent VT traffic for diagnostics.
Return total byte count observed since initialization or
clear().
Append data, retaining at most
max_bytestrailing bytes.
Return up to max_bytes of the most recently recorded input bytes.
Render snapshot in
output_format.
Return the lower-cased version of the member name.
Bases:
StrEnumReason
Terminal.changes_since()emitted a full resynchronization.Return the lower-cased version of the member name.
Bases:
objectMulti-consumer incremental screen update from
Terminal.changes_since().Previous watermark supplied by the caller.
Count of rows the primary viewport scrolled up into history since from_token (
0on full resync or non-history scroll).
Sorted zero-based viewport row indices modified after shifting the previous viewport upward by
viewport_scroll_up.
Newly sealed scrollback rows appended since from_token, ordered oldest to newest.
Count of oldest scrollback rows evicted by scrollback capacity since from_token when
history_clearedisFalse.
TruewhenED 3cleared scrollback since from_token.
Truewhen cursor position, visibility, shape, orpending_wrapchanged.
Truewhen enabled ANSI/DEC modes changed.
TruewhenSIXELor Kitty placements mutated.
Return
Truewhen the consumer must replace cached state.
Return
Truewhen any grid, history, cursor, mode, or metadata changed.
Apply this delta in place to mutable history and viewport line lists.
Apply this delta in place to mutable history and viewport row views.
Bases:
objectImmutable point-in-time capture of terminal screen, history, and metadata.
-
prompt_zones¶attributeattributeprompt_zones¶
Recorded primary-screen
OSC 133semantic prompt zones (empty whenactive_is_altisTrue).- Type:
tuple[PromptZone, …]
-
program_status¶attributeattributeprogram_status¶
Highest-urgency active
OSC 7501/OSC 9;4status record.- Type:
ProgramStatus|None
Read-only mapping of stored
SIXEL/ KittyImageMetaitems.
-
placements¶attributeattributeplacements¶
Immutable active + scrollback
ImagePlacementrecords.- Type:
tuple[ImagePlacement, …]
- Parameters:
rows (
tuple[_Row, ...])history (
_FrozenHistory|Sequence[FrozenRow])cols (
int)cursor (
Cursor)title (
str)cwd (
str)cwd_uri (
str)active_is_alt (
bool)prompt_zones (
tuple[PromptZone, ...])program_status (
ProgramStatus|None)program_statuses (
Mapping[str,ProgramStatus])generation (
int)placements (
tuple[ImagePlacement, ...])
- Return type:
Decode
tmux capture-paneoutput directly into aSnapshot.- Parameters:
- Return type:
Return monotonic count of rows scrolled off the active screen’s top.
Return count of scrollback rows evicted from the active screen.
Return zero-based viewport row for abs_row, or
None.
Return
RowViewat abs_row in history or viewport.- Parameters:
abs_row (
int) – Monotonic absolute row coordinate.- Returns:
Immutable view of the row from scrollback or the active viewport.
- Return type:
- Raises:
IndexError– When abs_row has been evicted from history or is out of range.
Return
O(1)immutableRowViewsequence over scrollback rows.
Return right-trimmed text for every visible row in the snapshot.
Return visible snapshot text with trailing blank rows omitted.
Serialize snapshot state into a deterministic JSON-compatible dict.
-
Bases:
objectReturn value from
Terminal.feed_until().Flag(s) that triggered termination of the step.
Bases:
IntFlagBoundary conditions for
Terminal.feed_until().Generate the next value when not given.
name: the name of the member start: the initial start value or None count: the number of existing members last_values: the last value assigned or None
Bases:
objectOpaque monotonic watermark passed to
Terminal.changes_since().Structural epoch incremented on
resize(),RIS, and?1049alternate-screen transitions.
Cumulative primary-screen lines scrolled into history.
Cumulative primary-screen history lines evicted by
maxlen.
scrolled_totalvalue at the most recentED 3history clear.
Monotonic counter of
ED 3history clears.
Enabled terminal modes at watermark capture.
Raw
OSC 7/OSC 9;9working directory URI at watermark capture.
Monotonic counter of prompt-zone, program-status, and window-metadata updates.
Monotonic graphics placement revision on the active screen.
Bases:
objectSans-I/O virtual terminal emulator over a streaming VT500 parser.
- Parameters:
- Return type:
Construct a
Terminalfromos.terminal_size.
Reconstruct a live
Terminalfromtmux capture-paneoutput.- Parameters:
- Return type:
-
propertyproperty
Return current
ParserState.
-
propertyproperty
Return attached
FlightRecorder, if any.
Return the currently active
Screen.
Return the dual primary/alternate
ScreenSet.
Return sealed scrollback
RowViewlines.
Return
tmuxwindow name set byESC k <name> ESC \.
Return local working directory path accepted under
Policy.osc7_hosts.
Return raw
OSC 7/OSC 9;9working directory URI.
-
propertyproperty
Return active screen’s
KittyKeyboardFlags.
Return
Truewhile DEC mode?2026synchronized output is active.
Return monotonic
?2026synchronized-update batch counter.
Return active screen’s stored
ImageMetamap.
-
propertyproperty
Return active screen’s
ImagePlacementrecords.
Return right-trimmed visible lines of the active screen.
Return visible active-screen text with trailing blank rows omitted.
Return tear-free committed
Snapshotrespecting?2026hold.
Return an immutable watermark token for
changes_since().- Parameters:
view (
SyncView) –"committed"(default, respecting?2026frame holds) or"working"(live in-progress buffer).- Returns:
Opaque watermark capturing current state without mutating the terminal.
- Return type:
Compute incremental changes relative to token without mutating state.
- Parameters:
token (
SyncToken|None) – Previous watermark fromsync_token()orScreenDelta.token;Nonerequests an initial full sync.view (
SyncView) –"committed"(default) or"working".
- Returns:
Incremental row/scrollback delta or full resynchronization record.
- Return type:
- Parameters:
event (
Event)- Return type:
Return and clear buffered
Eventrecords.- Return type:
tuple[Event, ...]
Return and clear buffered sans-I/O query reply bytes.
- Return type:
Encode event into outbound PTY bytes using active terminal modes.
- Parameters:
event (
InputEvent)- Return type:
Release a stalled
?2026hold when sync_generation matches.Returns
Trueif an active?2026batch was expired, orFalsewhen?2026was already inactive or belonged to a newer batch.
Prune transient
working/blockedOSC 7501status records.- Return type:
- Parameters:
rect (
Rect)cause (
EraseCause)
- Return type:
Resize terminal screens to
(rows, cols).
Reset terminal state (
DECSTRwhen soft isTrue, elseRIS).
Encode text as UTF-8 and feed into the terminal.
Consume all bytes in data, updating terminal state in place.
Feed bytes starting at offset until a stop boundary occurs.
- Parameters:
- Return type:
Emulate data on a fresh
(rows, cols)terminal and returntext.
Strip VT escape, CSI, OSC, DCS, and APC sequences, keeping plain text.