1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-25 15:00:58 +01:00

Merge pull request #94 from Koolvin/master

Multiline Highlighting in Diffusion
This commit is contained in:
Evan Priestley 2012-02-25 12:52:45 -08:00
commit efa2ab2fef
2 changed files with 20 additions and 5 deletions

View file

@ -265,7 +265,7 @@ class AphrontDefaultApplicationConfiguration
'browse/'. 'browse/'.
'(?P<path>.*?)'. '(?P<path>.*?)'.
'(?:[;](?P<commit>[a-z0-9]+))?'. '(?:[;](?P<commit>[a-z0-9]+))?'.
'(?:[$](?P<line>\d+))?'. '(?:[$](?P<line>\d+(?:-\d+)?))?'.
'$' '$'
=> 'DiffusionBrowseController', => 'DiffusionBrowseController',
'diff/'. 'diff/'.

View file

@ -313,6 +313,19 @@ class DiffusionBrowseFileController extends DiffusionController {
$range = 1; $range = 1;
} }
$targ = '';
$min_line = 0;
$line = $drequest->getLine();
if (strpos($line,'-') !== false) {
list($min,$max) = explode('-',$line,2);
$min_line = min($min, $max);
$max_line = max($min, $max);
} else if (strlen($line)) {
$min_line = $line;
$max_line = $line;
}
foreach ($text_list as $k => $line) { foreach ($text_list as $k => $line) {
if ($needs_blame) { if ($needs_blame) {
// If the line's rev is same as the line above, show empty content // If the line's rev is same as the line above, show empty content
@ -370,11 +383,13 @@ class DiffusionBrowseFileController extends DiffusionController {
} }
// Highlight the line of interest if needed. // Highlight the line of interest if needed.
if ($n == $drequest->getLine()) { if ($min_line > 0 && ($n >= $min_line && $n <= $max_line)) {
$tr = '<tr style="background: #ffff00;">'; $tr = '<tr style="background: #ffff00;">';
$targ = '<a id="scroll_target"></a>'; if ($targ == '') {
Javelin::initBehavior('diffusion-jump-to', $targ = '<a id="scroll_target"></a>';
array('target' => 'scroll_target')); Javelin::initBehavior('diffusion-jump-to',
array('target' => 'scroll_target'));
}
} else { } else {
$tr = '<tr>'; $tr = '<tr>';
$targ = null; $targ = null;