line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ColorThemeUtil::ANSI; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2020-06-09'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'ColorThemeUtil-ANSI'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
55804
|
use 5.010001; |
|
1
|
|
|
|
|
11
|
|
9
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use Exporter 'import'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
260
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
14
|
|
|
|
|
|
|
item_color_to_ansi |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub item_color_to_ansi { |
18
|
1
|
|
|
1
|
1
|
542
|
require Color::ANSI::Util; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
7730
|
my ($color, $is_bg) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1
|
50
|
33
|
|
|
8
|
return unless defined $color && length($color); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
2
|
my $ansi; |
25
|
1
|
50
|
|
|
|
5
|
if (ref $color eq 'HASH') { |
|
|
50
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
my $ansifg = $color->{ansi_fg}; |
27
|
|
|
|
|
|
|
$ansifg //= Color::ANSI::Util::ansifg($color->{fg}) |
28
|
0
|
0
|
0
|
|
|
0
|
if defined $color->{fg}; |
29
|
0
|
|
0
|
|
|
0
|
$ansifg //= ""; |
30
|
0
|
|
|
|
|
0
|
my $ansibg = $color->{ansi_bg}; |
31
|
|
|
|
|
|
|
$ansibg //= Color::ANSI::Util::ansibg($color->{bg}) |
32
|
0
|
0
|
0
|
|
|
0
|
if defined $color->{bg}; |
33
|
0
|
|
0
|
|
|
0
|
$ansibg //= ""; |
34
|
0
|
|
|
|
|
0
|
$ansi = $ansifg . $ansibg; |
35
|
|
|
|
|
|
|
} elsif (ref $color) { |
36
|
0
|
|
|
|
|
0
|
die "Cannot handle color $color"; |
37
|
|
|
|
|
|
|
} else { |
38
|
1
|
50
|
|
|
|
13
|
$ansi = $is_bg ? Color::ANSI::Util::ansibg($color) : |
39
|
|
|
|
|
|
|
Color::ANSI::Util::ansifg($color); |
40
|
|
|
|
|
|
|
} |
41
|
1
|
|
|
|
|
989
|
$ansi; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
# ABSTRACT: Utility routines related to color themes and ANSI code |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |