libvt.recorder

Terminal input/resize recorder protocol and bounded diagnostic ring buffer.

class libvt.recorder.CompositeRecorder
class libvt.recorder.CompositeRecorder

Bases: object

Fan-out TerminalRecorder dispatching to multiple child recorders.

Flattens nested CompositeRecorder instances at construction so hot-path dispatch remains a single flat tuple loop and find_flight_recorder() inspects every member in O(k).

class libvt.recorder.FlightRecorder
class libvt.recorder.FlightRecorder

Bases: object

Bounded raw-byte ring buffer capturing recent VT traffic for diagnostics.

Implements TerminalRecorder so it can be attached directly to Terminal via recorder=FlightRecorder().

Examples

>>> from libvt.recorder import FlightRecorder
>>> from libvt.terminal import Terminal
>>> rec = FlightRecorder(max_bytes=128)
>>> term = Terminal(rows=2, cols=10, recorder=rec)
>>> term.feed(b"\x1b[1;32mREADY\x1b[0m")
>>> rec.total_bytes, rec.tail()
(16, b'\x1b[1;32mREADY\x1b[0m')
class libvt.recorder.TerminalRecorder
class libvt.recorder.TerminalRecorder

Bases: Protocol

Structural recorder hook receiving normalized bytes and host resizes.

Implementations receive every non-empty byte span fed into feed() or feed_until() as a contiguous 1-D unsigned byte memoryview, plus every explicit host-initiated resize() (excluding internal DECCOLM column switches already present in the recorded VT stream).

Recorders that retain input beyond on_feed() must copy bytes (for example bytes(data)) before returning because callers may reuse or mutate the underlying buffer after feed() completes.

libvt.recorder.find_flight_recorder(recorder)
function[source]
function[source]
libvt.recorder.find_flight_recorder(recorder)

Return the first FlightRecorder in recorder, unwrapping composites.

Parameters:

recorder (TerminalRecorder | None)

Return type:

FlightRecorder | None