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