libghostty-vt is a C library which implements a modern terminal emulator, extracted from the Ghostty terminal emulator.
libghostty-vt contains the logic for handling the core parts of a terminal emulator: parsing terminal escape sequences, maintaining terminal state, encoding input events, etc. It can handle scrollback, line wrapping, reflow on resize, and more.
- Warning
- This library is currently in development and the API is not yet stable. Breaking changes are expected in future versions. Use with caution in production code.
API Reference
The API is organized into the following groups:
- Terminal - Complete terminal emulator state and rendering
- Render State - Incremental render state updates for custom renderers
- Formatter - Format terminal content as plain text, VT sequences, or HTML
- Terminal Snapshot - Encode and incrementally restore terminal state
- Search - Search terminal contents, including scrollback
- OSC Parser - Parse OSC (Operating System Command) sequences
- SGR Parser - Parse SGR (Select Graphic Rendition) sequences
- Paste - Paste into a terminal, validate and encode paste data
- Unicode Utilities - Codepoint properties for text layout
- Build Info - Query compile-time build configuration
- Memory Management - Memory management and custom allocators
- Byte-stream I/O - Reusable synchronous reader and writer callbacks
- WebAssembly Utilities - WebAssembly convenience functions
Encoding related APIs:
Examples
Complete working examples: