ansi_style: Add ANSI Style Escape Sequences Codes Around Elements of a...

Description Usage Arguments Value See Also Examples

Description

Prepends and appends the necessary ANSI sequences to produce the requested style. Valid styles are those in names(ansistyle:::ansi.codes). Nesting is not supported, except for those ANSI sequences that have different terminators (e.g. font colors vs. background colors). For a better and more complete implementation see the crayon package by Gabor Csardi.

Usage

1
ansi_style(txt, style, use.style = getOption("ansistyle.use.style"))

Arguments

txt

character vector to style; every element of the vector will have escape sequences added at the beginning and end of the string

style

character, either length 1L or same length as txt, what style to use, see valid_ansi_styles

use.style

logical(1L) whether to use style or not. Provides a mechanism for turning off styling for systems that do not support it; if set to NULL will auto detect with ansi_available()

Value

character vector, txt with ansi escape sequences added

See Also

valid_ansi_styles, ansi_style_palette

Examples

1
2
3
4
cat(ansi_style("hello", "red"), "\n")

## some nesting possible if escape sequences allow it
cat(ansi_style(c("baz", ansi_style("foo", "bgGreen"), "bar"), "blue"), "\n")

brodieG/ansistyle documentation built on May 13, 2019, 7:45 a.m.