| 1 | package App::ansicolumn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 141 | our $VERSION = "1.65"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 141 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 141 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 141 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 141 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 141 | ▶ | use open IO => 'utf8', ':std'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 141 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 141 | ▶ | use Getopt::EX::Long qw(:DEFAULT Configure ExConfigure); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 141 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 141 | ▶ | use List::Util qw(max sum min any); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 141 | ▶ | use Clone qw(clone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 141 | ▶ | use Text::ANSI::Fold qw(ansi_fold); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 141 | ▶ | use Text::ANSI::Fold::Util qw(ansi_width); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 141 | ▶ | use Text::ANSI::Printf qw(ansi_printf ansi_sprintf); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 141 | ▶ | use App::ansicolumn::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 141 | ▶ | use App::ansicolumn::Document; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 141 | ▶ | use App::ansicolumn::Table; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 141 | ▶ | use App::ansicolumn::Border; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 141 | ▶ | use Getopt::EX::RPN qw(rpn_calc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 141 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 141 | our @EXPORT_OK = qw(ansicolumn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 139 | ▶ | sub ansicolumn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ansicolumn: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 139 | __PACKAGE__->new->perform(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 141 | my %DEFAULT_COLORMAP = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | BORDER => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | BORDER_LABEL => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | TEXT => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 141 | ▶ | use Getopt::EX::Hashed 1.0701; { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 141 | Getopt::EX::Hashed->configure( DEFAULT => [ is => 'rw' ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 141 | has debug => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 141 | has help => ' h ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 141 | has version => ' v ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 141 | has width => ' =s w c ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 141 | has fillrows => ' x ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 141 | has table => ' t ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 141 | has table_columns_limit => ' =i l ' , default => -1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 141 | has table_align => ' ! A ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 141 | has table_tabs => ' + T ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 141 | has table_right => ' =s R ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 141 | has table_center => ' =s ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 141 | has item_format => ' =s ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 141 | has table_wrap_mark => ' =s ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 141 | has table_cell_mark => ' =s ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 141 | has table_head => ' =i ' , default => 0 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 141 | has table_remove => ' =s K ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 141 | has table_squeeze => ' ! ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 141 | has padding => ' ! ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 141 | has separator => ' =s s ' , default => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 141 | has regex_sep => ' r ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 141 | has output_separator => ' =s o ' , default => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 141 | has document => ' ! D ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 141 | has parallel => ' ! V ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 141 | has filename => ' ! H ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 141 | has filename_format => ' =s ' , default => ': %s'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 141 | has ignore_empty => ' ! I ' , default => 0 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 141 | has pages => ' ! ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 141 | has up => ' :s U ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 141 | has page => ' :i P ' , min => 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | has no_page => ' ' , action => sub { $_->page = undef } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 141 | has pane => ' =s C ' , default => 0 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 141 | has cell => ' =s X ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 141 | has pane_width => ' =s S pw ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 141 | has widen => ' ! W ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 141 | has paragraph => ' ! p ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 141 | has height => ' =s ' , default => 0 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 141 | has column_unit => ' =i cu ' , min => 1, default => 8 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 141 | has margin => ' =i ' , min => 0, default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 141 | has tabstop => ' =i ' , min => 1, default => 8 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 141 | has tabhead => ' =s ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 141 | has tabspace => ' =s ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 141 | has tabstyle => ' :s ts ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 141 | has ignore_space => ' ! is ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 141 | has linestyle => ' =s ls ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 141 | has boundary => ' =s ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 141 | has linebreak => ' =s lb ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 141 | has runin => ' =i ' , min => 0, default => 2 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 141 | has runout => ' =i ' , min => 0, default => 2 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 141 | has runlen => ' =i ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 141 | has pagebreak => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | has border => ' :s ' ; has B => '' , action => sub { $_->border = '' } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | ▶ | has no_border => ' ' , action => sub { $_->border = 'none' } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 141 | has border_style => ' =s bs ' , default => 'box' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 141 | has label => ' =s% ' , default => {} ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 141 | has page_label => ' =s% ' , default => {} ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 141 | has white_space => ' ! ' , default => 2 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 141 | has isolation => ' ! ' , default => 2 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | has fillup => ' :s ' ; has F => '' , action => sub { $_->fillup = '' } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 141 | has fillup_str => ' :s ' , default => '' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 141 | has ambiguous => ' =s ' , default => 'narrow' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 141 | has discard_el => ' ! ' , default => 1 ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 141 | has padchar => ' =s ' , default => ' ' ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 141 | has colormap => ' =s@ cm ' , default => [] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 141 | has factotum => ' =s@ ' , default => [] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 141 | has highlight => ' :s hi ' , action => \&_highlight ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | ▶ | has no_highlight => ' ' , action => sub { $_->highlight = undef } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ▶ | has no_hi => ' ' , action => sub { $_->highlight = undef } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 141 | has '+boundary' => any => [ qw(none word space) ] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 141 | has '+linestyle' => any => [ qw(none wordwrap wrap truncate) ] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 141 | has '+fillup' => any => [ qw(pane page none), '' ] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 141 | has '+ambiguous' => any => [ qw(wide narrow) ] ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # --2up .. --9up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $nup = sub { $_[0] =~ /^(\d+)/ and $_->up = $1 } ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 141 | for my $n (2..9) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1128 | has "${n}up" => '', action => $nup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # for run-time use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 141 | has span => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 141 | has panes => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 141 | has border_height => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 141 | has current_page => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 141 | has _bl => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 141 | has _pbl => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 141 | Getopt::EX::Hashed->configure( DEFAULT => [] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | has '+help' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | pod2usage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | -verbose => 99, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | -sections => [ qw(SYNOPSIS VERSION) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | has '+version' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | say "Version: $VERSION"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ### RPN calc for --height, --width, --pane, --up, --pane-width | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 157 | ▶ | has [ qw(+height +width +pane +up +pane_width) ] => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 157 | my $obj = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 157 | my($name, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 157 | ▶ | $obj->$name = $val !~ /\D/ ? $val : do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $init = $name =~ /height/ ? $obj->term_height : $obj->term_width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | rpn_calc($init, $val) // die "$val: invalid $name.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
rpn_calc($init, $val) // die("${val}: invalid $name.\n")
MC/DC0%0/1
rpn_calc($init, $val) // die("${val}: invalid $name.\n")
rpn_calc($init, $val)
Truth table0%0/2
A
A= rpn_calc($init, $val)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ### --ambiguous=wide | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | has '+ambiguous' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if ($_[1] eq 'wide') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $Text::VisualWidth::PP::EastAsian = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | Text::ANSI::Fold->configure(ambiguous => 'wide'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ### --runlen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | has '+runlen' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $_->runin = $_->runout = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ### --tabstop, --tabstyle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | has [ qw(+tabstop +tabstyle) ] => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my($name, $val) = map "$_", @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ($val eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | list_tabstyle(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | Text::ANSI::Fold->configure($name => $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | ### --tabhead, --tabspace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 141 | ▶ | use charnames ':loose'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | has [ qw(+tabhead +tabspace) ] => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my($name, $c) = map "$_", @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | if length($c) > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | Text::ANSI::Fold->configure($name => $c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ### -A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | ▶ | has '+table_align' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | ▶ | if ($_->table_align = $_[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | $_->table = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | ### -T, -TT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | has '+table_tabs' => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # incremental behavior | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | $_->table_tabs += $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | if ($_->table_tabs == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # enable -t and -A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | $_->table = $_->table_align = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } elsif ($_->table_tabs == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # set -rs '\t+' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $_->regex_sep = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $_->separator = '\\t+'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 141 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 141 | has TERM_SIZE => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 141 | has COLORHASH => default => { %DEFAULT_COLORMAP }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 141 | has COLORLIST => default => []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 141 | has COLOR => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 141 | has BORDER => ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 141 | ▶ | } no Getopt::EX::Hashed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub list_tabstyle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_tabstyle: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my %style = %Text::ANSI::Fold::TABSTYLE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $max = max map length, keys %style; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | for my $name (sort keys %style) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my($head, $space) = @{$style{$name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | printf "%*s %s%s\n", $max, $name, $head, $space x 7; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # --highlight[=NAME]: the value is optional, so Getopt::Long takes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # the word after the option for it. When the word is a file and not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # the name of a highlighter, it is given back to be read as a file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 15 | ▶ | sub _highlight { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_highlight: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 15 | my $obj = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 15 | my($name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 15 | ▶ | if ($value ne '' and not _highlighter($value) and -e $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$value ne "" and not _highlighter($value) and -e $value
$value ne "" and not _highlighter($value)
MC/DC100%3/3
$value ne "" and not _highlighter($value) and -e $value
$value ne ""
not _highlighter($value)
-e $value
Truth table100%4/4
A and not(B) and C
A= $value ne ""B= not _highlighter($value)C= -e $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3 | unshift @ARGV, $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3 | $value = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 15 | $obj->highlight = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 10 | ▶ | sub _highlighter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_highlighter: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 10 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | $name =~ /\A\w+\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 10 | ▶ | and grep { !ref and -f "$_/IO/Factotum/Highlight/$name.pm" } @INC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
!ref($_) && -f "$_/IO/Factotum/Highlight/$name.pm"
MC/DC50%1/2
!ref($_) && -f "$_/IO/Factotum/Highlight/$name.pm"
!ref($_)
-f "$_/IO/Factotum/Highlight/$name.pm"
Truth table66%2/3
not(A) && B
A= !ref($_)B= -f "$_/IO/Factotum/Highlight/$name.pm"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 139 | ▶ | sub perform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
perform: called CC=12 SCAR=25.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 139 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 139 | local @ARGV = decode_argv(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 139 | ExConfigure BASECLASS => [ __PACKAGE__, "Getopt::EX" ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 139 | Configure qw(bundling no_auto_abbrev no_ignore_case); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 139 | ▶ | $obj->getopt || pod2usage(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 139 | $obj->setup_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # --factotum: converters of IO::Factotum, for read_files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # --highlight[=NAME] is that of IO::Factotum::Highlight::NAME, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # skylighting by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 139 | my @names = map { split /,/ } @{$obj->factotum}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 139 | ▶ | if (defined(my $name = $obj->highlight)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 12 | ▶ | push @names, 'Highlight::' . ($name eq '' ? 'skylighting' : $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 139 | ▶ | if (@names) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 16 | ▶ | eval { require IO::Factotum; 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | or die "--factotum requires IO::Factotum.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 16 | IO::Factotum::load(@names); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 137 | ▶ | warn Dumper $obj if $obj->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 137 | ▶ | my @files = $obj->read_files(@ARGV ? @ARGV : '-') or return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 136 | ▶ | if ($obj->ignore_empty) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | @files = grep { not $_->is_empty } @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 136 | ▶ | if ($obj->table) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 63 | my @lines = map { $_->lines } @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 63 | $obj->table_out(@lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | elsif ($obj->parallel) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 16 | $obj->parallel_out(@files); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 57 | $obj->nup_out(@files); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 136 | return 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 139 | ▶ | sub setup_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setup_options: called CC=30 SCAR=38.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 139 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ## --parallel or @ARGV > 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 139 | ▶ | if ($obj->parallel //= @ARGV > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$obj->parallel //= @ARGV > 1
MC/DC100%1/1
$obj->parallel //= @ARGV > 1
$obj->parallel
Truth table100%2/2
A
A= $obj->parallel
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 16 | ▶ | $obj->linestyle ||= 'wrap'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->linestyle ||= "wrap"
MC/DC0%0/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table50%1/2
A
A= $obj->linestyle
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 16 | ▶ | $obj->widen //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->widen //= 1
MC/DC0%0/1
$obj->widen //= 1
$obj->widen
Truth table50%1/2
A
A= $obj->widen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 16 | ▶ | $obj->border //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$obj->border //= ""
MC/DC100%1/1
$obj->border //= ""
$obj->border
Truth table100%2/2
A
A= $obj->border
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ## --border takes optional border-style value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 139 | ▶ | if (defined(my $border = $obj->border)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 25 | ▶ | if ($border ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 20 | $obj->border_style = $border; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 25 | $obj->border = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 25 | ▶ | $obj->fillup //= 'pane'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$obj->fillup //= "pane"
MC/DC100%1/1
$obj->fillup //= "pane"
$obj->fillup
Truth table100%2/2
A
A= $obj->fillup
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | ## --linestyle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 139 | ▶ | if ($obj->linestyle eq 'wordwrap') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $obj->linestyle = 'wrap'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $obj->boundary = 'word'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | ## -P | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 139 | ▶ | if (defined $obj->page) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 15 | ▶ | $obj->widen = 1 if $obj->pane and not $obj->pane_width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$obj->pane and not $obj->pane_width
MC/DC50%1/2
$obj->pane and not $obj->pane_width
$obj->pane
not $obj->pane_width
Truth table66%2/3
A and not(B)
A= $obj->paneB= not $obj->pane_width
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 15 | ▶ | $obj->height ||= $obj->page || $obj->term_height - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$obj->height ||= $obj->page || $obj->term_height - 1
$obj->page || $obj->term_height - 1
MC/DC0%0/3
$obj->height ||= $obj->page || $obj->term_height - 1
$obj->height
$obj->page
$obj->term_height - 1
Truth table0%0/4
A ||= B || C
A= $obj->heightB= $obj->pageC= $obj->term_height - 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 15 | ▶ | $obj->linestyle ||= 'wrap'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->linestyle ||= "wrap"
MC/DC0%0/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table50%1/2
A
A= $obj->linestyle
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 15 | ▶ | $obj->border //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$obj->border //= 1
MC/DC100%1/1
$obj->border //= 1
$obj->border
Truth table100%2/2
A
A= $obj->border
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 15 | ▶ | $obj->fillup //= 'pane'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$obj->fillup //= "pane"
MC/DC100%1/1
$obj->fillup //= "pane"
$obj->fillup
Truth table100%2/2
A
A= $obj->fillup
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | ## -U | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 139 | ▶ | if ($obj->up) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $obj->pane = $obj->up; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $obj->widen = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | $obj->linestyle ||= 'wrap'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$obj->linestyle ||= "wrap"
MC/DC0%0/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table0%0/2
A
A= $obj->linestyle
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | $obj->border //= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$obj->border //= 1
MC/DC0%0/1
$obj->border //= 1
$obj->border
Truth table0%0/2
A
A= $obj->border
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | $obj->fillup //= 'pane'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$obj->fillup //= "pane"
MC/DC0%0/1
$obj->fillup //= "pane"
$obj->fillup
Truth table0%0/2
A
A= $obj->fillup
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | ## -D | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 139 | ▶ | if ($obj->document) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 20 | $obj->widen = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 20 | ▶ | $obj->linebreak ||= 'all'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->linebreak ||= "all"
MC/DC0%0/1
$obj->linebreak ||= "all"
$obj->linebreak
Truth table50%1/2
A
A= $obj->linebreak
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 20 | ▶ | $obj->linestyle ||= 'wrap'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$obj->linestyle ||= "wrap"
MC/DC100%1/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table100%2/2
A
A= $obj->linestyle
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 20 | ▶ | $obj->boundary ||= 'word'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->boundary ||= "word"
MC/DC0%0/1
$obj->boundary ||= "word"
$obj->boundary
Truth table50%1/2
A
A= $obj->boundary
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 20 | ▶ | $obj->white_space = 0 if $obj->white_space > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 20 | ▶ | $obj->isolation = 0 if $obj->isolation > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ## --colormap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 141 | ▶ | use Getopt::EX::Colormap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | my $cm = Getopt::EX::Colormap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | ->new(HASH => $obj->{COLORHASH}, LIST => $obj->{COLORLIST}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 139 | ->load_params(@{$obj->colormap}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 139 | ▶ | $obj->{COLOR} = sub { $cm->color(@_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | ## --border | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 139 | ▶ | if ($obj->border) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 31 | my $style = $obj->border_style; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 31 | ▶ | ($obj->{BORDER} = App::ansicolumn::Border->new) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
($obj->{"BORDER"} = "App::ansicolumn::Border"->new)->style($style) // die("${style}: Unknown style.\n")
MC/DC0%0/1
($obj->{"BORDER"} = "App::ansicolumn::Border"->new)->style($style) // die("${style}: Unknown style.\n")
($obj->{"BORDER"} = "App::ansicolumn::Border"->new)->style($style)
Truth table50%1/2
A
A= ($obj->{"BORDER"} = "App::ansicolumn::Border"->new)->style($style)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | ->style($style) // die "$style: Unknown style.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 139 | $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1569 | ▶ | sub color { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1569 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 1569 | $obj->{COLOR}->(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 16 | ▶ | sub parallel_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parallel_out: called CC=14 SCAR=28.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 16 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 16 | my @files = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 16 | my $max_line_length = max map { $_->width } @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 16 | ▶ | $obj->pane ||= @files; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$obj->pane ||= @files
MC/DC0%0/2
$obj->pane ||= @files
$obj->pane
@files
Truth table66%2/3
A ||= B
A= $obj->paneB= @files
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 16 | $obj->set_horizontal($max_line_length); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # calculate span and set for each file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 16 | ▶ | if (my $cell = $obj->cell) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | my @spans = split /,+/, $cell; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | for my $i (keys @files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | ▶ | my $span = $spans[$i] // $spans[-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$spans[$i] // $spans[-1]
MC/DC0%0/2
$spans[$i] // $spans[-1]
$spans[$i]
$spans[-1]
Truth table33%1/3
A // B
A= $spans[$i]B= $spans[-1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 2 | ▶ | if ($span =~ /^[-+]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $span += $obj->{span}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | $span < 0 and die "Invalid number: $cell\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | elsif ($span =~ s/^(<=|[<=])//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $length = $files[$i]->width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $span = $span ? min($length, $span) : $length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | elsif ($span !~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | die "Invalid number: $cell\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 2 | $files[$i]->span($span); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 16 | $obj->set_contents($_) for @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 16 | my $column_out = $obj->_column_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 16 | ▶ | for ($obj->current_page = 0; @files; $obj->current_page++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 16 | my @rows = splice @files, 0, $obj->pane; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 16 | my @data = map { [ $_->lines ] } @rows; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 16 | my $max_length = max map { int @$_ } @data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 16 | ▶ | my @span = map { $_->span // $obj->span } @rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_->span // $obj->span
MC/DC0%0/2
$_->span // $obj->span
$_->span
$obj->span
Truth table66%2/3
A // B
A= $_->spanB= $obj->span
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 16 | ▶ | if ($obj->filename) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | my $w = $obj->span + $obj->border_width('center'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | my $format = join '', ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | (map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 2 | my $w = $_ + $obj->border_width('center'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 2 | "%-${w}.${w}s"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } @span[0..$#span-1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | "%s\n"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | ansi_printf $format, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 2 | ansi_sprintf $obj->filename_format, $_->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } @rows; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | $column_out->({ span => \@span, names => [ map $_->name, @rows ] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 16 | push @$_, (($obj->fillup_str) x ($max_length - @$_)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 33 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } @data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 16 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 57 | ▶ | sub nup_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nup_out: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 57 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 57 | my @files = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 57 | my $max_length = max map { $_->width } @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 57 | $obj->set_horizontal($max_length); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 57 | for my $file (@files) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 58 | ▶ | next if $file->is_empty; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 55 | my $page = clone($obj)->set_contents($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 55 | my @data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 55 | $page->set_vertical([ $file->lines ]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ->set_layout(\@data, $file->parts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 55 | $page->page_out($file->name, @data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 57 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 137 | ▶ | sub read_files { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_files: called CC=11 SCAR=24.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 137 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # The content is divided at formfeeds where a formfeed is a break. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # It is not with --no-pagebreak, and in the table and the parallel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # view, where the panes are not filled: the formfeeds are left in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # the text there. --pages divides it in any case, and makes a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # file of every part. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 137 | ▶ | my $divide = $obj->pages || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%9/9
$obj->pages || $obj->pagebreak && !$obj->parallel && !$obj->table
$obj->pagebreak and not $obj->parallel and not $obj->table
$obj->pagebreak and not $obj->parallel
MC/DC100%4/4
$obj->pages || $obj->pagebreak && !$obj->parallel && !$obj->table
$obj->pages
$obj->pagebreak
not $obj->parallel
not $obj->table
Truth table100%5/5
A || B and not(C) and not(D)
A= $obj->pagesB= $obj->pagebreakC= not $obj->parallelD= not $obj->table
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ($obj->pagebreak && !$obj->parallel && !$obj->table); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 137 | my @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # When IO::Factotum is loaded (--factotum=NAME), the files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # are opened by it, and those which a converter takes are read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # through that converter. The names stay as they are. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 137 | my $factotum = IO::Factotum->can('open_input'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 137 | for my $file (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 144 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 144 | ▶ | if ($factotum) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 25 | ▶ | $fh = $factotum->($file) or die "$file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 24 | binmode $fh, ':utf8'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 119 | ▶ | open $fh, $file or die "$file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 143 | ▶ | my $content = do { local $/; <$fh> } // do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
do {
local $/;
readline $fh
} // do {
warn "${file}: $!\n" if $!;
next
}
MC/DC0%0/2
do {
local $/;
readline $fh
} // do {
warn "${file}: $!\n" if $!;
next
}
do {
local $/;
readline $fh
}
do {
warn "${file}: $!\n" if $!;
next
}
Truth table33%1/3
A // B
A= do {
local $/;
readline $fh
}B= do {
warn "${file}: $!\n" if $!;
next
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | warn "$file: $!\n" if $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 143 | my $doc = App::ansicolumn::Document->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | name => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | text => $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | formfeed => $divide, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 143 | ▶ | push @files, map { $obj->prepare($_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | $obj->pages ? $doc->pages : $doc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 136 | @files; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # Make the lines of a document ready to be laid out, and find the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # width of the longest. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 154 | ▶ | sub prepare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 154 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 154 | my $doc = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 154 | ▶ | $doc->filter(\&insert_space) if $obj->paragraph; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 154 | my @width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 154 | ▶ | if ($obj->table) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 63 | @width = map { length } $doc->lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 619 | ▶ | $doc->replace(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 619 | my($text, $width) = $obj->expand_tab($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 619 | push @width, $width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 619 | $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 91 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 154 | ▶ | $doc->width(max(@width) // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&max(@width) // 0
MC/DC100%1/1
&max(@width) // 0
&max(@width)
Truth table100%2/2
A
A= &max(@width)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 154 | $doc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # Expand the tabs in a line. Returns the line and its width. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 619 | ▶ | sub expand_tab { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_tab: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 619 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 619 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 619 | my($result, $width) = ('', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 619 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 621 | my($folded, $rest, $w) = ansi_fold $text, -1, expand => 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 621 | $result .= $folded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 621 | ▶ | $width = $w if $w > $width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # ansi_fold stops before formfeeds in the middle of the text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 621 | ▶ | $result .= $1 if $rest =~ s/^(\f+)//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # every turn must take something from the text; otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # this loop never ends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 621 | ▶ | $rest eq '' or $rest ne $text or die sprintf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$rest eq "" or $rest ne $text
MC/DC0%0/2
$rest eq "" or $rest ne $text
$rest eq ""
$rest ne $text
Truth table66%2/3
A or B
A= $rest eq ""B= $rest ne $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | "Text is not consumed, at %s (please report this).\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $rest =~ s/([^\x20-\x7e])/sprintf '\\x{%02x}', ord $1/ger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 621 | $text = $rest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } while ($text ne ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 619 | ($result, $width); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 73 | ▶ | sub set_horizontal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_horizontal: called CC=11 SCAR=24.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 73 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 73 | my $max_data_length = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 141 | ▶ | use integer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 73 | my $width = $obj->get_width - $obj->border_width(qw(left right)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 73 | ▶ | my $unit = $obj->column_unit // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->column_unit // 1
MC/DC0%0/1
$obj->column_unit // 1
$obj->column_unit
Truth table50%1/2
A
A= $obj->column_unit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 73 | my $span; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | my $panes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 73 | ▶ | my $claim = sum($max_data_length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$obj->border_width('center') || $obj->margin
MC/DC0%0/2
$obj->border_width('center') || $obj->margin
$obj->border_width('center')
$obj->margin
Truth table66%2/3
A || B
A= $obj->border_width('center')B= $obj->margin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | $obj->runin_margin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | $obj->border_width('center') || $obj->margin); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 73 | ▶ | if ($obj->widen and not $obj->pane_width) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$obj->widen and not $obj->pane_width
MC/DC50%1/2
$obj->widen and not $obj->pane_width
$obj->widen
not $obj->pane_width
Truth table66%2/3
A and not(B)
A= $obj->widenB= not $obj->pane_width
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 39 | ▶ | $panes = $obj->pane || $width / $claim || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$obj->pane || $width / $claim || 1
$obj->pane or $width / $claim
MC/DC50%1/2
$obj->pane || $width / $claim || 1
$obj->pane
$width / $claim
Truth table66%2/3
A or B
A= $obj->paneB= $width / $claim
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 39 | $span = ($width + $obj->border_width('center')) / $panes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 34 | ▶ | $span = $obj->pane_width || roundup($claim, $unit); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$obj->pane_width || &roundup($claim, $unit)
MC/DC0%0/2
$obj->pane_width || &roundup($claim, $unit)
$obj->pane_width
&roundup($claim, $unit)
Truth table33%1/3
A || B
A= $obj->pane_widthB= &roundup($claim, $unit)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 34 | ▶ | $panes = $obj->pane || $width / $span || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$obj->pane || $width / $span || 1
$obj->pane or $width / $span
MC/DC100%2/2
$obj->pane || $width / $span || 1
$obj->pane
$width / $span
Truth table100%3/3
A or B
A= $obj->paneB= $width / $span
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 73 | $span -= $obj->border_width('center'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 73 | ▶ | $span < 1 and die "Not enough space.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 73 | ($obj->span, $obj->panes) = ($span, $panes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 73 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 88 | ▶ | sub set_contents { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_contents: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 88 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 88 | my $fp = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 88 | ▶ | (my $cell_width = $obj->span) < 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | and die "Not enough space.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # Fold long lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 88 | ▶ | if ($obj->linestyle and $obj->linestyle ne 'none') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$obj->linestyle and $obj->linestyle ne "none"
MC/DC50%1/2
$obj->linestyle and $obj->linestyle ne "none"
$obj->linestyle
$obj->linestyle ne "none"
Truth table66%2/3
A and B
A= $obj->linestyleB= $obj->linestyle ne "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 61 | ▶ | my $w = $fp->span // $cell_width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$fp->span // $cell_width
MC/DC0%0/2
$fp->span // $cell_width
$fp->span
$cell_width
Truth table66%2/3
A // B
A= $fp->spanB= $cell_width
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 61 | ▶ | my $fold = $obj->foldsub($w) or die; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 61 | $fp->replace($fold); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 88 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 55 | ▶ | sub set_vertical { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_vertical: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 55 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 55 | my $dp = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 55 | $obj->border_height = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 110 | sum map { length > 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 55 | map { $obj->get_border($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | qw(top bottom); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 55 | ▶ | $obj->height ||= div(int @$dp, $obj->panes) + $obj->border_height; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$obj->height ||= div(int @$dp, $obj->panes) + $obj->border_height
MC/DC0%0/2
$obj->height ||= div(int @$dp, $obj->panes) + $obj->border_height
$obj->height
div(int @$dp, $obj->panes) + $obj->border_height
Truth table66%2/3
A ||= B
A= $obj->heightB= div(int @$dp, $obj->panes) + $obj->border_height
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 55 | ▶ | die "Not enough height.\n" if $obj->effective_height <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 55 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 55 | ▶ | sub page_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
page_out: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 55 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 55 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 55 | my $column_out = $obj->_column_out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 55 | ▶ | for ($obj->current_page = 0; @_; $obj->current_page++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 67 | my @columns = grep { @$_ } do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 67 | ▶ | if ($obj->fillrows) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 1 | xpose map { [ splice @_, 0, $obj->panes ] } 1 .. $obj->effective_height; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 66 | map { [ splice @_, 0, $obj->effective_height ] } 1 .. $obj->panes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 67 | $column_out->({ names => [($name) x scalar @columns] }, @columns); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 55 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 639 | ▶ | sub color_border { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color_border: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 639 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 639 | $obj->color('BORDER', $obj->get_border(@_)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 142 | ▶ | sub _parse_labels { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_labels: called CC=7 SCAR=37.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 142 | my $hash = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 142 | ▶ | return 0 unless %$hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my %result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | while (my($key, $s) = each %$hash) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | next unless defined $s and $s ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $s and $s ne ""
MC/DC0%0/2
defined $s and $s ne ""
defined $s
$s ne ""
Truth table0%0/3
A and B
A= defined $sB= $s ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my $offset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | if ($s =~ s/@(\d+)$//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $offset = $1 + 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $s =~ s/%n/%1\$d/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $s =~ s/%p/%2\$d/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $s =~ s/%f/%3\$s/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $s =~ s/%F/%4\$s/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $result{lc $key} = [ $offset, $s ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | %result ? \%result : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | # Overlay labels onto a border line string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # $fs/$fe: fill region start/end. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | # $ml/$mr: border margin accessible via @0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # $n/$p: pane number / page number for sprintf expansion. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | # $file: filename (path as given) - used as %3$s (basename) and %4$s (path as given). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | sub _overlay_labels { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_overlay_labels: not called CC=8 SCAR=38.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my($obj, $str, $fs, $fe, $ml, $mr, $n, $p, $file, $left, $center, $right) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 141 | ▶ | use File::Basename qw(basename); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 141 | ▶ | use Text::ANSI::Fold::Util qw(ansi_substr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | my $base = defined $file ? basename($file) : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | for my $item ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | [ $left, sub { $fs - $ml + ($_[0] // $ml) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$_[0] // $ml
MC/DC0%0/2
$_[0] // $ml
$_[0]
$ml
Truth table0%0/3
A // B
A= $_[0]B= $ml
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | [ $right, sub { $fe + $mr - ($_[0] // $mr) - $_[1] } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$_[0] // $mr
MC/DC0%0/2
$_[0] // $mr
$_[0]
$mr
Truth table0%0/3
A // B
A= $_[0]B= $mr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | [ $center, sub { $fs + int(($fe - $fs - $_[1]) / 2) } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my($spec, $pos_fn) = @$item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | next unless $spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | my $fmt = $spec->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | next unless defined $fmt && $fmt ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fmt and $fmt ne ""
MC/DC0%0/2
defined $fmt and $fmt ne ""
defined $fmt
$fmt ne ""
Truth table0%0/3
A and B
A= defined $fmtB= $fmt ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | my $text = $fmt =~ /%/ ? sprintf($fmt, $n, $p, $base, $file // '') : $fmt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$file // ""
MC/DC0%0/1
$file // ""
$file
Truth table0%0/2
A
A= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my $lw = ansi_width($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $label = $obj->color('BORDER_LABEL', $text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $str = ansi_substr($str, $pos_fn->($spec->[0], $lw), $lw, $label); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 71 | ▶ | sub _column_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_column_out: called CC=15 SCAR=35.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 71 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 71 | my %bd = map { $_ => $obj->get_border($_) } qw(top bottom); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 71 | ▶ | my $bl = $obj->{_bl} //= _parse_labels($obj->label); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$obj->{"_bl"} //= _parse_labels($obj->label)
MC/DC0%0/2
$obj->{"_bl"} //= _parse_labels($obj->label)
$obj->{"_bl"}
_parse_labels($obj->label)
Truth table33%1/3
A //= B
A= $obj->{"_bl"}B= _parse_labels($obj->label)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 71 | ▶ | my $pbl = $obj->{_pbl} //= _parse_labels($obj->page_label); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$obj->{"_pbl"} //= _parse_labels($obj->page_label)
MC/DC0%0/2
$obj->{"_pbl"} //= _parse_labels($obj->page_label)
$obj->{"_pbl"}
_parse_labels($obj->page_label)
Truth table33%1/3
A //= B
A= $obj->{"_pbl"}B= _parse_labels($obj->page_label)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # pre-build pane label closures per pane index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 71 | my(@pane_top, @pane_bottom, @page_top, @page_bottom); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 71 | my($bw_l, $bw_c, $bw_r); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 71 | ▶ | if ($bl || $pbl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$bl or $pbl
MC/DC0%0/2
$bl or $pbl
$bl
$pbl
Truth table33%1/3
A or B
A= $blB= $pbl
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $bw_l = ansi_width($obj->get_border('left', 0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $bw_c = ansi_width($obj->get_border('center', 0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $bw_r = ansi_width($obj->get_border('right', 0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $span = $obj->{span}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | for my $set ([ \@pane_top, \@page_top, qw(nw n ne) ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | [ \@pane_bottom, \@page_bottom, qw(sw s se) ]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my($pane_list, $page_list, @keys) = @$set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if ($bl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my @g = map { $bl->{$_} } @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if (grep { $_ } @g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $fp = $bw_l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | for my $i (0 .. $obj->panes - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my($fs, $fe) = ($fp, $fp + $span); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | push @$pane_list, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $obj->_overlay_labels($_[0], $fs, $fe, $bw_l, $bw_r, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | $_[1] + $i + 1, $_[2], $_[3], @g); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | $fp += $span + $bw_c; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | if ($pbl) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my @g = map { $pbl->{$_} } @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if (grep { $_ } @g) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | push @$page_list, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | my $w = ansi_width($_[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | $obj->_overlay_labels($_[0], 1, $w - 1, 1, 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | $_[1] + 1, $_[2], $_[3], @g); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 71 | ▶ | my $has_labels = @pane_top || @pane_bottom || @page_top || @page_bottom; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
@pane_top || @pane_bottom || @page_top || @page_bottom
@pane_top or @pane_bottom or @page_top
@pane_top or @pane_bottom
MC/DC0%0/4
@pane_top || @pane_bottom || @page_top || @page_bottom
@pane_top
@pane_bottom
@page_top
@page_bottom
Truth table20%1/5
A or B or C || D
A= @pane_topB= @pane_bottomC= @page_topD= @page_bottom
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # pre-build border strings for 3 positions (top=0, middle=1, bottom=2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 71 | my %border; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 71 | for my $pos (0, 1, 2) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 213 | $border{$pos} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | left => $obj->color_border('left', $pos), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | center => $obj->color_border('center', $pos), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | right => $obj->color_border('right', $pos), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 166 | ▶ | my $print_border = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=24.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 166 | my($side, $pos, $span, $npanes, $n0, $p, $names, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | $pane_labels, $page_labels) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 166 | ▶ | return unless $bd{$side}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 36 | my $bd = $border{$pos}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | my $line = join '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | $bd->{left}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | join($bd->{center}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 68 | map { $obj->color('BORDER', $bd{$side} x $_) } @$span), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 36 | $bd->{right}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 36 | ▶ | if (@$pane_labels) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | for (@{$pane_labels}[0 .. $npanes - 1]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | $line = $_->($line, $n0, $p, $names->[$i++] // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$$names[$i++] // ""
MC/DC0%0/1
$$names[$i++] // ""
$$names[$i++]
Truth table0%0/2
A
A= $$names[$i++]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 36 | ▶ | $line = $_->($line, $n0, $p, $names->[0] // '') for @$page_labels; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$names->[0] // ""
MC/DC0%0/1
$names->[0] // ""
$names->[0]
Truth table0%0/2
A
A= $names->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 36 | print $line, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 71 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 83 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=25.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 83 | ▶ | my $opt = ref $_[0] eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 83 | ▶ | my @span = $opt->{span} ? @{$opt->{span}} : (($obj->{span}) x @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 83 | ▶ | my $page = $obj->current_page // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$obj->current_page // 0
MC/DC0%0/1
$obj->current_page // 0
$obj->current_page
Truth table50%1/2
A
A= $obj->current_page
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 83 | my $npanes = scalar @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 83 | ▶ | my($n0, $p) = $has_labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$obj->panes // 1
MC/DC0%0/1
$obj->panes // 1
$obj->panes
Truth table0%0/2
A
A= $obj->panes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | ? ($page * ($obj->panes // 1), $page + 1) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 83 | ▶ | my $names = $opt->{names} // []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opt->{"names"} // []
MC/DC0%0/1
$opt->{"names"} // []
$opt->{"names"}
Truth table50%1/2
A
A= $opt->{"names"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 83 | $print_border->('top', 0, \@span, $npanes, $n0, $p, $names, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | \@pane_top, \@page_top); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # content rows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 83 | my $max = max map $#{$_}, @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 83 | for my $i (0 .. $max) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | my $pos = !$bd{top} && $i == 0 ? 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 400 | ▶ | : !$bd{bottom} && $i == $max ? 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
not $bd{"top"} and $i == 0
not $bd{"bottom"} and $i == $max
MC/DC100%2/2
not $bd{"top"} and $i == 0
not $bd{"top"}
$i == 0
MC/DC100%2/2
not $bd{"bottom"} and $i == $max
not $bd{"bottom"}
$i == $max
Truth table100%3/3
not(A) and B
A= not $bd{"top"}B= $i == 0
Truth table100%3/3
not(A) and B
A= not $bd{"bottom"}B= $i == $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 400 | my $bd = $border{$pos}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 400 | my @span = @span; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | my @panes = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 400 | ▶ | @$_ ? ansi_sprintf("%-*s", shift @span, shift @$_) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 400 | print $bd->{left}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | print join $bd->{center}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 400 | map { $obj->color('TEXT', $_) } @panes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 400 | print $bd->{right}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 400 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 83 | $print_border->('bottom', 2, \@span, $npanes, $n0, $p, $names, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | \@pane_bottom, \@page_bottom); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 83 | $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 71 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 107 | ▶ | sub _numbers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_numbers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 107 | require Getopt::EX::Numbers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 107 | Getopt::EX::Numbers->new(min => 1, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 63 | ▶ | sub table_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_out: called CC=56 SCAR=40.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 63 | my $obj = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 63 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 62 | my $split = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 62 | ▶ | if ($obj->separator eq ' ') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # /\s+/a does not work as expected, maybe perl's bug | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 10 | ▶ | $obj->ignore_space ? ' ' : qr/\s{1,9999}/a; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | } elsif ($obj->regex_sep) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | qr($obj->{separator}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 52 | qr/[\Q$obj->{separator}\E]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 62 | my @lines = map { [ split $split, $_, $obj->table_columns_limit ] } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 62 | ▶ | if (my $spec = $obj->table_remove) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 50 | my $max_cols = max map { scalar @$_ } @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 100 | my %discard = map { ($_ - 1) => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 50 | map { _numbers(max => $max_cols)->parse($_)->sequence } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | split /,/, $spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 50 | my @keep = grep { !$discard{$_} } 0 .. $max_cols - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 50 | @$_ = @$_[@keep] for @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 62 | ▶ | if ($obj->table_squeeze) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 5 | ▶ | my @keep = grep { my $c = $_; any { length $_->[$c] } @lines } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | 0 .. max(map { $#$_ } @lines); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 1 | @$_ = @$_[@keep] for @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # -w / --cell: fit table into width, wrapping over-wide cells | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 62 | my @fixed_width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | my @continued; # [row][col] true for a wrapped cell's 2nd+ line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 62 | my @length; # [row][col] width of the cell | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 62 | ▶ | if (not $obj->table_align and not $obj->table_tabs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
not $obj->table_align || $obj->table_tabs and defined $obj->width || $obj->cell
$obj->table_align || $obj->table_tabs
defined $obj->width or $obj->cell
MC/DC75%3/4
not $obj->table_align || $obj->table_tabs and defined $obj->width || $obj->cell
$obj->table_align
$obj->table_tabs
defined $obj->width
$obj->cell
Truth table80%4/5
not(A || B) and C or D
A= $obj->table_alignB= $obj->table_tabsC= defined $obj->widthD= $obj->cell
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | and (defined $obj->width or $obj->cell)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 44 | my @cw = map { [ map { ansi_width $_ } @$_ ] } @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 44 | my @content = map { max @$_ } xpose @cw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 44 | ▶ | my $overhead = $obj->item_format ? ansi_width(ansi_sprintf($obj->item_format, '')) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 44 | my $sep = ansi_width($obj->output_separator); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 44 | ▶ | my $fixed = $obj->cell ? parse_cell_spec($obj->cell, \@content) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 44 | ▶ | my $budget = defined $obj->width ? $obj->get_width - $sep * (@content - 1) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 44 | @lines = $obj->fit_table_rows(\@lines, \@cw, \@content, $budget, $overhead, $fixed, 4, \@continued, \@length); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 44 | ▶ | @fixed_width = map { defined $_ ? $_ + $overhead : undef } @$fixed if $fixed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 62 | my @blank = map { [ map { $_ eq '' } @$_ ] } @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 62 | ▶ | @length = map { [ map { ansi_width $_ } @$_ ] } @lines unless @length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 62 | ▶ | if (my $fmt = $obj->item_format) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | # A format with a single %s only adds text around the cell, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # it is put by hand and the width of the text is added. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 23 | ▶ | if (my($pre, $post) = $fmt =~ /\A([^%]*+)%s([^%]*+)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 23 | my $add = ansi_width($pre . $post); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 23 | for my $r (keys @lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 89 | my $line = $lines[$r]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 89 | for my $c (keys @$line) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 181 | ▶ | $line->[$c] = defined $line->[$c] ? "$pre$line->[$c]$post" : ansi_sprintf($fmt, undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 181 | $length[$r][$c] += $add; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | for my $line (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | @$line = map { ansi_sprintf($fmt, $_) } @$line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | @length = map { [ map { ansi_width $_ } @$_ ] } @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | # --table-wrap-mark: put the mark where a continuation line starts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | # in place of leading pad as far as the mark is wide. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | # --table-cell-mark: same for the first line of every non-empty cell | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | # in a column that has a wrapped cell, so that a row start can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | # told from a continuation line; the first --table-head rows (a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | # wrapped row counting as one) are a header and get no mark. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 62 | my @marked; # [row][col] mark string, for alignment below | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 37 | ▶ | my $put_mark = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 37 | my($mark, $r, $c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 37 | my $mw = ansi_width($mark); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 37 | $lines[$r][$c] =~ s/^\h{0,$mw}/$mark/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 37 | $length[$r][$c] = ansi_width($lines[$r][$c]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 37 | $marked[$r][$c] = $mark; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 62 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 62 | ▶ | if ((my $mark = $obj->table_wrap_mark) ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 5 | for my $r (grep { $continued[$_] } keys @continued) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 6 | $put_mark->($mark, $r, $_) for grep { $continued[$r][$_] } keys @{$continued[$r]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 62 | ▶ | if ((my $mark = $obj->table_cell_mark) ne '' and grep { $_ } @continued) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
(my $mark = $obj->table_cell_mark) ne "" and grep {$_;} @continued
MC/DC100%2/2
(my $mark = $obj->table_cell_mark) ne "" and grep {$_;} @continued
(my $mark = $obj->table_cell_mark) ne ""
grep {$_;} @continued
Truth table100%3/3
A and B
A= (my $mark = $obj->table_cell_mark) ne ""B= grep {$_;} @continued
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 12 | my %wrapped; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 12 | for my $r (grep { $continued[$_] } keys @continued) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 21 | $wrapped{$_}++ for grep { $continued[$r][$_] } keys @{$continued[$r]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 12 | my $row = 0; # logical row number of a non-continuation line | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 12 | for my $r (grep { not $continued[$_] } keys @lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 34 | ▶ | next if $row++ < $obj->table_head; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 29 | ▶ | $put_mark->($mark, $r, $_) for grep { $wrapped{$_} and not $blank[$r][$_] } keys @{$lines[$r]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$wrapped{$_} && !$blank[$r][$_]
MC/DC50%1/2
$wrapped{$_} && !$blank[$r][$_]
$wrapped{$_}
!$blank[$r][$_]
Truth table66%2/3
A && not(B)
A= $wrapped{$_}B= !$blank[$r][$_]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 62 | my @max = map { max @$_ } xpose @length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 62 | for my $i (grep { defined $fixed_width[$_] } keys @fixed_width) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 18 | ▶ | $max[$i] = max($max[$i] // 0, $fixed_width[$i]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$max[$i] // 0
MC/DC0%0/1
$max[$i] // 0
$max[$i]
Truth table50%1/2
A
A= $max[$i]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 62 | ▶ | if ($obj->table_align) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 4 | my @tabs = map { roundup $_, $obj->column_unit, $obj->margin } @max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | # --table-tabs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 4 | ▶ | if ($obj->table_tabs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 1 | my $cu = $obj->column_unit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 1 | ▶ | while (my($lx, $l) = each @lines) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 10 | ▶ | while (my($fx, $f) = each @$l) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 100 | print $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 100 | ▶ | if ($fx == $#{$l}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 10 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 90 | print "\t" x div($tabs[$fx] - $length[$lx][$fx], $cu); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 1 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 3 | @max = map { $_ - $obj->margin } @tabs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 3 | $obj->output_separator = ' ' x $obj->margin; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | my @align = newlist(count => int @max, default => '-', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | [ map --$_, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 5 | _numbers(max => int @max)->parse($_)->sequence | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } split /,/, $obj->table_right ] => '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | [ map --$_, map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 61 | _numbers(max => int @max)->parse($_)->sequence | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } split /,/, $obj->table_center ] => '='); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 61 | ▶ | my @format = map { $align[$_] eq '=' ? "%-$max[$_]s" : "%$align[$_]$max[$_]s" } keys @max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 61 | for my $r (keys @lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 381 | my $line = $lines[$r]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 381 | ▶ | next unless @$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 381 | for my $i (keys @$line) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | # Pad right/center aligned cells here, keeping a mark at the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | # left edge of the cell rather than in front of the content. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 1107 | ▶ | next if $align[$i] eq '-'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 67 | my $pad = $max[$i] - $length[$r][$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 67 | ▶ | next if $pad <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 34 | ▶ | $pad = int($pad / 2) if $align[$i] eq '='; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 34 | $line->[$i] = (' ' x $pad) . $line->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 34 | $length[$r][$i] += $pad; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 34 | ▶ | if (my $mark = $marked[$r][$i]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 8 | $line->[$i] =~ s/^(\h+)\Q$mark\E/$mark$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 381 | my @fmt = @format[keys @$line]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 381 | ▶ | $fmt[$#fmt] = '%s' if $align[$#fmt] ne '' and !$obj->padding; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$align[$#fmt] ne "" and not $obj->padding
MC/DC100%2/2
$align[$#fmt] ne "" and not $obj->padding
$align[$#fmt] ne ""
not $obj->padding
Truth table100%3/3
A and not(B)
A= $align[$#fmt] ne ""B= not $obj->padding
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 381 | ▶ | if (grep { not defined } @$line) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | my $format = join($obj->output_separator, @fmt) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ansi_printf $format, @$line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | # the width of every cell is known: pad it here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | my @out = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 381 | my $space = ' ' x ($max[$_] - $length[$r][$_]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 1107 | ▶ | $fmt[$_] eq '%s' ? $line->[$_] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | : $align[$_] eq '' ? $space . $line->[$_] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | : $line->[$_] . $space; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } keys @$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 381 | print join($obj->output_separator, @out), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 61 | return $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 141 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||