StdioTerminal class

A InlineTerminal backed by the process standard input and output.

stdin is a single-subscription stream that can only ever be listened to once for the lifetime of the process, and cancelling that subscription makes it impossible to listen again. To allow several components to read input in sequence, this class subscribes to the input source exactly once and re-publishes its events through a long-lived broadcast stream.

Because the underlying subscription keeps the Dart VM alive, call dispose once the program is completely finished reading terminal input so the process can exit cleanly.

Implemented types

Constructors

StdioTerminal({Stdin? stdinOverride, Stdout? stdoutOverride, Stream<List<int>>? inputOverride})
Creates a terminal using the global stdin and stdout by default.

Properties

columns int
The current width of the terminal in columns, or a sensible default when the width cannot be determined.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
hasTerminal bool
Whether the process is attached to an interactive terminal (both input and output).
no setteroverride
input Stream<List<int>>
Raw input bytes from the terminal.
no setteroverride
interruptSignals Stream<void>
Emits an event when the user requests an interrupt (Ctrl+C / SIGINT).
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportsColor bool
Whether the terminal supports ANSI color escape codes.
no setteroverride

Methods

disableRawMode() → void
Restores the terminal modes that were active before enableRawMode.
override
dispose() Future<void>
Cancels the input subscription and releases resources.
override
enableRawMode() → void
Switches the terminal into raw mode, disabling line buffering and echo so individual key presses can be read immediately.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
write(String text) → void
Writes text to the terminal without adding a trailing newline.
override

Operators

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