Skip to content

Commit

Permalink
[jan] Add Horde_Text_Diff_Renderer_Unified_Colored as a renderer with…
Browse files Browse the repository at this point in the history
… color highlighting.
  • Loading branch information
yunosh committed Mar 6, 2017
1 parent 6e74d21 commit cdfc842
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 8 deletions.
19 changes: 19 additions & 0 deletions 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.
@@ -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)
);
}
}
31 changes: 23 additions & 8 deletions framework/Text_Diff/package.xml
Expand Up @@ -17,18 +17,18 @@
<email>jan@horde.org</email>
<active>yes</active>
</lead>
<date>2016-02-02</date>
<date>2017-03-06</date>
<version>
<release>2.1.3</release>
<api>1.1.0</api>
<release>2.2.0</release>
<api>1.2.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Add Horde_Text_Diff_Renderer_Unified_Colored as a renderer with color highlighting.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand All @@ -42,9 +42,11 @@
<file name="diff.php" role="doc" />
</dir> <!-- /doc/Horde/Text/Diff/examples -->
<file name="COPYING" role="doc" />
<file name="UPGRADING" role="doc" />
</dir> <!-- /doc/Horde/Text/Diff -->
</dir> <!-- /doc/Horde/Text -->
</dir> <!-- /doc/Horde -->
<file name="horde.yml" role="doc" />
</dir> <!-- /doc -->
<dir name="lib">
<dir name="Horde">
Expand All @@ -64,6 +66,9 @@
<file name="Delete.php" role="php" />
</dir> <!-- /lib/Horde/Text/Diff/Op -->
<dir name="Renderer">
<dir name="Unified">
<file name="Colored.php" role="php" />
</dir> <!-- /lib/Horde/Text/Diff/Renderer/Unified -->
<file name="Context.php" role="php" />
<file name="Inline.php" role="php" />
<file name="Unified.php" role="php" />
Expand Down Expand Up @@ -139,6 +144,13 @@
</package>
</required>
<optional>
<package>
<name>Horde_Cli</name>
<channel>pear.horde.org</channel>
<min>2.1.0</min>
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
<package>
<name>Horde_Test</name>
<channel>pear.horde.org</channel>
Expand All @@ -155,7 +167,9 @@
</dependencies>
<phprelease>
<filelist>
<install as="horde.yml" name="doc/horde.yml" />
<install as="COPYING" name="doc/Horde/Text/Diff/COPYING" />
<install as="UPGRADING" name="doc/Horde/Text/Diff/UPGRADING" />
<install as="examples/1.txt" name="doc/Horde/Text/Diff/examples/1.txt" />
<install as="examples/2.txt" name="doc/Horde/Text/Diff/examples/2.txt" />
<install as="examples/diff.php" name="doc/Horde/Text/Diff/examples/diff.php" />
Expand All @@ -176,6 +190,7 @@
<install as="Horde/Text/Diff/Renderer/Context.php" name="lib/Horde/Text/Diff/Renderer/Context.php" />
<install as="Horde/Text/Diff/Renderer/Inline.php" name="lib/Horde/Text/Diff/Renderer/Inline.php" />
<install as="Horde/Text/Diff/Renderer/Unified.php" name="lib/Horde/Text/Diff/Renderer/Unified.php" />
<install as="Horde/Text/Diff/Renderer/Unified/Colored.php" name="lib/Horde/Text/Diff/Renderer/Unified/Colored.php" />
<install as="Horde/Text/Diff/ThreeWay/BlockBuilder.php" name="lib/Horde/Text/Diff/ThreeWay/BlockBuilder.php" />
<install as="Horde/Text/Diff/ThreeWay/Op/Base.php" name="lib/Horde/Text/Diff/ThreeWay/Op/Base.php" />
<install as="Horde/Text/Diff/ThreeWay/Op/Copy.php" name="lib/Horde/Text/Diff/ThreeWay/Op/Copy.php" />
Expand Down Expand Up @@ -423,15 +438,15 @@
</release>
<release>
<version>
<release>2.1.3</release>
<api>1.1.0</api></version>
<release>2.2.0</release>
<api>1.2.0</api></version>
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2016-02-02</date>
<date>2017-03-06</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [jan] Add Horde_Text_Diff_Renderer_Unified_Colored as a renderer with color highlighting.
</notes>
</release>
</changelog>
Expand Down

0 comments on commit cdfc842

Please sign in to comment.