libvt 0.0.1a0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. libvt-0.0.1a0/.gitignore +61 -0
  2. libvt-0.0.1a0/CHANGES +120 -0
  3. libvt-0.0.1a0/LICENSE +21 -0
  4. libvt-0.0.1a0/MIGRATION +15 -0
  5. libvt-0.0.1a0/PKG-INFO +133 -0
  6. libvt-0.0.1a0/README.md +102 -0
  7. libvt-0.0.1a0/conftest.py +20 -0
  8. libvt-0.0.1a0/docs/__init__.py +3 -0
  9. libvt-0.0.1a0/docs/_static/img/libvt.svg +5 -0
  10. libvt-0.0.1a0/docs/api/aio.md +6 -0
  11. libvt-0.0.1a0/docs/api/codec.md +6 -0
  12. libvt-0.0.1a0/docs/api/config.md +6 -0
  13. libvt-0.0.1a0/docs/api/events.md +6 -0
  14. libvt-0.0.1a0/docs/api/exc.md +6 -0
  15. libvt-0.0.1a0/docs/api/graphics.md +6 -0
  16. libvt-0.0.1a0/docs/api/index.md +120 -0
  17. libvt-0.0.1a0/docs/api/input.md +6 -0
  18. libvt-0.0.1a0/docs/api/libvt.md +7 -0
  19. libvt-0.0.1a0/docs/api/modes.md +6 -0
  20. libvt-0.0.1a0/docs/api/parser.md +6 -0
  21. libvt-0.0.1a0/docs/api/pytest_plugin.md +6 -0
  22. libvt-0.0.1a0/docs/api/screen.md +6 -0
  23. libvt-0.0.1a0/docs/api/status.md +6 -0
  24. libvt-0.0.1a0/docs/api/style.md +6 -0
  25. libvt-0.0.1a0/docs/api/terminal.md +6 -0
  26. libvt-0.0.1a0/docs/api/testing.md +6 -0
  27. libvt-0.0.1a0/docs/api/tmux.md +6 -0
  28. libvt-0.0.1a0/docs/conf.py +63 -0
  29. libvt-0.0.1a0/docs/history.md +11 -0
  30. libvt-0.0.1a0/docs/index.md +73 -0
  31. libvt-0.0.1a0/docs/justfile +116 -0
  32. libvt-0.0.1a0/docs/manifest.json +18 -0
  33. libvt-0.0.1a0/docs/migration.md +9 -0
  34. libvt-0.0.1a0/docs/project/adr/0001-clean-room-provenance-and-license-firewall.md +94 -0
  35. libvt-0.0.1a0/docs/project/adr/0002-sans-io-layers-profiles-and-closed-events.md +125 -0
  36. libvt-0.0.1a0/docs/project/adr/0003-two-tier-packed-viewport-and-rle-scrollback.md +124 -0
  37. libvt-0.0.1a0/docs/project/adr/0004-zero-based-row-col-coordinates-and-sync-stepping.md +100 -0
  38. libvt-0.0.1a0/docs/project/adr/0005-utf8-c1-isolation-and-unicode-17-grapheme-width.md +108 -0
  39. libvt-0.0.1a0/docs/project/adr/0006-charset-designations-and-single-truth-mode-reconciliation.md +95 -0
  40. libvt-0.0.1a0/docs/project/adr/0007-rex-osc-7501-program-status-and-semantic-prompts.md +115 -0
  41. libvt-0.0.1a0/docs/project/adr/0008-mode-aware-input-encoding-and-paste-safety.md +96 -0
  42. libvt-0.0.1a0/docs/project/adr/0009-declarative-sequence-codec-and-stream-explainer.md +68 -0
  43. libvt-0.0.1a0/docs/project/adr/0010-transport-only-asyncio-and-diagnostic-pytest-plugin.md +107 -0
  44. libvt-0.0.1a0/docs/project/adr/_template.md +37 -0
  45. libvt-0.0.1a0/docs/project/adr/index.md +22 -0
  46. libvt-0.0.1a0/docs/project/benchmark.md +46 -0
  47. libvt-0.0.1a0/docs/project/code-style.md +5 -0
  48. libvt-0.0.1a0/docs/project/compatibility.md +17 -0
  49. libvt-0.0.1a0/docs/project/contributing.md +11 -0
  50. libvt-0.0.1a0/docs/project/deprecations.md +14 -0
  51. libvt-0.0.1a0/docs/project/index.md +82 -0
  52. libvt-0.0.1a0/docs/project/public-api.md +32 -0
  53. libvt-0.0.1a0/docs/project/releasing.md +35 -0
  54. libvt-0.0.1a0/docs/quickstart.md +86 -0
  55. libvt-0.0.1a0/docs/redirects.txt +0 -0
  56. libvt-0.0.1a0/docs/topics/architecture.md +61 -0
  57. libvt-0.0.1a0/docs/topics/index.md +45 -0
  58. libvt-0.0.1a0/docs/topics/migrating-from-pyte.md +46 -0
  59. libvt-0.0.1a0/docs/topics/protocols-and-input.md +59 -0
  60. libvt-0.0.1a0/docs/topics/sync-and-asyncio.md +59 -0
  61. libvt-0.0.1a0/pyproject.toml +272 -0
  62. libvt-0.0.1a0/src/libvt/__about__.py +19 -0
  63. libvt-0.0.1a0/src/libvt/__init__.py +279 -0
  64. libvt-0.0.1a0/src/libvt/__main__.py +54 -0
  65. libvt-0.0.1a0/src/libvt/_grid.py +1075 -0
  66. libvt-0.0.1a0/src/libvt/_ucd.py +460 -0
  67. libvt-0.0.1a0/src/libvt/aio.py +787 -0
  68. libvt-0.0.1a0/src/libvt/codec.py +234 -0
  69. libvt-0.0.1a0/src/libvt/config.py +352 -0
  70. libvt-0.0.1a0/src/libvt/events.py +388 -0
  71. libvt-0.0.1a0/src/libvt/exc.py +213 -0
  72. libvt-0.0.1a0/src/libvt/graphics.py +1695 -0
  73. libvt-0.0.1a0/src/libvt/input.py +529 -0
  74. libvt-0.0.1a0/src/libvt/modes.py +145 -0
  75. libvt-0.0.1a0/src/libvt/parser.py +1208 -0
  76. libvt-0.0.1a0/src/libvt/py.typed +0 -0
  77. libvt-0.0.1a0/src/libvt/pytest_plugin.py +173 -0
  78. libvt-0.0.1a0/src/libvt/screen.py +1607 -0
  79. libvt-0.0.1a0/src/libvt/status.py +372 -0
  80. libvt-0.0.1a0/src/libvt/style.py +207 -0
  81. libvt-0.0.1a0/src/libvt/terminal.py +4264 -0
  82. libvt-0.0.1a0/src/libvt/testing.py +282 -0
  83. libvt-0.0.1a0/src/libvt/tmux.py +1011 -0
  84. libvt-0.0.1a0/tests/__init__.py +3 -0
  85. libvt-0.0.1a0/tests/fixtures/GraphemeBreakTest-17.0.0.txt +796 -0
  86. libvt-0.0.1a0/tests/test_aio.py +136 -0
  87. libvt-0.0.1a0/tests/test_benchmark.py +48 -0
  88. libvt-0.0.1a0/tests/test_codec.py +59 -0
  89. libvt-0.0.1a0/tests/test_exc.py +388 -0
  90. libvt-0.0.1a0/tests/test_graphics.py +181 -0
  91. libvt-0.0.1a0/tests/test_input.py +67 -0
  92. libvt-0.0.1a0/tests/test_libvt.py +79 -0
  93. libvt-0.0.1a0/tests/test_parser.py +173 -0
  94. libvt-0.0.1a0/tests/test_screen.py +390 -0
  95. libvt-0.0.1a0/tests/test_status.py +230 -0
  96. libvt-0.0.1a0/tests/test_terminal.py +405 -0
  97. libvt-0.0.1a0/tests/test_testing.py +78 -0
  98. libvt-0.0.1a0/tests/test_tmux.py +309 -0
  99. libvt-0.0.1a0/tests/test_ucd.py +366 -0
