| 1 | package Tk::TextHighlight::Perl; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | $VERSION = '0.4'; | |||||||||||||||||||
| 5 | #use Syntax::Highlight::Perl; | ||||||||||||||||||||
| 6 | #use base 'Syntax::Highlight::Perl::Improved'; | ||||||||||||||||||||
| 7 | BEGIN | ||||||||||||||||||||
| 8 | 1 | ▶ | { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.1
| |||||||||||||||||||||
| 9 | 1 | my $havePerlImproved = 0; | |||||||||||||||||||
| 10 | 1 | ▶ | eval 'use base "Syntax::Highlight::Perl::ImprovedMore"; $havePerlImproved = 1; 1'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 1 | ▶ | unless ($havePerlImproved) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 12 | 1 | ▶ | eval 'use base "Syntax::Highlight::Perl::Improved"; $havePerlImproved = 1; 1'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | eval 'use base "Syntax::Highlight::Perl"; 1' unless ($havePerlImproved); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 21 | 0 | my ($proto, $rules) = @_; | |||||||||||||||||||
| 22 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 23 | 0 | my $self = $class->SUPER::new; | |||||||||||||||||||
| 24 | 0 | ▶ | if (not defined($rules)) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 0 | $rules = [ | |||||||||||||||||||
| 26 | ['DEFAULT', -foreground => 'black'], | ||||||||||||||||||||
| 27 | ['Comment_Normal', -foreground => 'lightblue'], | ||||||||||||||||||||
| 28 | ['Comment_Pod', -foreground => 'lightblue'], | ||||||||||||||||||||
| 29 | ['Directive', -foreground => 'brown'], | ||||||||||||||||||||
| 30 | ['Label', -foreground => 'black'], | ||||||||||||||||||||
| 31 | ['Quote', -foreground => 'red'], | ||||||||||||||||||||
| 32 | ['String', -foreground => 'red'], | ||||||||||||||||||||
| 33 | ['Variable_Scalar', -foreground => 'blue'], | ||||||||||||||||||||
| 34 | ['Variable_Array', -foreground => 'blue'], | ||||||||||||||||||||
| 35 | ['Variable_Hash', -foreground => 'blue'], | ||||||||||||||||||||
| 36 | ['Subroutine', -foreground => 'orange'], | ||||||||||||||||||||
| 37 | ['Character', -foreground => 'magenta'], | ||||||||||||||||||||
| 38 | ['Keyword', -foreground => 'brown'], | ||||||||||||||||||||
| 39 | ['Builtin_Operator', -foreground => 'darkgreen'], | ||||||||||||||||||||
| 40 | ['Operator', -foreground => 'brown'], | ||||||||||||||||||||
| 41 | ['Number', -foreground => 'darkblue'], | ||||||||||||||||||||
| 42 | ]; | ||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||
| 44 | 0 | $self->{'rules'} = []; | |||||||||||||||||||
| 45 | 0 | bless ($self, $class); | |||||||||||||||||||
| 46 | 0 | $self->rules($rules); | |||||||||||||||||||
| 47 | 0 | $self->unstable(1); | |||||||||||||||||||
| 48 | 0 | return $self; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | sub highlight { | ||||||||||||||||||
|
Subroutine
highlight: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 52 | 0 | my $hlt = shift; | |||||||||||||||||||
| 53 | 0 | my $txt = $hlt->format_string(shift); | |||||||||||||||||||
| 54 | 0 | my @target = (); | |||||||||||||||||||
| 55 | 0 | my @lst = split /\e\e\e/o, $txt; #start to retrieve the color info tags. | |||||||||||||||||||
| 56 | 0 | ▶ | while (@lst) { #set up the insert command options. | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 0 | push(@target, length(shift @lst), shift @lst); | |||||||||||||||||||
| 58 | }; | ||||||||||||||||||||
| 59 | 0 | return @target; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub rules { | ||||||||||||||||||
|
Subroutine
rules: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 63 | 0 | my $hlt = shift; | |||||||||||||||||||
| 64 | 0 | ▶ | if (@_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | 0 | my $r = shift; | |||||||||||||||||||
| 66 | 0 | my %format = (); | |||||||||||||||||||
| 67 | 0 | foreach my $k (@$r) { | |||||||||||||||||||
| 68 | 0 | $format{$k->[0]} = ["", "\e\e\e" . $k->[0] . "\e\e\e"]; | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | 0 | $hlt->set_format(%format); | |||||||||||||||||||
| 71 | 0 | $hlt->reset; | |||||||||||||||||||
| 72 | 0 | $hlt->{'rules'} = $r; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | 0 | return $hlt->{'rules'}; | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | ▶ | sub stateCompare { | ||||||||||||||||||
|
Subroutine
stateCompare: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 78 | 0 | my ($hlt, $state) = @_; | |||||||||||||||||||
| 79 | 0 | my $h = [ $hlt->stateGet ]; | |||||||||||||||||||
| 80 | 0 | my $equal = 1; | |||||||||||||||||||
| 81 | 0 | ▶ | if (Dumper($h) ne Dumper($state)) { $equal = 0 }; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | 0 | return $equal; | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | ▶ | sub stateGet { | ||||||||||||||||||
|
Subroutine
stateGet: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 86 | 0 | my $hlt = shift; | |||||||||||||||||||
| 87 | return ( | ||||||||||||||||||||
| 88 | $hlt->in_heredoc, | ||||||||||||||||||||
| 89 | $hlt->in_string, | ||||||||||||||||||||
| 90 | $hlt->in_pod, | ||||||||||||||||||||
| 91 | $hlt->was_pod, | ||||||||||||||||||||
| 92 | $hlt->in_data, | ||||||||||||||||||||
| 93 | $hlt->{'quote_instigator'}, | ||||||||||||||||||||
| 94 | $hlt->{'quote_terminator'}, | ||||||||||||||||||||
| 95 | $hlt->{'quote_type'}, | ||||||||||||||||||||
| 96 | $hlt->{'found_multi'}, | ||||||||||||||||||||
| 97 | $hlt->{'awaiting_multi'}, | ||||||||||||||||||||
| 98 | $hlt->{'awaiting_variable'}, | ||||||||||||||||||||
| 99 | $hlt->{'awaiting_class'}, | ||||||||||||||||||||
| 100 | $hlt->{'last_token'}, | ||||||||||||||||||||
| 101 | $hlt->{'last_token_type'}, | ||||||||||||||||||||
| 102 | 0 | $hlt->{'reentrant'}, | |||||||||||||||||||
| 103 | ); | ||||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | ▶ | sub stateSet { | ||||||||||||||||||
|
Subroutine
stateSet: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 107 | 0 | my $hlt = shift; | |||||||||||||||||||
| 108 | 0 | $hlt->{'in_heredoc'} = shift; | |||||||||||||||||||
| 109 | 0 | $hlt->{'in_string'} = shift; | |||||||||||||||||||
| 110 | 0 | $hlt->{'in_pod'} = shift; | |||||||||||||||||||
| 111 | 0 | $hlt->{'was_pod'} = shift; | |||||||||||||||||||
| 112 | 0 | $hlt->{'in_data'} = shift; | |||||||||||||||||||
| 113 | 0 | $hlt->{'quote_instigator'} = shift; | |||||||||||||||||||
| 114 | 0 | $hlt->{'quote_terminator'} = shift; | |||||||||||||||||||
| 115 | 0 | $hlt->{'quote_type'} = shift; | |||||||||||||||||||
| 116 | 0 | $hlt->{'found_multi'} = shift; | |||||||||||||||||||
| 117 | 0 | $hlt->{'awaiting_multi'} = shift; | |||||||||||||||||||
| 118 | 0 | $hlt->{'awaiting_variable'} = shift; | |||||||||||||||||||
| 119 | 0 | $hlt->{'awaiting_class'} = shift; | |||||||||||||||||||
| 120 | 0 | $hlt->{'last_token'} = shift; | |||||||||||||||||||
| 121 | 0 | $hlt->{'last_token_type'} = shift; | |||||||||||||||||||
| 122 | 0 | $hlt->{'reentrant'} = shift; | |||||||||||||||||||
| 123 | } | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | 0 | ▶ | sub syntax { | ||||||||||||||||||
|
Subroutine
syntax: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 126 | 0 | my $hlt = shift; | |||||||||||||||||||
| 127 | 0 | return 'Perl', | |||||||||||||||||||
| 128 | } | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 1 | 1; | |||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | __END__ | ||||||||||||||||||||