xterm library

An API-compatible replacement for package:xterm 4.0.0 on top of libghostty-vt, Ghostty's terminal emulation engine: the same names as xterm's package:xterm/xterm.dart, which exports core.dart and ui.dart.

Migrating is meant to be an import change:

// import 'package:xterm/xterm.dart';
import 'package:ghostty_dart_xterm/xterm.dart';

xterm's zmodem.dart (exported by xterm's xterm.dart) is not provided yet. COMPATIBILITY.md lists every xterm member and its status.

MIGRATING_FROM_XTERM.md explains every difference and the additive Terminal.dispose(), writeBytes and onOutputBytes.

Classes

AltInputHandler
A TerminalInputHandler that translates alt + key events into escape sequences. For example, alt + a becomes ^[a.
Buffer
One screen of a Terminal: the main buffer (with scrollback) or the alternate buffer used by full-screen programs.
BufferLine
One line of cells, four 32-bit words per cell: foreground, background, attributes (CellAttr) and content (code point and width, see CellContent); colours are packed as CellColor describes.
BufferRange
A range of cells between begin and end: a stream of lines (BufferRangeLine) or a rectangle (BufferRangeBlock).
BufferRangeBlock
A rectangular range with corners begin and end, like a block (column) selection.
BufferRangeLine
A range that runs in line order from begin to end, like a text selection: the rest of the first line, every line between, and the start of the last line.
BufferSegment
A BufferSegment represents a range within a line.
CascadeInputHandler
A TerminalInputHandler that chains multiple handlers together. If any handler returns a non-null value, it is returned. Otherwise, null is returned.
CascadeMouseHandler
A TerminalMouseHandler that tries each of its handlers in order and returns the first non-null result.
CellAnchor
A handle to a cell in a BufferLine that can be used to track the location of the cell. Anchors are guaranteed to be stable, retaining their relative position to each other after mutations to the buffer.
CellAttr
The attribute bits of CellData.flags and of CursorStyle.attrs.
CellColor
The packing of a colour value: the colour in the low 24 bits (valueMask) and its kind at typeShift.
CellContent
The packing of CellData.content.
CellData
One cell in xterm's packed format: colours as CellColor values, flags as CellAttr bits, and content as the code point plus the width shifted by CellContent.widthShift.
CellFlags
Cell attribute bits; the same values as CellAttr, without strikethrough. Unused by xterm 4.0.0 itself, kept for its API.
CellOffset
A cell position in a buffer: column x and buffer row y, where row 0 is the oldest scrollback row (not the top of the screen).
ClickMouseHandler
Reports presses of the left, middle and right buttons while the program uses MouseMode.clickOnly (X10, DEC mode 9).
CtrlInputHandler
A TerminalInputHandler that translates ctrl + key events into escape sequences. For example, ctrl + a becomes ^A.
CursorPosition
A mutable cell position.
CursorStyle
The text style new text is written with (the SGR pen): colours as CellColor values and CellAttr bits. Not the cursor's shape.
KeyboardVisibilty
Calls onKeyboardShow and onKeyboardHide when the soft keyboard appears or disappears (the view's bottom inset changes). The name's typo is xterm's API.
KeyboardVisibiltyState
The state of a KeyboardVisibilty: observes the window's metrics.
KeytabInputHandler
A TerminalInputHandler that translates key events according to a keytab file. If no keytab is provided, Keytab.defaultKeytab is used.
NamedColor
The 16 named colours, as the low bits of a CellColor.named colour.
PointerInputs
A set of PointerInputs.
Terminal
Terminal is an interface to interact with command line applications. It translates escape sequences from the application into updates to the buffer and events such as onTitleChange or onBell, as well as translating user input into escape sequences that the application can understand.
TerminalController
The selection, highlights and pointer settings of a TerminalView.
TerminalHighlight
A coloured range of a terminal, made by TerminalController.highlight; dispose removes it.
TerminalInputHandler
TerminalInputHandler contains the logic for translating a TerminalKeyboardEvent into escape sequences that can be recognized by the terminal.
TerminalKeyboardEvent
The key event received from the keyboard, along with the state of the modifier keys and state of the terminal. Typically consumed by the TerminalInputHandler to produce a escape sequence that can be recognized by the terminal.
TerminalMouseEvent
A mouse button press or release (or a wheel step) at a cell, with the terminal's state, as a TerminalMouseHandler receives it.
TerminalMouseHandler
Translates a TerminalMouseEvent into the text to send to the program.
TerminalState
The modes and size of a terminal, as the input and mouse handlers see it. Terminal implements it.
TerminalStyle
The font of a TerminalView: size, line height, family and fallbacks.
TerminalTheme
The colours of a TerminalView: the cursor, the selection, the default foreground and background, the 16 ANSI colours, and three search-hit colours that xterm 4.0.0 never paints (kept for the API).
TerminalThemes
xterm's built-in TerminalThemes.
TerminalView
A widget that shows a Terminal and sends the user's keys, text and mouse input to it: xterm's TerminalView, drawn by ghostty_dart_flutter.
TerminalViewState
The state of a TerminalView: shows and hides the soft keyboard and tells where the cursor is. Reach it with a GlobalKey<TerminalViewState>.
UpDownMouseHandler
Reports presses, releases and wheel steps (never a wheel "release") while the program uses MouseMode.upDownScroll or one of the modes that extend it.

Enums

MouseMode
Which mouse events the program asked to receive.
MouseReportMode
How mouse events are encoded.
PointerInput
A kind of pointer event that TerminalView may report to the program while it tracks the mouse (see TerminalController.setPointerInputs).
SelectionMode
How a selection covers the cells between its two ends.
TerminalCursorType
The shape TerminalView draws the cursor in.
TerminalKey
A key the input handlers translate, as xterm 4.0.0 names it.
TerminalMouseButton
A mouse button or wheel direction, as reported to the program.
TerminalMouseButtonState
Whether a mouse event is a release or a press.
TerminalTargetPlatform
The platform a Terminal behaves as. The input handlers read it, for example to leave Option+letter alone on macOS.

Constants

defaultInputHandler → const CascadeInputHandler
The default input handler for the terminal. That is composed of a KeytabInputHandler, a CtrlInputHandler, and a AltInputHandler.
defaultMouseHandler → const CascadeMouseHandler
The default mouse handler: a ClickMouseHandler then an UpDownMouseHandler, which together report what the program's MouseMode asks for.

Properties

defaultTerminalShortcuts → Map<ShortcutActivator, Intent>
xterm's default shortcuts of TerminalView for the current platform: Ctrl+Shift+C copies, Ctrl+V pastes and Ctrl+A selects all on Android, Fuchsia, Linux and Windows; Cmd+C, Cmd+V and Cmd+A on iOS and macOS.
no setter