diffStr {diffobj} | R Documentation |
Diff Object Structures
Description
Compares the str
output of target
and current
. If
the max.level
parameter to str
is left unspecified, will
attempt to find the largest max.level
that fits within
line.limit
and shows at least one difference.
Usage
diffStr(target, current, ...)
## S4 method for signature 'ANY'
diffStr(
target,
current,
mode = gdo("mode"),
context = gdo("context"),
format = gdo("format"),
brightness = gdo("brightness"),
color.mode = gdo("color.mode"),
word.diff = gdo("word.diff"),
pager = gdo("pager"),
guides = gdo("guides"),
trim = gdo("trim"),
rds = gdo("rds"),
unwrap.atomic = gdo("unwrap.atomic"),
max.diffs = gdo("max.diffs"),
disp.width = gdo("disp.width"),
ignore.white.space = gdo("ignore.white.space"),
convert.hz.white.space = gdo("convert.hz.white.space"),
tab.stops = gdo("tab.stops"),
line.limit = gdo("line.limit"),
hunk.limit = gdo("hunk.limit"),
align = gdo("align"),
style = gdo("style"),
palette.of.styles = gdo("palette"),
frame = par_frame(),
interactive = gdo("interactive"),
term.colors = gdo("term.colors"),
tar.banner = NULL,
cur.banner = NULL,
strip.sgr = gdo("strip.sgr"),
sgr.supported = gdo("sgr.supported"),
extra = list()
)
Arguments
target |
the reference object |
current |
the object being compared to |
... |
unused, for compatibility of methods with generics |
mode |
character(1L), one of:
|
context |
integer(1L) how many lines of context are shown on either side
of differences (defaults to 2). Set to |
format |
character(1L), controls the diff output format, one of:
Defaults to “auto”. See |
brightness |
character, one of “light”, “dark”,
“neutral”, useful for adjusting color scheme to light or dark
terminals. “neutral” by default. See |
color.mode |
character, one of “rgb” or “yb”.
Defaults to “yb”. “yb” stands for “Yellow-Blue” for
color schemes that rely primarily on those colors to style diffs.
Those colors can be easily distinguished by individuals with
limited red-green color sensitivity. See |
word.diff |
TRUE (default) or FALSE, whether to run a secondary word
diff on the in-hunk differences. For atomic vectors setting this to
FALSE could make the diff slower (see the |
pager |
one of “auto” (default), “on”,
“off”, a “auto” and “on” are the same, except that in non-interactive
mode “auto” is equivalent to “off”. “off” will always
send output to the console. If “on”, whether the output
actually gets routed to the pager depends on the pager Depending on your system configuration different styles and corresponding
pagers will get selected, unless you specify a If See |
guides |
TRUE (default), FALSE, or a function that accepts at least two
arguments and requires no more than two arguments. Guides
are additional context lines that are not strictly part of a hunk, but
provide important contextual data (e.g. column headers). If TRUE, the
context lines are shown in addition to the normal diff output, typically
in a different color to indicate they are not part of the hunk. If a
function, the function should accept as the first argument the object
being diffed, and the second the character representation of the object.
The function should return the indices of the elements of the
character representation that should be treated as guides. See
|
trim |
TRUE (default), FALSE, or a function that accepts at least two
arguments and requires no more than two arguments. Function should compute
for each line in captured output what portion of those lines should be
diffed. By default, this is used to remove row meta data differences
(e.g. |
rds |
TRUE (default) or FALSE, if TRUE will check whether
|
unwrap.atomic |
TRUE (default) or FALSE. Relevant primarily for
|
max.diffs |
integer(1L), number of differences (default 50000L)
after which we abandon the |
disp.width |
integer(1L) number of display columns to take up; note that
in “sidebyside” |
ignore.white.space |
TRUE or FALSE, whether to consider differences in horizontal whitespace (i.e. spaces and tabs) as differences (defaults to TRUE). |
convert.hz.white.space |
TRUE or FALSE, whether modify input strings
that contain tabs and carriage returns in such a way that they display as
they would with those characters, but without using those
characters (defaults to TRUE). The conversion assumes that tab stops are
spaced evenly eight characters apart on the terminal. If this is not the
case you may specify the tab stops explicitly with |
tab.stops |
integer, what tab stops to use when converting hard tabs to spaces. If not integer will be coerced to integer (defaults to 8L). You may specify more than one tab stop. If display width exceeds that addressable by your tab stops the last tab stop will be repeated. |
line.limit |
integer(2L) or integer(1L), if length 1 how many lines of
output to show, where |
hunk.limit |
integer(2L) or integer (1L), how many diff hunks to show.
Behaves similarly to |
align |
numeric(1L) between 0 and 1, proportion of
words in a line of |
style |
“auto”, a |
palette.of.styles |
|
frame |
an environment to use as the evaluation frame for the
|
interactive |
TRUE or FALSE whether the function is being run in
interactive mode, defaults to the return value of
|
term.colors |
integer(1L) how many ANSI colors are supported by the
terminal. This variable is provided for when
|
tar.banner |
character(1L), language, or NULL, used to generate the
text to display ahead of the diff section representing the target output.
If NULL will use the deparsed |
cur.banner |
character(1L) like |
strip.sgr |
TRUE, FALSE, or NULL (default), whether to strip ANSI CSI SGR sequences prior to comparison and for display of diff. If NULL, resolves to TRUE if 'style' resolves to an ANSI formatted diff, and FALSE otherwise. The default behavior is to avoid confusing diffs where the original SGR and the SGR added by the diff are mixed together. |
sgr.supported |
TRUE, FALSE, or NULL (default), whether to assume the standard output device supports ANSI CSI SGR sequences. If TRUE, strings will be manipulated accounting for the SGR sequences. If NULL, resolves to TRUE if 'style' resolves to an ANSI formatted diff, and to 'crayon::has_color()' otherwise. This only controls how the strings are manipulated, not whether SGR is added to format the diff, which is controlled by the 'style' parameter. This parameter is exposed for the rare cases where you might wish to control string manipulation behavior directly. |
extra |
list additional arguments to pass on to the functions used to
create text representation of the objects to diff (e.g. |
Details
Due to the seemingly inconsistent nature of max.level
when used with
objects with nested attributes, and also due to the relative slowness of
str
, this function simulates the effect of max.level
by hiding
nested lines instead of repeatedly calling str
with varying values of
max.level
.
Value
a Diff
object; see diffPrint
.
See Also
diffPrint
for details on the diff*
functions,
diffObj
, diffStr
,
diffChr
to compare character vectors directly,
diffDeparse
to compare deparsed objects,
ses
for a minimal and fast diff
Examples
## `pager="off"` for CRAN compliance; you may omit in normal use
with(mtcars, diffStr(lm(mpg ~ hp)$qr, lm(mpg ~ disp)$qr, pager="off"))