@@ -0,0 +1,61 @@
1
+ # Mac stuff
2
+ .DS_Store
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ .venv/
15
+ *env*/
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ downloads/
20
+ eggs/
21
+ .eggs/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ var/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+
31
+ # Unit test / coverage reports
32
+ htmlcov/
33
+ .tox/
34
+ .coverage
35
+ .coverage.*
36
+ .cache
37
+ coverage.xml
38
+ *.cover
39
+ .hypothesis/
40
+ .pytest_cache/
41
+ .ruff_cache/
42
+
43
+ # Sphinx documentation
44
+ docs/_build/
45
+ docs/_mermaid_cache/
46
+ docs/_static/fonts/
47
+ docs/_static/css/fonts.css
48
+
49
+ # Editors
50
+ .idea
51
+ .ropeproject
52
+ *.swp
53
+ .vim
54
+
55
+ # Local benchmark overrides
56
+ scripts/benchmark.local.toml
57
+
58
+ # Claude code
59
+ **/CLAUDE.local.md
60
+ **/CLAUDE.*.md
61
+ **/.claude/settings.local.json
libvt-0.0.1a0/CHANGES ADDED
@@ -0,0 +1,120 @@
1
+ # Changelog
2
+
3
+ ## libvt 0.0.1a1 (Yet to be released)
4
+
5
+ <!-- KEEP THIS PLACEHOLDER - DO NOT REMOVE OR MODIFY THIS LINE -->
6
+ _Notes on the upcoming release will go here._
7
+ <!-- END PLACEHOLDER - ADD NEW CHANGELOG ENTRIES BELOW THIS LINE -->
8
+
9
+ ## libvt 0.0.1a0 (2026-11-22)
10
+
11
+ Initial pre-alpha release of `libvt`: a pure-Python, zero-dependency virtual
12
+ terminal emulator, streaming VT500 byte parser, mode-aware input encoder,
13
+ `asyncio` POSIX PTY adapter, and `pytest` plugin.
14
+
15
+ ### What's new
16
+
17
+ #### Sans-I/O terminal core, two-tier RLE grid, and Unicode 17 width (#2)
18
+
19
+ {class}`~libvt.terminal.Terminal`, {class}`~libvt.screen.Screen`, and
20
+ {class}`~libvt.terminal.Snapshot` emulate primary and `?1049` alternate
21
+ screens with zero-based `(row, col)` coordinates, lazy 64-bit inline
22
+ viewport attributes, run-length-encoded scrollback history, and
23
+ primary-screen soft-wrap resize reflow. Top-level
24
+ {func}`~libvt.terminal.render`, {func}`~libvt.terminal.strip`, and
25
+ {func}`~libvt.codec.explain` helpers handle common rendering, stripping,
26
+ and sequence disassembly tasks, backed by `python -m libvt` CLI
27
+ subcommands.
28
+
29
+ {class}`~libvt.parser.Parser` decodes incremental UTF-8, colon-delimited
30
+ ITU T.416 SGR subparameters (`4:3`, `38:2::R:G:B`, `58:5:idx`), `G0`–`G3`
31
+ character-set designations (`ESC ( 0` DEC Special Graphics, `SO`/`SI`,
32
+ `SS2`/`SS3`), `HPR`/`VPR` (`CSI a` / `CSI e`), `CBT`/`CHT`,
33
+ `DECSCA`/`DECSED`/`DECSEL`, `CSI 3 J` / `CSI 22 J`, and `DCS tmux;`
34
+ passthrough framing while isolating UTF-8 `0x9C` and `U+009B` bytes from
35
+ 8-bit `C1` controls (with optional `encoding="latin-1"` 8-bit wire mode).
36
+ SHA-256-pinned Unicode 17.0.0 two-stage tables drive East Asian width and
37
+ DEC `?2027` UAX #29 grapheme clustering across ZWJ emoji, Regional
38
+ Indicator flag pairs, Indic conjuncts, Hangul jamo, and `VS15` / `VS16`
39
+ emoji variation sequences. See {doc}`topics/architecture` for details.
40
+
41
+ #### Synchronized output stepping, Rex `OSC 7501`, and host queries (#2)
42
+
43
+ {meth}`~libvt.terminal.Terminal.committed`,
44
+ {meth}`~libvt.terminal.Terminal.feed_until`, and
45
+ {meth}`~libvt.terminal.Terminal.expire_synchronized_output` provide
46
+ lazy copy-on-write frame holds and generation-tagged timeout recovery
47
+ for DEC mode `?2026` synchronized updates.
48
+ {class}`~libvt.terminal.Formatter` exports snapshots to plain text, VT
49
+ escape sequences, and span-coalesced HTML with URI scheme allowlisting.
50
+
51
+ {class}`~libvt.status.ProgramStatusStore` and
52
+ {class}`~libvt.status.ProgramStatus` implement the Rex `OSC 7501`
53
+ Program Status specification, including hierarchical task identifiers,
54
+ ancestor `app` inheritance, urgency ranking, base64 `title`/`msg`
55
+ validation, profile- and policy-gated `OSC 7501 ; ?` capability replies,
56
+ `OSC 9;4` fallback, and lifecycle pruning alongside `OSC 133` prompt zones,
57
+ `OSC 7` RFC 8089 working directory updates, `OSC 52` clipboard writes,
58
+ `OSC 10`/`11` and `OSC 110`/`111` dynamic colors, `tmux` `ESC k` window
59
+ renames ({class}`~libvt.events.WindowRenamed`), `DA1`/`DA2`, `DSR`,
60
+ `DECRQM`, `DECRQSS`, `XTVERSION`, `XTGETTCAP`, and `?2031`/`?996n`
61
+ color-scheme queries. Configuration splits cleanly across {class}`~libvt.config.Profile`
62
+ (including versioned {meth}`~libvt.config.Profile.tmux` phantom-column
63
+ and resize compatibility profiles), {class}`~libvt.config.Policy`, and
64
+ {class}`~libvt.config.Limits`. See {doc}`topics/protocols-and-input` for
65
+ details.
66
+
67
+ #### Mode-aware input encoding, `asyncio` PTY bridge, and pytest plugin (#2)
68
+
69
+ {class}`~libvt.input.KeyEvent`, {class}`~libvt.input.MouseEvent`,
70
+ {class}`~libvt.input.FocusEvent`, and {class}`~libvt.input.PasteEvent`
71
+ encode outbound PTY bytes against active terminal modes, including
72
+ per-screen Kitty `CSI u` keyboard stacks (`>u`, `<u`, `=u`, `?u`), `SGR`
73
+ and `SGR-Pixel` mouse tracking (`?1006`, `?1016`), and fail-closed
74
+ bracketed paste validation raising {exc}`~libvt.exc.UnsafePasteError`.
75
+
76
+ {class}`~libvt.aio.AsyncTerminalStream` and {func}`~libvt.aio.open_pty`
77
+ connect sans-I/O terminals to `asyncio` streams and controlling POSIX
78
+ pseudo-terminals (`TIOCSCTTY` and `tty_mode`) without importing `asyncio`
79
+ or `pty` on `import libvt`. The `pytest11` plugin provides
80
+ protocol-typed `vt_terminal`, `vt_factory`, `vt_parser`, `vt_recorder`,
81
+ and `vt_pty` fixtures alongside {func}`~libvt.testing.assert_screen`,
82
+ {func}`~libvt.testing.assert_screen_box`,
83
+ {exc}`~libvt.exc.TerminalTimeoutError` stream diagnostics, and
84
+ {class}`~libvt.terminal.FlightRecorder` ring buffers. See
85
+ {doc}`topics/sync-and-asyncio` for details.
86
+
87
+ #### Incremental sync deltas, `tmux` capture reconstruction, and graphics (#13–#20)
88
+
89
+ {meth}`~libvt.terminal.Terminal.sync_token` and
90
+ {meth}`~libvt.terminal.Terminal.changes_since` emit non-destructive
91
+ multi-consumer {class}`~libvt.terminal.ScreenDelta` updates across both
92
+ `"committed"` (`?2026`-held) and `"working"` views, paired with
93
+ {meth}`~libvt.terminal.ScreenDelta.apply_lines`,
94
+ {meth}`~libvt.terminal.ScreenDelta.apply_rows`, and `O(1)` copy-on-write
95
+ {attr}`~libvt.terminal.Snapshot.history` sequence views.
96
+
97
+ {func}`~libvt.tmux.decode_tmux_capture`,
98
+ {class}`~libvt.tmux.TmuxPaneMetadata`, and
99
+ {func}`~libvt.tmux.unescape_tmux_control_output` reconstruct live
100
+ {class}`~libvt.terminal.Terminal` and {class}`~libvt.terminal.Snapshot`
101
+ state from `tmux capture-pane` (handling bare `SO`/`SI` ACS borders,
102
+ `GRID_FLAG_TAB` tabstops, `-F` / `-J` soft wraps, phantom-column
103
+ `pending_wrap`, and `-a` saved primary screens).
104
+ {mod}`libvt.graphics` tracks zero-dependency `SIXEL` and Kitty `APC G`
105
+ image metadata ({class}`~libvt.graphics.ImageMeta`) and monotonic
106
+ `abs_row` grid placements ({class}`~libvt.graphics.ImagePlacement` and
107
+ {meth}`~libvt.graphics.ImagePlacement.occupies_abs`) resolved alongside
108
+ {class}`~libvt.events.PromptZone` anchors via
109
+ {meth}`~libvt.terminal.Snapshot.at_abs` and
110
+ {meth}`~libvt.terminal.Snapshot.viewport_row`.
111
+ {exc}`~libvt.exc.TerminalTimeoutError` attaches multi-line viewport and
112
+ flight-recorder diagnostics via PEP 678 `__notes__` while keeping
113
+ `str(exc)` single-line.
114
+
115
+ ### Documentation
116
+
117
+ - Add Architecture Decision Records `0001`–`0010` documenting clean-room
118
+ provenance, sans-I/O layering, two-tier RLE storage, Unicode 17
119
+ clustering, protocol semantics, input safety, and `asyncio`/pytest
120
+ boundaries in {doc}`project/adr/index` (#2).
libvt-0.0.1a0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026- libvt contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ # Migration notes
2
+
3
+ Migration and deprecation notes for `libvt` are recorded here; see
4
+ {ref}`changelog` as well.
5
+
6
+ `libvt` is pre-1.0. Pin a minor version range in downstream projects
7
+ (`libvt>=0.1,<0.2`).
8
+
9
+ ---
10
+
11
+ ## Upcoming Release
12
+
13
+ <!-- KEEP THIS PLACEHOLDER - DO NOT REMOVE OR MODIFY THIS LINE -->
14
+ _Detailed migration steps for the next version will be posted here._
15
+ <!-- END PLACEHOLDER - ADD NEW MIGRATION ENTRIES BELOW THIS LINE -->
libvt-0.0.1a0/PKG-INFO ADDED
@@ -0,0 +1,133 @@
1
+ Metadata-Version: 2.5
2
+ Name: libvt
3
+ Version: 0.0.1a0
4
+ Summary: Pure-Python, zero-dependency, typed virtual terminal emulator and streaming VT parser.
5
+ Project-URL: Bug Tracker, https://github.com/tmux-python/libvt/issues
6
+ Project-URL: Documentation, https://libvt.git-pull.com
7
+ Project-URL: Repository, https://github.com/tmux-python/libvt
8
+ Project-URL: Changes, https://github.com/tmux-python/libvt/blob/master/CHANGES
9
+ Author-email: Tony Narlock <tony@git-pull.com>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: ansi,emulator,pytest,terminal,tmux,vt,vt100,vt500
13
+ Classifier: Development Status :: 2 - Pre-Alpha
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: MacOS :: MacOS X
18
+ Classifier: Operating System :: POSIX
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Programming Language :: Python :: 3.15
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Classifier: Topic :: Terminals :: Terminal Emulators/X Terminals
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: <4.0,>=3.12
30
+ Description-Content-Type: text/markdown
31
+
32
+ # libvt
33
+
34
+ `libvt` (`pip install libvt`, `import libvt`) is a pure-Python,
35
+ zero-dependency, typed virtual terminal emulator and streaming VT parser
36
+ (`py3-none-any.whl` — no C shared library required).
37
+
38
+ [![tests](https://github.com/tmux-python/libvt/actions/workflows/tests.yml/badge.svg)](https://github.com/tmux-python/libvt/actions/workflows/tests.yml)
39
+ [![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/tmux-python/libvt/blob/master/LICENSE)
40
+
41
+ ## Highlights
42
+
43
+ - **Sans-I/O core**: Zero runtime dependencies, zero I/O on `import libvt`,
44
+ and no `asyncio`, `pty`, or `pytest` imports until requested.
45
+ - **Compact two-tier grid**: Lazy 64-bit inline viewport attributes plus
46
+ run-length-encoded scrollback rows and primary-screen soft-wrap resize
47
+ reflow.
48
+ - **Unicode 17 clustering**: Bundled two-stage width and UAX #29 tables
49
+ handling CJK wide glyphs, ZWJ emoji, Regional Indicator flag pairs,
50
+ Indic conjuncts, and `VS15` / `VS16` under DEC `?2027`.
51
+ - **Modern terminal protocols**: Rex `OSC 7501` Program Status (with
52
+ `OSC 9;4` fallback), `OSC 133` semantic prompt zones, `OSC 7` working
53
+ directory, `OSC 8` hyperlinks, `OSC 52` clipboard, `?2026`
54
+ synchronized-output stepping, `DECRQM`, `DECRQSS`, `XTGETTCAP`, and
55
+ `DCS tmux;` passthrough events.
56
+ - **Mode-aware input & testing**: Outbound key/mouse/focus/paste
57
+ encoding (including Kitty `CSI u` and fail-closed bracketed paste),
58
+ `libvt.aio` stream and controlling-TTY POSIX PTY helpers, `vt_*`
59
+ pytest fixtures, and `assert_screen` / `assert_screen_box` diffs with
60
+ `FlightRecorder` disassembly.
61
+
62
+ ## Requirements
63
+
64
+ - Python >= 3.12 (CPython and PyPy)
65
+ - Zero runtime dependencies
66
+
67
+ ## Installation
68
+
69
+ Install with `uv`:
70
+
71
+ ```console
72
+ $ uv add libvt
73
+ ```
74
+
75
+ Install with `pip`:
76
+
77
+ ```console
78
+ $ pip install libvt
79
+ ```
80
+
81
+ `libvt` is pre-1.0; pin a minor range in downstream projects
82
+ (`libvt>=0.1,<0.2`).
83
+
84
+ ## Quickstart
85
+
86
+ One-liner helpers render, strip, or disassemble VT byte streams without
87
+ managing an emulator instance:
88
+
89
+ ```python
90
+ >>> import libvt
91
+ >>> libvt.render(b"\x1b[1;32mready\x1b[0m\r\nitem 1", rows=4, cols=20)
92
+ 'ready\nitem 1'
93
+ >>> libvt.strip(b"\x1b[31merror:\x1b[0m failed")
94
+ 'error: failed'
95
+ ```
96
+
97
+ Stateful emulation tracks zero-based `(row, col)` cells, SGR colon
98
+ subparameters, query replies, and `OSC 7501` program status:
99
+
100
+ ```python
101
+ >>> term = libvt.Terminal(rows=4, cols=20)
102
+ >>> term.feed(b"\x1b[1;4:3;38:2::40:180:160mstatus\x1b[0m\x1b[6n")
103
+ >>> term[0, 0].style.underline
104
+ <UnderlineStyle.CURLY: 3>
105
+ >>> term.drain_replies()
106
+ b'\x1b[1;7R'
107
+ >>> term.feed(b"\x1b]7501;state=working:id=build:progress=60\x1b\\")
108
+ >>> term.program_status.value, term.program_status.progress
109
+ ('working', 60)
110
+ ```
111
+
112
+ Boxed visual assertions verify CJK wide-character alignment and cursor
113
+ coordinates in tests:
114
+
115
+ ```python
116
+ >>> from libvt.testing import assert_screen_box
117
+ >>> t = libvt.Terminal(rows=2, cols=8)
118
+ >>> t.feed("日本ok\r\ndone".encode())
119
+ >>> assert_screen_box(
120
+ ... t,
121
+ ... """
122
+ ... ┌────────┐
123
+ ... │日本ok │
124
+ ... │done │
125
+ ... └────────┘
126
+ ... """,
127
+ ... cursor=(1, 4),
128
+ ... )
129
+ ```
130
+
131
+ ## License
132
+
133
+ MIT License. See [LICENSE](LICENSE).
@@ -0,0 +1,102 @@
1
+ # libvt
2
+
3
+ `libvt` (`pip install libvt`, `import libvt`) is a pure-Python,
4
+ zero-dependency, typed virtual terminal emulator and streaming VT parser
5
+ (`py3-none-any.whl` — no C shared library required).
6
+
7
+ [![tests](https://github.com/tmux-python/libvt/actions/workflows/tests.yml/badge.svg)](https://github.com/tmux-python/libvt/actions/workflows/tests.yml)
8
+ [![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/tmux-python/libvt/blob/master/LICENSE)
9
+
10
+ ## Highlights
11
+
12
+ - **Sans-I/O core**: Zero runtime dependencies, zero I/O on `import libvt`,
13
+ and no `asyncio`, `pty`, or `pytest` imports until requested.
14
+ - **Compact two-tier grid**: Lazy 64-bit inline viewport attributes plus
15
+ run-length-encoded scrollback rows and primary-screen soft-wrap resize
16
+ reflow.
17
+ - **Unicode 17 clustering**: Bundled two-stage width and UAX #29 tables
18
+ handling CJK wide glyphs, ZWJ emoji, Regional Indicator flag pairs,
19
+ Indic conjuncts, and `VS15` / `VS16` under DEC `?2027`.
20
+ - **Modern terminal protocols**: Rex `OSC 7501` Program Status (with
21
+ `OSC 9;4` fallback), `OSC 133` semantic prompt zones, `OSC 7` working
22
+ directory, `OSC 8` hyperlinks, `OSC 52` clipboard, `?2026`
23
+ synchronized-output stepping, `DECRQM`, `DECRQSS`, `XTGETTCAP`, and
24
+ `DCS tmux;` passthrough events.
25
+ - **Mode-aware input & testing**: Outbound key/mouse/focus/paste
26
+ encoding (including Kitty `CSI u` and fail-closed bracketed paste),
27
+ `libvt.aio` stream and controlling-TTY POSIX PTY helpers, `vt_*`
28
+ pytest fixtures, and `assert_screen` / `assert_screen_box` diffs with
29
+ `FlightRecorder` disassembly.
30
+
31
+ ## Requirements
32
+
33
+ - Python >= 3.12 (CPython and PyPy)
34
+ - Zero runtime dependencies
35
+
36
+ ## Installation
37
+
38
+ Install with `uv`:
39
+
40
+ ```console
41
+ $ uv add libvt
42
+ ```
43
+
44
+ Install with `pip`:
45
+
46
+ ```console
47
+ $ pip install libvt
48
+ ```
49
+
50
+ `libvt` is pre-1.0; pin a minor range in downstream projects
51
+ (`libvt>=0.1,<0.2`).
52
+
53
+ ## Quickstart
54
+
55
+ One-liner helpers render, strip, or disassemble VT byte streams without
56
+ managing an emulator instance:
57
+
58
+ ```python
59
+ >>> import libvt
60
+ >>> libvt.render(b"\x1b[1;32mready\x1b[0m\r\nitem 1", rows=4, cols=20)
61
+ 'ready\nitem 1'
62
+ >>> libvt.strip(b"\x1b[31merror:\x1b[0m failed")
63
+ 'error: failed'
64
+ ```
65
+
66
+ Stateful emulation tracks zero-based `(row, col)` cells, SGR colon
67
+ subparameters, query replies, and `OSC 7501` program status:
68
+
69
+ ```python
70
+ >>> term = libvt.Terminal(rows=4, cols=20)
71
+ >>> term.feed(b"\x1b[1;4:3;38:2::40:180:160mstatus\x1b[0m\x1b[6n")
72
+ >>> term[0, 0].style.underline
73
+ <UnderlineStyle.CURLY: 3>
74
+ >>> term.drain_replies()
75
+ b'\x1b[1;7R'
76
+ >>> term.feed(b"\x1b]7501;state=working:id=build:progress=60\x1b\\")
77
+ >>> term.program_status.value, term.program_status.progress
78
+ ('working', 60)
79
+ ```
80
+
81
+ Boxed visual assertions verify CJK wide-character alignment and cursor
82
+ coordinates in tests:
83
+
84
+ ```python
85
+ >>> from libvt.testing import assert_screen_box
86
+ >>> t = libvt.Terminal(rows=2, cols=8)
87
+ >>> t.feed("日本ok\r\ndone".encode())
88
+ >>> assert_screen_box(
89
+ ... t,
90
+ ... """
91
+ ... ┌────────┐
92
+ ... │日本ok │
93
+ ... │done │
94
+ ... └────────┘
95
+ ... """,
96
+ ... cursor=(1, 4),
97
+ ... )
98
+ ```
99
+
100
+ ## License
101
+
102
+ MIT License. See [LICENSE](LICENSE).
@@ -0,0 +1,20 @@
1
+ """Root pytest configuration and doctest namespace setup for libvt."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing as t
6
+
7
+ import pytest
8
+
9
+ import libvt
10
+ from libvt.testing import assert_screen, assert_screen_box
11
+
12
+
13
+ @pytest.fixture(autouse=True)
14
+ def _seed_doctest_namespace(doctest_namespace: dict[str, t.Any]) -> None:
15
+ """Populate doctest globals with common ``libvt`` entry points."""
16
+ doctest_namespace["libvt"] = libvt
17
+ doctest_namespace["Terminal"] = libvt.Terminal
18
+ doctest_namespace["AnsiColor"] = libvt.AnsiColor
19
+ doctest_namespace["assert_screen"] = assert_screen
20
+ doctest_namespace["assert_screen_box"] = assert_screen_box
@@ -0,0 +1,3 @@
1
+ """Documentation for the libvt package."""
2
+
3
+ from __future__ import annotations
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" fill="none">
2
+ <rect x="4" y="8" width="56" height="48" rx="8" fill="#0f172a" stroke="#14b8a6" stroke-width="3"/>
3
+ <path d="M16 24L26 32L16 40" stroke="#2dd4bf" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <rect x="32" y="36" width="16" height="4" rx="2" fill="#99f6e4"/>
5
+ </svg>
@@ -0,0 +1,6 @@
1
+ # `libvt.aio`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.aio
5
+ :members:
6
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.codec`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.codec
5
+ :members:
6
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.config`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.config
5
+ :members:
6
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.events`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.events
5
+ :members:
6
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.exc`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.exc
5
+ :members:
6
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.graphics`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.graphics
5
+ :members:
6
+ ```
@@ -0,0 +1,120 @@
1
+ (api)=
2
+
3
+ (reference)=
4
+
5
+ # API Reference
6
+
7
+ Public modules and types shipped by `libvt`.
8
+
9
+ ::::{grid} 1 1 2 2
10
+ :gutter: 2 2 3 3
11
+
12
+ :::{grid-item-card} `libvt`
13
+ :link: libvt
14
+ :link-type: doc
15
+ Top-level re-exports, progressive-disclosure helpers, and package metadata.
16
+ :::
17
+
18
+ :::{grid-item-card} `libvt.terminal`
19
+ :link: terminal
20
+ :link-type: doc
21
+ `Terminal`, `Snapshot`, `Formatter`, `FlightRecorder`, `render`, and `strip`.
22
+ :::
23
+
24
+ :::{grid-item-card} `libvt.screen`
25
+ :link: screen
26
+ :link-type: doc
27
+ `Screen`, `ScreenSet`, `Cell`, `RowView`, `RowRun`, `RegionView`, and `Cursor`.
28
+ :::
29
+
30
+ :::{grid-item-card} `libvt.parser`
31
+ :link: parser
32
+ :link-type: doc
33
+ Streaming VT500 `Parser`, `CsiParams`, `Action` records, and `parse_sgr`.
34
+ :::
35
+
36
+ :::{grid-item-card} `libvt.style` & `libvt.modes`
37
+ :link: style
38
+ :link-type: doc
39
+ `Style`, `AnsiColor`, `IndexedColor`, `RgbColor`, `Hyperlink`, and DEC/ANSI `Mode`s.
40
+ :::
41
+
42
+ :::{grid-item-card} `libvt.config`, `events`, & `status`
43
+ :link: config
44
+ :link-type: doc
45
+ `Profile`, `Policy`, `Limits`, closed `Event` union, and `OSC 7501` `ProgramStatus`.
46
+ :::
47
+
48
+ :::{grid-item-card} `libvt.input` & `libvt.codec`
49
+ :link: input
50
+ :link-type: doc
51
+ Mode-aware `KeyEvent`, `MouseEvent`, `PasteEvent`, and VT sequence `explain`.
52
+ :::
53
+
54
+ :::{grid-item-card} `libvt.aio`, `testing`, & `pytest_plugin`
55
+ :link: aio
56
+ :link-type: doc
57
+ `AsyncTerminalStream`, POSIX `open_pty`, `assert_screen`, and `vt_*` fixtures.
58
+ :::
59
+
60
+ :::{grid-item-card} `libvt.graphics`
61
+ :link: graphics
62
+ :link-type: doc
63
+ Zero-dependency `SIXEL` and Kitty `APC G` `ImageMeta` and `ImagePlacement`.
64
+ :::
65
+
66
+ :::{grid-item-card} `libvt.tmux`
67
+ :link: tmux
68
+ :link-type: doc
69
+ `decode_tmux_capture`, `TmuxPaneMetadata`, and `-CC` `%output` unescaping.
70
+ :::
71
+
72
+ ::::
73
+
74
+ ## Policy and Guarantees
75
+
76
+ ::::{grid} 1 2 3 3
77
+ :gutter: 2
78
+
79
+ :::{grid-item-card} Public API
80
+ :link: ../project/public-api
81
+ :link-type: doc
82
+ What is and is not part of the public API.
83
+ :::
84
+
85
+ :::{grid-item-card} Compatibility
86
+ :link: ../project/compatibility
87
+ :link-type: doc
88
+ Supported Python versions and platforms.
89
+ :::
90
+
91
+ :::{grid-item-card} Deprecations
92
+ :link: ../project/deprecations
93
+ :link-type: doc
94
+ Active deprecations and migration guidance.
95
+ :::
96
+
97
+ ::::
98
+
99
+ ```{toctree}
100
+ :hidden:
101
+ :maxdepth: 1
102
+
103
+ libvt
104
+ terminal
105
+ screen
106
+ parser
107
+ style
108
+ modes
109
+ config
110
+ events
111
+ status
112
+ input
113
+ codec
114
+ graphics
115
+ tmux
116
+ aio
117
+ testing
118
+ pytest_plugin
119
+ exc
120
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.input`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.input
5
+ :members:
6
+ ```
@@ -0,0 +1,7 @@
1
+ # `libvt`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt
5
+ :members:
6
+ :no-index:
7
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.modes`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.modes
5
+ :members:
6
+ ```
@@ -0,0 +1,6 @@
1
+ # `libvt.parser`
2
+
3
+ ```{eval-rst}
4
+ .. automodule:: libvt.parser
5
+ :members:
6
+ ```