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 onCurrentDirectoryChange(String title)?, void onSemanticPrompt(TerminalSemanticPromptState state)?, int? onColorQuery(int code, int? index)?, TerminalColorScheme? onColorSchemeQuery()?, String? onXtVersionQuery()?, String? onEnquiry()?, void onClipboardStore(String selector, String text)?, FutureOr<String?> onClipboardQuery(String selector)?, 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)?, bool reflowEnabled = true, Set<int>? wordSeparators})

Properties

altBuffer Buffer
no setter
altBufferMouseScrollMode bool
no setteroverride
altEscPrefixMode bool
no setteroverride
altSendsEscapeMode bool
no setteroverride
appKeypadMode bool
no setteroverride
applicationCursorType TerminalCursorType?
no setter
autoWrapMode bool
no setteroverride
backarrowKeyMode bool
no setteroverride
backgroundColorOverride int?
no setter
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
no setter
cursor CursorStyle
no setteroverride
cursorBlinkMode bool
no setteroverride
cursorColorOverride int?
no setter
cursorKeysMode bool
no setteroverride
cursorVisibleMode bool
no setteroverride
foregroundColorOverride int?
no setter
graphemeClusterMode bool
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
ignoreKeypadWithNumLockMode bool
no setteroverride
inBandSizeReportMode bool
no setteroverride
indexedColorOverrides Iterable<MapEntry<int, int>>
no setter
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
kittyKeyboardMode int
no setteroverride
lineFeedMode bool
no setteroverride
lines → IndexAwareCircularBuffer<BufferLine>
Lines of the active buffer.
no setter
listeners Set<void Function()>
finalinherited
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
modifyOtherKeysMode int
no setteroverride
mouseHandler TerminalMouseHandler?
getter/setter pair
mouseMode MouseMode
no setteroverride
mouseReportMode MouseReportMode
no setteroverride
mouseShiftCaptureMode bool
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
onClipboardQuery FutureOr<String?> Function(String selector)?
Called when the application requests clipboard contents through OSC 52.
getter/setter pair
onClipboardStore ↔ void Function(String selector, String text)?
Called when the application requests copying text through OSC 52.
getter/setter pair
onColorQuery int? Function(int code, int? index)?
Resolves the currently displayed color for OSC color queries. code is 4 for an indexed color or 10–12 for dynamic colors; index is provided only for code 4. The return value is a 24-bit RGB color.
getter/setter pair
onColorSchemeQuery TerminalColorScheme? Function()?
Resolves the current terminal color scheme for CSI ? 996 n queries. Return null to ignore the query.
getter/setter pair
onCurrentDirectoryChange ↔ void Function(String title)?
Called when the application reports its current directory using OSC 7.
getter/setter pair
onEnquiry String? Function()?
Called when the application sends ENQ (0x05). Return null or an empty string to keep the request silent.
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. icon is 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
onSemanticPrompt ↔ void Function(TerminalSemanticPromptState state)?
Called when the application reports shell-integration prompt state using OSC 133.
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
onXtVersionQuery String? Function()?
Resolves the terminal version string for XTVERSION (CSI > q) queries. Return null or an empty string to use the default xterm2 version.
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
reportColorSchemeMode bool
no setteroverride
reportFocusMode bool
no setteroverride
reverseDisplayMode bool
no setteroverride
reverseWrapExtendedMode bool
no setteroverride
reverseWrapMode bool
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticPromptState TerminalSemanticPromptState
no setter
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

