Showing 1 of 5 files from the diff.
Other files ignored by Codecov

@@ -102,9 +102,10 @@
Loading
102 102
#'    the macOS R app, or RKWard IDE, `TRUE` is returned.
103 103
#' 7. Otherwise `FALSE` is returned.
104 104
#'
105 -
#' @param stream The stream to inspect, an R connection object.
106 -
#' Note that it defaults to the standard _error_ stream, since
107 -
#' informative messages are typically printed there.
105 +
#' @param stream The stream to inspect or manipulate, an R connection
106 +
#' object. It can also be a string, one of `"auto"`, `"message"`,
107 +
#' `"stdout"`, `"stderr"`. `"auto"` will select `stdout()` if the session is
108 +
#' interactive and there are no sinks.
108 109
#'
109 110
#' @family terminal capabilities
110 111
#' @export
@@ -112,7 +113,10 @@
Loading
112 113
#' is_dynamic_tty()
113 114
#' is_dynamic_tty(stdout())
114 115
115 -
is_dynamic_tty <- function(stream = cli_output_connection()) {
116 +
is_dynamic_tty <- function(stream = "auto") {
117 +
118 +
  stream <- get_real_output(stream)
119 +
116 120
  ## Option?
117 121
  if (!is.null(x <- getOption("cli.dynamic"))) {
118 122
    return(isTRUE(x))
@@ -148,7 +152,7 @@
Loading
148 152
#' * The terminal is not "dumb".
149 153
#' * `stream` is either the standard output or the standard error stream.
150 154
#'
151 -
#' @param stream The stream to check.
155 +
#' @inheritParams is_dynamic_tty
152 156
#' @return `TRUE` or `FALSE`.
153 157
#'
154 158
#' @family terminal capabilities
@@ -156,7 +160,10 @@
Loading
156 160
#' @examples
157 161
#' is_ansi_tty()
158 162
159 -
is_ansi_tty <- function(stream = stderr()) {
163 +
is_ansi_tty <- function(stream = "auto") {
164 +
165 +
  stream <- get_real_output(stream)
166 +
160 167
  # Option takes precedence
161 168
  opt <- getOption("cli.ansi")
162 169
  if (isTRUE(opt)) {
@@ -188,27 +195,30 @@
Loading
188 195
#' `ansi_with_hidden_cursor()` temporarily hides the cursor for
189 196
#' evaluating an expression.
190 197
#'
191 -
#' @param stream The stream of the terminal to output the ANSI sequence to.
198 +
#' @inheritParams is_dynamic_tty
192 199
#' @param expr R expression to evaluate.
193 200
#'
194 201
#' @family terminal capabiltiies
195 202
#' @export
196 203
197 -
ansi_hide_cursor <- function(stream = stderr()) {
204 +
ansi_hide_cursor <- function(stream = "auto") {
205 +
  stream <- get_real_output(stream)
198 206
  if (is_ansi_tty(stream)) cat(ANSI_HIDE_CURSOR, file = stream)
199 207
}
200 208
201 209
#' @export
202 210
#' @name ansi_hide_cursor
203 211
204 -
ansi_show_cursor <- function(stream = stderr()) {
212 +
ansi_show_cursor <- function(stream = "auto") {
213 +
  stream <- get_real_output(stream)
205 214
  if (is_ansi_tty(stream)) cat(ANSI_SHOW_CURSOR, file = stream)
206 215
}
207 216
208 217
#' @export
209 218
#' @name ansi_hide_cursor
210 219
211 -
ansi_with_hidden_cursor <- function(expr, stream = stderr()) {
220 +
ansi_with_hidden_cursor <- function(expr, stream = "auto") {
221 +
  stream <- get_real_output(stream)
212 222
  ansi_hide_cursor(stream)
213 223
  on.exit(ansi_show_cursor(), add = TRUE)
214 224
  expr
Files Coverage
R 80.42%
Project Totals (30 files) 80.42%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading