Skip to content

Commit

Permalink
Added colspan option for the InlineDiffFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Jan 31, 2011
1 parent f22c196 commit c495dc4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions inc/DifferenceEngine.php
Expand Up @@ -1087,6 +1087,7 @@ function _changed($orig, $closing) {
*
*/
class InlineDiffFormatter extends DiffFormatter {
var $colspan = 4;

function InlineDiffFormatter() {
$this->leading_context_lines = 2;
Expand All @@ -1113,7 +1114,7 @@ function _block_header($xbeg, $xlen, $ybeg, $ylen) {
$xbeg .= "," . $xlen;
if ($ylen != 1)
$ybeg .= "," . $ylen;
$r = '<tr><td class="diff-blockheader">@@ '.$lang['line']." -$xbeg +$ybeg @@";
$r = '<tr><td colspan="'.$this->colspan.'" class="diff-blockheader">@@ '.$lang['line']." -$xbeg +$ybeg @@";
$r .= ' <span class="diff-deletedline"><del>'.$lang['deleted'].'</del></span>';
$r .= ' <span class="diff-addedline">'.$lang['created'].'</span>';
$r .= "</td></tr>\n";
Expand All @@ -1132,19 +1133,19 @@ function _lines($lines, $prefix=' ', $color="white") {

function _added($lines) {
foreach ($lines as $line) {
print('<tr><td class="diff-addedline">'. $line . "</td></tr>\n");
print('<tr><td colspan="'.$this->colspan.'" class="diff-addedline">'. $line . "</td></tr>\n");
}
}

function _deleted($lines) {
foreach ($lines as $line) {
print('<tr><td class="diff-deletedline"><del>' . $line . "</del></td></tr>\n");
print('<tr><td colspan="'.$this->colspan.'" class="diff-deletedline"><del>' . $line . "</del></td></tr>\n");
}
}

function _context($lines) {
foreach ($lines as $line) {
print('<tr><td class="diff-context">'.$line."</td></tr>\n");
print('<tr><td colspan="'.$this->colspan.'" class="diff-context">'.$line."</td></tr>\n");
}
}

Expand All @@ -1153,7 +1154,7 @@ function _changed($orig, $closing) {
$add = $diff->inline();

foreach ($add as $line)
print('<tr><td>'.$line."</td></tr>\n");
print('<tr><td colspan="'.$this->colspan.'">'.$line."</td></tr>\n");
}
}

Expand Down

0 comments on commit c495dc4

Please sign in to comment.