libvt¶
Pure-Python virtual terminal emulator and streaming VT parser.
-
class libvt.AnsiColorclass[source]class[source]class libvt.AnsiColor
Bases:
IntEnumStandard and bright ECMA-48 / aixterm 16-color palette indices.
-
BLACK = 0attributeattributeBLACK = 0
-
RED = 1attributeattributeRED = 1
-
GREEN = 2attributeattributeGREEN = 2
-
YELLOW = 3attributeattributeYELLOW = 3
-
BLUE = 4attributeattributeBLUE = 4
-
MAGENTA = 5attributeattributeMAGENTA = 5
-
CYAN = 6attributeattributeCYAN = 6
-
WHITE = 7attributeattributeWHITE = 7
-
BRIGHT_BLACK = 8attributeattributeBRIGHT_BLACK = 8
-
BRIGHT_RED = 9attributeattributeBRIGHT_RED = 9
-
BRIGHT_GREEN = 10attributeattributeBRIGHT_GREEN = 10
-
BRIGHT_YELLOW = 11attributeattributeBRIGHT_YELLOW = 11
-
BRIGHT_BLUE = 12attributeattributeBRIGHT_BLUE = 12
-
BRIGHT_MAGENTA = 13attributeattributeBRIGHT_MAGENTA = 13
-
BRIGHT_CYAN = 14attributeattributeBRIGHT_CYAN = 14
-
BRIGHT_WHITE = 15attributeattributeBRIGHT_WHITE = 15
-
-
class libvt.Bellclass[source]class[source]class libvt.Bell
Bases:
objectEmitted when
BEL(0x07) executes inGROUND.
-
class libvt.BlockKindclass[source]class[source]class libvt.BlockKind
Bases:
StrEnumReason categories when
StatusState.BLOCKEDrequests user action.-
PERMISSION = 'permission'attributeattributePERMISSION = 'permission'
-
QUESTION = 'question'attributeattributeQUESTION = 'question'
-
AUTH = 'auth'attributeattributeAUTH = 'auth'
-
-
class libvt.CaptureCompletenessclass[source]class[source]class libvt.CaptureCompleteness
Bases:
objectExplicit fidelity report for a decoded
tmux capture-panesnapshot.-
attributeattribute
Truewhen cell glyphs, styles, and tab expansions were decoded from-e -p -Noutput.
-
attributeattribute
Truewhen soft-wrap flags came from-For an exact-Jcompanion capture.
-
attributeattribute
Truewhen pre- and post-capturepane_output_generationcounters were supplied and matched.
Internal terminal state fields that
tmuxdoes not expose through format variables orcapture-pane.
-
-
class libvt.Cellclass[source]class[source]class libvt.Cell
Bases:
objectImmutable view of a single terminal grid cell.
-
attributeattribute
Grapheme cluster string (
" "for narrow blanks,""forWidthRole.SPACER_TAILandWidthRole.SPACER_HEAD).
-
width_role: WidthRoleattributeattributewidth_role: WidthRole
Column occupancy role (narrow, wide lead, or spacer).
Active
OSC 8hyperlink, when present.
-
attributeattribute
DECSCAprotection attribute respected byDECSED/DECSEL.
-
__init__(text=' ', style=Style(fg=None, bg=None, underline_color=None, bold=False, dim=False, italic=False, underline=<UnderlineStyle.NONE: 0>, blink=False, reverse=False, hidden=False, strikethrough=False, overline=False), width_role=WidthRole.NARROW, hyperlink=None, protected=False)method[source]method[source]__init__(text=' ', style=Style(fg=None, bg=None, underline_color=None, bold=False, dim=False, italic=False, underline=<UnderlineStyle.NONE: 0>, blink=False, reverse=False, hidden=False, strikethrough=False, overline=False), width_role=WidthRole.NARROW, hyperlink=None, protected=False)
-
propertyproperty
Return
Truewhen the cell holds an unstyled narrow space.
-
-
class libvt.ClipboardWriteclass[source]class[source]class libvt.ClipboardWrite
Bases:
objectEmitted when
OSC 52writes base64-decoded text to a selection target.
-
class libvt.ColorSchemeclass[source]class[source]class libvt.ColorScheme
Bases:
IntEnumCSI ? 997 ; Ps ncolor-scheme values (DEC ?2031/DSR ?996n).-
DARK = 1attributeattributeDARK = 1
-
LIGHT = 2attributeattributeLIGHT = 2
-
-
class libvt.ColorSchemeQueriedclass[source]class[source]class libvt.ColorSchemeQueried
Bases:
objectEmitted when
CSI ? 996 nqueries the host color scheme.-
attributeattribute
Scheme reported back to the application.
-
__init__(scheme)method[source]method[source]__init__(scheme)
- Parameters:
scheme (
ColorScheme)- Return type:
-
-
class libvt.CsiParamsclass[source]class[source]class libvt.CsiParams
Bases:
objectParsed CSI parameter list preserving
;vs:subparameter boundaries.Clamped integer parameter values (
0for omitted slots).
-
attributeattribute
Bitmask where bit
iis1whenvalues[i]was preceded by:(an ITU T.416 subparameter of the nearest preceding;slot).
-
attributeattribute
Bitmask where bit
iis1when sloticontained no digits.
-
class libvt.Cursorclass[source]class[source]class libvt.Cursor
Bases:
objectZero-based cursor state on a
Screen.-
attributeattribute
Visual cursor shape.
-
attributeattribute
Truewhen a glyph filledcols - 1underDECAWMand the next printable character will wrap to the next line.
-
-
class libvt.CursorShapeclass[source]class[source]class libvt.CursorShape
Bases:
StrEnumCursor glyph shape configured via
DECSCUSR(CSI Ps SP q).-
BLOCK = 'block'attributeattributeBLOCK = 'block'
-
UNDERLINE = 'underline'attributeattributeUNDERLINE = 'underline'
-
BAR = 'bar'attributeattributeBAR = 'bar'
-
-
class libvt.DecrpmValueclass[source]class[source]class libvt.DecrpmValue
Bases:
IntEnumDECRPMstatus codes returned inCSI ? Ps ; Pm $ yreplies.-
NOT_RECOGNIZED = 0attributeattributeNOT_RECOGNIZED = 0
-
SET = 1attributeattributeSET = 1
-
RESET = 2attributeattributeRESET = 2
-
PERMANENTLY_SET = 3attributeattributePERMANENTLY_SET = 3
-
PERMANENTLY_RESET = 4attributeattributePERMANENTLY_RESET = 4
-
-
class libvt.EraseCauseclass[source]class[source]class libvt.EraseCause
Bases:
StrEnumReason a screen rectangle was cleared or scrolled.
-
ED = 'ed'attributeattributeED = 'ed'
-
EL = 'el'attributeattributeEL = 'el'
-
ECH = 'ech'attributeattributeECH = 'ech'
-
DECSED = 'decsed'attributeattributeDECSED = 'decsed'
-
DECSEL = 'decsel'attributeattributeDECSEL = 'decsel'
-
SCROLL = 'scroll'attributeattributeSCROLL = 'scroll'
-
RESET = 'reset'attributeattributeRESET = 'reset'
-
-
class libvt.ExplainedSpanclass[source]class[source]class libvt.ExplainedSpan
Bases:
objectHuman-readable disassembly of one parsed VT token.
-
attributeattribute
Token family (
"PRINT","C0","ESC","CSI","OSC","DCS", or"APC").
-
attributeattribute
Standard ECMA-48 / DEC / modern VT mnemonic (e.g.
"CUP","SGR","DECSET","OSC 7501").
-
-
class libvt.FlightRecorderclass[source]class[source]class libvt.FlightRecorder
Bases:
objectBounded raw-byte ring buffer capturing recent VT traffic for diagnostics.
-
_bufattributeattribute_buf
-
_max_bytesattributeattribute_max_bytes
-
_total_bytesattributeattribute_total_bytes
-
-
class libvt.FocusEventclass[source]class[source]class libvt.FocusEvent
Bases:
objectTerminal window focus-in / focus-out event (
?1004).-
attributeattribute
Trueon focus gain (ESC [ I);Falseon focus loss (ESC [ O).
-
-
class libvt.Formatterclass[source]class[source]class libvt.Formatter
Bases:
objectSerialize a
SnapshotorTerminalto text, VT, or HTML.-
output_formatattributeattributeoutput_format
-
policyattributeattributepolicy
-
profileattributeattributeprofile
-
-
class libvt.GraphicsProtocolclass[source]class[source]class libvt.GraphicsProtocol
Bases:
StrEnumTerminal graphics protocol family.
-
SIXEL = 'sixel'attributeattributeSIXEL = 'sixel'
-
KITTY = 'kitty'attributeattributeKITTY = 'kitty'
-
-
class libvt.Hyperlinkclass[source]class[source]class libvt.Hyperlink
Bases:
objectOSC 8hyperlink attached to printed cells independent ofSGR 0.
-
class libvt.ImageMetaclass[source]class[source]class libvt.ImageMeta
Bases:
objectStored sans-I/O image metadata without buffered pixel bitmaps.
-
attributeattribute
Originating graphics protocol (
SIXELorKITTY).
-
attributeattribute
Protocol image identifier (auto-assigned positive integer for
SIXELor unnumbered Kitty uploads).
-
attributeattribute
Optional Kitty
I=non-unique image number (0when unset).
-
attributeattribute
Kitty
f=pixel format (8,16,24,32, or100PNG), or0forSIXEL.
-
attributeattribute
Truewhen transmitted with Kittyo=zzlib compression.
-
attributeattribute
Total encoded payload byte count observed across upload chunks.
-
-
class libvt.ImagePlacementclass[source]class[source]class libvt.ImagePlacement
Bases:
objectImmutable snapshot of a
SIXELor Kitty image placement on a screen.-
attributeattribute
Originating graphics protocol.
-
attributeattribute
Kitty
p=placement identifier (0when default/unnumbered).
-
attributeattribute
Truefor KittyU=1Unicode-placeholder virtual placements.
-
attributeattribute
Parent image ID for Kitty
P=relative placements (0when none).
-
attributeattribute
Parent placement ID for Kitty
Q=relative placements.
-
attributeattribute
Sub-cell pixel X offset within the anchor cell.
-
attributeattribute
Sub-cell pixel Y offset within the anchor cell.
Bitmask of
rows * colsvisible cells forSIXELunder"cell_mask"erase policy (bitr * cols + cis1when intact);Nonewhen all cells in(rows, cols)are intact.
-
__init__(protocol, image_id, placement_id, abs_row, col, rows, cols, z_index=0, virtual=False, parent_image_id=0, parent_placement_id=0, source_x=0, source_y=0, source_width=0, source_height=0, cell_offset_x=0, cell_offset_y=0, visible_mask=None)method[source]method[source]__init__(protocol, image_id, placement_id, abs_row, col, rows, cols, z_index=0, virtual=False, parent_image_id=0, parent_placement_id=0, source_x=0, source_y=0, source_width=0, source_height=0, cell_offset_x=0, cell_offset_y=0, visible_mask=None)
- Parameters:
- Return type:
-
propertyproperty
Return rendering plane derived from
z_index.
-
-
class libvt.InBandResizeclass[source]class[source]class libvt.InBandResize
Bases:
objectEmitted when
resize()queues a?2048in-band resize report.
-
class libvt.IndexedColorclass[source]class[source]class libvt.IndexedColor
Bases:
object256-color palette entry (
SGR 38;5;n/SGR 48;5;n).-
attributeattribute
Palette index in
0..255. Kept distinct fromAnsiColorfor indices0..15soSGR 38;5;1round-trips separately fromSGR 31.
-
-
class libvt.KeyActionclass[source]class[source]class libvt.KeyAction
Bases:
IntEnumKey press lifecycle event type for Kitty
CSI u.-
PRESS = 1attributeattributePRESS = 1
-
REPEAT = 2attributeattributeREPEAT = 2
-
RELEASE = 3attributeattributeRELEASE = 3
-
-
class libvt.KeyEventclass[source]class[source]class libvt.KeyEvent
Bases:
objectStructured keyboard event for outbound PTY encoding.
-
attributeattribute
Single Unicode character (e.g.
"a","A") or canonical key name ("enter","tab","escape","backspace","up","down","right","left","home","end","page_up","page_down","insert","delete","f1"through"f12").
-
attributeattribute
Optional associated text for Kitty flag
REPORT_ASSOCIATED_TEXT.
-
-
class libvt.KeyModclass[source]class[source]class libvt.KeyMod
Bases:
IntFlagKeyboard and mouse modifier bitmask matching Kitty
CSI ubits.-
_generate_next_value_(name, start, count, last_values)staticmethod method[source]staticmethod method[source]_generate_next_value_(name, start, count, last_values)
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
-
_boundary_ = 'keep'attributeattribute_boundary_ = 'keep'
-
_flag_mask_ = 63attributeattribute_flag_mask_ = 63
-
_singles_mask_ = 63attributeattribute_singles_mask_ = 63
-
_all_bits_ = 63attributeattribute_all_bits_ = 63
-
_inverted_ = Noneattributeattribute_inverted_ = None
-
NONE = 0attributeattributeNONE = 0
-
SHIFT = 1attributeattributeSHIFT = 1
-
ALT = 2attributeattributeALT = 2
-
CTRL = 4attributeattributeCTRL = 4
-
SUPER = 8attributeattributeSUPER = 8
-
HYPER = 16attributeattributeHYPER = 16
-
META = 32attributeattributeMETA = 32
-
-
class libvt.KittyCommandclass[source]class[source]class libvt.KittyCommand
Bases:
objectZero-dependency
APC GKitty graphics protocol record.Immutable key-value control header pairs before
;.
-
class libvt.KittyGraphicclass[source]class[source]class libvt.KittyGraphic
Bases:
objectEmitted when an
APC GKitty graphics sequence completes.-
attributeattribute
Captured Kitty control dictionary and payload.
-
__init__(command)method[source]method[source]__init__(command)
- Parameters:
command (
KittyCommand)- Return type:
-
-
class libvt.KittyKeyboardFlagsclass[source]class[source]class libvt.KittyKeyboardFlags
Bases:
IntFlagProgressive-enhancement flags for the Kitty Keyboard Protocol (
CSI u).-
_generate_next_value_(name, start, count, last_values)staticmethod method[source]staticmethod method[source]_generate_next_value_(name, start, count, last_values)
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
-
_boundary_ = 'keep'attributeattribute_boundary_ = 'keep'
-
_flag_mask_ = 31attributeattribute_flag_mask_ = 31
-
_singles_mask_ = 31attributeattribute_singles_mask_ = 31
-
_all_bits_ = 31attributeattribute_all_bits_ = 31
-
_inverted_ = Noneattributeattribute_inverted_ = None
-
NONE = 0attributeattributeNONE = 0
-
DISAMBIGUATE = 1attributeattributeDISAMBIGUATE = 1
-
REPORT_EVENT_TYPES = 2attributeattributeREPORT_EVENT_TYPES = 2
-
REPORT_ALTERNATE_KEYS = 4attributeattributeREPORT_ALTERNATE_KEYS = 4
-
REPORT_ALL_KEYS = 8attributeattributeREPORT_ALL_KEYS = 8
-
REPORT_ASSOCIATED_TEXT = 16attributeattributeREPORT_ASSOCIATED_TEXT = 16
-
-
exception libvt.LibVtErrorexception[source]exception[source]exception libvt.LibVtError
Bases:
ExceptionBase exception for all libvt errors.
-
class libvt.Limitsclass[source]class[source]class libvt.Limits
Bases:
objectResource ceilings protecting memory and CPU against hostile byte streams.
-
attributeattribute
Maximum Unicode codepoints stored in a single grid cell (default
32).
-
attributeattribute
Maximum parameter slots retained in a
CSIorDCSheader.
-
attributeattribute
Maximum payload bytes buffered for an
OSCsequence.
-
attributeattribute
Maximum payload bytes buffered for a
DCSsequence (default8_388_608, sized abovemax_apc_bytesso 4 MiB graphics wrapped inDCS tmux;fit without truncation).
-
attributeattribute
Maximum payload bytes buffered for an
APCsequence.
-
attributeattribute
Maximum unread bytes queued in
drain_replies().
-
attributeattribute
Maximum repeat count executed by
REP(CSI Ps b).
-
attributeattribute
Maximum
OSC 133prompt zones retained on a terminal.
-
attributeattribute
Maximum concurrent
OSC 7501task records retained in the store (default256).
-
attributeattribute
Maximum unread
Eventitems retained whenrecord_events=True.
-
attributeattribute
Maximum cumulative payload bytes retained across unread events when
record_events=True(default16_777_216).
-
attributeattribute
Maximum entries per screen in the Kitty
CSI ukeyboard stack.
-
attributeattribute
Maximum raw input bytes retained by
FlightRecorder.
-
attributeattribute
Maximum stored Kitty /
SIXELimage metadata entries per screen (default256).
-
attributeattribute
Maximum active + scrollback image placements retained per screen (default
1_024).
-
attributeattribute
Maximum pixel width or height accepted for
SIXELor Kitty images (default10_000).
-
__init__(*, max_grapheme_codepoints=32, max_csi_params=32, max_osc_bytes=131072, max_dcs_bytes=8388608, max_apc_bytes=4194304, max_reply_bytes=65536, max_rep_count=4096, max_prompt_zones=1024, max_status_records=256, max_events=4096, max_event_bytes=16777216, max_keyboard_stack=8, max_recorder_bytes=4096, max_images=256, max_placements=1024, max_image_dimension=10000)method[source]method[source]__init__(*, max_grapheme_codepoints=32, max_csi_params=32, max_osc_bytes=131072, max_dcs_bytes=8388608, max_apc_bytes=4194304, max_reply_bytes=65536, max_rep_count=4096, max_prompt_zones=1024, max_status_records=256, max_events=4096, max_event_bytes=16777216, max_keyboard_stack=8, max_recorder_bytes=4096, max_images=256, max_placements=1024, max_image_dimension=10000)
- Parameters:
max_grapheme_codepoints (
int)max_csi_params (
int)max_osc_bytes (
int)max_dcs_bytes (
int)max_apc_bytes (
int)max_reply_bytes (
int)max_rep_count (
int)max_prompt_zones (
int)max_status_records (
int)max_events (
int)max_event_bytes (
int)max_keyboard_stack (
int)max_recorder_bytes (
int)max_images (
int)max_placements (
int)max_image_dimension (
int)
- Return type:
-
-
class libvt.Modeclass[source]class[source]class libvt.Mode
Bases:
IntEnumANSI standard modes and DEC private modes (
0x8000 | code).-
IRM = 4attributeattributeIRM = 4
-
LNM = 20attributeattributeLNM = 20
-
DECCKM = 32769attributeattributeDECCKM = 32769
-
DECOM = 32774attributeattributeDECOM = 32774
-
DECAWM = 32775attributeattributeDECAWM = 32775
-
MOUSE_X10 = 32777attributeattributeMOUSE_X10 = 32777
-
DECTCEM = 32793attributeattributeDECTCEM = 32793
-
REVERSE_WRAP = 32813attributeattributeREVERSE_WRAP = 32813
-
ALT_SCREEN_47 = 32815attributeattributeALT_SCREEN_47 = 32815
-
DECLRMM = 32837attributeattributeDECLRMM = 32837
-
DECSDM = 32848attributeattributeDECSDM = 32848
-
MOUSE_VT200 = 33768attributeattributeMOUSE_VT200 = 33768
-
MOUSE_BUTTON_EVENT = 33770attributeattributeMOUSE_BUTTON_EVENT = 33770
-
MOUSE_ANY_EVENT = 33771attributeattributeMOUSE_ANY_EVENT = 33771
-
FOCUS_EVENT = 33772attributeattributeFOCUS_EVENT = 33772
-
MOUSE_SGR = 33774attributeattributeMOUSE_SGR = 33774
-
MOUSE_SGR_PIXELS = 33784attributeattributeMOUSE_SGR_PIXELS = 33784
-
ALT_SCREEN_1047 = 33815attributeattributeALT_SCREEN_1047 = 33815
-
DECSC_1048 = 33816attributeattributeDECSC_1048 = 33816
-
ALT_SCREEN = 33817attributeattributeALT_SCREEN = 33817
-
BRACKETED_PASTE = 34772attributeattributeBRACKETED_PASTE = 34772
-
SYNCHRONIZED_OUTPUT = 34794attributeattributeSYNCHRONIZED_OUTPUT = 34794
-
GRAPHEME_CLUSTERING = 34795attributeattributeGRAPHEME_CLUSTERING = 34795
-
COLOR_SCHEME_UPDATES = 34799attributeattributeCOLOR_SCHEME_UPDATES = 34799
-
IN_BAND_RESIZE = 34816attributeattributeIN_BAND_RESIZE = 34816
-
-
class libvt.ModeStateclass[source]class[source]class libvt.ModeState
Bases:
objectMutable set of active ANSI and DEC private modes.
-
class libvt.MouseActionclass[source]class[source]class libvt.MouseAction
Bases:
StrEnumMouse pointer action.
-
PRESS = 'press'attributeattributePRESS = 'press'
-
RELEASE = 'release'attributeattributeRELEASE = 'release'
-
MOVE = 'move'attributeattributeMOVE = 'move'
-
-
class libvt.MouseButtonclass[source]class[source]class libvt.MouseButton
Bases:
IntEnumMouse buttons and scroll wheel directions.
-
LEFT = 0attributeattributeLEFT = 0
-
MIDDLE = 1attributeattributeMIDDLE = 1
-
RIGHT = 2attributeattributeRIGHT = 2
-
NONE = 3attributeattributeNONE = 3
-
WHEEL_UP = 64attributeattributeWHEEL_UP = 64
-
WHEEL_DOWN = 65attributeattributeWHEEL_DOWN = 65
-
-
class libvt.MouseEventclass[source]class[source]class libvt.MouseEvent
Bases:
objectZero-based
(row, col)mouse event for outbound SGR / X10 encoding.-
attributeattribute
Mouse button or scroll wheel.
-
attributeattribute
Pointer action (
press,release, ormove).
-
attributeattribute
Active keyboard modifiers during the mouse event.
-
__init__(button, action, row, col, modifiers=<KeyMod.NONE: 0>, pixel_x=0, pixel_y=0)method[source]method[source]__init__(button, action, row, col, modifiers=<KeyMod.NONE: 0>, pixel_x=0, pixel_y=0)
- Parameters:
button (
MouseButton)action (
MouseAction)row (
int)col (
int)modifiers (
KeyMod)pixel_x (
int)pixel_y (
int)
- Return type:
-
-
class libvt.OutputFormatclass[source]class[source]class libvt.OutputFormat
Bases:
StrEnumExport target formats supported by
Formatter.-
PLAIN = 'plain'attributeattributePLAIN = 'plain'
-
VT = 'vt'attributeattributeVT = 'vt'
-
HTML = 'html'attributeattributeHTML = 'html'
-
-
class libvt.Parserclass[source]class[source]class libvt.Parser
Bases:
objectStreaming VT500 / ANSI escape-sequence byte parser.
-
_encoding: ParserEncodingattributeattribute_encoding: ParserEncoding
-
_intermediatesattributeattribute_intermediates
-
_limitsattributeattribute_limits
-
attributeattribute
-
_str_bufattributeattribute_str_buf
-
attributeattribute
-
_utf8attributeattribute_utf8
-
_decode_utf8_bytes(raw, sink)method[source]method[source]_decode_utf8_bytes(raw, sink)
- Parameters:
raw (
bytes|memoryview)sink (
ActionSink)
- Return type:
-
_dispatch_apc(sink)method[source]method[source]_dispatch_apc(sink)
- Parameters:
sink (
ActionSink)- Return type:
-
_dispatch_dcs(sink)method[source]method[source]_dispatch_dcs(sink)
- Parameters:
sink (
ActionSink)- Return type:
-
_dispatch_osc(sink, terminator)method[source]method[source]_dispatch_osc(sink, terminator)
- Parameters:
sink (
ActionSink)terminator (
bytes)
- Return type:
-
_flush_incomplete_utf8(sink)method[source]method[source]_flush_incomplete_utf8(sink)
- Parameters:
sink (
ActionSink)- Return type:
-
_handle_c1_anywhere(b, sink)method[source]method[source]_handle_c1_anywhere(b, sink)
- Parameters:
b (
int)sink (
ActionSink)
- Return type:
-
property encoding: ParserEncodingpropertypropertyproperty encoding: ParserEncoding
Return wire character encoding (
"utf-8"or"latin-1").
-
feed_to(data, sink)method[source]method[source]feed_to(data, sink)
Feed data directly into sink without allocating action wrappers.
- Parameters:
data (
Buffer)sink (
ActionSink)
- Return type:
-
propertyproperty
Return the current
ParserState.
-
-
class libvt.ParserStateclass[source]class[source]class libvt.ParserState
Bases:
IntEnumStates of the DEC ANSI / VT500 byte state machine.
-
GROUND = 0attributeattributeGROUND = 0
-
ESCAPE = 1attributeattributeESCAPE = 1
-
ESCAPE_INTERMEDIATE = 2attributeattributeESCAPE_INTERMEDIATE = 2
-
CSI_ENTRY = 3attributeattributeCSI_ENTRY = 3
-
CSI_PARAM = 4attributeattributeCSI_PARAM = 4
-
CSI_INTERMEDIATE = 5attributeattributeCSI_INTERMEDIATE = 5
-
CSI_IGNORE = 6attributeattributeCSI_IGNORE = 6
-
DCS_ENTRY = 7attributeattributeDCS_ENTRY = 7
-
DCS_PARAM = 8attributeattributeDCS_PARAM = 8
-
DCS_INTERMEDIATE = 9attributeattributeDCS_INTERMEDIATE = 9
-
DCS_PASSTHROUGH = 10attributeattributeDCS_PASSTHROUGH = 10
-
DCS_IGNORE = 11attributeattributeDCS_IGNORE = 11
-
OSC_STRING = 12attributeattributeOSC_STRING = 12
-
SOS_PM_APC_STRING = 13attributeattributeSOS_PM_APC_STRING = 13
-
STRING_ESC = 14attributeattributeSTRING_ESC = 14
-
-
class libvt.Passthroughclass[source]class[source]class libvt.Passthrough
Bases:
objectEmitted when a
DCS tmux; ESC ESC ... STpassthrough envelope arrives.
-
class libvt.PasteEventclass[source]class[source]class libvt.PasteEvent
Bases:
objectClipboard paste payload encoded with
?2004bracketing and safety checks.-
attributeattribute
When
False(default), raiseUnsafePasteErroron control or escape characters. WhenTrue, strip control/escape codepoints in a single character-level pass.
-
attributeattribute
Permit
\rand\nwhen?2004bracketed paste is disabled.
-
-
class libvt.Policyclass[source]class[source]class libvt.Policy
Bases:
objectDefault-deny host security and strictness policy.
-
attributeattribute
Permit
CSI 21 twindow-title report replies (defaultFalse).
-
attributeattribute
Permit
DECRQCRArectangular checksum replies (defaultFalse).
-
attributeattribute
Permit
OSC 52 ; ... ; ?clipboard read replies (defaultFalse).
-
attributeattribute
Emit
ClipboardWriteevents onOSC 52writes (defaultTrue; no host clipboard is ever mutated bylibvt).
-
attributeattribute
Permit
OSC 10 ; ?,OSC 11 ; ?, andCSI ? 996 npalette and color-scheme replies (defaultTrue).
-
attributeattribute
Permit
OSC 7501 ; ?capability replies wheneverprofile.osc_7501_capabilitiesis non-empty (defaultTrue).
-
attributeattribute
Allow schemes outside
http://,https://, andmailto:in HTML<a href>output (defaultFalse).
-
attributeattribute
Replay unwrapped
DCS tmux; ESC ESC ... STinner byte streams through a persistent passthrough parser in addition to emittingPassthrough(defaultFalse, matchingtmux’sallow-passthrough off).
-
attributeattribute
When
True, dispatch an accumulatedOSCstring if interrupted by a non-\ESCbyte (matchingtmux/Ghosttystate-exit behavior). Defaults toFalse(DEC STD 070 abort-and-drop).
Lowercase hostnames in
OSC 7file://<host>/...URIs permitted to updatecwd.None(default) uses{"", "localhost"}in sans-I/OTerminaland automatically adds the local hostname inopen_pty().
-
attributeattribute
Raise
ProtocolErroron unrecognized or overflowing escape sequences instead of ignoring or recordingUnhandledSequence(defaultFalse).
-
attributeattribute
Track sans-I/O
SIXELand KittyAPC Gimage metadata and grid placements (defaultTrue).
-
__init__(*, allow_title_report=False, allow_checksum_report=False, allow_clipboard_read=False, allow_clipboard_write=True, allow_color_queries=True, allow_program_status_query=True, allow_unsafe_uris=False, allow_passthrough=False, abort_dispatch_osc=False, osc7_hosts=None, strict=False, track_graphics=True)method[source]method[source]__init__(*, allow_title_report=False, allow_checksum_report=False, allow_clipboard_read=False, allow_clipboard_write=True, allow_color_queries=True, allow_program_status_query=True, allow_unsafe_uris=False, allow_passthrough=False, abort_dispatch_osc=False, osc7_hosts=None, strict=False, track_graphics=True)
- Parameters:
- Return type:
-
-
class libvt.Profileclass[source]class[source]class libvt.Profile
Bases:
objectTerminal identity responses and compatibility switches.
-
attributeattribute
Version banner emitted in
DCS > | <xtversion> ST(CSI > q).
-
attributeattribute
Payload body returned for
OSC 7501 ; ?queries when enabled (""when unsupported,"?"fortmux, or full capability list onDEFAULT_PROFILE).
-
attributeattribute
Default scheme reported for
CSI ? 996 ncolor-scheme queries.
Default foreground 8-bit RGB reported for
OSC 10 ; ?.
Default background 8-bit RGB reported for
OSC 11 ; ?.
-
attributeattribute
When
True(TMUX_PROFILE),pending_wraptreats the cursor as occupying phantom columncolsacrossEL/ED,ECH/ICH/DCH, vertical motions,DECRC,CPR, andCUB/BS, matchingtmux’sscreen-write.c.
-
attributeattribute
When
True(default),U+FE0Enarrows standalone wide emoji listed inemoji-variation-sequences.txtfrom2columns to1.FalseonTMUX_PROFILEto matchtmux 3.8a.
-
attributeattribute
When
True,U+FE0Fwidens any narrow spacing base rather than onlyemoji-variation-sequences.txtbases.
-
attributeattribute
When
True(TMUX_PROFILE),ESC k <name> ESC \is consumed as a window-rename control string rather than printed onto the grid.
-
attributeattribute
Default reflow behavior for
resize()whenreflow=None(TrueonDEFAULT_PROFILEandTMUX_PROFILE,FalseonXTERM_PROFILE).
-
attributeattribute
When
True(XTERM_PROFILEandTMUX_PROFILE),CSI 3 Jexecuted while the alternate screen is active still clears primary scrollback history.
-
attributeattribute
When
True,HPR(CSI Ps a) andVPR(CSI Ps e) move the cursor relatively; whenFalse(TMUX_PROFILE), both are quietly ignored.
-
attributeattribute
When
True(ECMA-48 /xterm/Ghostty),ILandDLmove the cursor to the active left margin; whenFalse(TMUX_PROFILE), the cursor column is preserved.
-
attributeattribute
When
True(default andtmux >= 3.9),REP(CSI Ps b) autowraps across the right margin; whenFalse(tmux <= 3.8),REPhalts at phantom columncols.
-
default_g1_charset: Charsetattributeattributedefault_g1_charset: Charset
Initial
G1character-set designation on startup andRIS("B"US-ASCII by default).
-
attributeattribute
When
True(default),DECSTR(CSI ! p) performs a soft terminal reset; whenFalse(TMUX_PROFILE),CSI ! pis ignored, matchingtmux’sinput.c.
-
attributeattribute
When
True(TMUX_PROFILE), primary-screenCSI 2 J(andCSI Jwith cursor at(0, 0)) scrolls rows up to the last non-empty or image-bearing row into scrollback before clearing withBCE, matchingtmux’sscroll-on-cleardefault.
-
attributeattribute
Nominal cell width in pixels used for
CSI 14 t,CSI 16 t, andSIXEL/ Kitty cell-grid geometry (default8).
-
attributeattribute
Nominal cell height in pixels used for
CSI 14 t,CSI 16 t, andSIXEL/ Kitty cell-grid geometry (default16).
-
sixel_erase_policy: SixelErasePolicyattributeattributesixel_erase_policy: SixelErasePolicy
How text overwrites and cell erases affect
SIXELplacements:"cell_mask"(default andtmux >= 3.9) clears individual cells;"whole_image"(tmux <= 3.8) deletes any intersectedSIXELplacement.
-
__init__(*, name='libvt', da1=b'\x1b[?62;22c', da2=b'\x1b[>1;10;0c', xtversion='libvt 0.1', osc_7501_capabilities='?:states=idle,working,done,blocked,error:kinds=permission,question,auth', color_scheme=
ColorScheme.DARK, fg_rgb=(229, 229, 229), bg_rgb=(30, 30, 30), pending_wrap_phantom_col=False, vs15_narrows_wide_emoji=True, vs16_always_wide=False, tmux_window_rename=False, reflow_on_resize=True, ed3_clears_scrollback_on_alt=False, hpr_vpr_enabled=True, il_dl_resets_col=True, rep_wraps=True, default_g1_charset='B', decstr_enabled=True, ed2_scrolls_primary_to_history=False, cell_width_px=8, cell_height_px=16, sixel_erase_policy='cell_mask')method[source]method[source]__init__(*, name='libvt', da1=b'\x1b[?62;22c', da2=b'\x1b[>1;10;0c', xtversion='libvt 0.1', osc_7501_capabilities='?:states=idle,working,done,blocked,error:kinds=permission,question,auth', color_scheme=ColorScheme.DARK, fg_rgb=(229, 229, 229), bg_rgb=(30, 30, 30), pending_wrap_phantom_col=False, vs15_narrows_wide_emoji=True, vs16_always_wide=False, tmux_window_rename=False, reflow_on_resize=True, ed3_clears_scrollback_on_alt=False, hpr_vpr_enabled=True, il_dl_resets_col=True, rep_wraps=True, default_g1_charset='B', decstr_enabled=True, ed2_scrolls_primary_to_history=False, cell_width_px=8, cell_height_px=16, sixel_erase_policy='cell_mask') - Parameters:
name (
str)da1 (
bytes)da2 (
bytes)xtversion (
str)osc_7501_capabilities (
str)color_scheme (
ColorScheme)pending_wrap_phantom_col (
bool)vs15_narrows_wide_emoji (
bool)vs16_always_wide (
bool)tmux_window_rename (
bool)reflow_on_resize (
bool)ed3_clears_scrollback_on_alt (
bool)hpr_vpr_enabled (
bool)il_dl_resets_col (
bool)rep_wraps (
bool)default_g1_charset (
Charset)decstr_enabled (
bool)ed2_scrolls_primary_to_history (
bool)cell_width_px (
int)cell_height_px (
int)sixel_erase_policy (
SixelErasePolicy)
- Return type:
-
-
class libvt.ProgramStatusclass[source]class[source]class libvt.ProgramStatus
Bases:
objectValidated
OSC 7501(orOSC 9;4fallback) task status record.-
attributeattribute
Lifecycle state (
idle,working,done,blocked, orerror).
-
attributeattribute
Hierarchical
/-delimited task identifier, or""for the root foreground task.
User-input category when
state == StatusState.BLOCKED.
Completion percentage in
0..100, when reported.
appwhen present, otherwise inherited from the nearest ancestor task prefix inProgramStatusStore.
Decoded UTF-8 detail message (
<= 2048UTF-8 bytes).
-
-
class libvt.ProgramStatusChangedclass[source]class[source]class libvt.ProgramStatusChanged
Bases:
objectEmitted when
OSC 7501orOSC 9;4mutates task status.-
attributeattribute
Updated task record, or
Nonewhen all records were cleared.
-
-
class libvt.ProgramStatusStoreclass[source]class[source]class libvt.ProgramStatusStore
Bases:
objectBounded store managing hierarchical
OSC 7501andOSC 9;4status.-
_max_recordsattributeattribute_max_records
-
_native_7501_seenattributeattribute_native_7501_seen
-
attributeattribute
-
apply_osc_7501(payload)method[source]method[source]apply_osc_7501(payload)
Apply a non-query
OSC 7501byte payload.- Returns:
(changed, updated_or_most_urgent)indicating whether store state changed and the resulting record (orNoneafter clear).- Return type:
tuple[bool,ProgramStatus|None]- Parameters:
payload (
bytes)
-
propertyproperty
Return the highest-urgency active record (preferring root on ties).
-
propertyproperty
Return a shallow copy of active task records keyed by
id.
-
-
class libvt.PromptKindclass[source]class[source]class libvt.PromptKind
Bases:
StrEnumOSC 133FinalTerm / semantic-shell prompt zone markers.-
PROMPT_START = 'A'attributeattributePROMPT_START = 'A'
-
COMMAND_START = 'B'attributeattributeCOMMAND_START = 'B'
-
COMMAND_EXECUTED = 'C'attributeattributeCOMMAND_EXECUTED = 'C'
-
COMMAND_FINISHED = 'D'attributeattributeCOMMAND_FINISHED = 'D'
-
-
class libvt.PromptMarkclass[source]class[source]class libvt.PromptMark
Bases:
objectEmitted when
OSC 133records a semantic prompt zone.-
attributeattribute
Recorded prompt zone descriptor.
-
__init__(zone)method[source]method[source]__init__(zone)
- Parameters:
zone (
PromptZone)- Return type:
-
-
class libvt.PromptZoneclass[source]class[source]class libvt.PromptZone
Bases:
objectSemantic shell prompt boundary emitted via
OSC 133.-
attributeattribute
Marker kind (
A,B,C, orD).
-
attributeattribute
Monotonic row index from the top of primary scroll history so scrolling never invalidates stored coordinates.
Parsed exit status on
Dmarkers when supplied, elseNone.
-
-
exception libvt.ProtocolErrorexception[source]exception[source]exception libvt.ProtocolError
Bases:
LibVtErrorRaised when
Policy.strictrejects a malformed or unsupported sequence.
-
class libvt.Rectclass[source]class[source]class libvt.Rect
Bases:
objectZero-based rectangular cell region.
-
class libvt.RegionViewclass[source]class[source]class libvt.RegionView
-
_col_rangeattributeattribute_col_range
-
_rowsattributeattribute_rows
Return right-trimmed text for each row in the region.
-
-
class libvt.RenderHoldChangedclass[source]class[source]class libvt.RenderHoldChanged
Bases:
objectEmitted when DEC mode
?2026synchronized output starts or ends.-
attributeattribute
Monotonic synchronized-update batch counter.
-
attributeattribute
Truewhen ended byexpire_synchronized_output().
-
-
class libvt.ResyncReasonclass[source]class[source]class libvt.ResyncReason
Bases:
StrEnumReason
Terminal.changes_since()emitted a full resynchronization.-
NONE = 'none'attributeattributeNONE = 'none'
-
INITIAL = 'initial'attributeattributeINITIAL = 'initial'
-
TERMINAL_MISMATCH = 'terminal_mismatch'attributeattributeTERMINAL_MISMATCH = 'terminal_mismatch'
-
EPOCH_CHANGED = 'epoch_changed'attributeattributeEPOCH_CHANGED = 'epoch_changed'
-
HISTORY_EVICTED = 'history_evicted'attributeattributeHISTORY_EVICTED = 'history_evicted'
-
-
class libvt.RgbColorclass[source]class[source]class libvt.RgbColor
Bases:
object24-bit direct RGB color (
SGR 38;2;r;g;b/SGR 38:2::r:g:b).
-
class libvt.RowRunclass[source]class[source]class libvt.RowRun
Bases:
objectContiguous run of identically styled cells within a
RowView.-
attributeattribute
Rendered text across
start_col..end_col(omitting spacer empty strings).
Shared
OSC 8hyperlink across the run, if any.
-
__init__(start_col, end_col, text, style=Style(fg=None, bg=None, underline_color=None, bold=False, dim=False, italic=False, underline=<UnderlineStyle.NONE: 0>, blink=False, reverse=False, hidden=False, strikethrough=False, overline=False), hyperlink=None)method[source]method[source]__init__(start_col, end_col, text, style=Style(fg=None, bg=None, underline_color=None, bold=False, dim=False, italic=False, underline=<UnderlineStyle.NONE: 0>, blink=False, reverse=False, hidden=False, strikethrough=False, overline=False), hyperlink=None)
-
-
class libvt.RowViewclass[source]class[source]class libvt.RowView
-
_col_rangeattributeattribute_col_range
-
_rowattributeattribute_row
-
_row_idxattributeattribute_row_idx
-
_screenattributeattribute_screen
Return coalesced
(style, hyperlink)spans up tousedcolumns.
-
propertyproperty
Return right-trimmed rendered text for this row slice.
-
-
class libvt.Screenclass[source]class[source]class libvt.Screen
Bases:
objectMutable 2D character grid with
FrozenRowRLE scrollback and reflow.-
_colsattributeattribute_cols
-
attributeattribute
-
attributeattribute
-
_history: _HistoryBufferattributeattribute_history: _HistoryBuffer
-
keyboard_stackattributeattributekeyboard_stack
-
scroll_regionattributeattributescroll_region
-
__init__(*, rows=24, cols=80, scrollback=2000, keyboard_stack_depth=8, cell_height_px=16, max_images=256, max_placements=1024, max_image_dimension=10000, is_alt=False)method[source]method[source]__init__(*, rows=24, cols=80, scrollback=2000, keyboard_stack_depth=8, cell_height_px=16, max_images=256, max_placements=1024, max_image_dimension=10000, is_alt=False)
Return
O(1)immutableRowViewsequence over scrollback.
Return stored
SIXEL/ KittyImageMetarecords.
Return right-trimmed text for every visible row.
-
propertyproperty
Return active + scrollback
ImagePlacementrecords.
-
scroll_down(count=1, *, top=None, bottom=None, left=0, right=None, bce_word=0, bce_ext=None, is_line_op=False)method[source]method[source]scroll_down(count=1, *, top=None, bottom=None, left=0, right=None, bce_word=0, bce_ext=None, is_line_op=False)
Scroll region
[top..bottom, left..right]downward by count lines.
-
scroll_up(count=1, *, top=None, bottom=None, left=0, right=None, save_history=True, bce_word=0, bce_ext=None, is_line_op=False)method[source]method[source]scroll_up(count=1, *, top=None, bottom=None, left=0, right=None, save_history=True, bce_word=0, bce_ext=None, is_line_op=False)
Scroll region
[top..bottom, left..right]upward by count lines.
-
propertyproperty
Return cumulative primary rows scrolled off the top margin.
Return sorted horizontal tabstop columns.
-
-
exception libvt.ScreenAssertionErrorexception[source]exception[source]exception libvt.ScreenAssertionError
Bases:
LibVtError,AssertionErrorRaised when
assert_screen()detects a screen mismatch.
-
class libvt.ScreenDeltaclass[source]class[source]class libvt.ScreenDelta
Bases:
objectMulti-consumer incremental screen update from
Terminal.changes_since().Previous watermark supplied by the caller.
-
attributeattribute
ResyncReason.NONEfor an incremental delta, or the reason a full resynchronization was required.
-
attributeattribute
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.
-
attributeattribute
Count of oldest scrollback rows evicted by scrollback capacity since from_token when
history_clearedisFalse.
-
attributeattribute
TruewhenED 3cleared scrollback since from_token.
-
attributeattribute
Truewhen cursor position, visibility, shape, orpending_wrapchanged.
-
attributeattribute
TruewhenSIXELor Kitty placements mutated.
-
attributeattribute
Immutable target
Snapshotcorresponding totoken.
-
__init__(token, from_token, resync_reason, viewport_scroll_up, dirty_rows, new_history, history_evicted, history_cleared, cursor_changed, modes_changed, metadata_changed, graphics_changed, snapshot)method[source]method[source]__init__(token, from_token, resync_reason, viewport_scroll_up, dirty_rows, new_history, history_evicted, history_cleared, cursor_changed, modes_changed, metadata_changed, graphics_changed, snapshot)
-
propertyproperty
Return
Truewhen the consumer must replace cached state.
-
class libvt.ScreenErasedclass[source]class[source]class libvt.ScreenErased
Bases:
objectEmitted when cells clear or scroll on the active screen.
-
attributeattribute
Operation that cleared or scrolled the region.
-
attributeattribute
Truewhen the erase occurred on the?1049alternate screen.
-
-
class libvt.ScreenSetclass[source]class[source]class libvt.ScreenSet
Bases:
objectDual primary and alternate (
?1049) screen pair.-
alternateattributeattributealternate
-
primaryattributeattributeprimary
-
__init__(*, rows=24, cols=80, scrollback=2000, keyboard_stack_depth=8, cell_height_px=16, max_images=256, max_placements=1024, max_image_dimension=10000)method[source]method[source]__init__(*, rows=24, cols=80, scrollback=2000, keyboard_stack_depth=8, cell_height_px=16, max_images=256, max_placements=1024, max_image_dimension=10000)
-
-
class libvt.ScrollRegionclass[source]class[source]class libvt.ScrollRegion
Bases:
objectInclusive zero-based scroll margin bounds (
DECSTBM/DECSLRM).
-
class libvt.SixelDataclass[source]class[source]class libvt.SixelData
Bases:
objectZero-dependency
DCS ... qSIXEL payload record.Parsed
DCSnumeric header parameters.
-
class libvt.SixelGraphicclass[source]class[source]class libvt.SixelGraphic
Bases:
objectEmitted when a
DCS ... qSIXEL graphic sequence completes.
-
class libvt.Snapshotclass[source]class[source]class libvt.Snapshot
Bases:
objectImmutable point-in-time capture of terminal screen, history, and metadata.
-
cursorattributeattributecursor
Zero-based cursor position, shape, visibility, and
pending_wrap.- Type:
-
titleattributeattributetitle
Window title set via
OSC 0/OSC 2.- Type:
-
cwdattributeattributecwd
Local working directory accepted under
Policy.osc7_hosts.- Type:
-
cwd_uriattributeattributecwd_uri
Raw
OSC 7/OSC 9;9working directory URI.- Type:
-
active_is_altattributeattributeactive_is_alt
Truewhen the alternate screen buffer is active.- Type:
-
prompt_zonesattributeattributeprompt_zones
Recorded primary-screen
OSC 133semantic prompt zones (empty whenactive_is_altisTrue).- Type:
tuple[PromptZone, …]
-
program_statusattributeattributeprogram_status
Highest-urgency active
OSC 7501/OSC 9;4status record.- Type:
ProgramStatus|None
-
attributeattribute
Read-only mapping of active
OSC 7501task records keyed byid.
-
generationattributeattributegeneration
Terminal mutation generation when this snapshot was captured.
- Type:
Read-only mapping of stored
SIXEL/ KittyImageMetaitems.
-
placementsattributeattributeplacements
Immutable active + scrollback
ImagePlacementrecords.- Type:
tuple[ImagePlacement, …]
-
_colsattributeattribute_cols
-
_evicted_totalattributeattribute_evicted_total
-
_frozenattributeattribute_frozen
-
_history: _FrozenHistoryattributeattribute_history: _FrozenHistory
-
_rowsattributeattribute_rows
-
_scrolled_totalattributeattribute_scrolled_total
-
__init__(*, rows, history=_EMPTY_FROZEN_HISTORY, cols, cursor, title, cwd, cwd_uri='', modes, active_is_alt, prompt_zones, program_status, program_statuses, generation, images=None, placements=(), scrolled_total=None, evicted_total=None)method[source]method[source]__init__(*, rows, history=_EMPTY_FROZEN_HISTORY, cols, cursor, title, cwd, cwd_uri='', modes, active_is_alt, prompt_zones, program_status, program_statuses, generation, images=None, placements=(), scrolled_total=None, evicted_total=None)
- 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:
-
at_abs(abs_row)method[source]method[source]at_abs(abs_row)
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.
-
propertyproperty
Return count of scrollback rows evicted from the active screen.
-
from_tmux_capture(captured, *, metadata=None, rows=24, cols=80, scrollback=None, flagged=False, joined_capture=None, saved_primary_capture=None, saved_primary_flagged=None, profile=TMUX_PROFILE, policy=TMUX_CAPTURE_POLICY, limits=DEFAULT_LIMITS)classmethod method[source]classmethod method[source]from_tmux_capture(captured, *, metadata=None, rows=24, cols=80, scrollback=None, flagged=False, joined_capture=None, saved_primary_capture=None, saved_primary_flagged=None, profile=TMUX_PROFILE, policy=TMUX_CAPTURE_POLICY, limits=DEFAULT_LIMITS)
Decode
tmux capture-paneoutput directly into aSnapshot.- Parameters:
- Return type:
Return
O(1)immutableRowViewsequence over scrollback rows.
Return right-trimmed text for every visible row in the snapshot.
-
propertyproperty
Return monotonic count of rows scrolled off the active screen’s top.
-
propertyproperty
Return visible snapshot text with trailing blank rows omitted.
-
-
class libvt.StatusStateclass[source]class[source]class libvt.StatusState
Bases:
StrEnumForeground task lifecycle states defined by
OSC 7501.-
IDLE = 'idle'attributeattributeIDLE = 'idle'
-
WORKING = 'working'attributeattributeWORKING = 'working'
-
DONE = 'done'attributeattributeDONE = 'done'
-
BLOCKED = 'blocked'attributeattributeBLOCKED = 'blocked'
-
ERROR = 'error'attributeattributeERROR = 'error'
-
CLEAR = 'clear'attributeattributeCLEAR = 'clear'
-
-
class libvt.StepResultclass[source]class[source]class libvt.StepResult
Bases:
objectReturn value from
Terminal.feed_until().-
attributeattribute
Flag(s) that triggered termination of the step.
-
-
class libvt.StopOnclass[source]class[source]class libvt.StopOn
Bases:
IntFlagBoundary conditions for
Terminal.feed_until().-
_generate_next_value_(name, start, count, last_values)staticmethod method[source]staticmethod method[source]_generate_next_value_(name, start, count, last_values)
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
-
_boundary_ = 'keep'attributeattribute_boundary_ = 'keep'
-
_flag_mask_ = 31attributeattribute_flag_mask_ = 31
-
_singles_mask_ = 31attributeattribute_singles_mask_ = 31
-
_all_bits_ = 31attributeattribute_all_bits_ = 31
-
_inverted_ = Noneattributeattribute_inverted_ = None
-
NONE = 0attributeattributeNONE = 0
-
EOF = 1attributeattributeEOF = 1
-
GROUND = 2attributeattributeGROUND = 2
-
SYNC_START = 4attributeattributeSYNC_START = 4
-
SYNC_END = 8attributeattributeSYNC_END = 8
-
PROMPT_MARK = 16attributeattributePROMPT_MARK = 16
-
-
class libvt.Styleclass[source]class[source]class libvt.Style
Bases:
objectImmutable SGR graphic rendition attributes for a cell or active pen.
-
fg: Colorattributeattributefg: Color
Foreground color, or
Nonefor terminal default foreground.
-
bg: Colorattributeattributebg: Color
Background color, or
Nonefor terminal default background.
-
underline_color: Colorattributeattributeunderline_color: Color
Underline color (
SGR 58), orNoneto inherit foreground.
-
attributeattribute
Underline style (
SGR 4/SGR 4:x/SGR 21).
-
__init__(fg=None, bg=None, underline_color=None, bold=False, dim=False, italic=False, underline=
UnderlineStyle.NONE, blink=False, reverse=False, hidden=False, strikethrough=False, overline=False)method[source]method[source]__init__(fg=None, bg=None, underline_color=None, bold=False, dim=False, italic=False, underline=UnderlineStyle.NONE, blink=False, reverse=False, hidden=False, strikethrough=False, overline=False)
-
-
class libvt.SyncTokenclass[source]class[source]class libvt.SyncToken
Bases:
objectOpaque monotonic watermark passed to
Terminal.changes_since().-
view: SyncViewattributeattributeview: SyncView
Tracked view (
"committed"or"working").
-
attributeattribute
Structural epoch incremented on
resize(),RIS, and?1049alternate-screen transitions.
-
attributeattribute
Cumulative primary-screen lines scrolled into history.
-
attributeattribute
Cumulative primary-screen history lines evicted by
maxlen.
-
attributeattribute
scrolled_totalvalue at the most recentED 3history clear.
-
attributeattribute
Monotonic counter of
ED 3history clears.
Enabled terminal modes at watermark capture.
-
attributeattribute
Raw
OSC 7/OSC 9;9working directory URI at watermark capture.
-
attributeattribute
Monotonic counter of prompt-zone, program-status, and window-metadata updates.
-
attributeattribute
Monotonic graphics placement revision on the active screen.
-
__init__(terminal_id, view, epoch, revision, scrolled_total, evicted_total, history_clear_at, history_clear_seq, cursor, modes, title, cwd, cwd_uri='', aux_revision=0, graphics_revision=0)method[source]method[source]__init__(terminal_id, view, epoch, revision, scrolled_total, evicted_total, history_clear_at, history_clear_seq, cursor, modes, title, cwd, cwd_uri='', aux_revision=0, graphics_revision=0)
-
-
class libvt.Terminalclass[source]class[source]class libvt.Terminal
Bases:
objectSans-I/O virtual terminal emulator over a streaming VT500 parser.
-
__init__(*, rows=24, cols=80, scrollback=2000, profile=DEFAULT_PROFILE, policy=DEFAULT_POLICY, limits=DEFAULT_LIMITS, on_event=None, on_pty_write=None, record_events=False, recorder=None, encoding='utf-8', newline_mode=False)method[source]method[source]__init__(*, rows=24, cols=80, scrollback=2000, profile=DEFAULT_PROFILE, policy=DEFAULT_POLICY, limits=DEFAULT_LIMITS, on_event=None, on_pty_write=None, record_events=False, recorder=None, encoding='utf-8', newline_mode=False)
- Parameters:
- Return type:
-
_notify_erase(rect, cause)method[source]method[source]_notify_erase(rect, cause)
- Parameters:
rect (
Rect)cause (
EraseCause)
- Return type:
-
changes_since(token=None, *, view='committed')method[source]method[source]changes_since(token=None, *, view='committed')
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:
-
propertyproperty
Return tear-free committed
Snapshotrespecting?2026hold.
-
propertyproperty
Return local working directory path accepted under
Policy.osc7_hosts.
-
propertyproperty
Return raw
OSC 7/OSC 9;9working directory URI.
-
expire_synchronized_output(sync_generation=None)method[source]method[source]expire_synchronized_output(sync_generation=None)
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.
-
from_size(size, *, scrollback=2000, profile=DEFAULT_PROFILE, policy=DEFAULT_POLICY, limits=DEFAULT_LIMITS)classmethod method[source]classmethod method[source]from_size(size, *, scrollback=2000, profile=DEFAULT_PROFILE, policy=DEFAULT_POLICY, limits=DEFAULT_LIMITS)
Construct a
Terminalfromos.terminal_size.
-
from_tmux_capture(captured, *, metadata=None, rows=24, cols=80, scrollback=None, flagged=False, joined_capture=None, saved_primary_capture=None, saved_primary_flagged=None, profile=TMUX_PROFILE, policy=TMUX_CAPTURE_POLICY, limits=DEFAULT_LIMITS)classmethod method[source]classmethod method[source]from_tmux_capture(captured, *, metadata=None, rows=24, cols=80, scrollback=None, flagged=False, joined_capture=None, saved_primary_capture=None, saved_primary_flagged=None, profile=TMUX_PROFILE, policy=TMUX_CAPTURE_POLICY, limits=DEFAULT_LIMITS)
Reconstruct a live
Terminalfromtmux capture-paneoutput.- Parameters:
- Return type:
Return sealed scrollback
RowViewlines.
Return active screen’s stored
ImageMetamap.
-
propertyproperty
Return active screen’s
KittyKeyboardFlags.
Return right-trimmed visible lines of the active screen.
-
propertyproperty
Return current
ParserState.
-
propertyproperty
Return active screen’s
ImagePlacementrecords.
-
propertyproperty
Return highest-urgency active
OSC 7501/OSC 9;4status.
-
propertyproperty
Return all active
OSC 7501task records keyed byid.
-
propertyproperty
Return recorded primary-screen
OSC 133semantic prompt zones.
-
propertyproperty
Return attached
FlightRecorder, if any.
-
propertyproperty
Return the dual primary/alternate
ScreenSet.
-
propertyproperty
Return monotonic
?2026synchronized-update batch counter.
-
sync_token(*, view='committed')method[source]method[source]sync_token(*, view='committed')
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:
-
propertyproperty
Return
Truewhile DEC mode?2026synchronized output is active.
-
propertyproperty
Return visible active-screen text with trailing blank rows omitted.
-
-
exception libvt.TerminalTimeoutErrorexception[source]exception[source]exception libvt.TerminalTimeoutError
Bases:
LibVtError,TimeoutErrorRaised when an async terminal stream or PTY wait exceeds its deadline.
- Parameters:
message (
str|None) – Concise single-line error summary; omitted whenNone.parser_state (
ParserState|None) – Parser state at timeout or premature EOF.screen_text (
str) – Visible screen text at failure time.recent_bytes (
collections.abc.Buffer) – Trailing raw bytes fromFlightRecorder.eof (
bool) –Truewhen the stream closed before the predicate matched.diagnostics (
str) – Pre-rendered viewport box and flight-recorder diagnostic block.attach_note (
bool) – WhenTrue(default), attach formatted diagnostics via PEP 678BaseException.add_note()while keepingstr(exc)single-line.
-
parser_stateattributeattributeparser_state
Parser state at timeout or premature EOF.
- Type:
ParserState|None
-
screen_textattributeattributescreen_text
Visible screen text at failure time.
- Type:
-
recent_bytesattributeattributerecent_bytes
Trailing raw bytes recorded prior to failure.
- Type:
-
eofattributeattributeeof
Truewhen end-of-stream occurred before matching.- Type:
-
diagnosticsattributeattributediagnostics
Explicit multi-line diagnostic text, if supplied.
- Type:
-
class libvt.TitleChangedclass[source]class[source]class libvt.TitleChanged
Bases:
objectEmitted when
OSC 0orOSC 2updates the window title.
-
class libvt.TmuxCaptureResultclass[source]class[source]class libvt.TmuxCaptureResult
Bases:
objectDecoded
tmuxcapture bundle ready for inspection or live streaming.-
attributeattribute
-
attributeattribute
Fidelity flags and terminal fields not exposed by
tmux.
-
attributeattribute
Per-line flags across
history + viewport(allNONEwhenflagged=False).
-
__init__(terminal, snapshot, completeness, line_flags)method[source]method[source]__init__(terminal, snapshot, completeness, line_flags)
- Parameters:
terminal (
Terminal)snapshot (
Snapshot)completeness (
CaptureCompleteness)line_flags (
tuple[TmuxLineFlags, ...])
- Return type:
-
-
class libvt.TmuxLineFlagsclass[source]class[source]class libvt.TmuxLineFlags
Bases:
IntFlagPer-line flags emitted by
tmux capture-pane -F(tmux >= 3.8).-
_generate_next_value_(name, start, count, last_values)staticmethod method[source]staticmethod method[source]_generate_next_value_(name, start, count, last_values)
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
-
_boundary_ = 'keep'attributeattribute_boundary_ = 'keep'
-
_flag_mask_ = 63attributeattribute_flag_mask_ = 63
-
_singles_mask_ = 63attributeattribute_singles_mask_ = 63
-
_all_bits_ = 63attributeattribute_all_bits_ = 63
-
_inverted_ = Noneattributeattribute_inverted_ = None
-
NONE = 0attributeattributeNONE = 0
-
DEAD = 1attributeattributeDEAD = 1
-
HYPERLINK = 2attributeattributeHYPERLINK = 2
-
START_OUTPUT = 4attributeattributeSTART_OUTPUT = 4
-
START_PROMPT = 8attributeattributeSTART_PROMPT = 8
-
WRAPPED = 16attributeattributeWRAPPED = 16
-
EXTENDED = 32attributeattributeEXTENDED = 32
-
-
class libvt.TmuxPaneMetadataclass[source]class[source]class libvt.TmuxPaneMetadata
Bases:
objectOut-of-band
tmuxpane state queried viaTMUX_METADATA_FORMAT.-
attributeattribute
Raw zero-based
#{cursor_x}(equalscolswhenpending_wrapis active intmux).
-
attributeattribute
Truewhen#{alternate_on}indicates an active alternate screen.
Saved primary-screen
x(#{alternate_saved_x};NonewhentmuxreportsUINT_MAXunder?47/?1047).
Saved primary-screen
y(#{alternate_saved_y};Nonewhen unset).
-
attributeattribute
Zero-based top scroll margin (
#{scroll_region_upper}).
Zero-based bottom scroll margin (
Nonedefaults torows - 1).
-
attributeattribute
DECCKMapplication cursor keys (#{keypad_cursor_flag}).
-
attributeattribute
?2004bracketed paste mode (#{bracket_paste_flag}).
-
attributeattribute
?1000VT200 mouse reporting (#{mouse_standard_flag}).
-
attributeattribute
?1002button-event mouse reporting (#{mouse_button_flag}).
-
attributeattribute
?1003all-motion mouse reporting (#{mouse_all_flag}).
-
attributeattribute
?1006SGR mouse encoding (#{mouse_sgr_flag}).
-
attributeattribute
?1004focus-in/out reporting (from#{pane_private_modes}).
DEC private mode numbers parsed from
#{pane_private_modes}.
Sorted zero-based tabstop columns from
#{pane_tabs}, orNoneto use standard 8-column tabstops.
-
attributeattribute
Current scrollback line count (
#{history_size}).
-
attributeattribute
?2026synchronized-output hold state (#{synchronized_output_flag}).
#{pane_output_generation}counter ontmux >= 3.8, elseNone.
-
__init__(cols=80, rows=24, cursor_x=0, cursor_y=0, cursor_visible=True, alternate_on=False, alternate_saved_x=None, alternate_saved_y=None, scroll_region_upper=0, scroll_region_lower=None, insert_flag=False, origin_flag=False, wrap_flag=True, keypad_cursor_flag=False, bracketed_paste_flag=False, mouse_standard_flag=False, mouse_button_flag=False, mouse_any_flag=False, mouse_sgr_flag=False, focus_events_flag=False, private_modes=frozenset({}), pane_tabs=None, history_size=0, history_limit=2000, synchronized=False, output_generation=None, cwd='', title='')method[source]method[source]__init__(cols=80, rows=24, cursor_x=0, cursor_y=0, cursor_visible=True, alternate_on=False, alternate_saved_x=None, alternate_saved_y=None, scroll_region_upper=0, scroll_region_lower=None, insert_flag=False, origin_flag=False, wrap_flag=True, keypad_cursor_flag=False, bracketed_paste_flag=False, mouse_standard_flag=False, mouse_button_flag=False, mouse_any_flag=False, mouse_sgr_flag=False, focus_events_flag=False, private_modes=frozenset({}), pane_tabs=None, history_size=0, history_limit=2000, synchronized=False, output_generation=None, cwd='', title='')
- Parameters:
cols (
int)rows (
int)cursor_x (
int)cursor_y (
int)cursor_visible (
bool)alternate_on (
bool)scroll_region_upper (
int)insert_flag (
bool)origin_flag (
bool)wrap_flag (
bool)keypad_cursor_flag (
bool)bracketed_paste_flag (
bool)mouse_standard_flag (
bool)mouse_button_flag (
bool)mouse_any_flag (
bool)mouse_sgr_flag (
bool)focus_events_flag (
bool)history_size (
int)history_limit (
int)synchronized (
bool)cwd (
str)title (
str)
- Return type:
-
propertyproperty
Return zero-based cursor column clamped into
[0, cols - 1].
-
propertyproperty
Return zero-based cursor row clamped into
[0, rows - 1].
-
-
class libvt.UnderlineStyleclass[source]class[source]class libvt.UnderlineStyle
Bases:
IntEnumITU T.416 / Kitty extended underline styles (
SGR 4:x).-
NONE = 0attributeattributeNONE = 0
-
SINGLE = 1attributeattributeSINGLE = 1
-
DOUBLE = 2attributeattributeDOUBLE = 2
-
CURLY = 3attributeattributeCURLY = 3
-
DOTTED = 4attributeattributeDOTTED = 4
-
DASHED = 5attributeattributeDASHED = 5
-
-
class libvt.UnhandledSequenceclass[source]class[source]class libvt.UnhandledSequence
Bases:
objectRecorded when an unrecognized control sequence arrives and
strict=False.-
attributeattribute
Sanitized compact representation of the unrecognized sequence.
-
-
exception libvt.UnsafePasteErrorexception[source]exception[source]exception libvt.UnsafePasteError
Bases:
LibVtErrorRaised when pasted text contains control or bracket-escape bytes.
-
class libvt.WidthRoleclass[source]class[source]class libvt.WidthRole
Bases:
IntEnumColumn occupancy role of a terminal grid cell.
-
NARROW = 0attributeattributeNARROW = 0
-
WIDE = 1attributeattributeWIDE = 1
-
SPACER_TAIL = 2attributeattributeSPACER_TAIL = 2
-
SPACER_HEAD = 3attributeattributeSPACER_HEAD = 3
-
-
class libvt.WindowRenamedclass[source]class[source]class libvt.WindowRenamed
Bases:
objectEmitted when
ESC k <name> ESC \updates thetmuxwindow name.
-
class libvt.WorkingDirectoryChangedclass[source]class[source]class libvt.WorkingDirectoryChanged
Bases:
objectEmitted when
OSC 7orOSC 9;9updates the working directory.
-
class libvt.ZLayerclass[source]class[source]class libvt.ZLayer
Bases:
StrEnumKitty graphics z-ordering plane relative to cell background and text.
-
BELOW_BG = 'below_bg'attributeattributeBELOW_BG = 'below_bg'
-
BELOW_TEXT = 'below_text'attributeattributeBELOW_TEXT = 'below_text'
-
ABOVE_TEXT = 'above_text'attributeattributeABOVE_TEXT = 'above_text'
-
-
libvt.decode_tmux_capture(captured, *, metadata=None, rows=24, cols=80, scrollback=None, flagged=False, joined_capture=None, saved_primary_capture=None, saved_primary_flagged=None, post_metadata=None, profile=TMUX_PROFILE, policy=TMUX_CAPTURE_POLICY, limits=DEFAULT_LIMITS)function[source]function[source]libvt.decode_tmux_capture(captured, *, metadata=None, rows=24, cols=80, scrollback=None, flagged=False, joined_capture=None, saved_primary_capture=None, saved_primary_flagged=None, post_metadata=None, profile=TMUX_PROFILE, policy=TMUX_CAPTURE_POLICY, limits=DEFAULT_LIMITS)
Reconstruct a
Terminalfromtmux capture-pane.Handles bare
SO/SI(0x0e/0x0f) ACS box-drawing runs without polluting the reconstructed terminal’s liveG1charset, expandsGRID_FLAG_TAB\tcells against#{pane_tabs}while preserving active SGR background/attributes, carries SGR across rows just liketmux’sgrid_string_cells(&gc), reconstructspending_wrapfromcursor_x >= pane_width, and optionally populates backgrounded primary history whenalternate_onis active.- Parameters:
captured (
CaptureInput) – Output oftmux capture-pane -S - -E - -e -p -N [-F]asstr,bytes, or a line sequence (e.g.libtmuxPane.capture_pane).metadata (
TmuxPaneMetadata|str|None) – ParsedTmuxPaneMetadataor raw format line emitted bydisplay-message -p TMUX_METADATA_FORMAT; whenNone, rows, cols, and scrollback defaults are used.rows (
int) – Fallback pane height when metadata isNone.cols (
int) – Fallback pane width when metadata isNone.scrollback (
int|None) – Explicit scrollback line cap; whenNone, defaults tometadata.history_limitif metadata is provided, else2000.flagged (
bool) –Truewhen captured includescapture-pane -Fline prefixes.joined_capture (
CaptureInput|None) – Optionalcapture-pane -S - -E - -e -p -Joutput used to infer soft wraps ontmux < 3.8whenflagged=False.saved_primary_capture (
CaptureInput|None) – Optionalcapture-pane -a -q -S - -E - -e -p -N [-F]output restoring the backgrounded primary screen and scrollback whenalternate_onisTrue.saved_primary_flagged (
bool|None) – Whether saved_primary_capture carries-Fprefixes (defaults to flagged).post_metadata (
TmuxPaneMetadata|str|None) – Optional second metadata sample taken immediately aftercapture-paneto verifypane_output_generationstability.profile (
Profile) – Compatibility profile for the reconstructed terminal.policy (
Policy) – Security policy for the reconstructed terminal.limits (
Limits) – Resource ceilings for the reconstructed terminal.
- Returns:
Reconstructed terminal, immutable snapshot, completeness report, and parsed per-line flags.
- Return type:
-
libvt.display_width(text, *, mode_2027=True, profile=None)function[source]function[source]libvt.display_width(text, *, mode_2027=True, profile=None)
Return rendered terminal column width of text.
-
function[source]function[source]
Encode event into outbound PTY bytes respecting active terminal modes.
- Parameters:
event (
InputEvent)modes (
ModeState)kitty_flags (
KittyKeyboardFlags)
- Return type:
-
libvt.encode_paste(text, *, bracketed, sanitize=False, allow_unbracketed_newlines=False)function[source]function[source]libvt.encode_paste(text, *, bracketed, sanitize=False, allow_unbracketed_newlines=False)
Encode text for pasting, failing closed on escape/control injection.
-
libvt.explain(data)function[source]function[source]libvt.explain(data)
Disassemble data into sanitized
ExplainedSpanrecords.- Parameters:
data (
Buffer|str)- Return type:
tuple[ExplainedSpan, ...]
-
libvt.format_explain(data)function[source]function[source]libvt.format_explain(data)
Format
explain()spans as aligned one-line records.
-
libvt.is_safe_paste(text, *, bracketed=True)function[source]function[source]libvt.is_safe_paste(text, *, bracketed=True)
Return
Truewhen text contains no escape or injection control bytes.
-
libvt.parse_flagged_line(line)function[source]function[source]libvt.parse_flagged_line(line)
Split a
tmux capture-pane -Fline into(flags, body).- Parameters:
line (
str) – Single line emitted bytmux capture-pane -F(without trailing\n).- Returns:
Parsed
TmuxLineFlagsand remaining SGR/text payload.- Return type:
- Raises:
ValueError– If line does not start with a valid<flags>space-delimited prefix.
-
libvt.parse_sgr(params, current=DEFAULT_STYLE, *, memo=None)function[source]function[source]libvt.parse_sgr(params, current=DEFAULT_STYLE, *, memo=None)
Apply
CSI ... mparameters to current and return a newStyle.
-
libvt.render(data, /, *, rows=24, cols=80, profile=DEFAULT_PROFILE, newline_mode=False)function[source]function[source]libvt.render(data, /, *, rows=24, cols=80, profile=DEFAULT_PROFILE, newline_mode=False)
Emulate data on a fresh
(rows, cols)terminal and returntext.
-
libvt.sanitize_terminal_text(text)function[source]function[source]libvt.sanitize_terminal_text(text)
Escape C0, C1,
DEL, and BiDi override codepoints for safe display.
-
libvt.strip(data, /)function[source]function[source]libvt.strip(data, /)
Strip VT escape, CSI, OSC, DCS, and APC sequences, keeping plain text.
-
libvt.unescape_tmux_control_output(data)function[source]function[source]libvt.unescape_tmux_control_output(data)
Decode
tmux -CC%outputoctal escapes into raw PTY bytes.tmuxcontrol mode escapes bytes< 0x20and backslash (0x5c->\134) as three-digit octal sequences\ooowhile passing printable ASCII and UTF-8 bytes verbatim (including split multi-byte UTF-8 sequences).- Parameters:
data (
collections.abc.Buffer|str) – Escaped payload following%output %<pane_id>.- Returns:
Unescaped raw VT byte stream ready for
feed().- Return type: