terminal
The terminal of the standard error stream, and the color conventions of the environment.
In the namespace platform.
Detailed description
The log handler asks these questions once, when it decides whether the terminal copy of a log line gets color (log-color §LGC-D-4). The caller asks the capability and never the operating system (kiln-runtime §KR-L1). One file per platform answers: `posix/Terminal_posix.cpp` and `windows/Terminal_win.cpp`. This file reads the environment, and it is the only file of the tree that may read these three variables (no-environment-variables §NEV-A10).
Function documentation
colorConvention
platform::terminal::ColorConvention terminal::colorConvention()
The color conventions of this process's environment.
`COLORTERM` is not read on Windows: Windows Terminal shows 24-bit color and does not set it, so the console's own answer decides there (log-color §LGC-D-5).
colorConventionOf
platform::terminal::ColorConvention terminal::colorConventionOf(QStringView noColor, QStringView clicolorForce, QStringView colorTerm)
The color conventions that noColor, clicolorForce and colorTerm give.
The values are those of `NO_COLOR`, `CLICOLOR_FORCE` and `COLORTERM`. An empty value counts as unset, as the convention of `CLICOLOR_FORCE` says and as no-color.org says for `NO_COLOR`. `COLORTERM` says 24-bit color only as `truecolor` or `24bit`.
stderrShowsTrueColor
bool terminal::stderrShowsTrueColor()
True when the standard error stream is a terminal that shows 24-bit SGR color codes.
Returns true when the standard error stream shows 24-bit color. No standard says that a terminal shows 24-bit color. On POSIX the answer is a terminal and `COLORTERM` set to `truecolor` or `24bit`. On Windows the console answers: a console that takes virtual terminal processing takes 24-bit codes, and the first call turns that processing on. On Android the answer is false, because the standard error stream goes to `/dev/null`.
stderrTakesEscapeCodes
bool terminal::stderrTakesEscapeCodes()
True when the console of the standard error stream accepts SGR codes at all.
Returns true when the console takes SGR codes. On POSIX: `isatty` of the standard error stream. On Windows: `GetConsoleMode` succeeds on its handle, and `SetConsoleMode` accepts `ENABLE_VIRTUAL_TERMINAL_PROCESSING`. `_isatty` is not used there, because it is also true for a printer or a serial port. On Android: false.