libvt 0.0.1a0__py3-none-any.whl

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.
libvt/__about__.py ADDED
@@ -0,0 +1,19 @@
1
+ """Metadata for libvt."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __title__ = "libvt"
6
+ __package_name__ = "libvt"
7
+ __version__ = "0.0.1a0"
8
+ __description__ = (
9
+ "Pure-Python, zero-dependency, typed virtual terminal emulator"
10
+ " and streaming VT parser."
11
+ )
12
+ __author__ = "Tony Narlock"
13
+ __email__ = "tony@git-pull.com"
14
+ __github__ = "https://github.com/tmux-python/libvt"
15
+ __docs__ = "https://libvt.git-pull.com"
16
+ __tracker__ = "https://github.com/tmux-python/libvt/issues"
17
+ __pypi__ = "https://pypi.org/project/libvt/"
18
+ __license__ = "MIT"
19
+ __copyright__ = "Copyright 2026- Tony Narlock"
libvt/__init__.py ADDED
@@ -0,0 +1,279 @@
1
+ """Pure-Python virtual terminal emulator and streaming VT parser."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+
7
+ from libvt.__about__ import (
8
+ __author__,
9
+ __copyright__,
10
+ __description__,
11
+ __docs__,
12
+ __email__,
13
+ __github__,
14
+ __license__,
15
+ __package_name__,
16
+ __pypi__,
17
+ __title__,
18
+ __tracker__,
19
+ __version__,
20
+ )
21
+ from libvt._ucd import (
22
+ UNICODE_VERSION,
23
+ WidthRole,
24
+ display_width,
25
+ sanitize_terminal_text,
26
+ )
27
+ from libvt.codec import ExplainedSpan, explain, format_explain
28
+ from libvt.config import (
29
+ DEFAULT_LIMITS,
30
+ DEFAULT_OSC7_HOSTS,
31
+ DEFAULT_POLICY,
32
+ DEFAULT_PROFILE,
33
+ LINUX_CONSOLE_PROFILE,
34
+ TMUX_CAPTURE_POLICY,
35
+ TMUX_PROFILE,
36
+ XTERM_PROFILE,
37
+ Charset,
38
+ ColorScheme,
39
+ Limits,
40
+ Policy,
41
+ Profile,
42
+ SixelErasePolicy,
43
+ )
44
+ from libvt.events import (
45
+ Bell,
46
+ ClipboardWrite,
47
+ ColorSchemeQueried,
48
+ EraseCause,
49
+ Event,
50
+ InBandResize,
51
+ KittyCommand,
52
+ KittyGraphic,
53
+ Passthrough,
54
+ ProgramStatusChanged,
55
+ PromptKind,
56
+ PromptMark,
57
+ PromptZone,
58
+ Rect,
59
+ RenderHoldChanged,
60
+ ScreenErased,
61
+ SixelData,
62
+ SixelGraphic,
63
+ TitleChanged,
64
+ UnhandledSequence,
65
+ WindowRenamed,
66
+ WorkingDirectoryChanged,
67
+ )
68
+ from libvt.exc import (
69
+ LibVtError,
70
+ ProtocolError,
71
+ ScreenAssertionError,
72
+ TerminalTimeoutError,
73
+ UnsafePasteError,
74
+ )
75
+ from libvt.graphics import (
76
+ GraphicsProtocol,
77
+ ImageMeta,
78
+ ImagePlacement,
79
+ ZLayer,
80
+ )
81
+ from libvt.input import (
82
+ FocusEvent,
83
+ InputEvent,
84
+ KeyAction,
85
+ KeyEvent,
86
+ KeyMod,
87
+ KittyKeyboardFlags,
88
+ MouseAction,
89
+ MouseButton,
90
+ MouseEvent,
91
+ PasteEvent,
92
+ encode_input,
93
+ encode_paste,
94
+ is_safe_paste,
95
+ )
96
+ from libvt.modes import DecrpmValue, Mode, ModeState
97
+ from libvt.parser import CsiParams, Parser, ParserState, parse_sgr
98
+ from libvt.screen import (
99
+ BLANK_CELL,
100
+ Cell,
101
+ Cursor,
102
+ CursorShape,
103
+ RegionView,
104
+ RowRun,
105
+ RowView,
106
+ Screen,
107
+ ScreenSet,
108
+ ScrollRegion,
109
+ )
110
+ from libvt.status import BlockKind, ProgramStatus, ProgramStatusStore, StatusState
111
+ from libvt.style import (
112
+ DEFAULT_STYLE,
113
+ AnsiColor,
114
+ Color,
115
+ Hyperlink,
116
+ IndexedColor,
117
+ RgbColor,
118
+ Style,
119
+ UnderlineStyle,
120
+ )
121
+ from libvt.terminal import (
122
+ FlightRecorder,
123
+ Formatter,
124
+ OutputFormat,
125
+ ResyncReason,
126
+ ScreenDelta,
127
+ Snapshot,
128
+ StepResult,
129
+ StopOn,
130
+ SyncToken,
131
+ SyncView,
132
+ Terminal,
133
+ render,
134
+ strip,
135
+ )
136
+ from libvt.tmux import (
137
+ TMUX_METADATA_FORMAT,
138
+ CaptureCompleteness,
139
+ CaptureInput,
140
+ TmuxCaptureResult,
141
+ TmuxLineFlags,
142
+ TmuxPaneMetadata,
143
+ decode_tmux_capture,
144
+ parse_flagged_line,
145
+ unescape_tmux_control_output,
146
+ )
147
+
148
+ logging.getLogger(__name__).addHandler(logging.NullHandler())
149
+
150
+ __all__ = [
151
+ "BLANK_CELL",
152
+ "DEFAULT_LIMITS",
153
+ "DEFAULT_OSC7_HOSTS",
154
+ "DEFAULT_POLICY",
155
+ "DEFAULT_PROFILE",
156
+ "DEFAULT_STYLE",
157
+ "LINUX_CONSOLE_PROFILE",
158
+ "TMUX_CAPTURE_POLICY",
159
+ "TMUX_METADATA_FORMAT",
160
+ "TMUX_PROFILE",
161
+ "UNICODE_VERSION",
162
+ "XTERM_PROFILE",
163
+ "AnsiColor",
164
+ "Bell",
165
+ "BlockKind",
166
+ "CaptureCompleteness",
167
+ "CaptureInput",
168
+ "Cell",
169
+ "Charset",
170
+ "ClipboardWrite",
171
+ "Color",
172
+ "ColorScheme",
173
+ "ColorSchemeQueried",
174
+ "CsiParams",
175
+ "Cursor",
176
+ "CursorShape",
177
+ "DecrpmValue",
178
+ "EraseCause",
179
+ "Event",
180
+ "ExplainedSpan",
181
+ "FlightRecorder",
182
+ "FocusEvent",
183
+ "Formatter",
184
+ "GraphicsProtocol",
185
+ "Hyperlink",
186
+ "ImageMeta",
187
+ "ImagePlacement",
188
+ "InBandResize",
189
+ "IndexedColor",
190
+ "InputEvent",
191
+ "KeyAction",
192
+ "KeyEvent",
193
+ "KeyMod",
194
+ "KittyCommand",
195
+ "KittyGraphic",
196
+ "KittyKeyboardFlags",
197
+ "LibVtError",
198
+ "Limits",
199
+ "Mode",
200
+ "ModeState",
201
+ "MouseAction",
202
+ "MouseButton",
203
+ "MouseEvent",
204
+ "OutputFormat",
205
+ "Parser",
206
+ "ParserState",
207
+ "Passthrough",
208
+ "PasteEvent",
209
+ "Policy",
210
+ "Profile",
211
+ "ProgramStatus",
212
+ "ProgramStatusChanged",
213
+ "ProgramStatusStore",
214
+ "PromptKind",
215
+ "PromptMark",
216
+ "PromptZone",
217
+ "ProtocolError",
218
+ "Rect",
219
+ "RegionView",
220
+ "RenderHoldChanged",
221
+ "ResyncReason",
222
+ "RgbColor",
223
+ "RowRun",
224
+ "RowView",
225
+ "Screen",
226
+ "ScreenAssertionError",
227
+ "ScreenDelta",
228
+ "ScreenErased",
229
+ "ScreenSet",
230
+ "ScrollRegion",
231
+ "SixelData",
232
+ "SixelErasePolicy",
233
+ "SixelGraphic",
234
+ "Snapshot",
235
+ "StatusState",
236
+ "StepResult",
237
+ "StopOn",
238
+ "Style",
239
+ "SyncToken",
240
+ "SyncView",
241
+ "Terminal",
242
+ "TerminalTimeoutError",
243
+ "TitleChanged",
244
+ "TmuxCaptureResult",
245
+ "TmuxLineFlags",
246
+ "TmuxPaneMetadata",
247
+ "UnderlineStyle",
248
+ "UnhandledSequence",
249
+ "UnsafePasteError",
250
+ "WidthRole",
251
+ "WindowRenamed",
252
+ "WorkingDirectoryChanged",
253
+ "ZLayer",
254
+ "__author__",
255
+ "__copyright__",
256
+ "__description__",
257
+ "__docs__",
258
+ "__email__",
259
+ "__github__",
260
+ "__license__",
261
+ "__package_name__",
262
+ "__pypi__",
263
+ "__title__",
264
+ "__tracker__",
265
+ "__version__",
266
+ "decode_tmux_capture",
267
+ "display_width",
268
+ "encode_input",
269
+ "encode_paste",
270
+ "explain",
271
+ "format_explain",
272
+ "is_safe_paste",
273
+ "parse_flagged_line",
274
+ "parse_sgr",
275
+ "render",
276
+ "sanitize_terminal_text",
277
+ "strip",
278
+ "unescape_tmux_control_output",
279
+ ]
libvt/__main__.py ADDED
@@ -0,0 +1,54 @@
1
+ """Command-line entry point for ``python -m libvt`` (explain, render, strip)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import pathlib
7
+ import sys
8
+
9
+ from libvt.codec import format_explain
10
+ from libvt.terminal import render, strip
11
+
12
+
13
+ def _read_input(path: str | None) -> bytes:
14
+ if path is None or path == "-":
15
+ return sys.stdin.buffer.read()
16
+ return pathlib.Path(path).read_bytes()
17
+
18
+
19
+ def main(argv: list[str] | None = None) -> int:
20
+ """Run ``python -m libvt`` subcommands."""
21
+ parser = argparse.ArgumentParser(
22
+ prog="python -m libvt",
23
+ description="Inspect, render, or strip VT byte streams.",
24
+ )
25
+ sub = parser.add_subparsers(dest="command", required=True)
26
+
27
+ p_explain = sub.add_parser("explain", help="Disassemble VT escape sequences")
28
+ p_explain.add_argument("file", nargs="?", default="-", help="Input file or '-'")
29
+
30
+ p_render = sub.add_parser("render", help="Render VT stream to plain screen text")
31
+ p_render.add_argument("file", nargs="?", default="-", help="Input file or '-'")
32
+ p_render.add_argument("--rows", type=int, default=24, help="Screen rows")
33
+ p_render.add_argument("--cols", type=int, default=80, help="Screen columns")
34
+
35
+ p_strip = sub.add_parser("strip", help="Strip VT control sequences from input")
36
+ p_strip.add_argument("file", nargs="?", default="-", help="Input file or '-'")
37
+
38
+ args = parser.parse_args(argv)
39
+ raw = _read_input(args.file)
40
+
41
+ if args.command == "explain":
42
+ out = format_explain(raw)
43
+ elif args.command == "render":
44
+ out = render(raw, rows=args.rows, cols=args.cols)
45
+ else:
46
+ out = strip(raw)
47
+
48
+ if out:
49
+ sys.stdout.write(out + ("\n" if not out.endswith("\n") else ""))
50
+ return 0
51
+
52
+
53
+ if __name__ == "__main__":
54
+ raise SystemExit(main())