ansi_strtrim: Truncate an ANSI string

Description Usage Arguments See Also Examples

View source: R/ansiex.R

Description

This function is similar to base::strtrim(), but works correcntly with ANSI styled strings. It also adds ... (or the corresponding Unicode character if Unicode characters are allowed) to the end of truncated strings.

Usage

1
ansi_strtrim(x, width = console_width(), ellipsis = symbol$ellipsis)

Arguments

x

Character vector of ANSI strings.

width

The width to truncate to.

ellipsis

The string to append to truncated strings. Supply an empty string if you don't want a marker.

See Also

Other ANSI string operations: ansi_align(), ansi_columns(), ansi_nchar(), ansi_strsplit(), ansi_strwrap(), ansi_substring(), ansi_substr(), ansi_toupper(), ansi_trimws()

Examples

1
2
text <- cli::col_red(cli:::lorem_ipsum())
ansi_strtrim(c(text, "foobar"), 40)

RonMobile/cli documentation built on Dec. 18, 2021, 11 a.m.