core library
The terminal model of package:xterm 4.0.0, on libghostty-vt: the
same names as xterm's package:xterm/core.dart, so code written for
xterm compiles after changing the import.
Parsing and the screen live in libghostty-vt (through ghostty_dart),
not in Dart: xterm's EscapeParser and EscapeHandler are not
provided (ADR 0004). COMPATIBILITY.md lists every xterm member and
whether it is the same, differs, is planned or will not be supported.
It provides Terminal, its Buffers, lines, ranges and anchors,
xterm's value types (CellOffset, CursorStyle, TerminalState, …)
and its key and mouse handlers (TerminalKey, defaultInputHandler,
defaultMouseHandler, …). Terminal holds native memory: call its
additive dispose() when you are done with it.
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.
- KeytabInputHandler
-
A TerminalInputHandler that translates key events according to a keytab
file. If no keytab is provided,
Keytab.defaultKeytabis used. - NamedColor
- The 16 named colours, as the low bits of a CellColor.named colour.
- 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.
- 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.
Terminalimplements it. - 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.
- 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
Terminalbehaves 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.