| 1 | # -*- indent-tabs-mode: nil -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Term::ANSIColor::Concise; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | our $VERSION = "3.07"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | our @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ansi_color ansi_color_24 ansi_code ansi_pair csi_code csi_report | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | cached_ansi_color | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | map_256_to_6 map_to_256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | our %EXPORT_TAGS = (all => [ @EXPORT_OK ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use List::Util qw(min max first); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use Term::ANSIColor::Concise::Transform qw(transform $mod_re); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | ▶ | use aliased; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | ▶ | my $Color = alias 'Term::ANSIColor::Concise::' . ($ENV{TAC_COLOR_PACKAGE} || 'ColorObject'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'TAC_COLOR_PACKAGE'} || 'ColorObject'
MC/DC0%0/1
$ENV{'TAC_COLOR_PACKAGE'} || 'ColorObject'
$ENV{'TAC_COLOR_PACKAGE'}
Truth table50%1/2
A
A= $ENV{'TAC_COLOR_PACKAGE'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 80 | ▶ | sub Color { $Color } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Color: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | our $NO_NO_COLOR //= $ENV{ANSICOLOR_NO_NO_COLOR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
our $NO_NO_COLOR //= $ENV{"ANSICOLOR_NO_NO_COLOR"}
MC/DC0%0/2
our $NO_NO_COLOR //= $ENV{"ANSICOLOR_NO_NO_COLOR"}
our $NO_NO_COLOR
$ENV{"ANSICOLOR_NO_NO_COLOR"}
Truth table33%1/3
A //= B
A= our $NO_NO_COLORB= $ENV{"ANSICOLOR_NO_NO_COLOR"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | our $NO_COLOR //= !$NO_NO_COLOR && defined $ENV{NO_COLOR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
our $NO_COLOR //= !$Term::ANSIColor::Concise::NO_NO_COLOR && defined $ENV{"NO_COLOR"}
!$Term::ANSIColor::Concise::NO_NO_COLOR && defined $ENV{'NO_COLOR'}
MC/DC0%0/1
our $NO_COLOR //= !$Term::ANSIColor::Concise::NO_NO_COLOR && defined $ENV{"NO_COLOR"}
our $NO_COLOR
Truth table50%1/2
A
A= our $NO_COLOR
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | our $RGB24 //= $ENV{ANSICOLOR_RGB24} // ($ENV{COLORTERM}//'' eq 'truecolor'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
our $RGB24 //=
$ENV{"ANSICOLOR_RGB24"} //
$ENV{"COLORTERM"} //
MC/DC0%0/1
our $RGB24 //=
our $RGB24
Truth table50%1/2
A
A= our $RGB24
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 5 | ▶ | our $LINEAR_256 //= $ENV{ANSICOLOR_LINEAR_256}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
our $LINEAR_256 //= $ENV{"ANSICOLOR_LINEAR_256"}
MC/DC0%0/2
our $LINEAR_256 //= $ENV{"ANSICOLOR_LINEAR_256"}
our $LINEAR_256
$ENV{"ANSICOLOR_LINEAR_256"}
Truth table33%1/3
A //= B
A= our $LINEAR_256B= $ENV{"ANSICOLOR_LINEAR_256"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | ▶ | our $LINEAR_GRAY //= $ENV{ANSICOLOR_LINEAR_GRAY}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
our $LINEAR_GRAY //= $ENV{"ANSICOLOR_LINEAR_GRAY"}
MC/DC0%0/2
our $LINEAR_GRAY //= $ENV{"ANSICOLOR_LINEAR_GRAY"}
our $LINEAR_GRAY
$ENV{"ANSICOLOR_LINEAR_GRAY"}
Truth table33%1/3
A //= B
A= our $LINEAR_GRAYB= $ENV{"ANSICOLOR_LINEAR_GRAY"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 5 | ▶ | our $NO_RESET_EL //= $ENV{ANSICOLOR_NO_RESET_EL}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
our $NO_RESET_EL //= $ENV{"ANSICOLOR_NO_RESET_EL"}
MC/DC0%0/2
our $NO_RESET_EL //= $ENV{"ANSICOLOR_NO_RESET_EL"}
our $NO_RESET_EL
$ENV{"ANSICOLOR_NO_RESET_EL"}
Truth table33%1/3
A //= B
A= our $NO_RESET_ELB= $ENV{"ANSICOLOR_NO_RESET_EL"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | ▶ | our $SPLIT_ANSI //= $ENV{ANSICOLOR_SPLIT_ANSI}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
our $SPLIT_ANSI //= $ENV{"ANSICOLOR_SPLIT_ANSI"}
MC/DC0%0/2
our $SPLIT_ANSI //= $ENV{"ANSICOLOR_SPLIT_ANSI"}
our $SPLIT_ANSI
$ENV{"ANSICOLOR_SPLIT_ANSI"}
Truth table33%1/3
A //= B
A= our $SPLIT_ANSIB= $ENV{"ANSICOLOR_SPLIT_ANSI"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | ▶ | our $NO_CUMULATIVE //= $ENV{ANSICOLOR_NO_CUMULATIVE}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
our $NO_CUMULATIVE //= $ENV{"ANSICOLOR_NO_CUMULATIVE"}
MC/DC0%0/2
our $NO_CUMULATIVE //= $ENV{"ANSICOLOR_NO_CUMULATIVE"}
our $NO_CUMULATIVE
$ENV{"ANSICOLOR_NO_CUMULATIVE"}
Truth table33%1/3
A //= B
A= our $NO_CUMULATIVEB= $ENV{"ANSICOLOR_NO_CUMULATIVE"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | my @nonlinear = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | map { ( $_->[0] ) x $_->[1] } ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | [ 0, 75 ], # 0 .. 74 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | [ 1, 40 ], # 75 .. 114 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | [ 2, 40 ], # 115 .. 154 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | [ 3, 40 ], # 155 .. 194 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | [ 4, 40 ], # 195 .. 234 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | [ 5, 21 ], # 235 .. 255 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 315 | ▶ | sub map_256_to_6 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_256_to_6: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 315 | my $i = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 315 | ▶ | if ($LINEAR_256) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | 5 * $i / 255; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # ( $i - 35 ) / 40; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 303 | $nonlinear[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub map_to_256 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map_to_256: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my($base, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ($i == 0) { 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | elsif ($base == 6) { $i * 40 + 55 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | elsif ($base == 12) { $i * 20 + 35 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | elsif ($base == 24) { $i * 10 + 25 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | else { die } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 17 | ▶ | sub ansi256_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ansi256_number: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 17 | my $code = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 17 | my($r, $g, $b, $gray); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 17 | ▶ | if ($code =~ /^([0-5])([0-5])([0-5])$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 11 | ($r, $g, $b) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif (my($n) = $code =~ /^L(\d+)/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 6 | ▶ | $n > 25 and croak "Color spec error: $code."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 6 | ▶ | if ($n == 0 or $n == 25) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$n == 0 or $n == 25
MC/DC100%2/2
$n == 0 or $n == 25
$n == 0
$n == 25
Truth table100%3/3
A or B
A= $n == 0B= $n == 25
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | $r = $g = $b = $n / 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | $gray = $n - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | croak "Color spec error: $code."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 17 | ▶ | defined $gray ? ($gray + 232) : ($r*36 + $g*6 + $b + 16); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 107 | ▶ | sub rgb24_number { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rgb24_number: called CC=8 SCAR=21.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 107 | my($rx, $gx, $bx) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 107 | my($r, $g, $b, $gray); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 107 | ▶ | if ($rx != 0 and $rx != 255 and $rx == $gx and $rx == $bx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$rx != 0 and $rx != 255 and $rx == $gx and $rx == $bx
$rx != 0 and $rx != 255 and $rx == $gx
$rx != 0 and $rx != 255
MC/DC100%4/4
$rx != 0 and $rx != 255 and $rx == $gx and $rx == $bx
$rx != 0
$rx != 255
$rx == $gx
$rx == $bx
Truth table100%5/5
A and B and C and D
A= $rx != 0B= $rx != 255C= $rx == $gxD= $rx == $bx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | if ($LINEAR_GRAY) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ## Divide area into 25 segments, and map to BLACK and 24 GRAYS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $gray = $rx * 25 / 255 - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($gray < 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $r = $g = $b = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $gray = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ## map to 8, 18, 28, ... 238 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | $gray = min(23, ($rx - 3) / 10); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 105 | ($r, $g, $b) = map { map_256_to_6 $_ } $rx, $gx, $bx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 107 | ▶ | defined $gray ? ($gray + 232) : ($r*36 + $g*6 + $b + 16); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 27 | ▶ | sub rgb24 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rgb24: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 27 | my $rgb = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 27 | $rgb =~ s/^#//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 27 | my $len = length $rgb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 27 | ▶ | croak "$rgb: Invalid RGB value." if $len == 0 || $len % 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$len == 0 or $len % 3
MC/DC0%0/2
$len == 0 or $len % 3
$len == 0
$len % 3
Truth table33%1/3
A or B
A= $len == 0B= $len % 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 27 | $len /= 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 27 | my $max = (2 ** ($len * 4)) - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 27 | map { hex($_) * 255 / $max } $rgb =~ /[0-9a-z]{$len}/gi; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 128 | ▶ | sub rgbseq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rgbseq: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 128 | my($mod, @rgb) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 128 | ▶ | if ($mod) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 33 | @rgb = transform($mod, @rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 127 | ▶ | if ($RGB24) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 20 | return (2, @rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 107 | return (5, rgb24_number @rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 5 | my %numbers = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ';' => undef, # ; : NOP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | N => undef, # N : None (NOP) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | E => 'EL', # E : Erase Line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | Z => 0, # Z : Zero (Reset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | D => 1, # D : Double Strike (Bold) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | P => 2, # P : Pale (Dark) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | I => 3, # I : Italic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | U => 4, # U : Underline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | F => 5, # F : Flash (Blink: Slow) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | Q => 6, # Q : Quick (Blink: Rapid) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | S => 7, # S : Stand out (Reverse) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | H => 8, # H : Hide (Concealed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | X => 9, # X : Cross out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | K => 30, k => 90, # K : Kuro (Black) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | R => 31, r => 91, # R : Red | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | G => 32, g => 92, # G : Green | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | Y => 33, y => 93, # Y : Yellow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | B => 34, b => 94, # B : Blue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | M => 35, m => 95, # M : Magenta | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | C => 36, c => 96, # C : Cyan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | W => 37, w => 97, # W : White | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | T => 39, t => 39, # T : Terminal (default color) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 5 | my $colorspec_re = qr{ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | (?<spec> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | (?<slash> /) # / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | | (?<reset> \^) # ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | | (?<uline> _) # _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # Fullcolor with modifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | | ((?<fullcolor> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | (?<hex> [0-9a-f]{6} ## RGB 24bit hex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | | \#([0-9a-f]{3})+ ) ## RGB generic hex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | | (?<dec>(rgb)? (?&TRIPLET) ) ## RGB 24bit decimal (0-255, 0-255, 0-255) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | | (?<hsl> hsl (?&TRIPLET) ) ## HSL (0-360, 0-100, 0-100) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | | (?<lch> lch (?&TRIPLET) ) ## LCHab (0-100, 0~130, 0-360) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | | (?<lab> lab (?&TRIPLET) ) ## Lab (0-100, -128-127, -128-127) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | | < (?<name> \w+ ) > ## <colorname> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | (?<mod> $mod_re* ) ## color modifiers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # Basic 256/16 colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | | (?<c256> [0-5][0-5][0-5] # 216 (6x6x6) colors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | | L([01][0-9]|[2][0-5]) ) # 24 gray levels + B/W | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | | (?<c16> [KRGYBMCWT] ) # 16 colors, and the default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | | (?<value> V (?<values> :[\d:]*\d ) ) # color by the values after it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # Effects and controls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | | (?<efct> ~[DPIUFQSHX] # ~effect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | | [DPIUFQSHX]:[\d:]* # effect:style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | | [;NZDPIUFQSHX] ) # effect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | | (?<csi> \{ (?<csi_name>[A-Z]+) # other CSI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | (?<P> \( )? # optional ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | (?<csi_param>[\d,:;]*) # 0;1;2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | (?(<P>) \) ) # closing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | \} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | | (?<csi_abbr>[E]) ) # abbreviation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | (?(DEFINE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | (?<DIGIT> -? \d+ (\.\d+)? ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | (?<TRIPLET> \( (?&DIGIT), (?&DIGIT), (?&DIGIT) \) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | }xi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # What a color is for: added to 38, the number for foreground. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 5 | ▶ | use constant { FG => 0, BG => 10, UL => 20 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 221 | ▶ | sub ansi_numbers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ansi_numbers: called CC=35 SCAR=35.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 221 | ▶ | local $_ = shift // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 221 | my @numbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 221 | my $target = FG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 221 | my %F; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 162 | ▶ | my $color_numbers = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 162 | my($type, @values) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 162 | my $n = 38 + $target; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 162 | ▶ | return ($n, $type, @values) if $target != UL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # Underline color is not as old as the others, and has no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # reason to use semicolons. A terminal which does not know it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # would take the numbers after 58 as effects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # ITU-T T.416: 2:[color space]:R:G:B. The color space is left | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # empty. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 25 | ▶ | unshift @values, '' if $type == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 25 | return join ':', $n, $type, @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 221 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 221 | ▶ | my $rgb_numbers = sub { $color_numbers->(rgbseq($F{mod}, @_)) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 221 | ▶ | while (m{\G (?: $colorspec_re | (?<err> .+ ) ) }xig) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 386 | %F = %+; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 386 | ▶ | if ($+{slash}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 15 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 39 | ▶ | $target = $target == BG ? FG : BG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | elsif ($+{reset}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | $target = FG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | elsif ($+{uline}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 26 | $target = UL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | elsif ($+{hex}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 27 | my @rgb = rgb24($+{hex}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 27 | push @numbers, $rgb_numbers->(@rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | elsif (my $dec = $+{dec}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 7 | my @rgb = $dec =~ /\d+/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 7 | ▶ | croak "Unexpected value: $dec." if grep { $_ > 255 } @rgb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 7 | push @numbers, $rgb_numbers->(@rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | elsif (my $hsl = $+{hsl}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 21 | ▶ | Color->can('hsl') or die "HSL format is not supported.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 21 | my @hsl = $hsl =~ /\d+/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 21 | my @rgb = Color->hsl(@hsl)->rgb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 21 | push @numbers, $rgb_numbers->(@rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | elsif (my $lch = $+{lch}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 7 | ▶ | Color->can('lch') or die "LCHab format is not supported.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 7 | my($L, $C, $H) = $lch =~ /-?\d+/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 7 | my @rgb = Color->lch($L, $C, $H)->rgb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 7 | push @numbers, $rgb_numbers->(@rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | elsif (my $lab = $+{lab}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 12 | ▶ | Color->can('lab') or die "Lab format is not supported.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 12 | my($L, $a, $b) = $lab =~ /-?\d+/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 12 | my @rgb = Color->lab($L, $a, $b)->rgb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 12 | push @numbers, $rgb_numbers->(@rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | elsif ($+{name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 55 | require Graphics::ColorNames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 55 | state $colornames = Graphics::ColorNames->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 55 | ▶ | if (my @rgb = $colornames->rgb($+{name})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 54 | push @numbers, $rgb_numbers->(@rgb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | croak "Unknown color name: $+{name}."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | elsif ($+{c256}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 17 | push @numbers, $color_numbers->(5, ansi256_number $+{c256}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | elsif ($+{c16}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 73 | my $n = $numbers{$+{c16}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 73 | ▶ | if ($target == UL and $n != 39) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$target == 20 and $n != 39
MC/DC100%2/2
$target == 20 and $n != 39
$target == 20
$n != 39
Truth table100%3/3
A and B
A= $target == 20B= $n != 39
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # 30-37 and 90-97 have no counterpart for underline | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 18 | ▶ | push @numbers, $color_numbers->(5, $n < 90 ? $n - 30 : $n - 90 + 8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 55 | push @numbers, $n + $target; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | elsif ($+{value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 11 | push @numbers, (38 + $target) . $+{values}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | elsif ($+{efct}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 66 | my $efct = uc $+{efct}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 66 | ▶ | my $offset = $efct =~ s/^~// ? 20 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 66 | ▶ | my $style = $efct =~ s/(:[\d:]*)$// ? $1 : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 66 | ▶ | if (defined (my $n = $numbers{$efct})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 61 | push @numbers, ($n + $offset) . $style; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | elsif (my $csi = $+{csi}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 15 | push @numbers, do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 15 | ▶ | if ($+{csi_abbr}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 3 | [ $numbers{uc $+{csi_abbr}} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 12 | my($name, $param) = (uc $+{csi_name}, $+{csi_param}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 12 | ▶ | croak "Color spec error: \"$csi\" in \"$_\"." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$name ne "SGR" and $param =~ /:/u
MC/DC100%2/2
$name ne "SGR" and $param =~ /:/u
$name ne "SGR"
$param =~ /:/u
Truth table100%3/3
A and B
A= $name ne "SGR"B= $param =~ /:/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | if $name ne q(SGR) and $param =~ /:/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 10 | [ $name, $param =~ /[\d:]+/g ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | elsif (my $err = $+{err}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 8 | croak "Color spec error: \"$err\" in \"$_\"." | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | croak "$_: Something strange."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 374 | ▶ | if ($SPLIT_ANSI) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 3 | ▶ | my $index = first { not ref $numbers[$_] } keys @numbers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 3 | ▶ | if (defined $index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | my @sgr = splice @numbers, $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | push @numbers, [ 'SGR', @sgr ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 209 | @numbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 5 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 5 | CSI => "\e[", # Control Sequence Introducer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | RESET => "\e[m", # SGR Reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | EL => "\e[K", # Erase Line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 5 | my %csi_terminator = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | ICH => '@', # Insert Character | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | CUU => 'A', # Cursor up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | CUD => 'B', # Cursor Down | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | CUF => 'C', # Cursor Forward | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | CUB => 'D', # Cursor Back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | CNL => 'E', # Cursor Next Line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | CPL => 'F', # Cursor Previous line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | CHA => 'G', # Cursor Horizontal Absolute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | CUP => 'H', # Cursor Position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ED => 'J', # Erase in Display (0 after, 1 before, 2 entire, 3 w/buffer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | EL => 'K', # Erase in Line (0 after, 1 before, 2 entire) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | IL => 'L', # Insert Line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | DL => 'M', # Delete Line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | DCH => 'P', # Delete Character | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | SU => 'S', # Scroll Up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | SD => 'T', # Scroll Down | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ECH => 'X', # Erase Character | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | VPA => 'd', # Vertical Position Absolute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | VPR => 'e', # Vertical Position Relative | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | HVP => 'f', # Horizontal Vertical Position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | SGR => 'm', # Select Graphic Rendition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | DSR => 'n', # Device Status Report (6 cursor position) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | SCP => 's', # Save Cursor Position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | RCP => 'u', # Restore Cursor Position | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # Non-standard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | CPR => 'R', # Cursor Position Report – VT100 to Host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | STBM => 'r', # Set Top and Bottom Margins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | SLRM => 's', # Set Left Right Margins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 5 | my %other_sequence = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | CSI => "\e[", # Control Sequence Introducer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | OSC => "\e]", # Operating System Command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | RIS => "\ec", # Reset to Initial State | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | DECSC => "\e7", # DEC Save Cursor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | DECRC => "\e8", # DEC Restore Cursor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | DECEC => "\e[?25h", # DEC Enable Cursor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | DECDC => "\e[?25l", # DEC Disable Cursor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | DECELRM => "\e[?69h", # DEC Enable Left Right Margin Mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | DECDLRM => "\e[?69l", # DEC Disable Left Right Margin Mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 215 | ▶ | sub csi_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csi_code: called CC=6 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 215 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 215 | ▶ | if (my $seq = $other_sequence{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return $seq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 215 | ▶ | my $c = $csi_terminator{$name} or die "$name: Unknown ANSI name.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 215 | ▶ | if ($name eq 'SGR' and @_ == 1 and $_[0] =~ /^0+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$name eq "SGR" and @_ == 1 and $_[0] =~ /^0+$/u
$name eq "SGR" and @_ == 1
MC/DC0%0/3
$name eq "SGR" and @_ == 1 and $_[0] =~ /^0+$/u
$name eq "SGR"
@_ == 1
$_[0] =~ /^0+$/u
Truth table75%3/4
A and B and C
A= $name eq "SGR"B= @_ == 1C= $_[0] =~ /^0+$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | @_ = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 215 | CSI . join(';', @_) . $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | sub csi_report { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csi_report: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my($name, $n, $report) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my $c = $csi_terminator{$name} or die "$name: Unknown ANSI name.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $format = quotemeta(CSI) . join(';', ('(\d+)') x $n) . $c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $report =~ /$format/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 221 | ▶ | sub ansi_code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ansi_code: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 221 | my $spec = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 221 | my @numbers = ansi_numbers $spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 209 | my @code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 209 | ▶ | while (@numbers) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 215 | my $item = shift @numbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 215 | ▶ | if (ref($item) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 15 | push @code, csi_code @$item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 200 | my @sgr = ($item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 200 | ▶ | while (@numbers and not ref $numbers[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@numbers and not ref $numbers[0]
MC/DC100%2/2
@numbers and not ref $numbers[0]
@numbers
not ref $numbers[0]
Truth table100%3/3
A and not(B)
A= @numbersB= not ref $numbers[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 391 | push @sgr, shift @numbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 200 | push @code, csi_code 'SGR', @sgr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 209 | join '', @code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 18 | ▶ | sub ansi_pair { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ansi_pair: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 18 | my $spec = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 18 | my $el = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 18 | ▶ | my $start = ansi_code $spec // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$spec // ""
MC/DC0%0/1
$spec // ""
$spec
Truth table50%1/2
A
A= $spec
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 18 | ▶ | my $end = $start eq '' ? '' : do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 16 | ▶ | if ($start =~ /(.*)(\e\[[0;]*K)(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 2 | $el = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | ▶ | if ($3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $1 . EL . RESET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | EL . RESET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 14 | ▶ | if ($NO_RESET_EL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | RESET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 14 | RESET . EL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 18 | ($start, $end, $el); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 46 | ▶ | sub ansi_color { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ansi_color: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 46 | cached_ansi_color(state $cache = {}, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | ▶ | sub ansi_color_24 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ansi_color_24: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | local $RGB24 = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | cached_ansi_color(state $cache = {}, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 48 | ▶ | sub cached_ansi_color { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cached_ansi_color: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 48 | my $cache = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 48 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 48 | ▶ | while (@_ >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 48 | my($spec, $text) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 48 | ▶ | for my $color (ref $spec eq 'ARRAY' ? @$spec : $spec) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 48 | $text = apply_color($cache, $color, $text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 48 | push @result, $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 48 | ▶ | croak "Wrong number of parameters." if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 48 | ▶ | wantarray ? @result : join('', @result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 5 | ▶ | sub IsEOL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
IsEOL: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 5 | <<"END"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0000\t0000 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 000A\t000D | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 2028\t2029 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | END | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 5 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 48 | ▶ | sub apply_color { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_color: called CC=10 SCAR=32.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 48 | (my($cache, $color), local($_)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 48 | ▶ | if (ref $color eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | return $color->($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ▶ | elsif (blessed $color and $color->can('call')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($color) and $color->can("call")
MC/DC0%0/2
builtin::blessed($color) and $color->can("call")
builtin::blessed($color)
$color->can("call")
Truth table33%1/3
A and B
A= builtin::blessed($color)B= $color->can("call")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | return $color->call; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | elsif ($NO_COLOR) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 18 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | elsif ($NO_CUMULATIVE) { # old behavior | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | my($s, $e, $el) = @{ $cache->{$color} //= [ ansi_pair($color) ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cache->{$color} //= [ansi_pair($color)]
MC/DC0%0/1
$cache->{$color} //= [ansi_pair($color)]
$cache->{$color}
Truth table0%0/2
A
A= $cache->{$color}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | state $reset = qr{ \e\[[0;]*m (?: \e\[[0;]*[Km] )* }x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | if ($el) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | s/(\A|(?<=\p{IsEOL})|$reset)\K(?<x>[^\e\p{IsEOL}]+|(?<!\n))/${s}$+{x}${e}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | s/(\A|(?<=\p{IsEOL})|$reset)\K(?<x>[^\e\p{IsEOL}]+)/${s}$+{x}${e}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 30 | ▶ | my($s, $e, $el) = @{ $cache->{$color} //= [ ansi_pair($color) ] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cache->{$color} //= [ansi_pair($color)]
MC/DC100%1/1
$cache->{$color} //= [ansi_pair($color)]
$cache->{$color}
Truth table100%2/2
A
A= $cache->{$color}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 30 | state $reset = qr{ \e\[[0;]*m (?: \e\[[0;]*[Km] )* }x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 30 | ▶ | if ($el) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | s/(?:\A|(?:\p{IsEOL}(?!\z)|$reset++))\K/${s}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | s/(\p{IsEOL}|(?<!\p{IsEOL})\z)/${e}${1}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 30 | s/(?:\A|\p{IsEOL}|$reset++)(?=.)\K/${s}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 30 | s/(?<!\e\[[Km])(\p{IsEOL}|(?<=\P{IsEOL})\z)/${e}${1}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 30 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||