line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Term::ANSIColorx::ColorNicknames; |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
25804
|
use Term::ANSIColor qw(colorstrip uncolor); |
|
6
|
|
|
|
|
35885
|
|
|
6
|
|
|
|
|
2186
|
|
5
|
6
|
|
|
6
|
|
3234
|
use common::sense; |
|
6
|
|
|
|
|
39
|
|
|
6
|
|
|
|
|
21
|
|
6
|
6
|
|
|
6
|
|
288
|
use base 'Exporter'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
3979
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '2.7191_1'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @FIXED = qw(color colorvalid colored); |
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(fix_color color colorvalid colored colorstrip uncolor); |
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK, fixed=>\@FIXED ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %NICKNAMES = ( |
15
|
|
|
|
|
|
|
normal => "clear", |
16
|
|
|
|
|
|
|
unbold => "clear", |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
blood => "red", |
19
|
|
|
|
|
|
|
umber => "bold red", |
20
|
|
|
|
|
|
|
sky => "bold blue", |
21
|
|
|
|
|
|
|
ocean => "cyan", |
22
|
|
|
|
|
|
|
lightblue => "cyan", |
23
|
|
|
|
|
|
|
cyan => "bold cyan", |
24
|
|
|
|
|
|
|
lime => "bold green", |
25
|
|
|
|
|
|
|
orange => "yellow", |
26
|
|
|
|
|
|
|
brown => "yellow", |
27
|
|
|
|
|
|
|
yellow => "bold yellow", |
28
|
|
|
|
|
|
|
purple => "magenta", |
29
|
|
|
|
|
|
|
violet => "bold magenta", |
30
|
|
|
|
|
|
|
pink => "bold magenta", |
31
|
|
|
|
|
|
|
pitch => "bold black", |
32
|
|
|
|
|
|
|
coal => "bold black", |
33
|
|
|
|
|
|
|
grey => "white", |
34
|
|
|
|
|
|
|
gray => "white", |
35
|
|
|
|
|
|
|
white => "bold white", |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
dire => "bold yellow on_red", |
38
|
|
|
|
|
|
|
alert => "bold yellow on_red", |
39
|
|
|
|
|
|
|
todo => "black on_yellow", |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
nc_dir => "bold white on_blue", |
42
|
|
|
|
|
|
|
nc_file => "bold white on_blue", |
43
|
|
|
|
|
|
|
nc_exe => "bold green on_blue", |
44
|
|
|
|
|
|
|
nc_exec => "bold green on_blue", |
45
|
|
|
|
|
|
|
nc_curs => "black on_cyan", |
46
|
|
|
|
|
|
|
nc_pwd => "black on_white", |
47
|
|
|
|
|
|
|
nc_cwd => "black on_white", |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
mc_dir => "bold white on_blue", |
50
|
|
|
|
|
|
|
mc_file => "bold white on_blue", |
51
|
|
|
|
|
|
|
mc_exe => "bold green on_blue", |
52
|
|
|
|
|
|
|
mc_exec => "bold green on_blue", |
53
|
|
|
|
|
|
|
mc_curs => "black on_cyan", |
54
|
|
|
|
|
|
|
mc_pwd => "black on_white", |
55
|
|
|
|
|
|
|
mc_cwd => "black on_white", |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub fix_color(_) { |
59
|
36
|
|
|
36
|
1
|
1345
|
my $color = shift; |
60
|
36
|
|
|
|
|
46
|
my $no_nick = $color =~ s/\a//g; |
61
|
|
|
|
|
|
|
|
62
|
36
|
|
|
|
|
72
|
$color =~ s/[^\w]/ /g; |
63
|
36
|
|
|
|
|
49
|
$color =~ s/on (\w+)/on_$1/g; |
64
|
36
|
|
|
|
|
31
|
$color =~ s/un bold/unbold/g; |
65
|
36
|
|
|
|
|
39
|
$color =~ s/([mn]c) (dir|file|exec?|curs|[pc]wd)/$1_$2/g; |
66
|
|
|
|
|
|
|
|
67
|
64
|
100
|
100
|
|
|
267
|
my @cl = map { |
68
|
36
|
|
|
|
|
62
|
(!$no_nick && exists $NICKNAMES{$_}) |
69
|
|
|
|
|
|
|
? split(" ", $NICKNAMES{$_}) : $_ |
70
|
|
|
|
|
|
|
} split(" ", $color); |
71
|
|
|
|
|
|
|
|
72
|
43
|
|
|
|
|
108
|
FIXCL: { |
73
|
36
|
|
|
|
|
43
|
my %m = (faint=>1, dark=>1, bold=>1, bright=>1, clear=>1); |
74
|
43
|
|
|
|
|
62
|
for my $i (0 .. $#cl) { |
75
|
70
|
100
|
|
|
|
146
|
if( $m{$cl[$i]} ) { |
76
|
25
|
|
|
|
|
17
|
my $l = 1; |
77
|
|
|
|
|
|
|
|
78
|
25
|
|
|
|
|
61
|
$l ++ while $m{$cl[ $i+$l ]}; |
79
|
|
|
|
|
|
|
|
80
|
25
|
100
|
|
|
|
40
|
if( $l > 1 ) { |
81
|
7
|
|
|
|
|
9
|
splice @cl, $i, $l, $cl[$i]; |
82
|
7
|
|
|
|
|
19
|
redo FIXCL; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
36
|
100
|
|
|
|
69
|
$color = join " ", @cl>1 ? grep {$_ ne "clear"} @cl : @cl; |
|
48
|
|
|
|
|
62
|
|
89
|
|
|
|
|
|
|
|
90
|
36
|
|
|
|
|
75
|
return $color; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub color(_) { |
94
|
23
|
|
|
23
|
1
|
2326
|
@_ = (fix_color $_[0]); |
95
|
23
|
|
|
|
|
65
|
goto &Term::ANSIColor::color; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub colorvalid(_) { |
99
|
6
|
|
|
6
|
1
|
365
|
@_ = (fix_color $_[0]); |
100
|
6
|
|
|
|
|
20
|
goto &Term::ANSIColor::colorvalid; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub colored { |
104
|
3
|
|
|
3
|
1
|
444
|
my ($string, @codes); |
105
|
|
|
|
|
|
|
|
106
|
3
|
100
|
|
|
|
5
|
if (ref $_[0]) { |
107
|
1
|
|
|
|
|
1
|
@codes = @{+shift}; |
|
1
|
|
|
|
|
2
|
|
108
|
1
|
|
|
|
|
2
|
$string = join ('', @_); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} else { |
111
|
2
|
|
|
|
|
3
|
$string = shift; |
112
|
2
|
|
|
|
|
2
|
@codes = @_; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
3
|
|
|
|
|
7
|
@_ = ($string, map {fix_color} @codes); |
|
3
|
|
|
|
|
4
|
|
116
|
3
|
|
|
|
|
7
|
goto &Term::ANSIColor::colored; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
"true"; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__END__ |