Terminal
The Terminal interface provides low-level access to terminal operations including rendering, cursor control, and screen management.Terminal Interface
Minimal terminal interface for TUI with input handling and screen control.ProcessTerminal Class
Real terminal implementation usingprocess.stdin/process.stdout.
Constructor
Creates a new ProcessTerminal instance.Methods
start()
Starts the terminal with input and resize handlers.Callback invoked when input data is received
Callback invoked when terminal is resized
stop()
Stops the terminal and restores previous state.drainInput()
Drains stdin before exiting to prevent Kitty key release events from leaking to the parent shell over slow SSH connections.Maximum time to drain in milliseconds
Exit early if no input arrives within this time in milliseconds
write()
Writes output to the terminal.Data to write to terminal
moveBy()
Moves cursor up or down by N lines relative to current position.Number of lines to move. Positive moves down, negative moves up.
hideCursor() / showCursor()
Controls cursor visibility.clearLine()
Clears the current line.clearFromCursor()
Clears from cursor to end of screen.clearScreen()
Clears entire screen and moves cursor to (0,0).setTitle()
Sets terminal window title.Window title text
Properties
columns
Current terminal width in columns.rows
Current terminal height in rows.kittyProtocolActive
Whether Kitty keyboard protocol is active.Features
Kitty Keyboard Protocol
The terminal automatically queries and enables the Kitty keyboard protocol when available, providing:- Disambiguated escape codes
- Key press/repeat/release events
- Alternate keys (shifted key, base layout key)
- Support for non-Latin keyboard layouts
Bracketed Paste Mode
Bracketed paste mode is automatically enabled, wrapping pastes in\x1b[200~ … \x1b[201~ sequences.
Windows VT Input Support
On Windows, automatically enablesENABLE_VIRTUAL_TERMINAL_INPUT so the terminal sends VT sequences for modified keys (e.g., \x1b[Z for Shift+Tab).
Example Usage
Environment Variables
Path to log all terminal writes (for debugging)