{"library":"pyte","title":"Pyte Terminal Emulator","description":"Pyte is a simple, VTXXX-compatible terminal emulator library for Python. It processes ANSI escape sequences and maintains the state of a terminal screen, allowing programmatic interaction with terminal output without a GUI. The current version is 0.8.2, and it has a moderate release cadence, with updates typically for bug fixes and minor features.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pyte"],"cli":null},"imports":["from pyte import Screen","from pyte import Stream"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pyte\nimport sys\n\n# Create a screen and a stream\nscreen = pyte.Screen(columns=80, rows=24)\nstream = pyte.Stream(screen)\n\n# Feed some data, must be bytes\nstream.feed(b\"\\x1b[31mHello, \\x1b[32mWorld!\\x1b[0m\\r\\n\")\nstream.feed(b\"\\x1b[1mThis is bold.\\x1b[0m\\r\\n\")\nstream.feed(b\"\\x1b[3mThis is italic.\\x1b[0m\\r\\n\")\n\n# Print the current state of the screen\nfor row_str in screen.display:\n    sys.stdout.write(row_str)\n\nprint(f\"\\nCursor position: ({screen.cursor.x}, {screen.cursor.y})\")\nprint(f\"Current mode: {screen.mode}\")","lang":"python","description":"Initializes a `pyte.Screen` and `pyte.Stream`, feeds some basic ANSI-encoded text, and then prints the current state of the screen to standard output, including cursor position and mode.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}