lib/App/ansicolumn.pm

filter: Statementstmt 93.1% 751 / 806 Branchbran 82.9% 262 / 316 Conditioncond 72.2% 161 / 223 MC/DCmcdc 49.2% 62 / 126 Subroutinesub 86.7% 72 / 83 Podpod 0.0% 0 / 16 totaltotal 83.3% 1308 / 1570 CC 272 SCAR 31.8
CC
272
Cov
87%
table_out
71.1
setup_options
47.6
parallel_out
19.1
CRAP 24.0
↑ Summary lib/App/ansicolumn/Table.pm »
1 package App::ansicolumn;
2  
3 303 our $VERSION = "1.73";
4  
5 303 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 303 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 303 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 303 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 303 ▶use open IO => 'utf8', ':std';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 303 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 303 ▶use Getopt::EX::Long qw(:DEFAULT Configure ExConfigure);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 303 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 303 ▶use List::Util qw(max sum min any);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 303 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 303 ▶use Text::ANSI::Fold qw(ansi_fold);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 303 ▶use Text::ANSI::Fold::Util qw(ansi_width);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 303 ▶use Text::ANSI::Printf qw(ansi_printf ansi_sprintf);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 303 ▶use App::ansicolumn::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 303 ▶use App::ansicolumn::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 303 ▶use App::ansicolumn::Table;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 303 ▶use App::ansicolumn::Border;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 303 ▶use Getopt::EX::RPN qw(rpn_calc);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 303 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 303 our @EXPORT_OK = qw(ansicolumn);
27  
28 # --intact: what joins the lines to be kept intact into one line
29 # (UNIT SEPARATOR, for now)
30 303 our $INTACT_SEP = "\x1F";
31 # --intact: what joins the lines of a group, kept intact in one pane,
32 # and the marks of its lines: RECORD SEPARATOR on the first line and
33 # GROUP SEPARATOR on the others
34 303 our $GROUP_SEP = "\x1D";
35 303 our $GROUP_FIRST = "\x1E";
36 303 our $GROUP_MARK = qr/[\x1D\x1E]/;
37 # --pane-osc: a private OSC, which terminals ignore, at the start of
38 # each pane, for a program which reads the output, as ansi2pdf
39 303 our $PANE_OSC = "\e]7772;\e\\";
40  
41 301 ▶sub ansicolumn {
Subroutine ansicolumn: called CC=1 SCAR=0.0
Pod undocumented
42 301 __PACKAGE__->new->perform(@_);
43 }
44  
45 303 my %DEFAULT_COLORMAP = (
46 BORDER => '',
47 BORDER_LABEL => '',
48 TEXT => '',
49 );
50  
51 303 ▶use Getopt::EX::Hashed 1.0701; {
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 303 Getopt::EX::Hashed->configure( DEFAULT => [ is => 'rw' ] );
54  
55 303 has debug => ' ' ;
56 303 has help => ' h ' ;
57 303 has version => ' v ' ;
58 303 has width => ' =s w c ' ;
59 303 has fillrows => ' x ' ;
60 303 has table => ' t ' ;
61 303 has table_columns_limit => ' =i l ' , default => -1 ;
62 303 has table_align => ' ! A ' ;
63 303 has table_tabs => ' + T ' ;
64 303 has table_right => ' =s R ' , default => '' ;
65 303 has table_center => ' =s ' , default => '' ;
66 303 has item_format => ' =s ' , default => '' ;
67 303 has table_wrap_mark => ' =s ' , default => '' ;
68 303 has table_cell_mark => ' =s ' , default => '' ;
69 303 has table_head => ' =i ' , default => 0 ;
70 303 has table_group => ' ! ' ;
71 303 has table_remove => ' =s K ' , default => '' ;
72 303 has table_squeeze => ' ! ' ;
73 303 has table_tight => ' ! ' , default => 1 ;
74 303 has padding => ' ! ' ;
75 303 has separator => ' =s s ' , default => ' ' ;
76 303 has regex_sep => ' r ' ;
77 303 has output_separator => ' =s o ' , default => ' ' ;
78 303 has document => ' ! D ' ;
79 303 has parallel => ' ! V ' ;
80 303 has filename => ' ! H ' ;
81 303 has filename_format => ' =s ' , default => ': %s';
82 303 has ignore_empty => ' ! I ' , default => 0 ;
83 303 has pages => ' ! ' ;
84 303 has up => ' :s U ' ;
85 303 has page => ' :i P ' , min => 0;
86 0 ▶ has no_page => ' ' , action => sub { $_->page = undef } ;
Subroutine __ANON__: not called CC=1 SCAR=1.2
87 303 has pane => ' =s C ' , default => 0 ;
88 303 has cell => ' =s X ' ;
89 303 has pane_width => ' =s S pw ' ;
90 303 has widen => ' ! W ' ;
91 303 has paragraph => ' ! p ' ;
92 303 has height => ' =s ' , default => 0 ;
93 303 has column_unit => ' =i cu ' , min => 1, default => 8 ;
94 303 has margin => ' =i ' , min => 0, default => 1 ;
95 303 has tabstop => ' =i ' , min => 1, default => 8 ;
96 303 has tabhead => ' =s ' ;
97 303 has tabspace => ' =s ' ;
98 303 has tabstyle => ' :s ts ' ;
99 303 has ignore_space => ' ! is ' , default => 1 ;
100 303 has linestyle => ' =s ls ' , default => '' ;
101 303 has boundary => ' =s ' , default => '' ;
102 303 has linebreak => ' =s lb ' , default => '' ;
103 303 has runin => ' =i ' , min => 0, default => 2 ;
104 303 has runout => ' =i ' , min => 0, default => 2 ;
105 303 has runlen => ' =i ' ;
106 303 has pagebreak => ' ! ' , default => 1 ;
107 303 has intact => ' ! ' ;
108 303 has pane_osc => ' ! ' ;
109 0 ▶ has border => ' :s ' ; has B => '' , action => sub { $_->border = '' } ;
Subroutine __ANON__: not called CC=1 SCAR=0.4
110 17 ▶ has no_border => ' ' , action => sub { $_->border = 'none' } ;
Subroutine __ANON__: called CC=1 SCAR=0.0
111 303 has border_style => ' =s bs ' , default => 'box' ;
112 303 has label => ' =s% ' , default => {} ;
113 303 has page_label => ' =s% ' , default => {} ;
114 303 has mark => ' =s% ' , default => {} ;
115 303 has white_space => ' ! ' , default => 2 ;
116 303 has isolation => ' ! ' , default => 2 ;
117 0 ▶ has fillup => ' :s ' ; has F => '' , action => sub { $_->fillup = '' } ;
Subroutine __ANON__: not called CC=1 SCAR=0.4
118 303 has fillup_str => ' :s ' , default => '' ;
119 303 has ambiguous => ' =s ' , default => 'narrow' ;
120 303 has discard_el => ' ! ' , default => 1 ;
121 303 has padchar => ' =s ' , default => ' ' ;
122 303 has colormap => ' =s@ cm ' , default => [] ;
123 303 has factotum => ' =s@ ' , default => [] ;
124 303 has highlight => ' :s hi ' , action => \&_highlight ;
125 1 ▶ has no_highlight => ' ' , action => sub { $_->highlight = undef } ;
Subroutine __ANON__: called CC=1 SCAR=0.0
126 4 ▶ has no_hi => ' ' , action => sub { $_->highlight = undef } ;
Subroutine __ANON__: called CC=1 SCAR=0.0
127  
128 303 has '+boundary' => any => [ qw(none word space) ] ;
129 303 has '+linestyle' => any => [ qw(none wordwrap wrap truncate) ] ;
130 303 has '+fillup' => any => [ qw(pane page none), '' ] ;
131 303 has '+ambiguous' => any => [ qw(wide narrow) ] ;
132  
133 # --2up .. --9up
134 0 ▶ my $nup = sub { $_[0] =~ /^(\d+)/ and $_->up = $1 } ;
Subroutine __ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^(\d+)/u and $_->up = $1 0 0 0
135 303 for my $n (2..9) {
136 2424 has "${n}up" => '', action => $nup;
137 }
138  
139 # for run-time use
140 303 has span => ;
141 303 has panes => ;
142 303 has border_height => ;
143 303 has current_page => ;
144 303 has _bl => ;
145 303 has _pbl => ;
146 303 has _mk => ;
147 303 has _total_panes => ;
148 303 has _cell_fold => ; # cells wrapped by the table mode, by width
149 303 has _total_pages => ;
150  
151 303 Getopt::EX::Hashed->configure( DEFAULT => [] );
152  
153 0 ▶ has '+help' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
154 0 pod2usage
155 -verbose => 99,
156 -sections => [ qw(SYNOPSIS VERSION) ];
157 303 };
158  
159 0 ▶ has '+version' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
160 0 say "Version: $VERSION";
161 0 exit;
162 303 };
163  
164 ### RPN calc for --height, --width, --pane, --up, --pane-width
165 352 ▶ has [ qw(+height +width +pane +up +pane_width) ] => sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
166 352 my $obj = $_;
167 352 my($name, $val) = @_;
168 352 $val =~ s/^=//; # -w=2/, as ansifold takes it
169 352 ▶ $obj->$name = $val !~ /\D/ ? $val : do {
Branch: 1 branch
BranchTrueFalseTotal
!($val =~ /\D/u) ? : 346 6 352
170 6 ▶ my $init = $name =~ /height/ ? $obj->term_height : $obj->term_width;
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /height/u ? : 0 6 6
171 6 ▶ rpn_calc($init, $val) // die "$val: invalid $name.\n";
Condition50%1/2
rpn_calc($init, $val) // die("${val}: invalid $name.\n")
l!l
60
MC/DC0%0/1
rpn_calc($init, $val) // die("${val}: invalid $name.\n")
rpn_calc($init, $val)
Truth table50%1/2
A
A= rpn_calc($init, $val)
Aresult
11
00
172 };
173 303 };
174  
175 ### --ambiguous=wide
176 0 ▶ has '+ambiguous' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
177 0 ▶ if ($_[1] eq 'wide') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] eq "wide") 0 0 0
178 0 $Text::VisualWidth::PP::EastAsian = 1;
179 0 Text::ANSI::Fold->configure(ambiguous => 'wide');
180 }
181 303 };
182  
183 ### --runlen
184 0 ▶ has '+runlen' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
185 0 $_->runin = $_->runout = $_[1];
186 303 };
187  
188 ### --tabstop, --tabstyle
189 0 ▶ has [ qw(+tabstop +tabstyle) ] => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
190 0 my($name, $val) = map "$_", @_;
191 0 ▶ if ($val eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($val eq "") 0 0 0
192 0 list_tabstyle();
193 0 exit;
194 }
195 0 Text::ANSI::Fold->configure($name => $val);
196 303 };
197  
198 ### --tabhead, --tabspace
199 303 ▶ use charnames ':loose';
Subroutine BEGIN: called CC=1 SCAR=0.0
200 0 ▶ has [ qw(+tabhead +tabspace) ] => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
201 0 my($name, $c) = map "$_", @_;
202 0 ▶ $c = charnames::string_vianame($c) || die "$c: invalid name\n"
Branch: 1 branch
BranchTrueFalseTotal
if length $c > 1 0 0 0
Condition0%0/2
charnames::string_vianame($c) || die("${c}: invalid name\n")
l!l
00
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)
Aresult
11
00
203 if length($c) > 1;
204 0 Text::ANSI::Fold->configure($name => $c);
205 303 };
206  
207 ### -A
208 3 ▶ has '+table_align' => sub {
Subroutine __ANON__: called CC=2 SCAR=7.2
209 3 ▶ if ($_->table_align = $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->table_align = $_[1]) 3 0 3
210 3 $_->table = $_[1];
211 }
212 303 };
213 ### -T, -TT
214 1 ▶ has '+table_tabs' => sub {
Subroutine __ANON__: called CC=3 SCAR=15.1
215 # incremental behavior
216 1 $_->table_tabs += $_[1];
217 1 ▶ if ($_->table_tabs == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->table_tabs == 1) { } 1 0 1
elsif ($_->table_tabs == 2) { } 0 0 0
218 # enable -t and -A
219 1 $_->table = $_->table_align = $_[1];
220 } elsif ($_->table_tabs == 2) {
221 # set -rs '\t+'
222 0 $_->regex_sep = 1;
223 0 $_->separator = '\\t+';
224 }
225 303 };
226  
227 303 has TERM_SIZE => ;
228 303 has COLORHASH => default => { %DEFAULT_COLORMAP };
229 303 has COLORLIST => default => [];
230 303 has COLOR => ;
231 303 has BORDER => ;
232  
233 303 ▶} no Getopt::EX::Hashed;
Subroutine BEGIN: called CC=1 SCAR=0.0
234  
235 0 ▶sub list_tabstyle {
Subroutine list_tabstyle: not called CC=2 SCAR=17.9
Pod undocumented
236 0 my %style = %Text::ANSI::Fold::TABSTYLE;
237 0 my $max = max map length, keys %style;
238 0 for my $name (sort keys %style) {
239 0 my($head, $space) = @{$style{$name}};
240 0 printf "%*s %s%s\n", $max, $name, $head, $space x 7;
241 }
242 }
243  
244 # --highlight[=NAME]: the value is optional, so Getopt::Long takes
245 # the word after the option for it. When the word is a file and not
246 # the name of a highlighter, it is given back to be read as a file.
247 23 ▶sub _highlight {
Subroutine _highlight: called CC=4 SCAR=13.9
248 23 my $obj = $_;
249 23 my($name, $value) = @_;
250 23 ▶ if ($value ne '' and not _highlighter($value) and -e $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value ne "" and not _highlighter($value) and -e $value) 3 20 23
Condition100%6/6
$value ne "" and not _highlighter($value) and -e $value
!ll&&!rl&&r
1913
$value ne "" and not _highlighter($value)
!ll&&!rl&&r
1094
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
ABCresult
0XX0
10X0
1100
1111
251 3 unshift @ARGV, $value;
252 3 $value = '';
253 }
254 23 $obj->highlight = $value;
255 }
256  
257 # The name of a highlighter of Text::ANSI::Highlight, or its short name
258 13 ▶sub _highlighter {
Subroutine _highlighter: called CC=2 SCAR=7.0
259 13 my $name = shift;
260 13 ▶ eval { require Text::ANSI::Highlight; 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Text::ANSI::Highlight; 1 } } and defined "Text::ANSI::Highlight"->highlighter($name) 13 0 13
261 and defined Text::ANSI::Highlight->highlighter($name);
262 }
263  
264 301 ▶sub perform {
Subroutine perform: called CC=14 SCAR=26.7
Pod undocumented
265 301 my $obj = shift;
266 301 local @ARGV = decode_argv(@_);
267 301 ExConfigure BASECLASS => [ __PACKAGE__, "Getopt::EX" ];
268 301 Configure qw(bundling no_auto_abbrev no_ignore_case);
269 301 ▶ $obj->getopt || pod2usage(2);
Branch: 1 branch
BranchTrueFalseTotal
$obj->getopt or pod2usage(2) 301 0 301
270  
271 301 $obj->setup_options;
272  
273 # --mark: an unknown name is an error, with or without a label
274 301 $obj->_marks;
275  
276 # The files are read through IO::Factotum when it is loaded
277 # (read_files), and this is the only place which knows what it
278 # reads them through.
279 #
280 # --factotum: converters of IO::Factotum, by their names.
281 300 my @names = map { split /,/ } @{$obj->factotum};
282 300 ▶ if (@names) {
Branch: 1 branch
BranchTrueFalseTotal
if (@names) 4 296 300
283 4 ▶ eval { require IO::Factotum; 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require IO::Factotum; 1 } } or die "--factotum requires IO::Factotum. " 4 0 4
284 or die "--factotum requires IO::Factotum.\n";
285 4 IO::Factotum::load(@names);
286 }
287 # --highlight[=NAME]: Text::ANSI::Highlight::IO gives the
288 # highlighter of the name to IO::Factotum, the default one without
289 # the name.
290 299 ▶ if (defined(my $name = $obj->highlight)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $name = $obj->highlight)) 20 279 299
291 20 ▶ eval { require Text::ANSI::Highlight::IO; 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Text::ANSI::Highlight::IO; 1 } } or die "--highlight requires Text::ANSI::Highlight::IO. " 20 0 20
292 or die "--highlight requires Text::ANSI::Highlight::IO.\n";
293 20 ▶ eval { Text::ANSI::Highlight::IO->setup($name eq '' ? () : $name); 1 }
Branch: 2 branches
BranchTrueFalseTotal
eval { do { "Text::ANSI::Highlight::IO"->setup($name eq "" ? () : $name); 1 } } or die $@ =~ s/ at .* line \d+\.?\n\z/\n/ru 19 1 20
$name eq '' ? : 12 8 20
294 or die $@ =~ s/ at .* line \d+\.?\n\z/\n/r;
295 }
296  
297 298 ▶ warn Dumper $obj if $obj->debug;
Branch: 1 branch
BranchTrueFalseTotal
if $obj->debug 0 298 298
298  
299 298 ▶ my @files = $obj->read_files(@ARGV ? @ARGV : '-') or return 1;
Branch: 2 branches
BranchTrueFalseTotal
my(@files) = $obj->read_files(@ARGV ? @ARGV : "-") or return 1 296 0 296
@ARGV ? : 45 253 298
300  
301 296 ▶ if ($obj->ignore_empty) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->ignore_empty) 0 296 296
302 0 @files = grep { not $_->is_empty } @files;
303 }
304  
305 296 ▶ if ($obj->table) {
Branch: 2 branches
BranchTrueFalseTotal
if ($obj->table) { } 165 131 296
elsif ($obj->parallel) { } 20 111 131
306 165 my @lines = map { $_->lines } @files;
307 165 $obj->table_out(@lines);
308 }
309 elsif ($obj->parallel) {
310 20 $obj->parallel_out(@files);
311 }
312 else {
313 111 $obj->nup_out(@files);
314 }
315  
316 296 return 0
317 }
318  
319 301 ▶sub setup_options {
Subroutine setup_options: called CC=30 SCAR=38.6
Pod undocumented
320 301 my $obj = shift;
321  
322 ## --parallel or @ARGV > 1
323 301 ▶ if ($obj->parallel //= @ARGV > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->parallel //= @ARGV > 1) 20 281 301
Condition100%2/2
$obj->parallel //= @ARGV > 1
l!l
19282
MC/DC100%1/1
$obj->parallel //= @ARGV > 1
$obj->parallel
Truth table100%2/2
A
A= $obj->parallel
Aresult
11
00
324 20 ▶ $obj->linestyle ||= 'wrap';
Condition50%1/2
$obj->linestyle ||= "wrap"
l!l
020
MC/DC0%0/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table50%1/2
A
A= $obj->linestyle
Aresult
11
00
325 20 ▶ $obj->widen //= 1;
Condition50%1/2
$obj->widen //= 1
l!l
020
MC/DC0%0/1
$obj->widen //= 1
$obj->widen
Truth table50%1/2
A
A= $obj->widen
Aresult
11
00
326 20 ▶ $obj->border //= '';
Condition100%2/2
$obj->border //= ""
l!l
155
MC/DC100%1/1
$obj->border //= ""
$obj->border
Truth table100%2/2
A
A= $obj->border
Aresult
11
00
327 }
328  
329 ## --border takes optional border-style value
330 301 ▶ if (defined(my $border = $obj->border)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $border = $obj->border)) 61 240 301
331 61 ▶ if ($border ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($border ne "") 36 25 61
332 36 $obj->border_style = $border;
333 }
334 61 $obj->border = 1;
335 61 ▶ $obj->fillup //= 'pane';
Condition100%2/2
$obj->fillup //= "pane"
l!l
358
MC/DC100%1/1
$obj->fillup //= "pane"
$obj->fillup
Truth table100%2/2
A
A= $obj->fillup
Aresult
11
00
336 }
337  
338 ## --linestyle
339 301 ▶ if ($obj->linestyle eq 'wordwrap') {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->linestyle eq "wordwrap") 0 301 301
340 0 $obj->linestyle = 'wrap';
341 0 $obj->boundary = 'word';
342 }
343  
344 ## -P
345 301 ▶ if (defined $obj->page) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $obj->page) 34 267 301
346 34 ▶ $obj->widen = 1 if $obj->pane and not $obj->pane_width;
Branch: 1 branch
BranchTrueFalseTotal
if $obj->pane and not $obj->pane_width 26 8 34
Condition66%2/3
$obj->pane and not $obj->pane_width
!ll&&!rl&&r
8026
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
ABresult
0X0
100
111
347 34 ▶ $obj->height ||= $obj->page || $obj->term_height - 1;
Condition33%2/6
$obj->height ||= $obj->page || $obj->term_height - 1
l!l&&r!l&&!r
0340
$obj->page || $obj->term_height - 1
l!l&&r!l&&!r
3400
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
ABCresult
1XX1
01X1
0011
0000
348 34 ▶ $obj->linestyle ||= 'wrap';
Condition50%1/2
$obj->linestyle ||= "wrap"
l!l
034
MC/DC0%0/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table50%1/2
A
A= $obj->linestyle
Aresult
11
00
349 34 ▶ $obj->border //= 1;
Condition100%2/2
$obj->border //= 1
l!l
286
MC/DC100%1/1
$obj->border //= 1
$obj->border
Truth table100%2/2
A
A= $obj->border
Aresult
11
00
350 34 ▶ $obj->fillup //= 'pane';
Condition100%2/2
$obj->fillup //= "pane"
l!l
286
MC/DC100%1/1
$obj->fillup //= "pane"
$obj->fillup
Truth table100%2/2
A
A= $obj->fillup
Aresult
11
00
351 }
352  
353 ## -U
354 301 ▶ if ($obj->up) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->up) 0 301 301
355 0 $obj->pane = $obj->up;
356 0 $obj->widen = 1;
357 0 ▶ $obj->linestyle ||= 'wrap';
Condition0%0/2
$obj->linestyle ||= "wrap"
l!l
00
MC/DC0%0/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table0%0/2
A
A= $obj->linestyle
Aresult
11
00
358 0 ▶ $obj->border //= 1;
Condition0%0/2
$obj->border //= 1
l!l
00
MC/DC0%0/1
$obj->border //= 1
$obj->border
Truth table0%0/2
A
A= $obj->border
Aresult
11
00
359 0 ▶ $obj->fillup //= 'pane';
Condition0%0/2
$obj->fillup //= "pane"
l!l
00
MC/DC0%0/1
$obj->fillup //= "pane"
$obj->fillup
Truth table0%0/2
A
A= $obj->fillup
Aresult
11
00
360 }
361  
362 ## -D
363 301 ▶ if ($obj->document) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->document) 20 281 301
364 20 $obj->widen = 1;
365 20 ▶ $obj->linebreak ||= 'all';
Condition50%1/2
$obj->linebreak ||= "all"
l!l
020
MC/DC0%0/1
$obj->linebreak ||= "all"
$obj->linebreak
Truth table50%1/2
A
A= $obj->linebreak
Aresult
11
00
366 20 ▶ $obj->linestyle ||= 'wrap';
Condition100%2/2
$obj->linestyle ||= "wrap"
l!l
515
MC/DC100%1/1
$obj->linestyle ||= "wrap"
$obj->linestyle
Truth table100%2/2
A
A= $obj->linestyle
Aresult
11
00
367 20 ▶ $obj->boundary ||= 'word';
Condition50%1/2
$obj->boundary ||= "word"
l!l
020
MC/DC0%0/1
$obj->boundary ||= "word"
$obj->boundary
Truth table50%1/2
A
A= $obj->boundary
Aresult
11
00
368 20 ▶ $obj->white_space = 0 if $obj->white_space > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $obj->white_space > 1 20 0 20
369 20 ▶ $obj->isolation = 0 if $obj->isolation > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $obj->isolation > 1 20 0 20
370 }
371  
372 ## --colormap
373 303 ▶ use Getopt::EX::Colormap;
Subroutine BEGIN: called CC=1 SCAR=0.0
374 my $cm = Getopt::EX::Colormap
375 ->new(HASH => $obj->{COLORHASH}, LIST => $obj->{COLORLIST})
376 301 ->load_params(@{$obj->colormap});
377 301 ▶ $obj->{COLOR} = sub { $cm->color(@_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
378  
379 ## --border
380 301 ▶ if ($obj->border) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->border) 67 234 301
381 67 my $style = $obj->border_style;
382 67 ▶ ($obj->{BORDER} = App::ansicolumn::Border->new)
Condition50%1/2
($obj->{"BORDER"} = "App::ansicolumn::Border"->new)->style($style) // die("${style}: Unknown style.\n")
l!l
670
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)
Aresult
11
00
383 ->style($style) // die "$style: Unknown style.\n";
384 }
385  
386 301 $obj;
387 }
388  
389 4062 ▶sub color {
Subroutine color: called CC=1 SCAR=0.0
Pod undocumented
390 4062 my $obj = shift;
391 4062 $obj->{COLOR}->(@_);
392 }
393  
394 20 ▶sub parallel_out {
Subroutine parallel_out: called CC=16 SCAR=29.5
Pod undocumented
395 20 my $obj = shift;
396 20 my @files = @_;
397  
398 20 my $max_line_length = max map { $_->width } @files;
399 20 ▶ $obj->pane ||= @files;
Condition66%2/3
$obj->pane ||= @files
l!l&&r!l&&!r
8120
MC/DC0%0/2
$obj->pane ||= @files
$obj->pane @files
Truth table66%2/3
A ||= B
A= $obj->paneB= @files
ABresult
1X1
011
000
400 20 $obj->set_horizontal($max_line_length);
401  
402 # calculate span and set for each file
403 20 ▶ if (my $cell = $obj->cell) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cell = $obj->cell) 1 19 20
404 1 my @spans = split /,+/, $cell;
405 1 for my $i (keys @files) {
406 2 ▶ my $span = $spans[$i] // $spans[-1];
Condition33%1/3
$spans[$i] // $spans[-1]
l!l&&r!l&&!r
200
MC/DC0%0/2
$spans[$i] // $spans[-1]
$spans[$i] $spans[-1]
Truth table33%1/3
A // B
A= $spans[$i]B= $spans[-1]
ABresult
1X1
011
000
407 2 ▶ if ($span =~ /^[-+]/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($span =~ /^[-+]/u) { } 0 2 2
elsif ($span =~ s/^(<=|[<=])//u) { } 0 2 2
elsif (not $span =~ /^\d+$/u) { } 0 2 2
408 0 $span += $obj->{span};
409 0 ▶ $span < 0 and die "Invalid number: $cell\n";
Branch: 1 branch
BranchTrueFalseTotal
$span < 0 and die "Invalid number: $cell\n" 0 0 0
410 }
411 elsif ($span =~ s/^(<=|[<=])//) {
412 0 my $length = $files[$i]->width;
413 0 ▶ $span = $span ? min($length, $span) : $length;
Branch: 1 branch
BranchTrueFalseTotal
$span ? : 0 0 0
414 }
415 elsif ($span !~ /^\d+$/) {
416 0 die "Invalid number: $cell\n";
417 }
418 2 $files[$i]->span($span);
419 }
420 }
421 20 $obj->set_contents($_) for @files;
422 # the files are not laid out in panes: no group is kept in one
423 20 ▶ if ($obj->intact) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->intact) 1 19 20
424 1 ▶ $_->replace(sub { $_[0] =~ s/^$GROUP_MARK//r }) for @files;
Subroutine __ANON__: called CC=1 SCAR=0.0
425 }
426 # for the labels: every file is a pane
427 20 $obj->{_total_panes} = @files;
428 20 $obj->{_total_pages} = roundup(scalar @files, $obj->pane) / $obj->pane;
429 20 my $column_out = $obj->_column_out;
430 20 ▶ for ($obj->current_page = 0; @files; $obj->current_page++) {
Branch: 1 branch
BranchTrueFalseTotal
if (@files) 21 20 41
431 21 my @rows = splice @files, 0, $obj->pane;
432 21 my @data = map { [ $_->lines ] } @rows;
433 21 my $max_length = max map { int @$_ } @data;
434 21 ▶ my @span = map { $_->span // $obj->span } @rows;
Condition66%2/3
$_->span // $obj->span
l!l&&r!l&&!r
2390
MC/DC0%0/2
$_->span // $obj->span
$_->span $obj->span
Truth table66%2/3
A // B
A= $_->spanB= $obj->span
ABresult
1X1
011
000
435 21 ▶ if ($obj->filename) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->filename) 3 18 21
436 3 my $w = $obj->span + $obj->border_width('center');
437 my $format = join '', (
438 (map {
439 3 my $w = $_ + $obj->border_width('center');
440 3 "%-${w}.${w}s";
441 } @span[0..$#span-1]),
442 "%s\n");
443 ansi_printf $format, map {
444 3 ansi_sprintf $obj->filename_format, $_->name;
445 } @rows;
446 }
447 $column_out->({ span => \@span, names => [ map $_->name, @rows ] },
448 map {
449 21 push @$_, (($obj->fillup_str) x ($max_length - @$_));
450 41 $_;
451 } @data);
452 }
453 20 return $obj;
454 }
455  
456 111 ▶sub nup_out {
Subroutine nup_out: called CC=3 SCAR=11.0
Pod undocumented
457 111 my $obj = shift;
458 111 my @files = @_;
459 111 my $max_length = max map { $_->width } @files;
460 111 $obj->set_horizontal($max_length);
461 111 for my $file (@files) {
462 112 ▶ next if $file->is_empty;
Branch: 1 branch
BranchTrueFalseTotal
if $file->is_empty 3 109 112
463 109 my $page = clone($obj)->set_contents($file);
464 109 my @data;
465 109 $page->set_vertical([ $file->lines ])
466 ->set_layout(\@data, $file->parts);
467 109 $page->page_out($file->name, @data);
468 }
469 111 return $obj;
470 }
471  
472 298 ▶sub read_files {
Subroutine read_files: called CC=11 SCAR=24.5
Pod undocumented
473 298 my $obj = shift;
474 # The content is divided at formfeeds where a formfeed is a break.
475 # It is not with --no-pagebreak, and in the table and the parallel
476 # view, where the panes are not filled: the formfeeds are left in
477 # the text there. --pages divides it in any case, and makes a
478 # file of every part.
479 298 ▶ my $divide = $obj->pages ||
Condition100%9/9
$obj->pages || $obj->pagebreak && !$obj->parallel && !$obj->table
l!l&&r!l&&!r
9111178
$obj->pagebreak and not $obj->parallel and not $obj->table
!ll&&!rl&&r
13165111
$obj->pagebreak and not $obj->parallel
!ll&&!rl&&r
112276
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
ABCDresult
1XXX1
01111
00XX0
010X0
01100
480 ($obj->pagebreak && !$obj->parallel && !$obj->table);
481 298 my @files;
482 # When IO::Factotum is loaded (--factotum=NAME), the files
483 # are opened by it, and those which a converter takes are read
484 # through that converter. The names stay as they are.
485 298 my $factotum = IO::Factotum->can('open_input');
486 298 for my $file (@_) {
487 309 my $fh;
488 309 ▶ if ($factotum) {
Branch: 1 branch
BranchTrueFalseTotal
if ($factotum) { } 34 275 309
489 34 ▶ $fh = $factotum->($file) or die "$file: $!";
Branch: 1 branch
BranchTrueFalseTotal
$fh = &$factotum($file) or die "${file}: $!" 32 2 34
490 32 binmode $fh, ':utf8';
491 } else {
492 275 ▶ open $fh, $file or die "$file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, $file or die "${file}: $!" 275 0 275
493 }
494 307 ▶ my $content = do { local $/; <$fh> } // do {
Condition33%1/3
do { local $/; readline $fh } // do { warn "${file}: $!\n" if $!; next }
l!l&&r!l&&!r
30700
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 }
ABresult
1X1
011
000
495 0 ▶ warn "$file: $!\n" if $!;
Branch: 1 branch
BranchTrueFalseTotal
if $! 0 0 0
496 0 next;
497 };
498 307 my $doc = App::ansicolumn::Document->new(
499 name => $file,
500 text => $content,
501 formfeed => $divide,
502 keep_ls => $obj->table,
503 );
504 307 ▶ push @files, map { $obj->prepare($_) }
Branch: 1 branch
BranchTrueFalseTotal
$obj->pages ? : 9 298 307
505 $obj->pages ? $doc->pages : $doc;
506 }
507 296 @files;
508 }
509  
510 #
511 # Make the lines of a document ready to be laid out, and find the
512 # width of the longest.
513 #
514 318 ▶sub prepare {
Subroutine prepare: called CC=6 SCAR=17.9
Pod undocumented
515 318 my $obj = shift;
516 318 my $doc = shift;
517 318 ▶ my $intact = $obj->intact && !$obj->table;
Condition100%3/3
$obj->intact && !$obj->table
!ll&&!rl&&r
301116
MC/DC100%2/2
$obj->intact && !$obj->table
$obj->intact !$obj->table
Truth table100%3/3
A && not(B)
A= $obj->intactB= !$obj->table
ABresult
0X0
100
111
518 # -p: an empty line between the lines given, before the lines joined
519 # for --intact are divided, so that none goes in a table or a group
520 318 ▶ $doc->filter(\&insert_space) if $obj->paragraph;
Branch: 1 branch
BranchTrueFalseTotal
if $obj->paragraph 1 317 318
521 # --intact: a line which has the separator holds lines to be kept
522 # intact, joined into one; it is divided into them, and every one
523 # keeps the separator at its start as its mark, until the line is
524 # folded (set_contents)
525 #
526 # A line which has GROUP SEPARATOR holds a group: lines kept intact
527 # and kept in one pane. Every line of it has the mark of a group
528 # after the separator: GROUP_FIRST on the first, GROUP_SEP on the
529 # others, until the layout (space_layout).
530 #
531 # Both may be in a line: it is divided by UNIT SEPARATOR first, and
532 # a part with GROUP SEPARATOR is a group, as the rows of a table
533 # with --table-group are.
534 10 ▶ my $group = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
535 10 my @l = split /$GROUP_SEP/, shift, -1;
536 10 ▶ map { $INTACT_SEP . ($_ ? $GROUP_SEP : $GROUP_FIRST) . $l[$_] } keys @l;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 18 10 28
537 318 };
538 16 ▶ $doc->filter(sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
539 map {
540 16 ▶ if (/$INTACT_SEP/) {
Branch: 2 branches
BranchTrueFalseTotal
if (/$App::ansicolumn::INTACT_SEP/u) { } 8 49 57
elsif (/$App::ansicolumn::GROUP_SEP/u) { } 8 41 49
541 8 ▶ map { /$GROUP_SEP/ ? $group->($_) : "$INTACT_SEP$_" }
Branch: 1 branch
BranchTrueFalseTotal
/$App::ansicolumn::GROUP_SEP/u ? : 2 18 20
542 split /$INTACT_SEP/, $_, -1;
543 }
544 elsif (/$GROUP_SEP/) {
545 8 $group->($_);
546 }
547 41 else { $_ }
548 } @_;
549 318 ▶ }) if $intact;
Branch: 1 branch
BranchTrueFalseTotal
if $intact 16 302 318
550 318 my @width;
551 318 ▶ if ($obj->table) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->table) { } 165 153 318
552 165 @width = map { length } $doc->lines;
553 } else {
554 2049 ▶ $doc->replace(sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
555 2049 my $line = shift;
556 2049 ▶ my $mark = $intact && $line =~ s/^$INTACT_SEP//;
Condition100%3/3
$intact && $line =~ s/^$App::ansicolumn::INTACT_SEP//u
!ll&&!rl&&r
19624146
MC/DC100%2/2
$intact && $line =~ s/^$App::ansicolumn::INTACT_SEP//u
$intact $line =~ s/^$App::ansicolumn::INTACT_SEP//u
Truth table100%3/3
A && B
A= $intactB= $line =~ s/^$App::ansicolumn::INTACT_SEP//u
ABresult
0X0
100
111
557 2049 ▶ my $group = $mark && $line =~ s/^($GROUP_MARK)// ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$mark && $line =~ s/^($App::ansicolumn::GROUP_MARK)//u ? : 28 2021 2049
Condition100%3/3
$mark and $line =~ s/^($App::ansicolumn::GROUP_MARK)//u
!ll&&!rl&&r
20031828
MC/DC100%2/2
$mark and $line =~ s/^($App::ansicolumn::GROUP_MARK)//u
$mark $line =~ s/^($App::ansicolumn::GROUP_MARK)//u
Truth table100%3/3
A and B
A= $markB= $line =~ s/^($App::ansicolumn::GROUP_MARK)//u
ABresult
0X0
100
111
558 2049 my($text, $width) = $obj->expand_tab($line);
559 2049 push @width, $width;
560 2049 ▶ $mark ? "$INTACT_SEP$group$text" : $text;
Branch: 1 branch
BranchTrueFalseTotal
$mark ? : 46 2003 2049
561 153 });
562 }
563 318 ▶ $doc->width(max(@width) // 0);
Condition100%2/2
&max(@width) // 0
l!l
3126
MC/DC100%1/1
&max(@width) // 0
&max(@width)
Truth table100%2/2
A
A= &max(@width)
Aresult
11
00
564 318 $doc;
565 }
566  
567 #
568 # Expand the tabs in a line. Returns the line and its width.
569 #
570 2049 ▶sub expand_tab {
Subroutine expand_tab: called CC=6 SCAR=18.0
Pod undocumented
571 2049 my $obj = shift;
572 2049 my $text = shift;
573 2049 my($result, $width) = ('', 0);
574 2049 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$text ne "" and do { do { () = ansi_fold($text, -1, "expand", 1); $result .= $folded; $width = $w if $w > $width; $result .= $1 if $rest =~ s/^(\f+)//u; $rest eq "" or $rest ne $text or die sprintf("Text is not consumed, at %s (please report this).\n", $rest =~ s/([^\x20-\x7e])/sprintf "\x{%02x}", ord $1;/egru); $text = $rest } } 2 2049 2051
575 2051 my($folded, $rest, $w) = ansi_fold $text, -1, expand => 1;
576 2051 $result .= $folded;
577 2051 ▶ $width = $w if $w > $width;
Branch: 1 branch
BranchTrueFalseTotal
if $w > $width 1949 102 2051
578 # ansi_fold stops before formfeeds in the middle of the text
579 2051 ▶ $result .= $1 if $rest =~ s/^(\f+)//;
Branch: 1 branch
BranchTrueFalseTotal
if $rest =~ s/^(\f+)//u 2 2049 2051
580 # every turn must take something from the text; otherwise
581 # this loop never ends
582 2051 ▶ $rest eq '' or $rest ne $text or die sprintf
Branch: 1 branch
BranchTrueFalseTotal
$rest eq "" or $rest ne $text or die sprintf("Text is not consumed, at %s (please report this).\n", $rest =~ s/([^\x20-\x7e])/sprintf "\x{%02x}", ord $1;/egru) 2051 0 2051
Condition66%2/3
$rest eq "" or $rest ne $text
l!l&&r!l&&!r
204920
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
ABresult
1X1
011
000
583 "Text is not consumed, at %s (please report this).\n",
584 0 $rest =~ s/([^\x20-\x7e])/sprintf '\\x{%02x}', ord $1/ger;
585 2051 $text = $rest;
586 } while ($text ne '');
587 2049 ($result, $width);
588 }
589  
590 131 ▶sub set_horizontal {
Subroutine set_horizontal: called CC=11 SCAR=24.2
Pod undocumented
591 131 my $obj = shift;
592 131 my $max_data_length = shift;
593  
594 303 ▶ use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
595 131 my $width = $obj->get_width - $obj->border_width(qw(left right));
596 131 ▶ my $unit = $obj->column_unit // 1;
Condition50%1/2
$obj->column_unit // 1
l!l
1310
MC/DC0%0/1
$obj->column_unit // 1
$obj->column_unit
Truth table50%1/2
A
A= $obj->column_unit
Aresult
11
00
597  
598 131 my $span;
599 my $panes;
600 131 ▶ my $claim = sum($max_data_length,
Condition66%2/3
$obj->border_width('center') || $obj->margin
l!l&&r!l&&!r
32990
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
ABresult
1X1
011
000
601 $obj->runin_margin,
602 $obj->border_width('center') || $obj->margin);
603 131 ▶ if ($obj->widen and not $obj->pane_width) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->widen and not $obj->pane_width) { } 59 72 131
Condition100%3/3
$obj->widen and not $obj->pane_width
!ll&&!rl&&r
70259
MC/DC100%2/2
$obj->widen and not $obj->pane_width
$obj->widen not $obj->pane_width
Truth table100%3/3
A and not(B)
A= $obj->widenB= not $obj->pane_width
ABresult
0X0
100
111
604 59 ▶ $panes = $obj->pane || $width / $claim || 1;
Condition80%4/5
$obj->pane || $width / $claim || 1
l!l
581
$obj->pane or $width / $claim
l!l&&r!l&&!r
5801
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
ABresult
1X1
011
000
605 59 $span = ($width + $obj->border_width('center')) / $panes;
606 } else {
607 72 ▶ $span = $obj->pane_width || roundup($claim, $unit);
Condition66%2/3
$obj->pane_width || &roundup($claim, $unit)
l!l&&r!l&&!r
22500
MC/DC0%0/2
$obj->pane_width || &roundup($claim, $unit)
$obj->pane_width &roundup($claim, $unit)
Truth table66%2/3
A || B
A= $obj->pane_widthB= &roundup($claim, $unit)
ABresult
1X1
011
000
608 72 ▶ $panes = $obj->pane || $width / $span || 1;
Condition100%5/5
$obj->pane || $width / $span || 1
l!l
711
$obj->pane or $width / $span
l!l&&r!l&&!r
52191
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
ABresult
1X1
011
000
609 }
610 131 $span -= $obj->border_width('center');
611 131 ▶ $span < 1 and die "Not enough space.\n";
Branch: 1 branch
BranchTrueFalseTotal
$span < 1 and die "Not enough space. " 0 131 131
612  
613 131 ($obj->span, $obj->panes) = ($span, $panes);
614  
615 131 return $obj;
616 }
617  
618 150 ▶sub set_contents {
Subroutine set_contents: called CC=9 SCAR=22.0
Pod undocumented
619 150 my $obj = shift;
620 150 my $fp = shift;
621 150 ▶ (my $cell_width = $obj->span) < 1
Branch: 1 branch
BranchTrueFalseTotal
(my $cell_width = $obj->span) < 1 and die "Not enough space. " 0 150 150
622 and die "Not enough space.\n";
623 # Fold long lines
624 150 ▶ my $intact = $obj->intact && !$obj->table;
Condition66%2/3
$obj->intact && !$obj->table
!ll&&!rl&&r
134016
MC/DC50%1/2
$obj->intact && !$obj->table
$obj->intact !$obj->table
Truth table66%2/3
A && not(B)
A= $obj->intactB= !$obj->table
ABresult
0X0
100
111
625 150 ▶ if ($obj->linestyle and $obj->linestyle ne 'none') {
Branch: 2 branches
BranchTrueFalseTotal
if ($obj->linestyle and $obj->linestyle ne 'none') { } 93 57 150
elsif ($intact) { } 9 48 57
Condition66%2/3
$obj->linestyle and $obj->linestyle ne "none"
!ll&&!rl&&r
57093
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"
ABresult
0X0
100
111
626 93 ▶ my $w = $fp->span // $cell_width;
Condition66%2/3
$fp->span // $cell_width
l!l&&r!l&&!r
2910
MC/DC0%0/2
$fp->span // $cell_width
$fp->span $cell_width
Truth table66%2/3
A // B
A= $fp->spanB= $cell_width
ABresult
1X1
011
000
627 93 ▶ my $fold = $obj->foldsub($w) or die;
Branch: 1 branch
BranchTrueFalseTotal
my $fold = $obj->foldsub($w) or die 93 0 93
628 93 ▶ if ($intact) {
Branch: 1 branch
BranchTrueFalseTotal
if ($intact) 7 86 93
629 # A line kept intact is laid out as it is: the room kept for
630 # run-in characters, word boundaries and line-break (kinsoku)
631 # rules are for text folded into lines. One that fits the
632 # pane is not folded, and a wider one is cut at the pane
633 # width, as a terminal does with a long line.
634 7 my $intact_fold = $obj->foldobj($w);
635 7 $intact_fold->configure(
636 margin => 0,
637 boundary => '',
638 linebreak => Text::ANSI::Fold::LINEBREAK_NONE,
639 );
640 7 my $line_fold = $fold;
641 7 my $truncate = $obj->linestyle eq 'truncate';
642 28 ▶ $fold = sub {
Subroutine __ANON__: called CC=6 SCAR=17.9
643 28 my $line = shift;
644 28 ▶ $line =~ s/^$INTACT_SEP// or return $line_fold->($line);
Branch: 1 branch
BranchTrueFalseTotal
$line =~ s/^$App::ansicolumn::INTACT_SEP//u or return &$line_fold($line) 14 14 28
645 14 ▶ my $group = $line =~ s/^($GROUP_MARK)// ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$line =~ s/^($App::ansicolumn::GROUP_MARK)//u ? : 7 7 14
646 14 my @chops = $intact_fold->text($line)->chops;
647 14 ▶ @chops = $chops[0] if $truncate;
Branch: 1 branch
BranchTrueFalseTotal
if $truncate 5 9 14
648 # a line folded from a line of a group is in the group
649 14 ▶ return @chops if $group eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $group eq "" 7 7 14
650 7 ▶ map { ($_ ? $GROUP_SEP : $group) . $chops[$_] } keys @chops;
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 1 7 8
651 7 };
652 }
653 93 $fp->replace($fold);
654 }
655 elsif ($intact) {
656 # the mark of a group stays, for the layout
657 9 ▶ $fp->replace(sub { $_[0] =~ s/^$INTACT_SEP//r });
Subroutine __ANON__: called CC=1 SCAR=0.0
658 }
659 150 return $obj;
660 }
661  
662 109 ▶sub set_vertical {
Subroutine set_vertical: called CC=3 SCAR=11.1
Pod undocumented
663 109 my $obj = shift;
664 109 my $dp = shift;
665 109 $obj->border_height = do {
666 218 sum map { length > 0 }
667 109 map { $obj->get_border($_) }
668 qw(top bottom);
669 };
670 109 ▶ $obj->height ||= div(int @$dp, $obj->panes) + $obj->border_height;
Condition66%2/3
$obj->height ||= div(int @$dp, $obj->panes) + $obj->border_height
l!l&&r!l&&!r
62470
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
ABresult
1X1
011
000
671 109 ▶ die "Not enough height.\n" if $obj->effective_height <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $obj->effective_height <= 0 0 109 109
672 109 return $obj;
673 }
674  
675 109 ▶sub page_out {
Subroutine page_out: called CC=6 SCAR=17.9
Pod undocumented
676 109 my $obj = shift;
677 109 my $name = shift;
678 # for the labels: the numbers of all the pages and the panes. A
679 # page is filled by panes, or by rows with --fillrows; the last
680 # one has the panes which the rest of the lines take.
681 {
682 109 my($lines, $panes, $height) = (scalar @_, $obj->panes, $obj->effective_height);
683 109 my $pages = roundup($lines, $panes * $height) / ($panes * $height);
684 109 my $rest = $lines - ($pages - 1) * $panes * $height;
685 109 ▶ my $last = $pages == 0 ? 0
Branch: 2 branches
BranchTrueFalseTotal
$pages == 0 ? : 0 109 109
$obj->fillrows ? : 1 108 109
686 : $obj->fillrows ? min($panes, $rest)
687 : roundup($rest, $height) / $height;
688 109 $obj->{_total_pages} = $pages;
689 109 ▶ $obj->{_total_panes} = $pages == 0 ? 0 : ($pages - 1) * $panes + $last;
Branch: 1 branch
BranchTrueFalseTotal
$pages == 0 ? : 0 109 109
690 }
691 109 my $column_out = $obj->_column_out;
692 109 ▶ for ($obj->current_page = 0; @_; $obj->current_page++) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 250 109 359
693 250 my @columns = grep { @$_ } do {
694 250 ▶ if ($obj->fillrows) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->fillrows) { } 1 249 250
695 1 xpose map { [ splice @_, 0, $obj->panes ] } 1 .. $obj->effective_height;
696 } else {
697 249 map { [ splice @_, 0, $obj->effective_height ] } 1 .. $obj->panes;
698 }
699 };
700 250 $column_out->({ names => [($name) x scalar @columns] }, @columns);
701 }
702 109 return $obj;
703 }
704  
705 1161 ▶sub color_border {
Subroutine color_border: called CC=1 SCAR=0.0
Pod undocumented
706 1161 my $obj = shift;
707 1161 $obj->color('BORDER', $obj->get_border(@_));
708 }
709  
710 258 ▶sub _parse_labels {
Subroutine _parse_labels: called CC=7 SCAR=19.8
711 258 my $hash = shift;
712 258 ▶ return 0 unless %$hash;
Branch: 1 branch
BranchTrueFalseTotal
unless %$hash 239 19 258
713 19 my %result;
714 19 ▶ while (my($key, $s) = each %$hash) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$hash) 26 19 45
715 26 ▶ next unless defined $s and $s ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $s and $s ne "" 0 26 26
Condition33%1/3
defined $s and $s ne ""
!ll&&!rl&&r
0026
MC/DC0%0/2
defined $s and $s ne ""
defined $s $s ne ""
Truth table33%1/3
A and B
A= defined $sB= $s ne ""
ABresult
0X0
100
111
716 26 my $offset;
717 26 ▶ if ($s =~ s/@(\d+)$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ s/@(\d+)$//u) 0 26 26
718 0 $offset = $1 + 0;
719 }
720 # the marks are empty where there is nothing in that direction,
721 # and a label left with no text by them is not shown
722 26 my $marked = $s =~ /%[LRUD]/;
723 26 $s =~ s/%n/%1\$d/g;
724 26 $s =~ s/%p/%2\$d/g;
725 26 $s =~ s/%f/%3\$s/g;
726 26 $s =~ s/%F/%4\$s/g;
727 26 $s =~ s/%N/%5\$d/g;
728 26 $s =~ s/%P/%6\$d/g;
729 26 $s =~ s/%L/%7\$s/g;
730 26 $s =~ s/%R/%8\$s/g;
731 26 $s =~ s/%U/%9\$s/g;
732 26 $s =~ s/%D/%10\$s/g;
733 26 $result{lc $key} = [ $offset, $s, $marked ];
734 }
735 19 ▶ %result ? \%result : 0;
Branch: 1 branch
BranchTrueFalseTotal
%result ? : 19 0 19
736 }
737  
738 # The marks of --label for the directions with something there, set
739 # by --mark
740 303 my %MARK = (
741 LEFT => '<', RIGHT => '>', UP => '^', DOWN => 'v',
742 # where there is nothing in that direction
743 LEFT_END => '', RIGHT_END => '', UP_END => '', DOWN_END => '',
744 );
745  
746 470 ▶sub _marks {
Subroutine _marks: called CC=4 SCAR=13.9
747 470 my $obj = shift;
748 470 ▶ $obj->{_mk} //= do {
Condition100%3/3
$obj->{"_mk"} //= do { my(%mark) = %MARK; while (() = each %{$obj->mark;}) { do { exists $mark{uc $name} or die "${name}: unknown mark\n"; $mark{uc $name} = $text }; } ; \%mark }
l!l&&r!l&&!r
1693001
MC/DC100%2/2
$obj->{"_mk"} //= do { my(%mark) = %MARK; while (() = each %{$obj->mark;}) { do { exists $mark{uc $name} or die "${name}: unknown mark\n"; $mark{uc $name} = $text }; } ; \%mark }
$obj->{"_mk"} do { my(%mark) = %MARK; while (() = each %{$obj->mark;}) { do { exists $mark{uc $name} or die "${name}: unknown mark\n"; $mark{uc $name} = $text }; } ; \%mark }
Truth table100%3/3
A //= B
A= $obj->{"_mk"}B= do { my(%mark) = %MARK; while (() = each %{$obj->mark;}) { do { exists $mark{uc $name} or die "${name}: unknown mark\n"; $mark{uc $name} = $text }; } ; \%mark }
ABresult
1X1
011
000
749 301 my %mark = %MARK;
750 301 ▶ while (my($name, $text) = each %{$obj->mark}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$obj->mark;}) 21 300 321
751 21 ▶ exists $mark{uc $name} or die "$name: unknown mark\n";
Branch: 1 branch
BranchTrueFalseTotal
exists $mark{uc $name} or die "${name}: unknown mark\n" 20 1 21
752 20 $mark{uc $name} = $text;
753 }
754 300 \%mark;
755 };
756 }
757  
758 # What a label has besides the numbers of the pane and the page: the
759 # numbers of all the panes and pages, and the marks. $p is the page
760 # (from 1), $i the pane in the row (from 0) of $npanes panes; a label
761 # of the page has no pane, and no mark for the left and the right.
762 169 ▶sub _label_more {
Subroutine _label_more: called CC=9 SCAR=22.1
763 169 my($obj, $p, $i, $npanes) = @_;
764 169 my $mark = $obj->_marks;
765 169 ▶ my $pages = $obj->{_total_pages} // 0;
Condition50%1/2
$obj->{"_total_pages"} // 0
l!l
1690
MC/DC0%0/1
$obj->{"_total_pages"} // 0
$obj->{"_total_pages"}
Truth table50%1/2
A
A= $obj->{"_total_pages"}
Aresult
11
00
766 [ $obj->{_total_panes} // 0, $pages,
767 (!defined $i ? '' : $i > 0 ? $mark->{LEFT} : $mark->{LEFT_END}),
768 (!defined $i ? '' : $i < $npanes - 1 ? $mark->{RIGHT} : $mark->{RIGHT_END}),
769 ($p > 1 ? $mark->{UP} : $mark->{UP_END}),
770 169 ▶ ($p < $pages ? $mark->{DOWN} : $mark->{DOWN_END}) ];
Branch: 6 branches
BranchTrueFalseTotal
!defined($i) ? : 16 153 169
$i > 0 ? : 19 134 153
!defined($i) ? : 16 153 169
$i < $npanes - 1 ? : 19 134 153
$p > 1 ? : 134 35 169
$p < $pages ? : 147 22 169
Condition50%1/2
$obj->{"_total_panes"} // 0
l!l
1690
MC/DC0%0/1
$obj->{"_total_panes"} // 0
$obj->{"_total_panes"}
Truth table50%1/2
A
A= $obj->{"_total_panes"}
Aresult
11
00
771 }
772  
773 # Overlay labels onto a border line string.
774 # $fs/$fe: fill region start/end.
775 # $ml/$mr: border margin accessible via @0.
776 # $n/$p: pane number / page number for sprintf expansion.
777 # $file: filename (path as given) - used as %3$s (basename) and %4$s (path as given).
778 # $more: the numbers of all the panes and pages (%N, %P), and the
779 # marks for the left, right, up and down (%L, %R, %U, %D), each empty
780 # where there is nothing in that direction.
781 169 ▶sub _overlay_labels {
Subroutine _overlay_labels: called CC=15 SCAR=27.7
782 169 my($obj, $str, $fs, $fe, $ml, $mr, $n, $p, $file, $more, $left, $center, $right) = @_;
783 303 ▶ use File::Basename qw(basename);
Subroutine BEGIN: called CC=1 SCAR=0.0
784 303 ▶ use Text::ANSI::Fold::Util qw(ansi_substr);
Subroutine BEGIN: called CC=1 SCAR=0.0
785 169 ▶ my $base = defined $file ? basename($file) : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $file ? : 169 0 169
786 169 for my $item (
787 5 ▶ [ $left, sub { $fs - $ml + ($_[0] // $ml) } ],
Subroutine __ANON__: called CC=2 SCAR=9.2
Condition33%1/3
$_[0] // $ml
l!l&&r!l&&!r
050
MC/DC0%0/2
$_[0] // $ml
$_[0] $ml
Truth table33%1/3
A // B
A= $_[0]B= $ml
ABresult
1X1
011
000
788 8 ▶ [ $right, sub { $fe + $mr - ($_[0] // $mr) - $_[1] } ],
Subroutine __ANON__: called CC=2 SCAR=9.2
Condition33%1/3
$_[0] // $mr
l!l&&r!l&&!r
080
MC/DC0%0/2
$_[0] // $mr
$_[0] $mr
Truth table33%1/3
A // B
A= $_[0]B= $mr
ABresult
1X1
011
000
789 240 ▶ [ $center, sub { $fs + int(($fe - $fs - $_[1]) / 2) } ],
Subroutine __ANON__: called CC=1 SCAR=0.0
790 ) {
791 507 my($spec, $pos_fn) = @$item;
792 507 ▶ next unless $spec;
Branch: 1 branch
BranchTrueFalseTotal
unless $spec 327 180 507
793 180 my $fmt = $spec->[1];
794 180 ▶ next unless defined $fmt && $fmt ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fmt and $fmt ne "" 0 180 180
Condition33%1/3
defined $fmt and $fmt ne ""
!ll&&!rl&&r
00180
MC/DC0%0/2
defined $fmt and $fmt ne ""
defined $fmt $fmt ne ""
Truth table33%1/3
A and B
A= defined $fmtB= $fmt ne ""
ABresult
0X0
100
111
795 180 ▶ my $text = $fmt =~ /%/ ? sprintf($fmt, $n, $p, $base, $file // '', @$more) : $fmt;
Branch: 1 branch
BranchTrueFalseTotal
$fmt =~ /%/u ? : 177 3 180
Condition50%1/2
$file // ""
l!l
1770
MC/DC0%0/1
$file // ""
$file
Truth table50%1/2
A
A= $file
Aresult
11
00
796 180 ▶ next if $spec->[2] and $text !~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $spec->[2] and not $text =~ /\S/u 22 158 180
Condition100%3/3
$spec->[2] and not $text =~ /\S/u
!ll&&!rl&&r
1332522
MC/DC100%2/2
$spec->[2] and not $text =~ /\S/u
$spec->[2] not $text =~ /\S/u
Truth table100%3/3
A and not(B)
A= $spec->[2]B= not $text =~ /\S/u
ABresult
0X0
100
111
797 158 my $lw = ansi_width($text);
798 158 my $pos = $pos_fn->($spec->[0], $lw);
799 # A label in the middle grows to the left first, when its number
800 # gets a digit more, then to the right, and so on. It is placed
801 # from the narrowest one, that of the first pane and page: a
802 # label longer than that by one is longer on the left.
803 158 ▶ if ($spec == ($center // 0) and $fmt =~ /%/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec == ($center // 0) and $fmt =~ /%/u) 142 16 158
Condition100%5/5
$spec == ($center // 0) and $fmt =~ /%/u
!ll&&!rl&&r
133142
$center // 0
l!l
14513
MC/DC100%2/2
$spec == ($center // 0) and $fmt =~ /%/u
$spec == ($center // 0) $fmt =~ /%/u
MC/DC100%1/1
$center // 0
$center
Truth table100%3/3
A and B
A= $spec == ($center // 0)B= $fmt =~ /%/u
ABresult
0X0
100
111
Truth table100%2/2
A
A= $center
Aresult
11
00
804 142 ▶ my $narrow = ansi_width(sprintf $fmt, 1, 1, $base, $file // '', @$more);
Condition50%1/2
$file // ""
l!l
1420
MC/DC0%0/1
$file // ""
$file
Truth table50%1/2
A
A= $file
Aresult
11
00
805 142 ▶ $pos = $pos_fn->($spec->[0], $narrow) - int(($lw - $narrow + 1) / 2)
Branch: 1 branch
BranchTrueFalseTotal
if $lw > $narrow 95 47 142
806 if $lw > $narrow;
807 }
808 158 my $label = $obj->color('BORDER_LABEL', $text);
809 158 $str = ansi_substr($str, $pos, $lw, $label);
810 }
811 169 $str;
812 }
813  
814 129 ▶sub _column_out {
Subroutine _column_out: called CC=15 SCAR=27.1
815 129 my $obj = shift;
816  
817 129 my %bd = map { $_ => $obj->get_border($_) } qw(top bottom);
818  
819 129 ▶ my $bl = $obj->{_bl} //= _parse_labels($obj->label);
Condition33%1/3
$obj->{"_bl"} //= _parse_labels($obj->label)
l!l&&r!l&&!r
01290
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)
ABresult
1X1
011
000
820 129 ▶ my $pbl = $obj->{_pbl} //= _parse_labels($obj->page_label);
Condition33%1/3
$obj->{"_pbl"} //= _parse_labels($obj->page_label)
l!l&&r!l&&!r
01290
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)
ABresult
1X1
011
000
821  
822 # pre-build pane label closures per pane index
823 129 my(@pane_top, @pane_bottom, @page_top, @page_bottom);
824 129 my($bw_l, $bw_c, $bw_r);
825 129 ▶ if ($bl || $pbl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bl or $pbl) 19 110 129
Condition100%3/3
$bl or $pbl
l!l&&r!l&&!r
154110
MC/DC100%2/2
$bl or $pbl
$bl $pbl
Truth table100%3/3
A or B
A= $blB= $pbl
ABresult
1X1
011
000
826 19 $bw_l = ansi_width($obj->get_border('left', 0));
827 19 $bw_c = ansi_width($obj->get_border('center', 0));
828 19 $bw_r = ansi_width($obj->get_border('right', 0));
829 19 my $span = $obj->{span};
830 19 for my $set ([ \@pane_top, \@page_top, qw(nw n ne) ],
831 [ \@pane_bottom, \@page_bottom, qw(sw s se) ]) {
832 38 my($pane_list, $page_list, @keys) = @$set;
833 38 ▶ if ($bl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bl) 30 8 38
834 30 my @g = map { $bl->{$_} } @keys;
835 30 ▶ if (grep { $_ } @g) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_;} @g) 17 13 30
836 17 my $fp = $bw_l;
837 17 for my $i (0 .. $obj->panes - 1) {
838 33 my($fs, $fe) = ($fp, $fp + $span);
839 153 ▶ push @$pane_list, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
840 153 my($line, $n0, $p, $name, $npanes) = @_;
841 153 $obj->_overlay_labels($line, $fs, $fe, $bw_l, $bw_r,
842 $n0 + $i + 1, $p, $name,
843 $obj->_label_more($p, $i, $npanes), @g);
844 33 };
845 33 $fp += $span + $bw_c;
846 }
847 }
848 }
849 38 ▶ if ($pbl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pbl) 8 30 38
850 8 my @g = map { $pbl->{$_} } @keys;
851 8 ▶ if (grep { $_ } @g) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_;} @g) 4 4 8
852 16 ▶ push @$page_list, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
853 16 my($line, $n0, $p, $name) = @_;
854 16 my $w = ansi_width($line);
855 16 $obj->_overlay_labels($line, 1, $w - 1, 1, 1,
856 $n0 + 1, $p, $name,
857 $obj->_label_more($p), @g);
858 4 };
859 }
860 }
861 }
862 }
863  
864 129 ▶ my $has_labels = @pane_top || @pane_bottom || @page_top || @page_bottom;
Condition88%8/9
@pane_top || @pane_bottom || @page_top || @page_bottom
l!l&&r!l&&!r
154110
@pane_top or @pane_bottom or @page_top
l!l&&r!l&&!r
150114
@pane_top or @pane_bottom
l!l&&r!l&&!r
114114
MC/DC75%3/4
@pane_top || @pane_bottom || @page_top || @page_bottom
@pane_top @pane_bottom @page_top @page_bottom
Truth table80%4/5
A or B or C || D
A= @pane_topB= @pane_bottomC= @page_topD= @page_bottom
ABCDresult
1XXX1
01XX1
001X1
00011
00000
865  
866 # pre-build border strings for 3 positions (top=0, middle=1, bottom=2)
867 129 my %border;
868 129 for my $pos (0, 1, 2) {
869 387 $border{$pos} = {
870 left => $obj->color_border('left', $pos),
871 center => $obj->color_border('center', $pos),
872 right => $obj->color_border('right', $pos),
873 };
874 }
875  
876 542 ▶ my $print_border = sub {
Subroutine __ANON__: called CC=7 SCAR=19.5
877 542 my($side, $pos, $span, $npanes, $n0, $p, $names,
878 $pane_labels, $page_labels) = @_;
879 542 ▶ return unless $bd{$side};
Branch: 1 branch
BranchTrueFalseTotal
unless $bd{$side} 204 338 542
880 338 my $bd = $border{$pos};
881 my $line = join '',
882 $bd->{left},
883 join($bd->{center},
884 416 map { $obj->color('BORDER', $bd{$side} x $_) } @$span),
885 338 $bd->{right};
886 338 ▶ if (@$pane_labels) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$pane_labels) 134 204 338
887 134 my $i = 0;
888 134 for (@{$pane_labels}[0 .. $npanes - 1]) {
889 153 ▶ $line = $_->($line, $n0, $p, $names->[$i++] // '', $npanes);
Condition50%1/2
$$names[$i++] // ""
l!l
1530
MC/DC0%0/1
$$names[$i++] // ""
$$names[$i++]
Truth table50%1/2
A
A= $$names[$i++]
Aresult
11
00
890 }
891 }
892 338 ▶ $line = $_->($line, $n0, $p, $names->[0] // '') for @$page_labels;
Condition50%1/2
$names->[0] // ""
l!l
160
MC/DC0%0/1
$names->[0] // ""
$names->[0]
Truth table50%1/2
A
A= $names->[0]
Aresult
11
00
893 338 print $line, "\n";
894 129 };
895  
896 271 ▶ sub {
Subroutine __ANON__: called CC=15 SCAR=27.1
897 271 ▶ my $opt = ref $_[0] eq 'HASH' ? shift : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 271 0 271
898 271 ▶ my @span = $opt->{span} ? @{$opt->{span}} : (($obj->{span}) x @_);
Branch: 1 branch
BranchTrueFalseTotal
$opt->{'span'} ? : 21 250 271
899 271 ▶ my $page = $obj->current_page // 0;
Condition50%1/2
$obj->current_page // 0
l!l
2710
MC/DC0%0/1
$obj->current_page // 0
$obj->current_page
Truth table50%1/2
A
A= $obj->current_page
Aresult
11
00
900 271 my $npanes = scalar @_;
901  
902 271 ▶ my($n0, $p) = $has_labels
Branch: 1 branch
BranchTrueFalseTotal
$has_labels ? : 147 124 271
Condition50%1/2
$obj->panes // 1
l!l
1470
MC/DC0%0/1
$obj->panes // 1
$obj->panes
Truth table50%1/2
A
A= $obj->panes
Aresult
11
00
903 ? ($page * ($obj->panes // 1), $page + 1) : ();
904 271 ▶ my $names = $opt->{names} // [];
Condition50%1/2
$opt->{"names"} // []
l!l
2710
MC/DC0%0/1
$opt->{"names"} // []
$opt->{"names"}
Truth table50%1/2
A
A= $opt->{"names"}
Aresult
11
00
905  
906 271 $print_border->('top', 0, \@span, $npanes, $n0, $p, $names,
907 \@pane_top, \@page_top);
908  
909 # content rows
910 271 my $max = max map $#{$_}, @_;
911 271 for my $i (0 .. $max) {
912 my $pos = !$bd{top} && $i == 0 ? 0
913 1171 ▶ : !$bd{bottom} && $i == $max ? 2
Branch: 2 branches
BranchTrueFalseTotal
!$bd{'top'} && $i == 0 ? : 102 1069 1171
!$bd{'bottom'} && $i == $max ? : 92 977 1069
Condition100%6/6
not $bd{"top"} and $i == 0
!ll&&!rl&&r
632437102
not $bd{"bottom"} and $i == $max
!ll&&!rl&&r
63234592
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
ABresult
0X0
100
111
Truth table100%3/3
not(A) and B
A= not $bd{"bottom"}B= $i == $max
ABresult
0X0
100
111
914 : 1;
915 1171 my $bd = $border{$pos};
916 1171 my @span = @span;
917 my @panes = map {
918 1171 ▶ @$_ ? ansi_sprintf("%-*s", shift @span, shift @$_) : ();
Branch: 1 branch
BranchTrueFalseTotal
@$_ ? : 2327 32 2359
919 } @_;
920 # --pane-osc: a pane starts where the OSC is
921 1171 ▶ my $mark = $obj->pane_osc && $i == 0 ? $PANE_OSC : '';
Branch: 1 branch
BranchTrueFalseTotal
$obj->pane_osc && $i == 0 ? : 2 1169 1171
Condition100%3/3
$obj->pane_osc and $i == 0
!ll&&!rl&&r
116722
MC/DC100%2/2
$obj->pane_osc and $i == 0
$obj->pane_osc $i == 0
Truth table100%3/3
A and B
A= $obj->pane_oscB= $i == 0
ABresult
0X0
100
111
922 1171 print $bd->{left};
923 print join $bd->{center},
924 1171 map { $mark . $obj->color('TEXT', $_) } @panes;
925 1171 print $bd->{right};
926 1171 print "\n";
927 }
928  
929 271 $print_border->('bottom', 2, \@span, $npanes, $n0, $p, $names,
930 \@pane_bottom, \@page_bottom);
931 271 $obj;
932 129 };
933 }
934  
935 281 ▶sub _numbers {
Subroutine _numbers: called CC=1 SCAR=0.0
936 281 require Getopt::EX::Numbers;
937 281 Getopt::EX::Numbers->new(min => 1, @_);
938 }
939  
940 165 ▶sub table_out {
Subroutine table_out: called CC=69 SCAR=42.6
Pod undocumented
941 165 my $obj = shift;
942 165 ▶ return unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 164 165
943 # A LINE SEPARATOR is not a space between columns: it breaks a cell.
944 164 my $space = qr/[^\S\x{2028}]/;
945 164 my $split = do {
946 164 ▶ if ($obj->separator eq ' ') {
Branch: 2 branches
BranchTrueFalseTotal
if ($obj->separator eq ' ') { } 11 153 164
elsif ($obj->regex_sep) { } 0 153 153
947 # /\s+/a does not work as expected, maybe perl's bug
948 11 ▶ $obj->ignore_space ? ' ' : qr/\s{1,9999}/a;
Branch: 1 branch
BranchTrueFalseTotal
$obj->ignore_space ? : 11 0 11
949 } elsif ($obj->regex_sep) {
950 0 qr($obj->{separator});
951 } else {
952 153 qr/[\Q$obj->{separator}\E]/;
953 }
954 };
955 my @lines = map {
956 # split ' ' takes a LINE SEPARATOR as a space: do as it does,
957 # without it
958 164 ▶ $split eq ' ' && /\x{2028}/
Branch: 1 branch
BranchTrueFalseTotal
$split eq ' ' && /\x{2028}/u ? : 1 460 461
Condition100%3/3
$split eq " " and /\x{2028}/u
!ll&&!rl&&r
398621
MC/DC100%2/2
$split eq " " and /\x{2028}/u
$split eq " " /\x{2028}/u
Truth table100%3/3
A and B
A= $split eq " "B= /\x{2028}/u
ABresult
0X0
100
111
959 ? [ split /$space+/, s/\A$space+//r, $obj->table_columns_limit ]
960 : [ split $split, $_, $obj->table_columns_limit ];
961 } @_;
962 164 ▶ if (my $spec = $obj->table_remove) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $spec = $obj->table_remove) 137 27 164
963 137 my $max_cols = max map { scalar @$_ } @lines;
964 274 my %discard = map { ($_ - 1) => 1 }
965 137 map { _numbers(max => $max_cols)->parse($_)->sequence }
966 split /,/, $spec;
967 137 my @keep = grep { !$discard{$_} } 0 .. $max_cols - 1;
968 137 @$_ = @$_[@keep] for @lines;
969 }
970 164 ▶ if ($obj->table_squeeze) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->table_squeeze) 1 163 164
971 5 ▶ my @keep = grep { my $c = $_; any { length $_->[$c] } @lines }
Subroutine __ANON__: called CC=1 SCAR=0.0
972 1 0 .. max(map { $#$_ } @lines);
973 1 @$_ = @$_[@keep] for @lines;
974 }
975 #
976 # -w / --cell: fit table into width, wrapping over-wide cells
977 #
978 164 my @fixed_width;
979 164 my $tight = 0; # --table-tight: spaces the last column may lose
980 164 my @continued; # [row][col] 1 for a wrapped cell's 2nd+ line,
981 # 2 for a line after a LINE SEPARATOR
982 my @length; # [row][col] width of the cell
983 164 ▶ if (not $obj->table_align and not $obj->table_tabs
Branch: 2 branches
BranchTrueFalseTotal
if (not $obj->table_align || $obj->table_tabs and defined $obj->width || $obj->cell) { } 132 32 164
elsif (grep {/\x{2028}/u;} map({@$_;} @lines)) { } 10 22 32
Condition88%8/9
not $obj->table_align || $obj->table_tabs and defined $obj->width || $obj->cell
!ll&&!rl&&r
428132
$obj->table_align || $obj->table_tabs
l!l&&r!l&&!r
40160
defined $obj->width or $obj->cell
l!l&&r!l&&!r
1201228
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
ABCDresult
1XXX0
01XX0
00000
001X1
00011
984 and (defined $obj->width or $obj->cell)) {
985 132 my @cw = map { [ map { cell_width($_) } @$_ ] } @lines;
986 132 my @content = map { max @$_ } xpose @cw;
987 132 ▶ my $overhead = $obj->item_format ? ansi_width(ansi_sprintf($obj->item_format, '')) : 0;
Branch: 1 branch
BranchTrueFalseTotal
$obj->item_format ? : 99 33 132
988 132 my $sep = ansi_width($obj->output_separator);
989 132 ▶ my $fixed = $obj->cell ? parse_cell_spec($obj->cell, \@content) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$obj->cell ? : 13 119 132
990 132 ▶ my $budget = defined $obj->width ? $obj->get_width - $sep * (@content - 1) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $obj->width ? : 120 12 132
991 # --table-tight: the spaces at the end of the item format are not
992 # counted in the last column; they are left out below when the
993 # table does not fit the width with them
994 132 ▶ if (defined $budget and $obj->table_tight and $obj->item_format =~ /%s( +)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $budget and $obj->table_tight and $obj->item_format =~ /%s( +)\z/u) 85 47 132
Condition100%6/6
defined $budget and $obj->table_tight and $obj->item_format =~ /%s( +)\z/u
!ll&&!rl&&r
212685
defined $budget and $obj->table_tight
!ll&&!rl&&r
129111
MC/DC100%3/3
defined $budget and $obj->table_tight and $obj->item_format =~ /%s( +)\z/u
defined $budget $obj->table_tight $obj->item_format =~ /%s( +)\z/u
Truth table100%4/4
A and B and C
A= defined $budgetB= $obj->table_tightC= $obj->item_format =~ /%s( +)\z/u
ABCresult
0XX0
10X0
1100
1111
995 85 $budget += $tight = length $1;
996 }
997 132 @lines = $obj->fit_table_rows(\@lines, \@cw, \@content, $budget, $overhead, $fixed, 4, \@continued, \@length);
998 132 ▶ @fixed_width = map { defined $_ ? $_ + $overhead : undef } @$fixed if $fixed;
Branch: 2 branches
BranchTrueFalseTotal
if $fixed 13 119 132
defined $_ ? : 18 7 25
999 }
1000 642 elsif (grep { /\x{2028}/ } map { @$_ } @lines) {
1001 # no wrapping, but a cell has lines
1002 10 my @cw = map { [ map { cell_width($_) } @$_ ] } @lines;
1003 10 @lines = $obj->expand_table_rows(\@lines, \@cw, [], [], \@continued, \@length);
1004 }
1005 164 my @blank = map { [ map { $_ eq '' } @$_ ] } @lines;
1006 164 ▶ @length = map { [ map { ansi_width $_ } @$_ ] } @lines unless @length;
Branch: 1 branch
BranchTrueFalseTotal
unless @length 22 142 164
1007 164 ▶ if (my $fmt = $obj->item_format) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fmt = $obj->item_format) 107 57 164
1008 # A format with a single %s only adds text around the cell, so
1009 # it is put by hand and the width of the text is added.
1010 107 ▶ if (my($pre, $post) = $fmt =~ /\A([^%]*+)%s([^%]*+)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $fmt =~ /\A([^%]*+)%s([^%]*+)\z/u) { } 107 0 107
1011 107 my $add = ansi_width($pre . $post);
1012 # --table-tight: the last column has a shorter format when
1013 # the table is wider than the width
1014 107 my($last, $cut) = (-1, 0);
1015 107 ▶ if ($tight) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tight) 85 22 107
1016 85 my @w = map { max @$_ } xpose @length;
1017 85 ▶ @w = map { max $w[$_] + $add, $fixed_width[$_] // 0 } keys @w;
Condition50%1/2
$fixed_width[$_] // 0
l!l
0353
MC/DC0%0/1
$fixed_width[$_] // 0
$fixed_width[$_]
Truth table50%1/2
A
A= $fixed_width[$_]
Aresult
11
00
1018 85 my $over = sum(@w) + ansi_width($obj->output_separator) * $#w - $obj->get_width;
1019 85 ▶ if ($over > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($over > 0) 71 14 85
1020 71 ($last, $cut) = ($#w, min($tight, $over));
1021 71 ▶ $fixed_width[$last] -= $cut if defined $fixed_width[$last];
Branch: 1 branch
BranchTrueFalseTotal
if defined $fixed_width[$last] 0 71 71
1022 }
1023 }
1024 107 my @post = ($post, substr($post, 0, length($post) - $cut));
1025 107 for my $r (keys @lines) {
1026 1210 my $line = $lines[$r];
1027 1210 for my $c (keys @$line) {
1028 5537 ▶ my $short = $c == $last ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$c == $last ? : 1079 4458 5537
1029 5537 ▶ $line->[$c] = $pre . ($line->[$c] // '') . $post[$short];
Condition50%1/2
$line->[$c] // ""
l!l
55370
MC/DC0%0/1
$line->[$c] // ""
$line->[$c]
Truth table50%1/2
A
A= $line->[$c]
Aresult
11
00
1030 5537 $length[$r][$c] += $add - $short * $cut;
1031 }
1032 }
1033 } else {
1034 0 for my $line (@lines) {
1035 0 @$line = map { ansi_sprintf($fmt, $_) } @$line;
1036 }
1037 0 @length = map { [ map { ansi_width $_ } @$_ ] } @lines;
1038 }
1039 }
1040 #
1041 # --table-wrap-mark: put the mark where a continuation line starts,
1042 # in place of leading pad as far as the mark is wide. A line which
1043 # starts after a LINE SEPARATOR is not a continuation and has none.
1044 # --table-cell-mark: same for the first line of every non-empty cell
1045 # in a column that has a wrapped cell, so that a row start can be
1046 # told from a continuation line; the first --table-head rows (a
1047 # wrapped row counting as one) are a header and get no mark.
1048 #
1049 164 my @marked; # [row][col] mark string, for alignment below
1050 42 ▶ my $put_mark = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
1051 42 my($mark, $r, $c) = @_;
1052 42 my $mw = ansi_width($mark);
1053 42 $lines[$r][$c] =~ s/^\h{0,$mw}/$mark/;
1054 42 $length[$r][$c] = ansi_width($lines[$r][$c]);
1055 42 $marked[$r][$c] = $mark;
1056 164 };
1057 164 ▶ if ((my $mark = $obj->table_wrap_mark) ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $mark = $obj->table_wrap_mark) ne "") 6 158 164
1058 6 for my $r (grep { $continued[$_] } keys @continued) {
1059 9 ▶ $put_mark->($mark, $r, $_) for grep { ($continued[$r][$_] // 0) == 1 } keys @{$continued[$r]};
Condition100%2/2
$continued[$r][$_] // 0
l!l
99
MC/DC100%1/1
$continued[$r][$_] // 0
$continued[$r][$_]
Truth table100%2/2
A
A= $continued[$r][$_]
Aresult
11
00
1060 }
1061 }
1062 164 ▶ if ((my $mark = $obj->table_cell_mark) ne '' and grep { $_ } @continued) {
Branch: 1 branch
BranchTrueFalseTotal
if ((my $mark = $obj->table_cell_mark) ne "" and grep {$_;} @continued) 14 150 164
Condition100%3/3
(my $mark = $obj->table_cell_mark) ne "" and grep {$_;} @continued
!ll&&!rl&&r
148214
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
ABresult
0X0
100
111
1063 14 my %wrapped;
1064 14 for my $r (grep { $continued[$_] } keys @continued) {
1065 22 $wrapped{$_}++ for grep { $continued[$r][$_] } keys @{$continued[$r]};
1066 }
1067 14 my $row = 0; # logical row number of a non-continuation line
1068 14 for my $r (grep { not $continued[$_] } keys @lines) {
1069 38 ▶ next if $row++ < $obj->table_head;
Branch: 1 branch
BranchTrueFalseTotal
if $row++ < $obj->table_head 6 32 38
1070 32 ▶ $put_mark->($mark, $r, $_) for grep { $wrapped{$_} and not $blank[$r][$_] } keys @{$lines[$r]};
Condition66%2/3
$wrapped{$_} && !$blank[$r][$_]
!ll&&!rl&&r
30034
MC/DC50%1/2
$wrapped{$_} && !$blank[$r][$_]
$wrapped{$_} !$blank[$r][$_]
Truth table66%2/3
A && not(B)
A= $wrapped{$_}B= !$blank[$r][$_]
ABresult
0X0
100
111
1071 }
1072 }
1073 164 my @max = map { max @$_ } xpose @length;
1074 164 for my $i (grep { defined $fixed_width[$_] } keys @fixed_width) {
1075 18 ▶ $max[$i] = max($max[$i] // 0, $fixed_width[$i]);
Condition50%1/2
$max[$i] // 0
l!l
180
MC/DC0%0/1
$max[$i] // 0
$max[$i]
Truth table50%1/2
A
A= $max[$i]
Aresult
11
00
1076 }
1077 164 ▶ if ($obj->table_align) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->table_align) 4 160 164
1078 4 my @tabs = map { roundup $_, $obj->column_unit, $obj->margin } @max;
1079 #
1080 # --table-tabs
1081 #
1082 4 ▶ if ($obj->table_tabs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($obj->table_tabs) 1 3 4
1083 1 my $cu = $obj->column_unit;
1084 1 ▶ while (my($lx, $l) = each @lines) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each @lines) 10 1 11
1085 10 ▶ while (my($fx, $f) = each @$l) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each @$l) 100 10 110
1086 100 print $f;
1087 100 ▶ if ($fx == $#{$l}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fx == $#{$l;}) { } 10 90 100
1088 10 print "\n";
1089 } else {
1090 90 print "\t" x div($tabs[$fx] - $length[$lx][$fx], $cu);
1091 }
1092 }
1093 }
1094 1 return $obj;
1095 }
1096 3 @max = map { $_ - $obj->margin } @tabs;
1097 3 $obj->output_separator = ' ' x $obj->margin;
1098 }
1099 my @align = newlist(count => int @max, default => '-',
1100 [ map --$_, map {
1101 5 _numbers(max => int @max)->parse($_)->sequence
1102 } split /,/, $obj->table_right ] => '',
1103 [ map --$_, map {
1104 163 _numbers(max => int @max)->parse($_)->sequence
1105 } split /,/, $obj->table_center ] => '=');
1106 163 ▶ my @format = map { $align[$_] eq '=' ? "%-$max[$_]s" : "%$align[$_]$max[$_]s" } keys @max;
Branch: 1 branch
BranchTrueFalseTotal
$align[$_] eq '=' ? : 2 549 551
1107 # --table-group: the lines of a row are joined by GROUP SEPARATOR,
1108 # so that --intact keeps them in one pane
1109 163 my $group = $obj->table_group;
1110 163 my $printed = 0;
1111 1561 ▶ my $out = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
1112 1561 my($r, $text) = @_;
1113 1561 ▶ print !$printed++ ? '' : $group && $continued[$r] ? $GROUP_SEP : "\n", $text;
Branch: 2 branches
BranchTrueFalseTotal
!$printed++ ? : 163 1398 1561
$group && $continued[$r] ? : 2 1396 1398
Condition100%3/3
$group and $continued[$r]
!ll&&!rl&&r
139422
MC/DC100%2/2
$group and $continued[$r]
$group $continued[$r]
Truth table100%3/3
A and B
A= $groupB= $continued[$r]
ABresult
0X0
100
111
1114 163 };
1115 163 for my $r (keys @lines) {
1116 1561 my $line = $lines[$r];
1117 1561 ▶ next unless @$line;
Branch: 1 branch
BranchTrueFalseTotal
unless @$line 0 1561 1561
1118 1561 for my $i (keys @$line) {
1119 # Pad right/center aligned cells here, keeping a mark at the
1120 # left edge of the cell rather than in front of the content.
1121 6593 ▶ next if $align[$i] eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $align[$i] eq "-" 6526 67 6593
1122 67 my $pad = $max[$i] - $length[$r][$i];
1123 67 ▶ next if $pad <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $pad <= 0 34 33 67
1124 33 ▶ $pad = int($pad / 2) if $align[$i] eq '=';
Branch: 1 branch
BranchTrueFalseTotal
if $align[$i] eq "=" 8 25 33
1125 33 $line->[$i] = (' ' x $pad) . $line->[$i];
1126 33 $length[$r][$i] += $pad;
1127 33 ▶ if (my $mark = $marked[$r][$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $mark = $marked[$r][$i]) 7 26 33
1128 7 $line->[$i] =~ s/^(\h+)\Q$mark\E/$mark$1/;
1129 }
1130 }
1131 1561 my @fmt = @format[keys @$line];
1132 1561 ▶ $fmt[$#fmt] = '%s' if $align[$#fmt] ne '' and !$obj->padding;
Branch: 1 branch
BranchTrueFalseTotal
if $align[$#fmt] ne "" and not $obj->padding 1442 119 1561
Condition100%3/3
$align[$#fmt] ne "" and not $obj->padding
!ll&&!rl&&r
28911442
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
ABresult
0X0
100
111
1133 1561 ▶ if (grep { not defined } @$line) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not defined $_;} @$line) 0 1561 1561
1134 0 my $format = join($obj->output_separator, @fmt);
1135 0 $out->($r, ansi_sprintf $format, @$line);
1136 0 next;
1137 }
1138 # the width of every cell is known: pad it here
1139 my @out = map {
1140 1561 my $space = ' ' x ($max[$_] - $length[$r][$_]);
1141 6593 ▶ $fmt[$_] eq '%s' ? $line->[$_]
Branch: 2 branches
BranchTrueFalseTotal
$fmt[$_] eq '%s' ? : 1442 5151 6593
$align[$_] eq '' ? : 58 5093 5151
1142 : $align[$_] eq '' ? $space . $line->[$_]
1143 : $line->[$_] . $space;
1144 } keys @$line;
1145 1561 $out->($r, join($obj->output_separator, @out));
1146 }
1147 163 ▶ print "\n" if $printed;
Branch: 1 branch
BranchTrueFalseTotal
if $printed 163 0 163
1148 163 return $obj;
1149 }
1150  
1151 303 1;
1152  
1153 __END__
↑ Summary lib/App/ansicolumn/Table.pm »