Terminal class

Provides access to the Ansi Terminal.

Constructors

Terminal()
Factory ctor to get a Terminal
factory

Properties

column int
Returns the column location of the cursor
getter/setter pair
columns int
The width of the terminal in columns. Where a column is one character wide. If no terminal is attached, a value of 80 is returned. This value can change if the user resizes the console window.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasTerminal bool
Whether a terminal is attached to stdin.
no setter
isAnsi bool
Returns true if ansi escape characters are supported.
no setter
lines int
Returns the current console height in rows.
no setter
row int
Returns the row location of the cursor. The first row is row 0.
getter/setter pair
rows int
The height of the terminal in rows. Where a row is one character high. If no terminal is attached to stdout, a StdoutException is thrown. This value can change if the users resizes the console window.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearLine({TerminalClearMode mode = TerminalClearMode.all}) → void
Clears the current console line without moving the cursor. If you want to write over the current line then call clearLine followed by startOfLine and then use write rather than print as it will leave the cursor on the current line. Alternatively use overwriteLine;
clearScreen({TerminalClearMode mode = TerminalClearMode.all}) → void
Clears the screen. If ansi escape sequences are not supported this is a no op. This call does not update the cursor position so in most cases you will want to call home after calling clearScreen.
cursorDown() → void
Moves the cursor down one row
cursorLeft() → void
Moves the cursor to the left one column
cursorRight() → void
Moves the cursor to the right one column
cursorUp() → void
Moves the cursor up one row
home() → void
Sets the cursor to the top left corner of the screen (0,0)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overwriteLine(String text) → void
Clears the current line, moves the cursor to column 0 and then prints text effectively overwriting the current console line. If the current console doesn't support ansi escape sequences (isAnsi == false) then this call will simply revert to calling print.
showCursor({required bool show}) → void
show/hide the cursor
startOfLine() → void
Moves the cursor to the start of line.
toString() String
A string representation of this object.
inherited
write(String text) → void
Writes text to the terminal at the current cursor location without appending a newline character.
writeLine(String text, {TextAlignment alignment = TextAlignment.left}) → void
Writes text to the console followed by a newline. You can control the alignment of text by passing the optional alignment argument which defaults to left alignment. The alignment is based on the current terminals width with spaces inserted to the left of the string to facilitate the alignment. Make certain the current line is clear and the cursor is at column 0 before calling this method otherwise the alignment will not work as expected.

Operators

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

Static Methods

previousLine() → void
Moves the cursor to the start of previous line.