has_ctl checks for any Control Sequence. You can check for different
types of sequences with the ctl parameter. Warnings are only emitted for
malformed CSI or OSC sequences.
Usage
has_ctl(x, ctl = "all", warn = getOption("fansi.warn", TRUE), which)Arguments
- x
a character vector or object that can be coerced to such.
- ctl
character, which Control Sequences should be treated specially. Special treatment is context dependent, and may include detecting them and/or computing their display/character width as zero. For the SGR subset of the ANSI CSI sequences, and OSC hyperlinks,
fansiwill also parse, interpret, and reapply the sequences as needed. You can modify whether a Control Sequence is treated specially with thectlparameter."nl": newlines.
"c0": all other "C0" control characters (i.e. 0x01-0x1f, 0x7F), except for newlines and the actual ESC (0x1B) character.
"sgr": ANSI CSI SGR sequences.
"csi": all non-SGR ANSI CSI sequences.
"url": OSC hyperlinks
"osc": all non-OSC-hyperlink OSC sequences.
"esc": all other escape sequences.
"all": all of the above, except when used in combination with any of the above, in which case it means "all but".
- warn
TRUE (default) or FALSE, whether to warn when potentially problematic Control Sequences are encountered. These could cause the assumptions
fansimakes 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 (usevalidUTF8for that).- which
character, deprecated in favor of
ctl.
See also
?fansi for details on how Control Sequences are
interpreted, particularly if you are getting unexpected results,
unhandled_ctl for detecting bad control sequences.