is_ansi_tty: Detect if a stream support ANSI escape characters

View source: R/tty.R

is_ansi_ttyR Documentation

Detect if a stream support ANSI escape characters

Description

We check that all of the following hold:

  • The stream is a terminal.

  • The platform is Unix.

  • R is not running inside R.app (the macOS GUI).

  • R is not running inside RStudio.

  • R is not running inside Emacs.

  • The terminal is not "dumb".

  • stream is either the standard output or the standard error stream.

Usage

is_ansi_tty(stream = "auto")

Arguments

stream

The stream to inspect or manipulate, an R connection object. It can also be a string, one of "auto", "message", "stdout", "stderr". "auto" will select stdout() if the session is interactive and there are no sinks, otherwise it will select stderr().

Value

TRUE or FALSE.

See Also

Other terminal capabilities: ansi_hide_cursor(), is_dynamic_tty()

Examples

is_ansi_tty()

cli documentation built on June 22, 2024, 10:57 a.m.