Changeset 2154
- Timestamp:
- 12/21/08 23:45:11 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre-Plugin-Perl6/lib/Padre/Document/Perl6.pm
r2153 r2154 23 23 my $text = $self->text_get; 24 24 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 ); 29 29 30 my @tokens; 31 32 eval { 33 @tokens = $p->tokens; 34 1; 35 }; 36 30 my @tokens; 31 eval { @tokens = $p->tokens; 1; }; 37 32 if($EVAL_ERROR) { 38 33 say "Parsing error, bye bye ->colorize"; … … 42 37 $self->remove_color; 43 38 44 my %colors = (39 my %colors = ( 45 40 'comp_unit' => Px::PADRE_BLUE, 46 41 'scope_declarator' => Px::PADRE_RED, … … 65 60 '_hash' => Px::PADRE_ORANGE, 66 61 '_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 } 76 73 } 77 }78 74 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) ; 81 77 } 82 78
Note: See TracChangeset
for help on using the changeset viewer.
