$window[2] =~ /^$COLOR*\+/ &&
$window[3] !~ /^$COLOR*\+/) {
print shift @window;
- show_pair(shift @window, shift @window);
+ show_hunk(shift @window, shift @window);
}
else {
print shift @window;
$window[1] =~ /^$COLOR*-/ &&
$window[2] =~ /^$COLOR*\+/) {
print shift @window;
- show_pair(shift @window, shift @window);
+ show_hunk(shift @window, shift @window);
}
# And then flush any remaining lines.
exit 0;
-sub show_pair {
+sub show_hunk {
+ my ($a, $b) = @_;
+
+ print highlight_pair($a, $b);
+}
+
+sub highlight_pair {
my @a = split_line(shift);
my @b = split_line(shift);
}
if (is_pair_interesting(\@a, $pa, $sa, \@b, $pb, $sb)) {
- print highlight(\@a, $pa, $sa);
- print highlight(\@b, $pb, $sb);
+ return highlight_line(\@a, $pa, $sa),
+ highlight_line(\@b, $pb, $sb);
}
else {
- print join('', @a);
- print join('', @b);
+ return join('', @a),
+ join('', @b);
}
}
split /($COLOR*)/;
}
-sub highlight {
+sub highlight_line {
my ($line, $prefix, $suffix) = @_;
return join('',