The detection mechanism is as follows:
If the
cli.ansioption is set toTRUE,TRUEis returned.If the
cli.ansioption is set toFALSE,FALSEis returned.If the
R_CLI_ANSIenvironment variable is set totrue(case insensitive), thenTRUEis returned.If
R_CLI_ANSIis not empty and set tofalse(case insensitive),FALSEis returned.If R is running in the Positron console, then
TRUEis returned, with 'positron' added as a name. Positron does not currently support hide/show cursor, scrolling regions, inserting and deleting lines and the alternate screen buffer.Otherwise we autodetect, by checking that all of the following hold:
The stream is a terminal, see
base::isatty().R is not running inside R.app (the macOS GUI).
R is not running inside Emacs.
The terminal is not "dumb".
streamis either the standard output or the standard error stream.
See also
Other terminal capabilities:
ansi_hide_cursor(),
is_dynamic_tty()