CliTerminal class abstract
The terminal a Cli talks through: where lines go (out, err), where a plain prompt reads them (readLine), what both can do (capabilities, mode), and, in the interactive mode, the terminal an inline twk app runs on (openInline).
CliTerminal.system is the process's stdio. Tests pass the fake one of
package:twk_test/cli.dart, which captures what is written and
replays what is typed.
Constructors
- CliTerminal()
- A terminal subclasses build on.
-
CliTerminal.system({bool reserveStdout, Map<
String, String> ? environment, bool? ansi, bool? interactive, bool? hyperlinks}) -
The process's stdio:
stdin,stdoutandstderr; withreserveStdoutwhat goes to stdout goes tostderr, for a program whose stdout is another's (a server speaking JSON-RPC on it).factory
Properties
- capabilities → CliCapabilities
-
What this terminal can do.
no setter
- clock → CliClock
-
Where the time of the session and its timers comes from.
no setter
- columns → int?
-
Width in columns; null when output is not a terminal and nothing
says how wide it is.
no setter
- err → StringSink
-
Where diagnostics go.
no setter
- exitCode ↔ int
-
The code the process ends with: on the process's terminal,
exitCodeof dart:io, which Cli.run sets when its body fails. Elsewhere it is kept here, 0 until it is set, so that a test reads it without ending its own process with it.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- mode → CliMode
-
How it may be talked to (CliCapabilities.mode).
no setter
- out → StringSink
-
Where ordinary output goes, line by line, while no inline session
holds the screen.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → Future< void> - Lets go of what it holds: on the process's terminal, stdin, once a readLine listened to it, so that the process can end. Nothing is read after it. Cli.close calls it; nothing by default.
-
flush(
) → Future< void> - Flushes out and err where they buffer.
-
interrupt(
) → void - What a Ctrl+C nothing live took does once the inline session has ended and handed the terminal back: on the process's terminal it sends the process SIGINT, so it ends as it would at a cooked terminal, unless the program watches the signal.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openInline(
) → Future< TerminalBackend> - Opens the terminal an inline twk app runs on, in the interactive mode: raw input, the normal screen. Called when the Cli's inline session starts, and again for a new one once a Ctrl+C ended the last (its terminal closed by then); the app closes it when the session ends.
-
promptShown(
String question) → void -
A prompt asking
questionis about to take its answer: its row is on the screen and takes keys, or a line is about to be read. Nothing happens on a terminal of the process; a terminal of a test answers it. -
readLine(
{}) → Future< String?> -
Reads one line as the terminal reads it, without its line break; null
at the end of input.
hiddenswitches echo off while it reads, where input is a terminal. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited