Description Usage Arguments Details Value Matrices and Data Frames See Also Examples
Runs the diff between the print
or show
output produced by
target
and current
. Given the extensive parameter list, this
documentation page is intended as a reference for all the diff*
methods. For a high level introduction see vignette("diffobj")
.
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 | diffPrint(target, current, ...)
## S4 method for signature 'ANY'
diffPrint(
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()
)
|
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. |
Almost all aspects of how the diffs are computed and displayed are
controllable through the diff*
methods parameters. This results in a
lengthy parameter list, but in practice you should rarely need to adjust
anything past the color.mode
parameter. Default values are specified
as options so that users may configure diffs in a persistent manner.
gdo
is a shorthand function to access diffobj
options.
Parameter order after color.mode
is not guaranteed. Future versions
of diffobj
may add parameters and re-order existing parameters past
color.mode
.
This and other diff*
functions are S4 generics that dispatch on the
target
and current
parameters. Methods with signature
c("ANY", "ANY")
are defined and act as the default methods. You can
use this to set up methods to pre-process or set specific parameters for
selected classes that can then callNextMethod
for the actual diff.
Note that while the generics include ...
as an argument, none of the
methods do.
Strings are re-encoded to UTF-8 with enc2utf8
prior to
comparison to avoid encoding-only differences.
The text representation of 'target' and 'current' should each have no more than ~INT_MAX/4 lines.
a Diff
object; this object has a show
method that will display the diff to screen or pager, as well as
summary
, any
, and as.character
methods.
If you store the return value instead of displaying it to screen, and
display it later, it is possible for the display to be thrown off if
there are environment changes (e.g. display width changes) in between
the time you compute the diff and the time you display it.
While diffPrint
attempts to handle the default R behavior that wraps
wide tables, the results are often sub-optimal. A better approach is to set
the disp.width
parameter to a large enough value such that wrapping is
not necessary, and a browser-based pager
. In the future we will add
the capability to specify different capture widths and wrap widths so that
this is an option for terminal output (see
issue 109).
One thing to keep in mind is that diffPrint
is not designed to work
with very large data frames.
diffObj
, diffStr
,
diffChr
to compare character vectors directly,
diffDeparse
to compare deparsed objects, ses
for a minimal and fast diff @param target the reference object
1 2 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.