TtyTerminal class final
POSIX /dev/tty terminal implementation.
This is a best-effort port of Ultraviolet's OpenTTY behavior for cases
where stdin/stdout are redirected but the process still has access to a
controlling TTY.
Notes:
- Uses
/dev/ttyfor input and output. - Uses
sttyto toggle raw mode and query size. - If any operation fails, it falls back to safe defaults (80x24, no-op raw).
- Implemented types
- Available extensions
Properties
- colorProfile → ColorProfile
-
The detected color profile of the terminal.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → int
-
The terminal height in rows.
no setteroverride
-
input
→ Stream<
List< int> > -
Stream of raw input bytes from the terminal.
no setteroverride
- isAltScreen → bool
-
Whether the terminal is currently in alternate screen mode.
no setteroverride
- isBracketedPasteEnabled → bool
-
Whether bracketed paste mode is currently enabled.
no setteroverride
- isMouseEnabled → bool
-
Whether mouse tracking is currently enabled.
no setteroverride
- isRawMode → bool
-
Whether raw mode is currently enabled.
no setteroverride
- isTerminal → bool
-
Whether output is connected to a real terminal (vs piped/redirected).
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → ({int height, int width})
-
The terminal size as a record of (width, height).
no setteroverride
- supportsAnsi → bool
-
Whether the terminal supports ANSI escape sequences.
no setteroverride
- width → int
-
The terminal width in columns.
no setteroverride
Methods
-
bell(
) → void -
Rings the terminal bell.
override
-
clearLine(
) → void -
Clears the current line.
override
-
clearLineToEnd(
) → void -
Clears from the cursor to the end of the line.
override
-
clearLineToStart(
) → void -
Clears from the cursor to the beginning of the line.
override
-
clearPreviousLines(
int lines) → void -
Clears the specified number of lines above the cursor.
override
-
clearScreen(
) → void -
Clears the entire screen.
override
-
clearToEnd(
) → void -
Clears from the cursor to the end of the screen.
override
-
clearToStart(
) → void -
Clears from the cursor to the beginning of the screen.
override
-
cursorDown(
[int lines = 1]) → void -
Moves the cursor down by
linesrows.override -
cursorHome(
) → void -
Moves the cursor to home position (1, 1).
override
-
cursorLeft(
[int cols = 1]) → void -
Moves the cursor left by
colscolumns.override -
cursorRight(
[int cols = 1]) → void -
Moves the cursor right by
colscolumns.override -
cursorToColumn(
int col) → void -
Moves the cursor to the specified
colon the current line (1-based).override -
cursorUp(
[int lines = 1]) → void -
Moves the cursor up by
linesrows.override -
disableBracketedPaste(
) → void -
Disables bracketed paste mode.
override
-
disableFocusReporting(
) → void -
Disables focus reporting.
override
-
disableMouse(
) → void -
Disables mouse tracking.
override
-
disableRawMode(
) → void -
Disables raw mode and restores original terminal settings.
override
-
dispose(
) → void -
Disposes of terminal resources and restores original state.
override
-
enableBracketedPaste(
) → void -
Enables bracketed paste mode.
override
-
enableFocusReporting(
) → void -
Enables focus reporting.
override
-
enableMouse(
) → void -
Enables mouse tracking.
override
-
enableMouseAllMotion(
) → void -
Enables mouse all motion tracking (includes hover events).
override
-
enableMouseCellMotion(
) → void -
Enables mouse cell motion tracking (clicks, wheel, drag).
override
-
enableRawMode(
) → RawModeGuard -
Enables raw mode (character-by-character input, no echo).
override
-
enterAltScreen(
) → void -
Enters the alternate screen buffer (fullscreen mode).
override
-
exitAltScreen(
) → void -
Exits the alternate screen buffer.
override
-
flush(
) → Future< void> -
Flushes any buffered output.
override
-
fullScreenRenderer(
{TuiRendererOptions options = const TuiRendererOptions()}) → FullScreenTuiRenderer -
Available on TuiTerminal, provided by the TuiTerminalRendererExtension extension
Creates a fullscreen renderer for this terminal. -
hideCursor(
) → void -
Hides the terminal cursor.
override
-
inlineRenderer(
{TuiRendererOptions options = const TuiRendererOptions(altScreen: false, hideCursor: false)}) → InlineTuiRenderer -
Available on TuiTerminal, provided by the TuiTerminalRendererExtension extension
Creates an inline renderer for this terminal. -
moveCursor(
int row, int col) → void -
Moves the cursor to the specified
rowandcol(1-based).override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
optimizeMovements(
) → ({bool useBackspace, bool useTabs}) -
Detects terminal capabilities for movement optimizations (e.g. hard tabs).
override
-
query(
String query, {Duration timeout = const Duration(seconds: 2)}) → Future< String?> -
Queries the terminal for information by writing query and waiting for a response.
override
-
readByte(
) → int -
Reads a single byte from input (blocking).
override
-
readLine(
) → String? -
Reads a line of input (blocking).
override
-
restoreCursor(
) → void -
Restores the previously saved cursor position.
override
-
saveCursor(
) → void -
Saves the current cursor position.
override
-
scrollDown(
[int lines = 1]) → void -
Scrolls the screen down by
linesrows.override -
scrollUp(
[int lines = 1]) → void -
Scrolls the screen up by
linesrows.override -
setProgressBar(
int state, int value) → void -
Sets the terminal progress bar (OSC 9;4).
override
-
setTitle(
String title) → void -
Sets the terminal window title.
override
-
showCursor(
) → void -
Shows the terminal cursor.
override
-
simpleRenderer(
{TuiRendererOptions options = const TuiRendererOptions()}) → SimpleTuiRenderer -
Available on TuiTerminal, provided by the TuiTerminalRendererExtension extension
Creates a simple renderer for this terminal. -
toString(
) → String -
A string representation of this object.
inherited
-
ultravioletRenderer(
{TuiRendererOptions options = const TuiRendererOptions()}) → UltravioletTuiRenderer -
Available on TuiTerminal, provided by the TuiTerminalRendererExtension extension
Creates an Ultraviolet-backed renderer for this terminal. -
write(
String text) → void -
Writes text to the terminal without a trailing newline.
override
-
writeln(
[String text = '']) → void -
Writes text to the terminal followed by a newline.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
tryOpen(
{String path = _defaultTtyPath, IOSink? output}) → TtyTerminal? -
Attempts to open
/dev/ttyand returns a TtyTerminal, ornullif not available on this platform.