line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Color::Theme::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2018-02-25'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.020'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
74453
|
use 5.010001; |
|
1
|
|
|
|
|
11
|
|
7
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
332
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
create_color_theme_transform |
14
|
|
|
|
|
|
|
get_color_theme |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub create_color_theme_transform { |
18
|
1
|
|
|
1
|
1
|
83
|
my ($basect, $func) = @_; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
3
|
my $derivedct = {}; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
1
|
for my $cn (keys %{ $basect->{colors} }) { |
|
1
|
|
|
|
|
5
|
|
23
|
2
|
|
|
|
|
4
|
my $cv = $basect->{colors}{$cn}; |
24
|
|
|
|
|
|
|
|
25
|
2
|
50
|
|
|
|
5
|
if ($cv) { |
26
|
|
|
|
|
|
|
$derivedct->{colors}{$cn} = sub { |
27
|
2
|
|
|
2
|
|
7
|
my ($self, %args) = @_; |
28
|
2
|
|
|
|
|
3
|
my $basec = $basect->{colors}{$cn}; |
29
|
2
|
100
|
|
|
|
7
|
if (ref($basec) eq 'CODE') { |
30
|
1
|
|
|
|
|
4
|
$basec = $basec->($self, name=>$cn, %args); |
31
|
|
|
|
|
|
|
} |
32
|
2
|
50
|
|
|
|
7
|
if ($basec) { |
33
|
2
|
50
|
|
|
|
5
|
if (ref($basec) eq 'ARRAY') { |
34
|
0
|
0
|
0
|
|
|
0
|
$basec = [map {defined($_) && /^#?[0-9A-Fa-f]{6}$/ ? |
|
0
|
|
|
|
|
0
|
|
35
|
|
|
|
|
|
|
$func->($_) : $_} @$basec]; |
36
|
|
|
|
|
|
|
} else { |
37
|
2
|
|
|
|
|
4
|
for ($basec) { |
38
|
2
|
50
|
33
|
|
|
15
|
$_ = defined($_) && /^#?[0-9A-Fa-f]{6}$/ ? |
39
|
|
|
|
|
|
|
$func->($_) : $_; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
2
|
|
|
|
|
19
|
return $basec; |
44
|
2
|
|
|
|
|
9
|
}; |
45
|
|
|
|
|
|
|
} else { |
46
|
|
|
|
|
|
|
#$derivedct->{colors}{$cn} = $cv; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
1
|
|
|
|
|
3
|
$derivedct; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_color_theme { |
53
|
1
|
|
|
1
|
|
8
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
257
|
|
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
0
|
1
|
|
my $opts = ref($_[0]) eq 'HASH' ? shift : {}; |
56
|
0
|
|
|
|
|
|
my $name0 = shift; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
0
|
|
|
|
my $modprefixes = $opts->{module_prefixes} // ["Generic::ColorTheme"]; |
59
|
0
|
|
0
|
|
|
|
my $themeprefixes0 = $opts->{theme_prefixes} // ["Default"]; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my (@themeprefixes, $name); |
62
|
0
|
0
|
|
|
|
|
if ($name0 =~ /(.+)::(.+)/) { |
63
|
0
|
|
|
|
|
|
@themeprefixes = ($1); |
64
|
0
|
|
|
|
|
|
$name = $2; |
65
|
|
|
|
|
|
|
} else { |
66
|
0
|
|
|
|
|
|
@themeprefixes = @$themeprefixes0; |
67
|
0
|
|
|
|
|
|
$name = $name0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my @searched_mods; |
71
|
0
|
|
|
|
|
|
for my $modprefix (@$modprefixes) { |
72
|
0
|
|
|
|
|
|
for my $themeprefix (@themeprefixes) { |
73
|
0
|
|
|
|
|
|
my $mod = "$modprefix\::$themeprefix"; |
74
|
0
|
|
|
|
|
|
push @searched_mods, $mod; |
75
|
0
|
|
|
|
|
|
(my $mod_pm = "$mod.pm") =~ s!::!/!g; |
76
|
0
|
0
|
|
|
|
|
if (eval { require $mod_pm; 1 }) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $color_themes = \%{"$mod\::color_themes"}; |
|
0
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
return $color_themes->{$name} if $color_themes->{$name}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
0
|
|
|
|
|
|
die "Can't find color theme '$name0' (searched in ". |
83
|
|
|
|
|
|
|
join(", ", @searched_mods).")"; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
# ABSTRACT: Utility routines related to color themes |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |