| 1 | package App::cat::v; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | our $VERSION = "1.06"; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use 5.024; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | ▶ | use open IO => ':utf8', ':std'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 12 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 12 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 12 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | *Data::Dumper::qquote = sub { qq["${\(shift)}"] }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | $Data::Dumper::Useperl = 1; | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | ▶ | use open IO => 'utf8', ':std'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | ▶ | use charnames ':loose'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | ▶ | use List::Util qw(max pairmap); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | ▶ | use Hash::Util qw(lock_keys); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 12 | ▶ | use Getopt::EX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | ▶ | use Text::ANSI::Tabs qw(ansi_expand); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 12 | ▶ | use Term::ANSIColor::Concise qw(ansi_color); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 12 | my %control = ( | |||||||||||||||||||||||||||||||||||||||||
| 27 | nul => [ 'm', "\x00", { s => "\x{2400}", # ␀ SYMBOL FOR NULL | ||||||||||||||||||||||||||||||||||||||||||
| 28 | m => "\x{2205}", } ], # ∅ EMPTY SET | ||||||||||||||||||||||||||||||||||||||||||
| 29 | soh => [ 's', "\x01", { s => "\x{2401}", } ], # ␁ SYMBOL FOR START OF HEADING | ||||||||||||||||||||||||||||||||||||||||||
| 30 | stx => [ 's', "\x02", { s => "\x{2402}", } ], # ␂ SYMBOL FOR START OF TEXT | ||||||||||||||||||||||||||||||||||||||||||
| 31 | etx => [ 's', "\x03", { s => "\x{2403}", } ], # ␃ SYMBOL FOR END OF TEXT | ||||||||||||||||||||||||||||||||||||||||||
| 32 | eot => [ 's', "\x04", { s => "\x{2404}", } ], # ␄ SYMBOL FOR END OF TRANSMISSION | ||||||||||||||||||||||||||||||||||||||||||
| 33 | enq => [ 's', "\x05", { s => "\x{2405}", } ], # ␅ SYMBOL FOR ENQUIRY | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ack => [ 's', "\x06", { s => "\x{2406}", } ], # ␆ SYMBOL FOR ACKNOWLEDGE | ||||||||||||||||||||||||||||||||||||||||||
| 35 | bel => [ 's', "\x07", { s => "\x{2407}", # ␇ SYMBOL FOR BELL | ||||||||||||||||||||||||||||||||||||||||||
| 36 | m => "\x{237E}", } ], # ⍾ BELL SYMBOL | ||||||||||||||||||||||||||||||||||||||||||
| 37 | bs => [ 's', "\x08", { s => "\x{2408}", } ], # ␈ SYMBOL FOR BACKSPACE | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ht => [ 's', "\x09", { s => "\x{2409}", } ], # ␉ SYMBOL FOR HORIZONTAL TABULATION | ||||||||||||||||||||||||||||||||||||||||||
| 39 | nl => [ 'm', "\x0a", { s => "\x{240A}", # ␊ SYMBOL FOR LINE FEED | ||||||||||||||||||||||||||||||||||||||||||
| 40 | m => "\x{23CE}", } ], # ⏎ RETURN SYMBOL | ||||||||||||||||||||||||||||||||||||||||||
| 41 | vt => [ 's', "\x0b", { s => "\x{240B}", } ], # ␋ SYMBOL FOR VERTICAL TABULATION | ||||||||||||||||||||||||||||||||||||||||||
| 42 | np => [ 'm', "\x0c", { s => "\x{240C}", , # ␌ SYMBOL FOR FORM FEED | ||||||||||||||||||||||||||||||||||||||||||
| 43 | m => "\x{2398}", } ], # ⎘ NEXT PAGE | ||||||||||||||||||||||||||||||||||||||||||
| 44 | cr => [ 's', "\x0d", { s => "\x{240D}", } ], # ␍ SYMBOL FOR CARRIAGE RETURN | ||||||||||||||||||||||||||||||||||||||||||
| 45 | so => [ 's', "\x0e", { s => "\x{240E}", } ], # ␎ SYMBOL FOR SHIFT OUT | ||||||||||||||||||||||||||||||||||||||||||
| 46 | si => [ 's', "\x0f", { s => "\x{240F}", } ], # ␏ SYMBOL FOR SHIFT IN | ||||||||||||||||||||||||||||||||||||||||||
| 47 | dle => [ 's', "\x10", { s => "\x{2410}", } ], # ␐ SYMBOL FOR DATA LINK ESCAPE | ||||||||||||||||||||||||||||||||||||||||||
| 48 | dc1 => [ 's', "\x11", { s => "\x{2411}", } ], # ␑ SYMBOL FOR DEVICE CONTROL ONE | ||||||||||||||||||||||||||||||||||||||||||
| 49 | dc2 => [ 's', "\x12", { s => "\x{2412}", } ], # ␒ SYMBOL FOR DEVICE CONTROL TWO | ||||||||||||||||||||||||||||||||||||||||||
| 50 | dc3 => [ 's', "\x13", { s => "\x{2413}", } ], # ␓ SYMBOL FOR DEVICE CONTROL THREE | ||||||||||||||||||||||||||||||||||||||||||
| 51 | dc4 => [ 's', "\x14", { s => "\x{2414}", } ], # ␔ SYMBOL FOR DEVICE CONTROL FOUR | ||||||||||||||||||||||||||||||||||||||||||
| 52 | nak => [ 's', "\x15", { s => "\x{2415}", } ], # ␕ SYMBOL FOR NEGATIVE ACKNOWLEDGE | ||||||||||||||||||||||||||||||||||||||||||
| 53 | syn => [ 's', "\x16", { s => "\x{2416}", } ], # ␖ SYMBOL FOR SYNCHRONOUS IDLE | ||||||||||||||||||||||||||||||||||||||||||
| 54 | etb => [ 's', "\x17", { s => "\x{2417}", } ], # ␗ SYMBOL FOR END OF TRANSMISSION BLOCK | ||||||||||||||||||||||||||||||||||||||||||
| 55 | can => [ 's', "\x18", { s => "\x{2418}", } ], # ␘ SYMBOL FOR CANCEL | ||||||||||||||||||||||||||||||||||||||||||
| 56 | em => [ 's', "\x19", { s => "\x{2419}", } ], # ␙ SYMBOL FOR END OF MEDIUM | ||||||||||||||||||||||||||||||||||||||||||
| 57 | sub => [ 's', "\x1a", { s => "\x{241A}", } ], # ␚ SYMBOL FOR SUBSTITUTE | ||||||||||||||||||||||||||||||||||||||||||
| 58 | esc => [ '0', "\x1b", { s => "\x{241B}", # ␛ SYMBOL FOR ESCAPE | ||||||||||||||||||||||||||||||||||||||||||
| 59 | m => "\x{21B0}", } ], # ↰ UPWARDS ARROW WITH TIP LEFTWARDS | ||||||||||||||||||||||||||||||||||||||||||
| 60 | fs => [ 's', "\x1c", { s => "\x{241C}", } ], # ␜ SYMBOL FOR FILE SEPARATOR | ||||||||||||||||||||||||||||||||||||||||||
| 61 | gs => [ 's', "\x1d", { s => "\x{241D}", } ], # ␝ SYMBOL FOR GROUP SEPARATOR | ||||||||||||||||||||||||||||||||||||||||||
| 62 | rs => [ 's', "\x1e", { s => "\x{241E}", } ], # ␞ SYMBOL FOR RECORD SEPARATOR | ||||||||||||||||||||||||||||||||||||||||||
| 63 | us => [ 's', "\x1f", { s => "\x{241F}", } ], # ␟ SYMBOL FOR UNIT SEPARATOR | ||||||||||||||||||||||||||||||||||||||||||
| 64 | sp => [ 'm', "\x20", { s => "\x{2420}", # ␠ SYMBOL FOR SPACE | ||||||||||||||||||||||||||||||||||||||||||
| 65 | m => "\x{00B7}", } ], # · MIDDLE DOT | ||||||||||||||||||||||||||||||||||||||||||
| 66 | del => [ 'm', "\x7f", { s => "\x{2421}", , # ␡ SYMBOL FOR DELETE | ||||||||||||||||||||||||||||||||||||||||||
| 67 | m => "\x{232B}", } ], # ⌫ ERASE TO THE LEFT | ||||||||||||||||||||||||||||||||||||||||||
| 68 | nbsp => [ 's', "\xa0", { s => "\x{237D}", } ], # ⍽ SHOULDERED OPEN BOX | ||||||||||||||||||||||||||||||||||||||||||
| 69 | fwsp => [ 's', "\x{3000}", { s => "\x{303C}", } ], # 〼 MASU MARK | ||||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | package # | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 12 | Visibility { | |||||||||||||||||||||||||||||||||||||||||
| 74 | 12 | ▶ | use v5.24; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 434 | ▶ | sub default { $_[0]->[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1043 | ▶ | sub code { $_[0]->[1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 612 | ▶ | sub cmap { $_[0]->[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmap: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 178 | ▶ | sub visible { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
visible: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 178 | my($c, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 178 | ▶ | $c->cmap->{$type} // $c->cmap->{$c->default || 's'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$c->cmap->{$type} // $c->cmap->{$c->default or "s"}
$c->default || 's'
MC/DC0%0/2
$c->cmap->{$type} // $c->cmap->{$c->default or "s"}
$c->cmap->{$type}
$c->cmap->{$c->default or "s"}
MC/DC0%0/1
$c->default || 's'
$c->default
Truth table66%2/3
A // B
A= $c->cmap->{$type}B= $c->cmap->{$c->default or "s"}
Truth table50%1/2
A
A= $c->default
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 12 | bless $_, 'Visibility' for values %control; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | # setup 'e' map | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 12 | for my $v (values %control) { | |||||||||||||||||||||||||||||||||||||||||
| 88 | 432 | my %map = ( | |||||||||||||||||||||||||||||||||||||||||
| 89 | "\t" => '\t', | ||||||||||||||||||||||||||||||||||||||||||
| 90 | "\n" => '\n', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | "\r" => '\r', | ||||||||||||||||||||||||||||||||||||||||||
| 92 | "\f" => '\f', | ||||||||||||||||||||||||||||||||||||||||||
| 93 | "\b" => '\b', | ||||||||||||||||||||||||||||||||||||||||||
| 94 | "\a" => '\a', | ||||||||||||||||||||||||||||||||||||||||||
| 95 | "\e" => '\e', | ||||||||||||||||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 432 | my $code = $v->code; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 432 | ▶ | $v->cmap->{e} = $map{$code} // sprintf(ord($code) > 0xff ? "\\x{%x}" : "\\x%02x", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$map{$code} // sprintf(ord $code > 255 ? "\x{%x}" : "\x%02x", ord $code)
MC/DC100%1/1
$map{$code} // sprintf(ord $code > 255 ? "\x{%x}" : "\x%02x", ord $code)
$map{$code}
Truth table100%2/2
A
A= $map{$code}
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | ord($code)); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 432 | ▶ | my %code = pairmap { $a => $b->code } %control; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 12 | our $DEFAULT_TABSTYLE = 'needle'; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 12 | ▶ | if ($DEFAULT_TABSTYLE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 12 | Text::ANSI::Tabs->configure(tabstyle => $DEFAULT_TABSTYLE); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub list_tabstyle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_tabstyle: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my %style = %Text::ANSI::Fold::TABSTYLE; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $max = max map length, keys %style; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | for my $name (sort keys %style) { | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my($head, $space) = $style{$name}->@*; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $tab = $head . $space x 7; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | printf "%*s %s\n", $max, $name, $tab x 3; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 12 | ▶ | use Getopt::EX::Hashed; { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 12 | Getopt::EX::Hashed->configure(DEFAULT => [ is => 'rw' ]); | |||||||||||||||||||||||||||||||||||||||||
| 121 | 12 | has visible => ' c =s@ ' ; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 12 | has reset => ' n ' ; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 12 | has color => ' C =s ' ; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 12 | has expand => ' t :1 ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 12 | has no_expand => ' T ! ' ; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 12 | has repeat => ' r =s ' , default => 'nl,np' ; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 12 | has original => ' o + ' , default => 0 ; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 12 | has debug => ' d ' ; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 12 | has tabstop => ' x =i ' , default => 8, min => 1 ; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 12 | has tabhead => ' =s ' ; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 12 | has tabspace => ' =s ' ; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 12 | has tabstyle => ' ts :s ' , default => $DEFAULT_TABSTYLE ; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 12 | has help => ' h ' ; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 12 | has version => ' v ' ; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 12 | has escape_backslash => 'E!' ; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | # -n | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 7 | ▶ | has '+reset' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 7 | for my $name (keys $_->flags->%*) { | |||||||||||||||||||||||||||||||||||||||||
| 140 | 252 | $_->flags->{$name} = '0'; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 | $_->repeat = ''; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | $_->expand = 0; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | has '+expand' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $_->expand = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | if ($_[1] > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | $_->tabstop = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | Text::ANSI::Tabs->configure(tabstop => $_->tabstop); | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # -T negate -t | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | has '+no_expand' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $_->expand = ! $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | has '+repeat' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my($name, $c) = ("$_[0]", $_[1]); | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($c =~ s/^\++//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $_->$name .= ",$c"; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $_->$name = $c; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # individual char option | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | ▶ | has [ keys %control ] => ':s', action => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.5
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | my($name, $c) = ("$_[0]", $_[1]); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | ▶ | if ($c =~ s/^\+//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | $_->repeat .= ",$name"; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | ▶ | $c = '1' if $c eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | ▶ | if (length($c) > 1 and my $u = charnames::string_vianame($c)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $c > 1 and my $u = charnames::string_vianame($c)
MC/DC0%0/2
length $c > 1 and my $u = charnames::string_vianame($c)
length $c > 1
my $u = charnames::string_vianame($c)
Truth table33%1/3
A and B
A= length $c > 1B= my $u = charnames::string_vianame($c)
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $c = $u; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | $_->flags->{$name} = $c; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | ### --tabstop, --tabstyle | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | has [ qw(+tabstop +tabstyle) ] => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my($name, $val) = map "$_", @_; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($val eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | list_tabstyle(); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | Text::ANSI::Tabs->configure($name => $val); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | ### --tabhead, --tabspace | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | has [ qw(+tabhead +tabspace) ] => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my($name, $c) = map "$_", @_; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | $c = charnames::string_vianame($c) || die "$c: invalid name\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
charnames::string_vianame($c) || die("${c}: invalid name\n")
MC/DC0%0/1
charnames::string_vianame($c) || die("${c}: invalid name\n")
charnames::string_vianame($c)
Truth table0%0/2
A
A= charnames::string_vianame($c)
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | if length($c) > 1; | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | Text::ANSI::Tabs->configure($name => $c); | |||||||||||||||||||||||||||||||||||||||||
| 197 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | has '+visible' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | my $param = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | if ($param !~ /^\w+=/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $param = "all=$param"; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | $param =~ s{ \ball\b }{ join('=', keys $_->flags->%*) }xe; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | push @{$_->visible}, $param; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | has '+help' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | pod2usage | |||||||||||||||||||||||||||||||||||||||||
| 210 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||
| 211 | -sections => [ qw(SYNOPSIS VERSION) ]; | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | has '+version' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | say "Version: $VERSION"; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 12 | }; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | # internal use | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 432 | ▶ | has flags => default => { pairmap { $a => $b->default } %control }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 12 | has convert => default => {}; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 11 | ▶ | has colorize => default => sub { sub { $_[0] } } ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 12 | ▶ | } no Getopt::EX::Hashed; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 11 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 11 | my $app = shift; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 11 | local @ARGV = splice @_; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 11 | $app->options->setup->doit; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 11 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 11 | ▶ | sub options { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
options: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 11 | my $app = shift; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 11 | for (@ARGV) { | |||||||||||||||||||||||||||||||||||||||||
| 237 | 27 | ▶ | $_ = decode 'utf8', $_ unless utf8::is_utf8($_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 12 | ▶ | use Getopt::EX::Long qw(:DEFAULT ExConfigure Configure); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 11 | ExConfigure BASECLASS => [ __PACKAGE__, 'Getopt::EX' ]; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 11 | Configure qw(bundling); | |||||||||||||||||||||||||||||||||||||||||
| 242 | 11 | ▶ | $app->getopt || pod2usage(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 11 | Getopt::EX::LabeledParam | |||||||||||||||||||||||||||||||||||||||||
| 245 | ->new(HASH => $app->flags, NEWLABEL => 0, DEFAULT => 1) | ||||||||||||||||||||||||||||||||||||||||||
| 246 | ->load_params($app->visible->@*); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 11 | ▶ | if (my $color = $app->color) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $app->colorize = sub { ansi_color($color, @_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 11 | return $app; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 11 | ▶ | sub setup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 11 | my $app = shift; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 11 | my $convert = $app->convert; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 11 | my $flags = $app->flags; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 11 | for my $name (keys $flags->%*) { | |||||||||||||||||||||||||||||||||||||||||
| 260 | 396 | ▶ | my $flag = $flags->{$name} or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 179 | my $char = $control{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 179 | my $code = $char->code; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 179 | ▶ | if ($flag eq 'c') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | ▶ | if ($code =~ /[\x00-\x1f]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | $convert->{$code} = '^' . pack('c',ord($code)+64); | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | elsif ($flag =~ /^([a-z\d])$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 178 | $convert->{$code} = $char->visible($flag); | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $convert->{$char->code} = $flag; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 11 | ▶ | $convert->{"\\"} = "\\\\" if $app->escape_backslash; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 11 | return $app; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 11 | ▶ | sub doit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
doit: called CC=8 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 11 | my $app = shift; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 11 | my $convert = $app->convert; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 11 | my $replace = join '', sort keys $convert->%*; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 11 | my $repeat_re = do { | |||||||||||||||||||||||||||||||||||||||||
| 284 | 11 | ▶ | if (my @c = map { $code{$_} } $app->repeat =~ /\w+/g) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 7 | local $" = ""; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 7 | qr/[\Q@c\E]/; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | qr/(*F)/; | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 11 | ▶ | while (<>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 78 | my $orig = $_; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 78 | ▶ | $_ = ansi_expand($_) if $app->expand; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 78 | ▶ | if ($replace ne '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 68 | s{ | |||||||||||||||||||||||||||||||||||||||||
| 296 | (?= (?<r> ${repeat_re}?) ) | ||||||||||||||||||||||||||||||||||||||||||
| 297 | (?<c> [\Q$replace\E] | ||||||||||||||||||||||||||||||||||||||||||
| 298 | | (*F) # without this line, the regex does not work | ||||||||||||||||||||||||||||||||||||||||||
| 299 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 300 | }{ | ||||||||||||||||||||||||||||||||||||||||||
| 301 | $app->colorize->($convert->{$+{c}}) . $+{r} | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 1505 | }xeg; | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 78 | ▶ | if ($app->original > 1 or ($app->original and $_ ne $orig)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$app->original > 1 or $app->original and $_ ne $orig
$app->original and $_ ne $orig
MC/DC0%0/3
$app->original > 1 or $app->original and $_ ne $orig
$app->original > 1
$app->original
$_ ne $orig
Truth table25%1/4
A or B and C
A= $app->original > 1B= $app->originalC= $_ ne $orig
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | print $orig; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 78 | print; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | __END__ | ||||||||||||||||||||||||||||||||||||||||||