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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ansiex.R
\name{ansi_align}
\alias{ansi_align}
\title{Align an ANSI colored string}
\usage{
ansi_align(
text,
width = console_width(),
align = c("left", "center", "right"),
type = "width"
)
}
\arguments{
\item{text}{The character vector to align.}
\item{width}{Width of the field to align in.}
\item{align}{Whether to align \code{"left"}, \code{"center"} or \code{"right"}.}
\item{type}{Passed on to \code{\link[=ansi_nchar]{ansi_nchar()}} and there to \code{\link[=nchar]{nchar()}}}
}
\value{
The aligned character vector.
}
\description{
Align an ANSI colored string
}
\details{
\if{html}{\out{<div class="sourceCode r">}}\preformatted{str <- c(
col_red("This is red"),
style_bold("This is bold")
)
astr <- ansi_align(str, width = 30)
boxx(astr)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> ┌────────────────────────────────────┐
#> │ │
#> │ <span style="color: #DC322F;">This is red</span> │
#> │ <span style="font-weight: bold;">This is bold</span> │
#> │ │
#> └────────────────────────────────────┘
</pre></div>
}}
\if{html}{\out{<div class="sourceCode r">}}\preformatted{str <- c(
col_red("This is red"),
style_bold("This is bold")
)
astr <- ansi_align(str, align = "center", width = 30)
boxx(astr)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> ┌────────────────────────────────────┐
#> │ │
#> │ <span style="color: #DC322F;">This is red</span> │
#> │ <span style="font-weight: bold;">This is bold</span> │
#> │ │
#> └────────────────────────────────────┘
</pre></div>
}}
\if{html}{\out{<div class="sourceCode r">}}\preformatted{str <- c(
col_red("This is red"),
style_bold("This is bold")
)
astr <- ansi_align(str, align = "right", width = 30)
boxx(astr)
}\if{html}{\out{</div>}}\if{html}{\out{
<div class="asciicast" style="color: #172431;font-family: 'Fira Code',Monaco,Consolas,Menlo,'Bitstream Vera Sans Mono','Powerline Symbols',monospace;line-height: 1.300000"><pre>
#> ┌────────────────────────────────────┐
#> │ │
#> │ <span style="color: #DC322F;">This is red</span> │
#> │ <span style="font-weight: bold;">This is bold</span> │
#> │ │
#> └────────────────────────────────────┘
</pre></div>
}}
}
\seealso{
Other ANSI string operations:
\code{\link{ansi_columns}()},
\code{\link{ansi_nchar}()},
\code{\link{ansi_strsplit}()},
\code{\link{ansi_strtrim}()},
\code{\link{ansi_strwrap}()},
\code{\link{ansi_substr}()},
\code{\link{ansi_substring}()},
\code{\link{ansi_toupper}()},
\code{\link{ansi_trimws}()}
}
\concept{ANSI string operations}
|