Terminal class
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.
- Implemented types
Constructors
-
Terminal({int maxLines = 1000, void onBell()?, void onTitleChange(String title)?, void onIconChange(String title)?, void onOutput(String title)?, void onResize(int width, int height, int pixelWidth, int pixelHeight)?, TerminalTargetPlatform platform = TerminalTargetPlatform.unknown, TerminalInputHandler? inputHandler = defaultInputHandler, TerminalMouseHandler? mouseHandler = defaultMouseHandler, void onPrivateOSC(String code, List<
String> args)?, void onStatus(TerminalStatusEvent event)?, bool reflowEnabled = true, Set<int> ? wordSeparators, TerminalColorScheme? colorScheme})
Properties
- altBuffer → Buffer
-
no setter
- altBufferMouseScrollMode → bool
-
no setteroverride
- ansiMode → bool
-
no setteroverride
- appKeypadMode → bool
-
no setteroverride
- autoWrapMode → bool
-
no setteroverride
- bracketedPasteMode → bool
-
no setteroverride
- buffer → Buffer
-
Current active buffer of the terminal. This is initially mainBuffer and
can be switched back and forth from altBuffer to mainBuffer when
the underlying program requests it.
no setter
- colorRevision → int
-
Monotonically increasing revision bumped whenever any dynamic color
override changes, so renderers can sync without per-frame diffing.
no setter
- colorScheme → TerminalColorScheme
-
The base color palette and dark/light appearance synced from the view.
no setter
- colorSchemeUpdatesMode → bool
-
no setteroverride
- cursor → CursorStyle
-
no setteroverride
- cursorBlinkMode → bool
-
no setteroverride
- cursorKeysMode → bool
-
no setteroverride
- cursorTypeOverride → TerminalCursorType?
-
Cursor shape requested by the application running in the terminal.
no setter
- cursorVisibleMode → bool
-
no setteroverride
- dynamicBackground → int?
-
Dynamic background color override (
0xRRGGBB) set viaOSC 11, ornull.no setter - dynamicCursor → int?
-
Dynamic cursor color override (
0xRRGGBB) set viaOSC 12, ornull.no setter - dynamicForeground → int?
-
Dynamic foreground color override (
0xRRGGBB) set viaOSC 10, ornull.no setter -
dynamicPalette
→ Map<
int, int> -
Dynamic 256-color palette overrides (
index -> 0xRRGGBB) set viaOSC 4.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- inputHandler ↔ TerminalInputHandler?
-
The TerminalInputHandler used by this terminal. defaultInputHandler is
used when not specified. User of this class can provide their own
implementation of TerminalInputHandler or extend defaultInputHandler
with CascadeInputHandler.
getter/setter pair
- insertMode → bool
-
no setteroverride
- isUsingAltBuffer → bool
-
no setter
- lineFeedMode → bool
-
no setteroverride
-
lines
→ IndexAwareCircularBuffer<
BufferLine> -
Lines of the active buffer.
no setter
- mainBuffer → Buffer
-
no setter
- maxLines → int
-
The number of lines that the scrollback buffer can hold. If the buffer
exceeds this size, the lines at the top of the buffer will be removed.
final
- mouseHandler ↔ TerminalMouseHandler?
-
getter/setter pair
- mouseMode → MouseMode
-
no setteroverride
- mouseReportMode → MouseReportMode
-
no setteroverride
- onBell ↔ void Function()?
-
Function that is called when the program requests the terminal to ring
the bell. If not set, the terminal will do nothing.
getter/setter pair
- onIconChange ↔ void Function(String title)?
-
Function that is called when the program requests the terminal to change
the icon of the window.
iconis the name of the icon.getter/setter pair - onOutput ↔ void Function(String title)?
-
Function that is called when the terminal emits data to the underlying
program. This is typically caused by user inputs from textInput,
keyInput, mouseInput, or paste.
getter/setter pair
-
onPrivateOSC
↔ void Function(String code, List<
String> args)? -
The callback that is called when the terminal receives a unrecognized
escape sequence.
getter/setter pair
- onResize ↔ void Function(int width, int height, int pixelWidth, int pixelHeight)?
-
Function that is called when the dimensions of the terminal change.
getter/setter pair
- onStatus ↔ void Function(TerminalStatusEvent event)?
-
Called for program status reports (OSC 7501), progress bars (OSC 9;4),
shell integration marks (OSC 133) and full resets. The terminal keeps no
records itself: feed them to a ProgramStatusRecords.
getter/setter pair
- onTitleChange ↔ void Function(String title)?
-
Function that is called when the program requests the terminal to change
the title of the window to
title.getter/setter pair - originMode → bool
-
no setteroverride
- platform → TerminalTargetPlatform
-
Flag to toggle os specific behaviors.
final
- reflowEnabled ↔ bool
-
Whether the terminal performs reflow when the viewport size changes or
simply truncates lines. true by default.
getter/setter pairoverride-getter
- reportFocusMode → bool
-
no setteroverride
- reverseDisplayMode → bool
-
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- viewHeight → int
-
Number of rows in this terminal.
no setteroverride
- viewWidth → int
-
Number of cells in a terminal row.
no setteroverride
-
wordSeparators
→ Set<
int> ? -
Characters that break selection when double clicking. If not set, the
Buffer.defaultWordSeparators will be used.
final
Methods
-
addInputListener(
void listener(String output)) → void -
Calls
listenerwith each key, character, text, paste or mouse report before it is sent to the program. -
addListener(
void listener()) → void -
inherited
-
backIndex(
) → void -
Handles DECBI / backward index.
override
-
backspaceReturn(
) → void -
override
-
backTab(
int amount) → void -
Handles CBT / cursor backward tabulation.
override
-
bell(
) → void -
override
-
carriageReturn(
) → void -
override
-
charInput(
int charCode, {bool alt = false, bool ctrl = false}) → bool - Similary to keyInput, but takes a character as input instead of a TerminalKey.
-
clearAllTabStops(
) → void -
Handles TBC 3 / clear all tab stops.
override
-
clearAltBuffer(
) → void -
override
-
clearTabStopUnderCursor(
) → void -
Handles TBC 0 / clear tab stop at the cursor column.
override
-
cursorNextLine(
int amount) → void -
Handles CNL / cursor next line.
override
-
cursorPrecedingLine(
int amount) → void -
Handles CPL / cursor preceding line.
override
-
deleteChars(
int amount) → void -
override
-
deleteLines(
int amount) → void -
override
-
designateCharset(
int charset, int name) → void -
override
-
eraseChars(
int amount) → void -
override
-
eraseDisplay(
) → void -
override
-
eraseDisplayAbove(
) → void -
override
-
eraseDisplayBelow(
) → void -
override
-
eraseLine(
) → void -
override
-
eraseLineLeft(
) → void -
override
-
eraseLineRight(
) → void -
override
-
eraseScrollbackOnly(
) → void -
Handles ED 3 / erase scrollback.
override
-
focusInput(
bool focused) → void - Reports terminal view focus changes to the application when enabled.
-
forwardIndex(
) → void -
Handles DECFI / forward index.
override
-
index(
) → void -
override
-
insertBlankChars(
int amount) → void -
Handles ICH / insert blank characters.
override
-
insertLines(
int amount) → void -
override
-
keyInput(
TerminalKey key, {bool shift = false, bool alt = false, bool ctrl = false}) → bool - Sends a key event to the underlying program.
-
lineFeed(
) → void -
override
-
mouseInput(
TerminalMouseButton button, TerminalMouseButtonState buttonState, CellOffset position, {TerminalMouseModifiers modifiers = TerminalMouseModifiers.none}) → bool -
Handles a mouse event and returns true if it was reported.
positionis on the screen, counted from its top-left cell, not from the buffer's. -
moveCursorX(
int offset) → void -
override
-
moveCursorY(
int n) → void -
override
-
nextLine(
) → void -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
inherited
-
paste(
String text) → void - Similar to textInput, except that when the program tells the terminal that it supports bracketedPasteMode, the text is wrapped in escape sequences to indicate that it is a paste operation. Prefer this method over textInput when pasting text.
-
queryDynamicColor(
int code, OscTerminator terminator) → void -
OSC 10 / 11 / 12 ; ?: queries the default foreground, background, or cursor color.terminatormatches the sequence's own terminator.override -
queryPaletteColor(
int index, OscTerminator terminator) → void -
OSC 4 ; index ; ?: queries a 256-color palette entry (0..255).terminatormatches the sequence's own terminator.override -
queryProgramStatus(
) → void -
OSC 7501 ; ? ST: whether the terminal reads program status reports.override -
removeInputListener(
void listener(String output)) → void -
removeListener(
void listener()) → void -
inherited
-
repeatPreviousCharacter(
int count) → void -
Handles REP / repeat preceding character.
override
-
requestMode(
int mode, {required bool isPrivate}) → void -
Handles DECRQM (
CSI Ps $ porCSI ? Ps $ p) / request mode state.override -
resetAllPaletteColors(
) → void -
OSC 104: resets all dynamic palette color overrides back to the base theme.override -
resetBackground(
) → void -
override
-
resetCursorStyle(
) → void -
override
-
resetDynamicColor(
int code) → void -
OSC 110 / 111 / 112: resets the default foreground (10), background (11), or cursor (12) color override back to the base theme.override -
resetForeground(
) → void -
override
-
resetPaletteColor(
int index) → void -
OSC 104 ; index: resets a single 256-color palette entry (0..255) back to the base theme.override -
resetTerminal(
) → void -
override
-
resize(
int newWidth, int newHeight, [int? pixelWidth, int? pixelHeight]) → void -
Resize the terminal screen.
newWidthandnewHeightshould be greater than 0. Text reflow is currently not implemented and will be avaliable in the future.override -
restoreCursor(
) → void -
override
-
restoreDecMode(
int mode) → void -
Handles XTRESTORE (
CSI ? Pm r) / restore DEC private mode state.override -
reverseIndex(
) → void -
override
-
saveCursor(
) → void -
override
-
saveDecMode(
int mode) → void -
Handles XTSAVE (
CSI ? Pm s) / save DEC private mode state.override -
screenAlignmentPattern(
) → void -
Handles DECALN / screen alignment pattern.
override
-
scrollDown(
int amount) → void -
override
-
scrollUp(
int amount) → void -
override
-
sendColorScheme(
) → void -
Handles DEC private DSR 996 (
CSI ? 996 n) / color scheme query.override -
sendCursorPosition(
) → void -
override
-
sendExtendedCursorPosition(
) → void -
Handles DEC private DSR 6 / extended cursor position report.
override
-
sendOperatingStatus(
) → void -
override
-
sendPrimaryDeviceAttributes(
) → void -
override
-
sendSecondaryDeviceAttributes(
) → void -
override
-
sendSize(
) → void -
Handles window manipulation size reports.
override
-
sendTertiaryDeviceAttributes(
) → void -
override
-
setAltBufferMouseScrollMode(
bool enabled) → void -
Handles DECSET/DECRST 1007 / alternate-scroll mouse mode.
override
-
setAnsiMode(
bool enabled) → void -
override
-
setAppKeypadMode(
bool enabled) → void -
override
-
setAutoWrapMode(
bool enabled) → void -
override
-
setBackgroundColor16(
int color) → void -
override
-
setBackgroundColor256(
int index) → void -
override
-
setBackgroundColorRgb(
int r, int g, int b) → void -
override
-
setBracketedPasteMode(
bool enabled) → void -
Handles DECSET/DECRST 2004 / bracketed paste mode.
override
-
setColorSchemeUpdatesMode(
bool enabled) → void -
Handles DECSET/DECRST 2031 / color scheme update notifications.
override
-
setColumnMode(
bool enabled) → void -
DECCOLM is ignored, as xterm ignores it unless mode 40 allows it: the
view decides the width, and
resetsendsCSI ? 3 l, which left any terminal 80 columns wide and cleared.override -
setCursor(
int x, int y) → void -
override
-
setCursorBlink(
) → void -
override
-
setCursorBlinkMode(
bool enabled) → void -
override
-
setCursorBold(
) → void -
override
-
setCursorFaint(
) → void -
override
-
setCursorInverse(
) → void -
override
-
setCursorInvisible(
) → void -
override
-
setCursorItalic(
) → void -
override
-
setCursorKeysMode(
bool enabled) → void -
override
-
setCursorOverline(
) → void -
override
-
setCursorShape(
int shape) → void -
Handles DECSCUSR / set cursor style.
override
-
setCursorStrikethrough(
) → void -
override
-
setCursorUnderline(
) → void -
override
-
setCursorVisibleMode(
bool enabled) → void -
override
-
setCursorX(
int x) → void -
override
-
setCursorY(
int y) → void -
override
-
setDynamicColor(
int code, int rgb) → void -
OSC 10 / 11 / 12 ; spec: sets the default foreground (10), background (11), or cursor (12) color to a 24-bit0xRRGGBBvalue.override -
setForegroundColor16(
int color) → void -
override
-
setForegroundColor256(
int index) → void -
override
-
setForegroundColorRgb(
int r, int g, int b) → void -
override
-
setIconName(
String name) → void -
override
-
setInsertMode(
bool enabled) → void -
override
-
setLineFeedMode(
bool enabled) → void -
override
-
setMargins(
int top, [int? bottom]) → void -
override
-
setMouseMode(
MouseMode mode) → void -
override
-
setMouseReportMode(
MouseReportMode mode) → void -
override
-
setOriginMode(
bool enabled) → void -
override
-
setPaletteColor(
int index, int rgb) → void -
OSC 4 ; index ; spec: sets a 256-color palette entry (0..255) to a 24-bit0xRRGGBBvalue.override -
setReportFocusMode(
bool enabled) → void -
Handles DECSET/DECRST 1004 / focus event reporting.
override
-
setReverseDisplayMode(
bool enabled) → void -
override
-
setTapStop(
) → void -
override
-
setTitle(
String name) → void -
override
-
setUnknownDecMode(
int mode, bool enabled) → void -
override
-
setUnknownMode(
int mode, bool enabled) → void -
override
-
shiftIn(
) → void -
override
-
shiftOut(
) → void -
override
-
singleShift(
int charset) → void -
Handles SS2/SS3 single-shift controls.
override
-
softResetTerminal(
) → void -
Handles DECSTR / soft terminal reset.
override
-
tab(
) → void -
override
-
terminalStatus(
TerminalStatusEvent event) → void -
A program status report, progress bar or shell integration mark
(OSC 7501, OSC 9;4, OSC 133).
override
-
textInput(
String text) → void - Sends regular text input to the underlying program.
-
toString(
) → String -
A string representation of this object.
override
-
unknownCSI(
int finalByte) → void -
override
-
unknownOSC(
String ps, List< String> pt) → void -
override
-
unknownSBC(
int char) → void -
override
-
unkownEscape(
int char) → void -
override
-
unsetCursorBlink(
) → void -
override
-
unsetCursorBold(
) → void -
override
-
unsetCursorFaint(
) → void -
override
-
unsetCursorInverse(
) → void -
override
-
unsetCursorInvisible(
) → void -
override
-
unsetCursorItalic(
) → void -
override
-
unsetCursorOverline(
) → void -
override
-
unsetCursorStrikethrough(
) → void -
override
-
unsetCursorUnderline(
) → void -
override
-
unsupportedStyle(
int param) → void -
override
-
updateColorScheme(
TerminalColorScheme scheme) → void - Updates the terminal's reported colors and dark/light appearance.
-
useAltBuffer(
) → void -
override
-
useMainBuffer(
) → void -
override
-
write(
String data) → void -
Writes the data from the underlying program to the terminal. Calling this
updates the states of the terminal and emits events such as onBell or
onTitleChange when the escape sequences in
datarequest it. -
writeChar(
int char) → void -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited