From cdfc84206b42c1501584a0d53bdb73d6bf70789a Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 6 Mar 2017 14:41:57 +0100 Subject: [PATCH] [jan] Add Horde_Text_Diff_Renderer_Unified_Colored as a renderer with color highlighting. --- .../Text_Diff/doc/Horde/Text/Diff/UPGRADING | 19 ++++++ .../Text/Diff/Renderer/Unified/Colored.php | 67 +++++++++++++++++++ framework/Text_Diff/package.xml | 31 ++++++--- 3 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 framework/Text_Diff/doc/Horde/Text/Diff/UPGRADING create mode 100644 framework/Text_Diff/lib/Horde/Text/Diff/Renderer/Unified/Colored.php diff --git a/framework/Text_Diff/doc/Horde/Text/Diff/UPGRADING b/framework/Text_Diff/doc/Horde/Text/Diff/UPGRADING new file mode 100644 index 00000000000..67087f31708 --- /dev/null +++ b/framework/Text_Diff/doc/Horde/Text/Diff/UPGRADING @@ -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. diff --git a/framework/Text_Diff/lib/Horde/Text/Diff/Renderer/Unified/Colored.php b/framework/Text_Diff/lib/Horde/Text/Diff/Renderer/Unified/Colored.php new file mode 100644 index 00000000000..0f71c31a527 --- /dev/null +++ b/framework/Text_Diff/lib/Horde/Text/Diff/Renderer/Unified/Colored.php @@ -0,0 +1,67 @@ + + * @category Horde + * @license http://www.horde.org/licenses/lgpl21 LGPL + * @package Text_Diff + */ + +/** + * "Unified" diff renderer with output coloring. + * + * @author Jan Schneider + * @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) + ); + } +} diff --git a/framework/Text_Diff/package.xml b/framework/Text_Diff/package.xml index a35a308a8c3..20ddf4135df 100644 --- a/framework/Text_Diff/package.xml +++ b/framework/Text_Diff/package.xml @@ -17,10 +17,10 @@ jan@horde.org yes - 2016-02-02 + 2017-03-06 - 2.1.3 - 1.1.0 + 2.2.0 + 1.2.0 stable @@ -28,7 +28,7 @@ LGPL-2.1 -* +* [jan] Add Horde_Text_Diff_Renderer_Unified_Colored as a renderer with color highlighting. @@ -42,9 +42,11 @@ + + @@ -64,6 +66,9 @@ + + + @@ -139,6 +144,13 @@ + + Horde_Cli + pear.horde.org + 2.1.0 + 3.0.0alpha1 + 3.0.0alpha1 + Horde_Test pear.horde.org @@ -155,7 +167,9 @@ + + @@ -176,6 +190,7 @@ + @@ -423,15 +438,15 @@ - 2.1.3 - 1.1.0 + 2.2.0 + 1.2.0 stable stable - 2016-02-02 + 2017-03-06 LGPL-2.1 -* +* [jan] Add Horde_Text_Diff_Renderer_Unified_Colored as a renderer with color highlighting.