Align an ANSI colored string

ansi_align(
  text,
  width = console_width(),
  align = c("left", "center", "right"),
  type = "width"
)

Arguments

text

The character vector to align.

width

Width of the field to align in.

align

Whether to align "left", "center" or "right".

type

Passed on to ansi_nchar() and there to nchar()

Value

The aligned character vector.

See also

Examples

ansi_align(col_red("foobar"), 20, "left")
#> <ansi_string> #> [1] foobar
ansi_align(col_red("foobar"), 20, "center")
#> <ansi_string> #> [1] foobar
ansi_align(col_red("foobar"), 20, "right")
#> <ansi_string> #> [1] foobar