Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

libvt

PyPI version tests license

libvt is a headless terminal emulator and VT parser for Python. Feed it terminal output to inspect screen contents, cursor positions, and cell styles, or use it to test terminal programs.

Requires Python 3.12 or later (CPython and PyPy). Written in Python, with type annotations and no runtime dependencies.

Installation

Install with uv:

$ uv add "libvt>=0.0.1a1,<0.1"

Install with pip:

$ pip install "libvt>=0.0.1a1,<0.1"

libvt is in pre-alpha (0.0.1a1). Minor and 0.0.x releases may include breaking API changes; pin libvt>=0.0.1a1,<0.1 while the package is pre-1.0.

Quickstart

Each call to feed() updates the terminal's screen. Read the resulting text, cells, and cursor position:

>>> import libvt
>>> term = libvt.Terminal(rows=2, cols=20)
>>> term.feed(b"Loading 10%")
>>> term.feed(b"\r\x1b[2KLoading 20%")
>>> term.text
'Loading 20%'
>>> term.cursor.row, term.cursor.col
(0, 11)

assert_screen_box() checks screen contents, wide-character column alignment, and cursor coordinates in tests:

>>> from libvt.testing import assert_screen_box
>>> t = libvt.Terminal(rows=2, cols=8)
>>> t.feed("日本ok\r\ndone".encode())
>>> assert_screen_box(
...     t,
...     """
...     ┌────────┐
...     │日本ok  │
...     │done    │
...     └────────┘
...     """,
...     cursor=(1, 4),
... )

render() returns screen text after processing terminal output. strip() removes control sequences without applying cursor movements. explain() identifies the sequences in a byte stream:

>>> libvt.render(b"\x1b[1;32mready\x1b[0m\r\nitem 1", rows=4, cols=20)
'ready\nitem 1'
>>> libvt.strip(b"\x1b[31merror:\x1b[0m failed")
'error: failed'
>>> [s.mnemonic for s in libvt.explain(b"\x1b[31merror:\x1b[0m")]
['SGR', 'TEXT', 'SGR']

Features

  • Check screen contents and cursor positions in tests, with expected and actual screens shown on failure.
  • Handle wide characters and emoji sequences using Unicode 17 width and grapheme rules.
  • Keep scrollback and reflow wrapped lines when the primary screen is resized.
  • Inspect completed redraws from applications that use synchronized output (?2026).
  • Encode keyboard, mouse, focus, and paste events according to the active terminal modes.
  • Run terminal programs on POSIX PTYs or connect to asyncio streams.

Read tmux captures as screen cells and decode control-mode output with libvt.tmux. Full guides and API reference are at libvt.git-pull.com.

License

MIT License. See LICENSE.

Metadata

Release files for libvt 0.0.1a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libvt 0.0.1a1
File Size Uploaded Provenance Actions
libvt-0.0.1a1.tar.gz 239.7 kB With provenance Details for libvt-0.0.1a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for libvt 0.0.1a1
File Interpreter ABI Platform Actions
libvt-0.0.1a1-py3-none-any.whl Python 3 none any Details for libvt-0.0.1a1-py3-none-any.whl

Total release size: 393.2 kB

Release files / libvt-0.0.1a1.tar.gz

Download URL libvt-0.0.1a1.tar.gz
Size 239.7 kB
Tags Source
SHA-256 checksum
How to use checksums
461214bd3e7a587eb7a11515f20e7b88e4c52cff0780813b2ddee68e07a98e81
BLAKE2b-256 checksum
How to use checksums
beac942afb51e358439bb933342f075864bec9c5aa098a46c5579ac13706e333
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / libvt-0.0.1a1-py3-none-any.whl

Download URL libvt-0.0.1a1-py3-none-any.whl
Size 153.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffb5063556774e35ee0e9f76c05061c66164cc5bdc2ab44016035576cc9f2812
BLAKE2b-256 checksum
How to use checksums
fdb90ffdf1d4a3a8610b938f9c64706a1cd681ff449f62800356d4a98658a5c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for libvt 0.0.1a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for libvt-0.0.1a1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page