These functions are deprecated in favor of the strwrap_ctl
flavors.
strwrap_sgr(
x,
width = 0.9 * getOption("width"),
indent = 0,
exdent = 0,
prefix = "",
simplify = TRUE,
initial = prefix,
warn = getOption("fansi.warn", TRUE),
term.cap = getOption("fansi.term.cap", dflt_term_cap()),
normalize = getOption("fansi.normalize", FALSE),
carry = getOption("fansi.carry", FALSE),
terminate = getOption("fansi.terminate", TRUE)
)strwrap2_sgr(
x,
width = 0.9 * getOption("width"),
indent = 0,
exdent = 0,
prefix = "",
simplify = TRUE,
initial = prefix,
wrap.always = FALSE,
pad.end = "",
strip.spaces = !tabs.as.spaces,
tabs.as.spaces = getOption("fansi.tabs.as.spaces", FALSE),
tab.stops = getOption("fansi.tab.stops", 8L),
warn = getOption("fansi.warn", TRUE),
term.cap = getOption("fansi.term.cap", dflt_term_cap()),
normalize = getOption("fansi.normalize", FALSE),
carry = getOption("fansi.carry", FALSE),
terminate = getOption("fansi.terminate", TRUE)
)
A character vector, or list of character vectors if simplify
is
false.
a character vector, or an object which can be converted to a
character vector by as.character
.
a positive integer giving the target column for wrapping lines in the output.
a non-negative integer giving the indentation of the first line in a paragraph.
a non-negative integer specifying the indentation of subsequent lines in paragraphs.
a character string to be used as prefix for
each line except the first, for which initial
is used.
a logical. If TRUE
, the result is a single
character vector of line text; otherwise, it is a list of the same
length as x
the elements of which are character vectors of
line text obtained from the corresponding element of x
.
(Hence, the result in the former case is obtained by unlisting that
of the latter.)
TRUE (default) or FALSE, whether to warn when potentially
problematic Control Sequences are encountered. These could cause the
assumptions fansi
makes about how strings are rendered on your display
to be incorrect, for example by moving the cursor (see ?fansi
).
At most one warning will be issued per element in each input vector. Will
also warn about some badly encoded UTF-8 strings, but a lack of UTF-8
warnings is not a guarantee of correct encoding (use validUTF8
for
that).
character a vector of the capabilities of the terminal, can
be any combination of "bright" (SGR codes 90-97, 100-107), "256" (SGR codes
starting with "38;5" or "48;5"), "truecolor" (SGR codes starting with
"38;2" or "48;2"), and "all". "all" behaves as it does for the ctl
parameter: "all" combined with any other value means all terminal
capabilities except that one. fansi
will warn if it encounters SGR codes
that exceed the terminal capabilities specified (see term_cap_test
for details). In versions prior to 1.0, fansi
would also skip exceeding
SGRs entirely instead of interpreting them. You may add the string "old"
to any otherwise valid term.cap
spec to restore the pre 1.0 behavior.
"old" will not interact with "all" the way other valid values for this
parameter do.
TRUE or FALSE (default) whether SGR sequence should be
normalized out such that there is one distinct sequence for each SGR code.
normalized strings will occupy more space (e.g. "\033[31;42m" becomes
"\033[31m\033[42m"), but will work better with code that assumes each SGR
code will be in its own escape as crayon
does.
TRUE, FALSE (default), or a scalar string, controls whether to
interpret the character vector as a "single document" (TRUE or string) or
as independent elements (FALSE). In "single document" mode, active state
at the end of an input element is considered active at the beginning of the
next vector element, simulating what happens with a document with active
state at the end of a line. If FALSE each vector element is interpreted as
if there were no active state when it begins. If character, then the
active state at the end of the carry
string is carried into the first
element of x
(see "Replacement Functions" for differences there). The
carried state is injected in the interstice between an imaginary zeroeth
character and the first character of a vector element. See the "Position
Semantics" section of substr_ctl
and the "State Interactions" section
of ?fansi
for details. Except for strwrap_ctl
where NA
is
treated as the string "NA"
, carry
will cause NA
s in inputs to
propagate through the remaining vector elements.
TRUE (default) or FALSE whether substrings should have
active state closed to avoid it bleeding into other strings they may be
prepended onto. This does not stop state from carrying if carry = TRUE
.
See the "State Interactions" section of ?fansi
for details.
TRUE or FALSE (default), whether to hard wrap at requested
width if no word breaks are detected within a line. If set to TRUE then
width
must be at least 2.
character(1L), a single character to use as padding at the
end of each line until the line is width
wide. This must be a printable
ASCII character or an empty string (default). If you set it to an empty
string the line remains unpadded.
TRUE (default) or FALSE, if TRUE, extraneous white spaces (spaces, newlines, tabs) are removed in the same way as base::strwrap does. When FALSE, whitespaces are preserved, except for newlines as those are implicit boundaries between output vector elements.
FALSE (default) or TRUE, whether to convert tabs to
spaces. This can only be set to TRUE if strip.spaces
is FALSE.
integer(1:n) indicating position of tab stops to use when converting tabs to spaces. If there are more tabs in a line than defined tab stops the last tab stop is re-used. For the purposes of applying tab stops, each input line is considered a line and the character count begins from the beginning of the input line.