addListener(void listener()) → void
inherited
assignUserPreferredSupplementalSet(int size, String charsetFinal) → void
override
backIndex() → void
override
backspaceReturn() → void
override
bell() → void
override
carriageReturn() → void
override
changeRectAttributes(int top, int left, int bottom, int right, int attribute) → 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
override
clearAltBuffer() → void
override
clearListeners() → void
inherited
clearTabStopUnderCursor() → void
override
copyRect(int sourceTop, int sourceLeft, int sourceBottom, int sourceRight, int sourcePage, int destinationTop, int destinationLeft, int destinationPage) → void
override
cursorNextLine(int amount) → void
override
cursorPrecedingLine(int amount) → void
override
deleteChars(int amount) → void
override
deleteColumns(int amount) → void
override
deleteLines(int amount) → void
override
designateCharset(int charset, int name) → void
override
dispose() → void
enquiry() → void
override
eraseChars(int amount) → void
override
eraseDisplay() → void
override
eraseDisplayAbove() → void
override
eraseDisplayAboveSelective() → void
override
eraseDisplayBelow() → void
override
eraseDisplayBelowSelective() → void
override
eraseDisplaySelective() → void
override
eraseLine() → void
override
eraseLineLeft() → void
override
eraseLineLeftSelective() → void
override
eraseLineRight() → void
override
eraseLineRightSelective() → void
override
eraseLineSelective() → void
override
eraseRect(int top, int left, int bottom, int right) → void
override
eraseScrollbackOnly() → void
override
fillRect(int char, int top, int left, int bottom, int right) → void
override
focusInput(bool focused) → void
Reports a terminal viewport focus change to the underlying application.
forwardIndex() → void
override
hyperlinkAt(CellOffset position) String?
hyperlinkIdAt(CellOffset position) int
index() → void
override
insertBlankChars(int amount) → void
override
insertColumns(int amount) → void
override
insertLines(int amount) → void
override
keyInput(TerminalKey key, {bool shift = false, bool alt = false, bool ctrl = false, TerminalKeyEventType type = TerminalKeyEventType.press, String? text}) bool
Sends a key event to the underlying program.
lineFeed() → void
override
mouseInput(TerminalMouseButton button, TerminalMouseButtonState buttonState, CellOffset position, {bool motion = false, TerminalMouseModifiers modifiers = TerminalMouseModifiers.none, CellOffset? pixelPosition}) bool
moveBackwardTabs(int count) → void
override
moveCursorX(int offset) → void
override
moveCursorY(int n) → void
override
moveForwardTabs(int count) → 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.
popKittyKeyboardModes(int count) → void
override
popTitle() → void
override
pushKittyKeyboardMode(int mode) → void
override
pushTitle() → void
override
queryClipboard(String selector) → void
override
queryDynamicColor(int code) → void
override
queryIndexedColor(int index) → void
override
removeListener(void listener()) → void
inherited
repeatPreviousCharacter(int count) → void
override
reportColorSchemeChange() → void
reportKittyKeyboardMode() → void
override
reportMode(int mode, bool decPrivate) → void
override
reportTitle() → void
override
reset() → void
override
resetBackground() → void
override
resetCursorStyle() → void
override
resetDynamicColor(int code) → void
override
resetForeground() → void
override
resetIndexedColors(List<int> indices) → void
override
resetTabStops() → void
override
resetUnderlineColor() → void
override
resize(int newWidth, int newHeight, [int? pixelWidth, int? pixelHeight]) → void
Resize the terminal screen. newWidth and newHeight should be greater than 0. Main-buffer text is reflowed when reflowEnabled is true.
override
restoreCursor() → void
override
restoreDecMode(int mode) → void
override
reverseIndex() → void
override
reverseRectAttributes(int top, int left, int bottom, int right, int attribute) → void
override
saveCursor() → void
override
saveCursorOrSetLeftRightMargins() → void
override
saveDecMode(int mode) → void
override
screenAlignmentTest() → void
override
scrollDown(int amount) → void
override
scrollUp(int amount) → void
override
selectiveEraseRect(int top, int left, int bottom, int right) → void
override
sendCellSize() → void
override
sendColorScheme() → void
override
sendCursorPosition() → void
override
sendOperatingStatus() → void
override
sendPixelSize() → void
override
sendPresentationStateReport(int request) → void
override
sendPrimaryDeviceAttributes() → void
override
sendPrivateDeviceStatusReport(List<int> params) → void
override
sendRectChecksum(int id, int page, int? top, int? left, int? bottom, int? right) → void
override
sendSecondaryDeviceAttributes() → void
override
sendSize() → void
override
sendStatusString(String query) → void
override
sendTerminalStateReport(int request) → void
override
sendTerminfoCapability(String query) → void
override
sendTertiaryDeviceAttributes() → void
override
sendUserPreferredSupplementalSet() → void
override
sendWindowReport() → void
override
sendXtVersion() → void
override
setActiveStatusDisplay(int display) → void
override
setAltBufferMouseScrollMode(bool enabled) → void
override
setAlternateTextColor(int attribute, int foreground, int background) → void
override
setAltEscPrefixMode(bool enabled) → void
override
setAltSendsEscapeMode(bool enabled) → void
override
setAppKeypadMode(bool enabled) → void
override
setAssignedColor(int selector, int foreground, int background) → void
override
setAttributeChangeExtent(bool rectangular) → void
override
setAutoRepeatMode(bool enabled) → void
override
setAutoWrapMode(bool enabled) → void
override
setBackarrowKeyMode(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
override
setColumnMode(bool enabled) → void
override
setColumnsPerPage(int cols) → void
override
setConformanceLevel(int level, int controls) → void
override
setCurrentDirectory(String uri) → void
override
setCursor(int x, int y) → void
override
override
setCursorBlinkMode(bool enabled) → void
override
setCursorBold() → void
override
setCursorDashedUnderline() → void
override
setCursorDottedUnderline() → void
override
setCursorDoubleUnderline() → void
override
setCursorFaint() → void
override
setCursorInverse() → void
override
setCursorInvisible() → void
override
setCursorItalic() → void
override
setCursorKeysMode(bool enabled) → void
override
setCursorOverline() → void
override
setCursorShape(int style) → void
override
setCursorStrikethrough() → void
override
setCursorUndercurl() → void
override
setCursorUnderline() → void
override
setCursorVisibleMode(bool enabled) → void
override
setCursorX(int x) → void
override
setCursorY(int y) → void
override
setDynamicColor(int code, String value) → void
override
setEnableColumnMode(bool enabled) → void
override
setForegroundColor16(int color) → void
override
setForegroundColor256(int index) → void
override
setForegroundColorRgb(int r, int g, int b) → void
override
setGraphemeClusterMode(bool enabled) → void
override
override
setIconName(String name) → void
override
setIgnoreKeypadWithNumLockMode(bool enabled) → void
override
setInBandSizeReportMode(bool enabled) → void
override
setIndexedColor(int index, String value) → void
override
setInsertMode(bool enabled) → void
override
setIsoProtectedMode(bool enabled) → void
override
setKeyboardActionMode(bool enabled) → void
override
setKeyClickVolume(int volume) → void
override
setKittyKeyboardMode(int mode, int behavior) → void
override
setLeftRightMarginMode(bool enabled) → void
override
setLeftRightMargins(int left, [int? right]) → void
override
setLineFeedMode(bool enabled) → void
override
setLinesPerPage(int rows) → void
override
setLineTransmitTerminationCharacter(int character) → void
override
setLockKeyStyle(int style) → void
override
setMarginBellVolume(int volume) → void
override
setMargins(int top, [int? bottom]) → void
override
setModifyOtherKeysMode(int resource, int mode) → void
override
setMouseMode(MouseMode mode) → void
override
setMouseReportMode(MouseReportMode mode) → void
override
setMouseShiftCaptureMode(bool enabled) → void
override
setOriginMode(bool enabled) → void
override
setProtectedFieldsAttribute(int attribute) → void
override
setProtectedMode(bool enabled) → void
override
setReportColorSchemeMode(bool enabled) → void
override
setReportFocusMode(bool enabled) → void
override
setReverseDisplayMode(bool enabled) → void
override
setReverseWrapExtendedMode(bool enabled) → void
override
setReverseWrapMode(bool enabled) → void
override
setSendReceiveMode(bool enabled) → void
override
setSlowScrollMode(bool enabled) → void
override
setStatusLineType(int type) → void
override
setSynchronizedUpdateMode(bool enabled) → void
override
setTapStop() → void
override
setTerminalModeEmulation(int mode) → void
override
setTitle(String name) → void
override
setTitleMode(int mode, bool enabled) → void
override
setTransmitTerminationCharacter(int character) → void
override
setUnderlineColor256(int index) → void
override
setUnderlineColorRgb(int r, int g, int b) → void
override
setUnknownDecMode(int mode, bool enabled) → void
override
setUnknownMode(int mode, bool enabled) → void
override
setWarningBellVolume(int volume) → void
override
shiftIn() → void
override
shiftOut() → void
override
singleShiftCharset(int charset) → void
override
softReset() → void
override
storeClipboard(String selector, String data) → void
override
tab() → void
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
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
useAltBuffer() → void
override
useCharset(int charset) → 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 data request it.
writeChar(int char) → void
override

Operators

operator ==(Object other) bool
The equality operator.
inherited