R/width.R

Defines functions console_width

Documented in console_width

#' Determine the width of the console
#'
#' It uses the `RSTUDIO_CONSOLE_WIDTH` environment variable, if set.
#' Otherwise it uses the `width` option. If this is not set either,
#' then 80 is used.
#'
#' @return Integer scalar, the console with, in number of characters.
#'
#' @export

console_width <- function() {
  width <- getOption(
    "cli.width",
    Sys.getenv(
      "RSTUDIO_CONSOLE_WIDTH",
      getOption("width", 80)
    )
  )
  as.integer(width)
}
r-lib/cliapp documentation built on Nov. 9, 2023, 11:18 a.m.