Renderer
in package
A class to render Diffs in different formats.
This class renders the diff in classic diff format. It is intended that this class be customized via inheritance, to obtain fancier outputs.
Copyright 2004-2017 Horde LLC (http://www.horde.org/)
See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Table of Contents
- $_leading_context_lines : mixed
- Number of leading context "lines" to preserve.
- $_trailing_context_lines : mixed
- Number of trailing context "lines" to preserve.
- __construct() : mixed
- Constructor.
- getParams() : array<string|int, mixed>
- Get any renderer parameters.
- render() : string
- Renders a diff.
- _added() : string
- Glues array of added lines to a >-prefixed string
- _block() : string
- Render a diff block
- _blockHeader() : string
- Render a Diff Block Header
- _changed() : string
- Produces a comparison string out of arrays of deleted and added lines
- _context() : string
- Glues array of context lines to a space-prefixed string
- _deleted() : string
- Glues array of added lines to a >-prefixed string
- _endBlock() : string
- _endDiff() : string
- _lines() : string
- Glue an array of lines to a string with prefixed lines
- _startBlock() : string
- _startDiff() : string
Properties
$_leading_context_lines
Number of leading context "lines" to preserve.
protected
mixed
$_leading_context_lines
= 0
This should be left at zero for this class, but subclasses may want to set this to other values.
$_trailing_context_lines
Number of trailing context "lines" to preserve.
protected
mixed
$_trailing_context_lines
= 0
This should be left at zero for this class, but subclasses may want to set this to other values.
Methods
__construct()
Constructor.
public
__construct([mixed $params = [] ]) : mixed
Parameters
- $params : mixed = []
Return values
mixed —getParams()
Get any renderer parameters.
public
getParams() : array<string|int, mixed>
Return values
array<string|int, mixed> —All parameters of this renderer object.
render()
Renders a diff.
public
render(Diff $diff) : string
Parameters
- $diff : Diff
-
A Horde_Text_Diff object.
Return values
string —The formatted output.
_added()
Glues array of added lines to a >-prefixed string
protected
_added([array<string|int, mixed> $lines = [] ]) : string
Parameters
- $lines : array<string|int, mixed> = []
Return values
string —_block()
Render a diff block
protected
_block(int $xbeg, int $xlen, int $ybeg, int $ylen, mixed &$edits) : string
Parameters
- $xbeg : int
- $xlen : int
- $ybeg : int
- $ylen : int
- $edits : mixed
-
Should be a list object rather than a writeable array reference
Return values
string —_blockHeader()
Render a Diff Block Header
protected
_blockHeader(int $xbeg, int $xlen, int $ybeg, int $ylen) : string
Headers look like: 186,187c180,181 or 204c198
Parameters
- $xbeg : int
- $xlen : int
- $ybeg : int
- $ylen : int
Return values
string —_changed()
Produces a comparison string out of arrays of deleted and added lines
protected
_changed([array<string|int, mixed> $orig = [] ][, array<string|int, mixed> $final = [] ]) : string
Parameters
- $orig : array<string|int, mixed> = []
- $final : array<string|int, mixed> = []
Return values
string —_context()
Glues array of context lines to a space-prefixed string
protected
_context([array<string|int, mixed> $lines = [] ]) : string
Parameters
- $lines : array<string|int, mixed> = []
Return values
string —_deleted()
Glues array of added lines to a >-prefixed string
protected
_deleted([array<string|int, mixed> $lines = [] ]) : string
Parameters
- $lines : array<string|int, mixed> = []
Return values
string —_endBlock()
protected
_endBlock() : string
Return values
string —_endDiff()
protected
_endDiff() : string
Return values
string —_lines()
Glue an array of lines to a string with prefixed lines
protected
_lines(array<string|int, mixed> $lines[, string $prefix = ' ' ]) : string
Parameters
- $lines : array<string|int, mixed>
- $prefix : string = ' '
-
defaults to a single space
Return values
string —_startBlock()
protected
_startBlock(string $header) : string
Parameters
- $header : string
Return values
string —_startDiff()
protected
_startDiff() : string