includes/diffengine/Renderer/unified.php
changeset 1 fe660c52c48f
equal deleted inserted replaced
0:902822492a68 1:fe660c52c48f
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * "Unified" diff renderer.
       
     5  *
       
     6  * This class renders the diff in classic "unified diff" format.
       
     7  *
       
     8  * $Horde: framework/Text_Diff/Diff/Renderer/unified.php,v 1.5 2006/01/08 00:06:57 jan Exp $
       
     9  *
       
    10  * @package Text_Diff
       
    11  */
       
    12 class Text_Diff_Renderer_unified extends Text_Diff_Renderer {
       
    13 
       
    14     /**
       
    15      * Number of leading context "lines" to preserve.
       
    16      */
       
    17     var $_leading_context_lines = 4;
       
    18 
       
    19     /**
       
    20      * Number of trailing context "lines" to preserve.
       
    21      */
       
    22     var $_trailing_context_lines = 4;
       
    23 
       
    24     function _blockHeader($xbeg, $xlen, $ybeg, $ylen)
       
    25     {
       
    26         if ($xlen != 1) {
       
    27             $xbeg .= ',' . $xlen;
       
    28         }
       
    29         if ($ylen != 1) {
       
    30             $ybeg .= ',' . $ylen;
       
    31         }
       
    32         return "@@ -$xbeg +$ybeg @@";
       
    33     }
       
    34 
       
    35     function _added($lines)
       
    36     {
       
    37         return $this->_lines($lines, '+');
       
    38     }
       
    39 
       
    40     function _deleted($lines)
       
    41     {
       
    42         return $this->_lines($lines, '-');
       
    43     }
       
    44 
       
    45     function _changed($orig, $final)
       
    46     {
       
    47         return $this->_deleted($orig) . $this->_added($final);
       
    48     }
       
    49 
       
    50 }