diffPrint {diffobj} | R Documentation |
print
ed ObjectsThis documentation page is intended as a reference document
for all the diff*
methods. For a high level introduction see
vignette("diffobj")
and the examples. 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.
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.
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, 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”, or a |
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 second
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. Only relevant for
|
max.diffs |
integer(1L), number of differences 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 FALSE) |
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 |
extra |
list additional arguments to pass on to the functions used to
create text representation of the objects to diff (e.g. |
Runs the diff between the print
or show
output produced by
target
and current
.
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.
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
## `pager="off"` for CRAN compliance; you may omit in normal use diffPrint(letters, letters[-5], pager="off")