Skip to contents

Color each element in input with one of the "256 color" ANSI CSI SGR codes. This is intended for testing and demo purposes.

Usage

fansi_lines(txt, step = 1)

Arguments

txt

character vector or object that can be coerced to character vector

step

integer(1L) how quickly to step through the color palette

Value

character vector with each element colored

Examples

NEWS <- readLines(file.path(R.home('doc'), 'NEWS'))
writeLines(fansi_lines(NEWS[1:20]))
#> R News
#> 
#> CHANGES IN R 4.5.1:
#> 
#>   NEW FEATURES:
#> 
#>     * The internal method of unzip() now follows unzip 6.00 in how it
#>       handles extracted file paths which contain "../".  With thanks to
#>       Ivan Krylov.
#> 
#>   INSTALLATION:
#> 
#>     * Standalone nmath can be built with early-2025 versions of
#>       clang-based compilers such as LLVM clang 20, Apple clang 17 and
#>       Intel icx 2025.0.
#> 
#>     * Tcl/Tk 9 can be used to build package tcltk: this has become the
#>       default in some Linux distributions.  *N.B.* several third-party
#>       packages currently require Tcl/Tk 8 or even 8.6 without declaring
#>       so.
writeLines(fansi_lines(NEWS[1:20], step=8))
#> R News
#> 
#> CHANGES IN R 4.5.1:
#> 
#>   NEW FEATURES:
#> 
#>     * The internal method of unzip() now follows unzip 6.00 in how it
#>       handles extracted file paths which contain "../".  With thanks to
#>       Ivan Krylov.
#> 
#>   INSTALLATION:
#> 
#>     * Standalone nmath can be built with early-2025 versions of
#>       clang-based compilers such as LLVM clang 20, Apple clang 17 and
#>       Intel icx 2025.0.
#> 
#>     * Tcl/Tk 9 can be used to build package tcltk: this has become the
#>       default in some Linux distributions.  *N.B.* several third-party
#>       packages currently require Tcl/Tk 8 or even 8.6 without declaring
#>       so.