powered by
This function is similar to base::strtrim(), but works correctly with ANSI styled strings. It also adds ... (or the corresponding Unicode character if Unicode characters are allowed) to the end of truncated strings.
base::strtrim()
...
ansi_strtrim(x, width = console_width(), ellipsis = symbol$ellipsis)
Character vector of ANSI strings.
The width to truncate to.
The string to append to truncated strings. Supply an empty string if you don't want a marker.
Note: ansi_strtrim() does not support NA values currently.
ansi_strtrim()
Other ANSI string operations: ansi_align(), ansi_columns(), ansi_nchar(), ansi_strsplit(), ansi_strwrap(), ansi_substr(), ansi_substring(), ansi_toupper(), ansi_trimws()
ansi_align()
ansi_columns()
ansi_nchar()
ansi_strsplit()
ansi_strwrap()
ansi_substr()
ansi_substring()
ansi_toupper()
ansi_trimws()
text <- cli::col_red(cli:::lorem_ipsum()) ansi_strtrim(c(text, "foobar"), 40)
Run the code above in your browser using DataLab