libvt.snapshot¶
Immutable terminal snapshots, incremental sync watermarks, and deltas.
-
class libvt.snapshot.ResyncReason¶class libvt.snapshot.ResyncReason¶
Bases:
StrEnumReason
changes_since()emitted a full resync.
-
class libvt.snapshot.ScreenDelta¶class libvt.snapshot.ScreenDelta¶
Bases:
objectMulti-consumer incremental update from
Terminal.changes_since.
-
class libvt.snapshot.Snapshot¶class libvt.snapshot.Snapshot¶
Bases:
objectImmutable point-in-time capture of terminal screen, history, and metadata.
Obtain instances via
committed(tear-free across?2026synchronized frames) orsnapshot()(immediate working buffer). Once captured, aSnapshotnever mutates when later bytes arrive on theTerminaland can be shared across threads without locking.Index
snap[row]for aRowView,snap[row, col]for an immutableCell, orsnap[r0:r1, c0:c1]for a rectangularRegionView. Render a visual grid box withformat_screen_box()or include header metadata andSGRspans withserialize_vt_snapshot().Examples
>>> from libvt.terminal import Terminal >>> from libvt.testing import serialize_vt_snapshot >>> term = Terminal(rows=2, cols=14) >>> term.feed(b"\x1b[1;32mREADY\x1b[0m api\r\n\x1b[7m> worker\x1b[0m") >>> snap = term.committed >>> print(serialize_vt_snapshot(snap)) size=14x2 cursor=(1,8,vis=True) alt=False modes=[] ┌──────────────┐ │READY api │ │> worker │ └──────────────┘ styles: r0[0..5]: bold fg=green r1[0..8]: reverse >>> snap[0, 0].text, snap[0, 0].style.bold, snap[1, 0].style.reverse ('R', True, True)
-
class libvt.snapshot.SnapshotDict¶class libvt.snapshot.SnapshotDict¶
Bases:
TypedDictTyped JSON-compatible dictionary returned by
Snapshot.to_dict().
-
class libvt.snapshot.SyncToken¶class libvt.snapshot.SyncToken¶
Bases:
objectOpaque per-
Terminalwatermark for incremental sync.Compare tokens with
==and store them in sets or dictionaries viahash(); obtain instances fromsync_token()orScreenDelta.token.Examples
>>> from libvt.terminal import Terminal >>> term = Terminal(rows=2, cols=12) >>> tok0 = term.sync_token() >>> term.feed(b"status: ok") >>> delta = term.changes_since(tok0) >>> delta.dirty_rows, delta.snapshot.lines ((0,), ('status: ok', ''))
Buffer view selector for
sync_token()andchanges_since().