Examples for 'cli::ansi-styles'


ANSI colored text

Aliases: ansi-styles bg_black bg_blue bg_cyan bg_green bg_magenta bg_red bg_white bg_yellow bg_none bg_br_black bg_br_blue bg_br_cyan bg_br_green bg_br_magenta bg_br_red bg_br_white bg_br_yellow col_black col_blue col_cyan col_green col_magenta col_red col_white col_yellow col_grey col_silver col_none col_br_black col_br_blue col_br_cyan col_br_green col_br_magenta col_br_red col_br_white col_br_yellow style_dim style_blurred style_bold style_hidden style_inverse style_italic style_reset style_strikethrough style_underline style_no_bold style_no_blurred style_no_dim style_no_italic style_no_underline style_no_inverse style_no_hidden style_no_strikethrough style_no_color style_no_bg_color

Keywords:

### ** Examples

col_blue("Hello ", "world!")
<cli_ansi_string>
[1] Hello world!
cat(col_blue("Hello ", "world!"))
Hello world!
cat("... to highlight the", col_red("search term"),
    "in a block of text\n")
... to highlight the search term in a block of text
## Style stack properly
cat(col_green(
 "I am a green line ",
 col_blue(style_underline(style_bold("with a blue substring"))),
 " that becomes green again!"
))
I am a green line with a blue substring that becomes green again!
error <- combine_ansi_styles("red", "bold")
warn <- combine_ansi_styles("magenta", "underline")
note <- col_cyan
cat(error("Error: subscript out of bounds!\n"))
Error: subscript out of bounds!
cat(warn("Warning: shorter argument was recycled.\n"))
Warning: shorter argument was recycled.
cat(note("Note: no such directory.\n"))
Note: no such directory.
# style_no_* functions, note that the color is not removed
style_italic(col_green(paste0(
  "italic before, ",
  style_no_italic("normal here, "),
  "italic after"
)))
<cli_ansi_string>
[1] italic before, normal here, italic after
# avoiding  color for substring
style_italic(col_red(paste(
  "red before",
  col_none("not red between"),
  "red after"
)))
<cli_ansi_string>
[1] red before not red between red after

[Package cli version 3.6.3 Index]