CliCapabilities class final
What a terminal can do, fixed when it is detected.
The process's terminal (CliTerminal.system) detects these from stdio
and the environment through CliCapabilities.detect; a fake terminal
states them outright.
final caps = CliCapabilities.detect(
environment: {'NO_COLOR': '1'},
inputIsTerminal: true,
outputIsTerminal: true,
outputSupportsAnsi: true,
);
print(caps.mode); // CliMode.plain
Constructors
- CliCapabilities({required bool ansi, required bool interactiveInput, required bool outputIsTerminal, bool? errorIsTerminal, bool? hyperlinks, ColorMode colorMode = ColorMode.trueColor, bool styledUnderlines = true})
-
Capabilities as given;
hyperlinksdefaults to styled output on a terminal,errorIsTerminaltooutputIsTerminal.const -
CliCapabilities.detect({required Map<
String, String> environment, required bool inputIsTerminal, required bool outputIsTerminal, required bool outputSupportsAnsi, bool? errorIsTerminal, bool? ansi, bool? interactive, bool? hyperlinks, bool windows = false}) -
Detects the capabilities from what stdio reports and from
environment, as twk_core reads it where it opens a terminal, withFORCE_COLOR,--no-colorand--no-inputon top.factory
Properties
- ansi → bool
-
Whether ANSI escapes (colors, styles, cursor moves) are written.
final
- colorMode → ColorMode
-
The colors styled output is written in, where it is (ansi).
final
- errorIsTerminal → bool
-
Whether the error output goes to a terminal: the same screen as the
output, where that is one too.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hyperlinks → bool
-
Whether links are written as OSC 8 hyperlinks rather than bare
labels.
final
- interactiveInput → bool
-
Whether somebody can answer a prompt: input is a terminal and asking
was not refused.
final
- mode → CliMode
-
The mode these capabilities allow: CliMode.nonInteractive where
nobody can answer, CliMode.interactive where output redraws,
CliMode.plain otherwise.
no setter
- outputIsTerminal → bool
-
Whether output goes to a terminal rather than a pipe or a file.
final
- redraws → bool
-
Whether output can be redrawn in place: cursor moves and line clears
reach a terminal that understands them.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- styledUnderlines → bool
-
Whether the terminal shows the underline styles (double, curly,
dotted, dashed); without them each is written as a plain underline.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited