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