Changeset 2154


Ignore:
Timestamp:
12/21/08 23:45:11 (3 years ago)
Author:
azawawi
Message:

Better indents in Document::Perl6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre-Plugin-Perl6/lib/Padre/Document/Perl6.pm

    r2153 r2154  
    2323    my $text   = $self->text_get; 
    2424 
    25   my $t0 = Benchmark->new; 
    26   my $p = Syntax::Highlight::Perl6->new( 
    27     text => $text, 
    28   ); 
     25    my $t0 = Benchmark->new; 
     26    my $p = Syntax::Highlight::Perl6->new( 
     27        text => $text, 
     28    ); 
    2929 
    30   my @tokens; 
    31  
    32     eval { 
    33     @tokens = $p->tokens; 
    34   1; 
    35     }; 
    36  
     30    my @tokens; 
     31    eval { @tokens = $p->tokens;   1; }; 
    3732    if($EVAL_ERROR) { 
    3833        say "Parsing error, bye bye ->colorize"; 
     
    4237    $self->remove_color; 
    4338 
    44   my %colors = ( 
     39    my %colors = ( 
    4540        'comp_unit'  => Px::PADRE_BLUE, 
    4641        'scope_declarator' => Px::PADRE_RED, 
     
    6560        '_hash' => Px::PADRE_ORANGE, 
    6661        '_comment' => Px::PADRE_GREEN, 
    67   ); 
    68   for my $htoken (@tokens) { 
    69     my %token = %{$htoken}; 
    70     my $color = $colors{ $token{rule} }; 
    71     if($color) { 
    72       my $len = length $token{buffer}; 
    73       my $start = $token{last_pos} - $len; 
    74       $editor->StartStyling($start, $color); 
    75       $editor->SetStyling($len, $color); 
     62    ); 
     63 
     64    for my $htoken (@tokens) { 
     65        my %token = %{$htoken}; 
     66        my $color = $colors{ $token{rule} }; 
     67        if($color) { 
     68              my $len = length $token{buffer}; 
     69              my $start = $token{last_pos} - $len; 
     70              $editor->StartStyling($start, $color); 
     71              $editor->SetStyling($len, $color); 
     72        } 
    7673    } 
    77   } 
    7874 
    79   my $td = timediff(new Benchmark, $t0); 
    80   say "->colorize took:" . timestr($td) ; 
     75      my $td = timediff(new Benchmark, $t0); 
     76      say "->colorize took:" . timestr($td) ; 
    8177} 
    8278 
Note: See TracChangeset for help on using the changeset viewer.