File: is_dynamic_tty.Rd

package info (click to toggle)
r-cran-cli 3.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,288 kB
  • sloc: ansic: 16,412; cpp: 37; sh: 13; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,919 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tty.R
\name{is_dynamic_tty}
\alias{is_dynamic_tty}
\title{Detect whether a stream supports \verb{\\\\r} (Carriage return)}
\usage{
is_dynamic_tty(stream = "auto")
}
\arguments{
\item{stream}{The stream to inspect or manipulate, an R connection
object. It can also be a string, one of \code{"auto"}, \code{"message"},
\code{"stdout"}, \code{"stderr"}. \code{"auto"} will select \code{stdout()} if the session is
interactive and there are no sinks, otherwise it will select \code{stderr()}.}
}
\description{
In a terminal, \verb{\\\\r} moves the cursor to the first position of the
same line. It is also supported by most R IDEs. \verb{\\\\r} is typically
used to achieve a more dynamic, less cluttered user interface, e.g.
to create progress bars.
}
\details{
If the output is directed to a file, then \verb{\\\\r} characters are typically
unwanted. This function detects if \verb{\\\\r} can be used for the given
stream or not.

The detection mechanism is as follows:
\enumerate{
\item If the \code{cli.dynamic} option is set to \code{TRUE}, \code{TRUE} is returned.
\item If the \code{cli.dynamic} option is set to anything else, \code{FALSE} is
returned.
\item If the \code{R_CLI_DYNAMIC} environment variable is not empty and set to
the string \code{"true"}, \code{"TRUE"} or \code{"True"}, \code{TRUE} is returned.
\item If \code{R_CLI_DYNAMIC} is not empty and set to anything else, \code{FALSE} is
returned.
\item If the stream is a terminal, then \code{TRUE} is returned.
\item If the stream is the standard output or error within RStudio,
the macOS R app, or RKWard IDE, \code{TRUE} is returned.
\item Otherwise \code{FALSE} is returned.
}
}
\examples{
is_dynamic_tty()
is_dynamic_tty(stdout())
}
\seealso{
Other terminal capabilities: 
\code{\link{ansi_hide_cursor}()},
\code{\link{is_ansi_tty}()}
}
\concept{terminal capabilities}