It uses the
cli.width option, if set. Otherwise it tries to
determine the size of the terminal or console window.
Integer scalar, the console with, in number of characters.
These are the exact rules:
cli.width option is set to a positive integer, it is used.
cli.width option is set, but it is not a positive integer,
and error is thrown.
Then we try to determine the size of the terminal or console window:
If we are not in RStudio, or we are in an RStudio temrinal,
then we try to use the
ps::ps_tty_size() function to query the
terminal size. This might fail if ps is not installed or R is not
running in a terminal, but failures are ignored.
If we are in the RStudio build pane, then the
environment variable is used. If the build pane is resized, then this
environment variable is not accurate any more, and the output might
We are not using the
RSTUDIO_CONSOLE_WIDTH environment variable
if we are in the RStudio console.
If we cannot determine the size of the terminal or console window, then
we use the
width option. If the
width option is not set, then
we return 80L.
console_width()#>  80