File: ansi_strtrim.Rd

package info (click to toggle)
r-cran-cli 3.6.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,288 kB
  • sloc: ansic: 16,412; cpp: 37; sh: 13; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,228 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_strtrim}
\alias{ansi_strtrim}
\title{Truncate an ANSI string}
\usage{
ansi_strtrim(x, width = console_width(), ellipsis = symbol$ellipsis)
}
\arguments{
\item{x}{Character vector of ANSI strings.}

\item{width}{The width to truncate to.}

\item{ellipsis}{The string to append to truncated strings. Supply an
empty string if you don't want a marker.}
}
\description{
This function is similar to \code{\link[base:strtrim]{base::strtrim()}}, but works correctly with
ANSI styled strings. It also adds \code{...} (or the corresponding Unicode
character if Unicode characters are allowed) to the end of truncated
strings.
}
\details{
Note: \code{ansi_strtrim()} does not support NA values currently.
}
\examples{
text <- cli::col_red(cli:::lorem_ipsum())
ansi_strtrim(c(text, "foobar"), 40)
}
\seealso{
Other ANSI string operations: 
\code{\link{ansi_align}()},
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_toupper}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}