Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[jan] Add Horde_Text_Diff_Renderer_Unified_Colored as a renderer with…
… color highlighting.
- Loading branch information
Showing
3 changed files
with
109 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
=========================== | ||
Upgrading Horde_Text_Diff | ||
=========================== | ||
|
||
:Contact: dev@lists.horde.org | ||
|
||
.. contents:: Contents | ||
.. section-numbering:: | ||
|
||
|
||
This lists the API changes between releases of the package. | ||
|
||
|
||
Upgrading to 2.2.0 | ||
================== | ||
|
||
- Horde_Text_Diff_Renderer_Unified_Color | ||
|
||
This class has been added. |
67 changes: 67 additions & 0 deletions
67
framework/Text_Diff/lib/Horde/Text/Diff/Renderer/Unified/Colored.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/** | ||
* Copyright 2017 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL). If you did | ||
* not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @author Jan Schneider <jan@horde.org> | ||
* @category Horde | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL | ||
* @package Text_Diff | ||
*/ | ||
|
||
/** | ||
* "Unified" diff renderer with output coloring. | ||
* | ||
* @author Jan Schneider <jan@horde.org> | ||
* @category Horde | ||
* @copyright 2017 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL | ||
* @package Text_Diff | ||
*/ | ||
class Horde_Text_Diff_Renderer_Unified_Colored | ||
extends Horde_Text_Diff_Renderer_Unified | ||
{ | ||
/** | ||
* CLI handler. | ||
* | ||
* Contrary to the name, it supports color highlighting for HTML too. | ||
* | ||
* @var Horde_Cli | ||
*/ | ||
protected $_cli; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public function __construct($params = array()) | ||
{ | ||
if (!isset($params['cli'])) { | ||
throw new BadMethodCallException('CLI handler is missing'); | ||
} | ||
parent::__construct($params); | ||
$this->_cli = $params['cli']; | ||
} | ||
|
||
protected function _blockHeader($xbeg, $xlen, $ybeg, $ylen) | ||
{ | ||
return $this->_cli->color( | ||
'lightmagenta', parent::_blockHeader($xbeg, $xlen, $ybeg, $ylen) | ||
); | ||
} | ||
|
||
protected function _added($lines) | ||
{ | ||
return $this->_cli->color( | ||
'lightgreen', parent::_added($lines) | ||
); | ||
} | ||
|
||
protected function _deleted($lines) | ||
{ | ||
return $this->_cli->color( | ||
'lightred', parent::_deleted($lines) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters