/[SVNBrowser]/trunk/lib/SVNBrowser/ColorDiff.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/SVNBrowser/ColorDiff.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 35 by dpavlin, Thu Dec 7 17:18:34 2006 UTC revision 36 by dpavlin, Mon Dec 11 17:58:07 2006 UTC
# Line 1  Line 1 
1  package SVNBrowser::ColorDiff;  package SVNBrowser::ColorDiff;
2    
3  use strict;  use strict;
 use Text::VimColor;  
4  use HTML::Entities;  use HTML::Entities;
5  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
6    
# Line 39  sub diff { Line 38  sub diff {
38                  local $/;                  local $/;
39                  $diff = <$diff_fh>;                  $diff = <$diff_fh>;
40          }          }
41          close($diff_fh) or warn "error closing $cmd: $!";          close($diff_fh); # or warn "error closing $cmd: $!";
42    
43          $diff =~ s/\r//gs;          $diff =~ s/\r//gs;
44    
# Line 47  sub diff { Line 46  sub diff {
46    
47          my $out = "<tt>$cmd</tt><br/>";          my $out = "<tt>$cmd</tt><br/>";
48    
49            $out .= "<pre>" . encode_entities($diff, '<>&"') . "</pre>";
         my $vim;  
         eval {  
                 local %ENV;  
                 $ENV{PATH} = "/usr/local/bin:/usr/bin:$ENV{PATH}";  
   
                 my $vim = Text::VimColor->new(  
                         string => $diff,  
                         filetype => 'diff',  
                         vim_command => Jifty->config->app('vim'),  
                         vim_options => [ qw( -RXZ -i NONE -u NONE -N ), "+set nomodeline" ]  
                 );  
         };  
   
         if ($@) {  
                 $out .= "<pre>" . encode_entities($diff, '<>&"') . "</pre>";  
         } else {  
                 foreach (my ($type,$val) = $vim->marked) {  
                         $out .= qq{<span class="$type">$val</span>};  
                 }  
         }  
50    
51          return $out;          return $out;
52    

Legend:
Removed from v.35  
changed lines
  Added in v.36

  ViewVC Help
Powered by ViewVC 1.1.26