Terminal class

The main entry point for interacting with the terminal backend.

Handles input parsing, cursor manipulation, and querying terminal dimensions.

Available extensions

Constructors

Terminal([TerminalBackend? backend])
Creates a new terminal using the specified backend.

Properties

backend TerminalBackend
The underlying platform-specific terminal implementation.
final
events Stream<InputEvent>
A stream of all incoming input events from the terminal.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size Future<Point<int>>
Retrieves the current dimensions (width and height) of the terminal.
no setter

Methods

clear() → void
Clears the entire terminal screen.
cursorPosition() Future<Point<int>>
Requests the current coordinates of the cursor asynchronously.
disableMouseTracking() → void
Sends the sequence to disable mouse tracking.
dispose() → void
Disposes of the terminal resources and disables raw mode.
enableMouseTracking() → void
Sends the sequence to enable mouse tracking.
enterAlternateScreen() → void
Sends the sequence to enter the alternate screen buffer.
exitAlternateScreen() → void
Sends the sequence to exit the alternate screen buffer.
goto({required int x, required int y}) → void
Moves the cursor to the specified 1-based x and y coordinates.
hideCursor() → void
Sends the sequence to hide the terminal cursor.
home() → void
Moves the cursor to the top-left corner (home) of the terminal.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
printWidget(Widget widget) → void

Available on Terminal, provided by the PrintWidgetExtension extension

Renders and prints the given widget to standard output at the current inline cursor position.
readInput() Future<InputEvent>
Reads a single input event from the terminal asynchronously.
relative({Direction dir = Direction.down, required int places}) → void
Moves the cursor a relative number of places in the given dir direction.
resetMousePointer() → void
Resets the mouse pointer shape back to the terminal's default pointer.
resetStyle() → void
Sends the sequence to reset all cell styling back to default.
setMousePointer(MousePointer pointer) → void
Sets the mouse pointer shape to the specified pointer type.
showCursor() → void
Sends the sequence to show the terminal cursor.
toString() String
A string representation of this object.
inherited
watchSize() Stream<Point<int>>
Returns a stream that emits new dimensions whenever the terminal is resized.

Operators

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

Static Methods

runGuarded<T>(FutureOr<T> body(Terminal terminal), {TerminalBackend? backend}) Future<T>
Runs a function with a raw terminal, ensuring raw mode is disabled and the terminal is restored if the program encounters an uncaught exception.

Constants

disableMouseTrackingSequence → const String
Sequence to disable mouse click and drag tracking.
enableMouseTrackingSequence → const String
Sequence to enable mouse click and drag tracking.
enterAlternateScreenSequence → const String
Sequence to enter the alternate screen buffer.
exitAlternateScreenSequence → const String
Sequence to exit the alternate screen buffer.
hideCursorSequence → const String
Sequence to hide the terminal cursor.
resetStyleSequence → const String
Sequence to reset all text styling to defaults.
showCursorSequence → const String
Sequence to show the terminal cursor.