TablePrint.pm

filter: Statementstmt 9.0% 53 / 587 Branchbran 0.3% 1 / 310 Conditioncond 0.0% 0 / 69 MC/DCmcdc 0.0% 0 / 45 Subroutinesub 45.7% 16 / 35 Podpod 100% 2 / 2 totaltotal 6.8% 72 / 1048 CC 200 SCAR 61.6
CC
200
Cov
6%
__calc_avail_col_width
870.0
__cols_to_string
870.0
print_table
756.0
CRAP 474.3
↑ Summary TablePrint/ProgressBar.pm »
1 package Term::TablePrint;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use 5.16.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.180';
8 1 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 our @EXPORT_OK = qw( print_table );
10  
11 1 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use List::Util qw( sum max );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Scalar::Util qw( looks_like_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use Term::Choose qw( choose );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Term::Choose::Constants qw( EXTRA_W PH SGR_ES );
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use Term::Choose::LineFold qw( print_columns cut_to_printwidth adjust_to_printwidth line_fold );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use Term::Choose::Screen qw( hide_cursor show_cursor );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use Term::Choose::ValidateOptions qw( validate_options );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Term::Choose::Util qw( get_term_width insert_sep );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Term::TablePrint::ProgressBar qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24  
25 BEGIN {
26 1 ▶ if ( $^O eq 'MSWin32' ) {
Subroutine BEGIN: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 1 1
27 0 require Win32::Console::ANSI;
28 }
29 }
30  
31  
32 sub new {
33 0 ▶ my $class = shift;
Subroutine new: not called CC=6 SCAR=37.4
Pod documented
34 0 ▶ croak "new: called with " . @_ . " arguments - 0 or 1 arguments expected." if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 0 0
35 0 my ( $opt ) = @_;
36  
37 #####
38 #choose( [ 'Continue with ENTER' ], { prompt => "The 'min_col_width' option has been renamed to 'col_trim_threshold'." } ) if exists $opt->{min_col_width}; # 21.02.2026
39 #choose( [ 'Continue with ENTER' ], { prompt => "The 'max_width_exp' option has been renamed to 'expanded_max_width'." } ) if exists $opt->{max_width_exp}; # 21.02.2026
40 #####
41  
42 0 my $instance_defaults = _defaults();
43 0 ▶ if ( defined $opt ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt) 0 0 0
44 0 ▶ croak "new: The (optional) argument is not a HASH reference." if ref $opt ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opt ne "HASH" 0 0 0
45 0 validate_options( _valid_options(), $opt, 'new' );
46 0 for my $key ( keys %$opt ) {
47 0 ▶ $instance_defaults->{$key} = $opt->{$key} if defined $opt->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->{$key} 0 0 0
48 }
49 }
50 0 my $self = bless $instance_defaults, $class;
51 0 $self->{backup_instance_defaults} = { %$instance_defaults };
52 0 return $self;
53 }
54  
55  
56 sub _valid_options {
57 return {
58 0 ▶ codepage_mapping => '[ 0 1 ]',
Subroutine _valid_options: not called CC=1 SCAR=6.9
59 expanded_line_spacing => '[ 0 1 ]',
60 hide_cursor => '[ 0 1 ]', # documentation
61 mouse => '[ 0 1 ]',
62 squash_spaces => '[ 0 1 ]',
63 table_expand => '[ 0 1 ]',
64 trunc_fract_first => '[ 0 1 ]',
65 pad_row_edges => '[ 0 1 ]',
66 binary_filter => '[ 0 1 2 ]',
67 choose_columns => '[ 0 1 2 ]',
68 color => '[ 0 1 2 ]',
69 page => '[ 0 1 2 ]', # undocumented
70 search => '[ 0 1 2 ]', #
71 keep => '[ 1-9 ][ 0-9 ]*', # undocumented
72 col_trim_threshold => '[ 0-9 ]+',
73 max_width_exp => '[ 0-9 ]+', # now expanded_max_width # 21.02.2026
74 expanded_max_width => '[ 0-9 ]+',
75 max_rows => '[ 0-9 ]+',
76 min_col_width => '[ 0-9 ]+', # now col_trim_threshold # 21.02.2026
77 progress_bar => '[ 0-9 ]+',
78 tab_width => '[ 0-9 ]+',
79 binary_string => 'Str', ##
80 decimal_separator => 'Str',
81 footer => 'Str',
82 info => 'Str',
83 prompt => 'Str',
84 undef => 'Str',
85 #thsd_sep => 'Str',
86 };
87 }
88  
89  
90 sub _defaults {
91 return {
92 0 ▶ binary_filter => 0,
Subroutine _defaults: not called CC=1 SCAR=6.9
93 binary_string => 'BNRY',
94 choose_columns => 0,
95 codepage_mapping => 0,
96 col_trim_threshold => 30,
97 color => 0,
98 decimal_separator => '.',
99 expanded_line_spacing => 1,
100 #expanded_max_width => undef,
101 #footer => undef,
102 hide_cursor => 1,
103 #info => undef,
104 #keep => undef,
105 max_rows => 0,
106 mouse => 0,
107 pad_row_edges => 0,
108 page => 2, ##
109 progress_bar => 40000,
110 prompt => '',
111 search => 1,
112 squash_spaces => 0,
113 tab_width => 2,
114 table_expand => 1,
115 trunc_fract_first => 1,
116 undef => '',
117 thsd_sep => ',', #
118 }
119 }
120  
121  
122 sub __reset {
123 0 ▶ my ( $self ) = @_;
Subroutine __reset: not called CC=7 SCAR=40.3
124 0 ▶ if ( $self->{hide_cursor} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"hide_cursor"}) 0 0 0
125 0 print show_cursor();
126 }
127 0 ▶ if ( exists $self->{backup_instance_defaults} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"backup_instance_defaults"}) 0 0 0
128 0 my $instance_defaults = $self->{backup_instance_defaults};
129 0 for my $key ( keys %$self ) {
130 0 ▶ if ( $key eq 'plugin' || $key eq 'backup_instance_defaults' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key eq 'plugin' or $key eq 'backup_instance_defaults') { } 0 0 0
elsif (exists $instance_defaults->{$key}) { } 0 0 0
Condition0%0/3
$key eq "plugin" or $key eq "backup_instance_defaults"
l!l&&r!l&&!r
000
MC/DC0%0/2
$key eq "plugin" or $key eq "backup_instance_defaults"
$key eq "plugin" $key eq "backup_instance_defaults"
Truth table0%0/3
A or B
A= $key eq "plugin"B= $key eq "backup_instance_defaults"
ABresult
1X1
011
000
131 0 next;
132 }
133 elsif ( exists $instance_defaults->{$key} ) {
134 0 $self->{$key} = $instance_defaults->{$key};
135 }
136 else {
137 0 delete $self->{$key};
138 }
139 }
140 }
141 }
142  
143  
144 1 my $last_write_table = 0;
145 1 my $window_width_changed = 1;
146 1 my $enter_search_string = 2;
147 1 my $from_filtered_table = 3;
148 1 my $choose_and_print = 4;
149  
150  
151 sub print_table {
152 0 ▶ if ( ref $_[0] ne __PACKAGE__ ) {
Subroutine print_table: not called CC=27 SCAR=66.3
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] ne __PACKAGE__) 0 0 0
153 0 my $ob = __PACKAGE__->new();
154 0 delete $ob->{backup_instance_defaults};
155 0 return $ob->print_table( @_ );
156 }
157 0 my $self = shift;
158 0 my ( $tbl_orig, $opt ) = @_;
159 0 ▶ croak "print_table: called with " . @_ . " arguments - 1 or 2 arguments expected." if @_ < 1 || @_ > 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 1 or @_ > 2 0 0 0
Condition0%0/3
@_ < 1 or @_ > 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ < 1 or @_ > 2
@_ < 1 @_ > 2
Truth table0%0/3
A or B
A= @_ < 1B= @_ > 2
ABresult
1X1
011
000
160 0 ▶ croak "print_table: requires an ARRAY reference as its first argument." if ref $tbl_orig ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $tbl_orig ne "ARRAY" 0 0 0
161 0 ▶ if ( defined $opt ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt) 0 0 0
162 0 ▶ croak "print_table: the (optional) second argument is not a HASH reference." if ref $opt ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opt ne "HASH" 0 0 0
163  
164 #####
165 #choose( [ 'Continue with ENTER' ], { prompt => "The 'min_col_width' option has been renamed to 'col_trim_threshold'." } ) if exists $opt->{min_col_width}; # 21.02.2026
166 #choose( [ 'Continue with ENTER' ], { prompt => "The 'max_width_exp' option has been renamed to 'expanded_max_width'." } ) if exists $opt->{max_width_exp}; # 21.02.2026
167 #####
168  
169 0 validate_options( _valid_options(), $opt, 'print_table' );
170 0 for my $key ( keys %$opt ) {
171 0 ▶ $self->{$key} = $opt->{$key} if defined $opt->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->{$key} 0 0 0
172 }
173 }
174 0 local $| = 1;
175 local $SIG{INT} = sub {
176 0 ▶ $self->__reset();
Subroutine __ANON__: not called CC=1 SCAR=6.9
177 0 print "\n";
178 0 exit;
179 0 };
180 0 ▶ if ( print_columns( $self->{decimal_separator} ) != 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (print_columns($self->{"decimal_separator"}) != 1) 0 0 0
181 0 $self->{decimal_separator} = '.';
182 }
183 0 ▶ if ( $self->{decimal_separator} ne '.' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"decimal_separator"} ne ".") 0 0 0
184 0 $self->{thsd_sep} = '_';
185 }
186 0 ▶ if ( $self->{hide_cursor} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"hide_cursor"}) 0 0 0
187 0 print hide_cursor();
188 # 'choose' functions: Deactivate 'hide_cursor', because if 'hide_cursor' is
189 # activated (default), 'choose' activates the cursor before returning.
190 }
191 0 ▶ if ( ! @$tbl_orig || ! @{$tbl_orig->[0]} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$tbl_orig and @{$tbl_orig->[0];}) 0 0 0
Condition0%0/3
@$tbl_orig and @{$tbl_orig->[0];}
!ll&&!rl&&r
000
MC/DC0%0/2
@$tbl_orig and @{$tbl_orig->[0];}
@$tbl_orig @{$tbl_orig->[0];}
Truth table0%0/3
A and B
A= @$tbl_origB= @{$tbl_orig->[0];}
ABresult
0X0
100
111
192 0 my $message;
193 0 ▶ if ( ! @$tbl_orig ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @$tbl_orig) { } 0 0 0
194 0 $message = "'print_table': Empty table without header row!";
195 }
196 else {
197 0 $message = "'print_table': No columns!";
198 }
199 # Choose
200 0 choose(
201 [ 'Close with ENTER' ],
202 { prompt => $message, hide_cursor => 0 }
203 );
204 0 $self->__reset();
205 0 return;
206 }
207 0 $self->{_last_index} = $#$tbl_orig; ##
208 0 ▶ if ( $self->{max_rows} && $self->{_last_index} > $self->{max_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"max_rows"} and $self->{"_last_index"} > $self->{"max_rows"}) 0 0 0
Condition0%0/3
$self->{"max_rows"} and $self->{"_last_index"} > $self->{"max_rows"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"max_rows"} and $self->{"_last_index"} > $self->{"max_rows"}
$self->{"max_rows"} $self->{"_last_index"} > $self->{"max_rows"}
Truth table0%0/3
A and B
A= $self->{"max_rows"}B= $self->{"_last_index"} > $self->{"max_rows"}
ABresult
0X0
100
111
209 0 $self->{_info_row} = sprintf( 'Limited to %s rows', insert_sep( $self->{max_rows}, $self->{thsd_sep} ) );
210 0 $self->{_info_row} .= sprintf( ' (total %s)', insert_sep( $self->{_last_index}, $self->{thsd_sep} ) );
211 0 ▶ $self->{_info_row} = ' ' . $self->{_info_row} if $self->{pad_row_edges};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pad_row_edges"} 0 0 0
212 0 $self->{_last_index} = $self->{max_rows};
213 }
214 0 $self->{_search_regex} = '';
215 0 $self->{_idx_search_matches} = [];
216 0 my $width = {};
217 0 ▶ $width->{edge} = $self->{pad_row_edges} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'pad_row_edges'} ? : 0 0 0
218 0 my ( $tbl_print, $header_rows ) = $self->__get_data( $tbl_orig, $width );
219 0 ▶ if ( ! defined $tbl_print ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tbl_print) 0 0 0
220 0 $self->__reset();
221 0 return;
222 }
223  
224 0 WRITE_TABLE: while ( 1 ) {
225 0 my $next = $self->__write_table( $tbl_orig, $tbl_print, $header_rows, $width );
226 0 ▶ if ( ! defined $next ) {
Branch: 5 branches
BranchTrueFalseTotal
if (not defined $next) { } 0 0 0
elsif ($next == $last_write_table) { } 0 0 0
elsif ($next == $window_width_changed or $next == $choose_and_print) { } 0 0 0
elsif ($next == $enter_search_string) { } 0 0 0
elsif ($next == $from_filtered_table) { } 0 0 0
227 0 die;
228 }
229 elsif ( $next == $last_write_table ) {
230 0 last WRITE_TABLE;
231 }
232 ▶ elsif ( $next == $window_width_changed || $next == $choose_and_print ) {
Condition0%0/3
$next == $window_width_changed or $next == $choose_and_print
l!l&&r!l&&!r
000
MC/DC0%0/2
$next == $window_width_changed or $next == $choose_and_print
$next == $window_width_changed $next == $choose_and_print
Truth table0%0/3
A or B
A= $next == $window_width_changedB= $next == $choose_and_print
ABresult
1X1
011
000
233 0 ( $tbl_print, $header_rows ) = $self->__get_data( $tbl_orig, $width, $next );
234 0 ▶ if ( ! defined $tbl_print ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tbl_print) 0 0 0
235 0 $self->__reset();
236 0 return;
237 }
238 0 next WRITE_TABLE;
239 }
240 elsif ( $next == $enter_search_string ) {
241 0 $self->__search( $tbl_orig );
242 0 next WRITE_TABLE;
243 }
244 elsif ( $next == $from_filtered_table ) {
245 0 $self->__reset_search();
246 0 next WRITE_TABLE;
247 }
248 }
249 0 $self->__reset();
250 0 return 1;
251 }
252  
253  
254 sub __used_columns {
255 0 ▶ my ( $self, $tbl_orig, $width, $next ) = @_;
Subroutine __used_columns: not called CC=13 SCAR=52.0
256 0 my $tcu = Term::Choose::Util->new(
257 { index => 1, all_by_default => 1, keep_chosen => 1, cs_begin => "\n", confirm => '-OK-', back => ' << ' } # pad_row_edges
258 );
259 0 my $cols;
260 0 ▶ if ( defined $next && $next == $window_width_changed ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $next and $next == $window_width_changed) { } 0 0 0
elsif ($self->{'choose_columns'} == 1) { } 0 0 0
Condition0%0/3
defined $next and $next == $window_width_changed
!ll&&!rl&&r
000
MC/DC0%0/2
defined $next and $next == $window_width_changed
defined $next $next == $window_width_changed
Truth table0%0/3
A and B
A= defined $nextB= $next == $window_width_changed
ABresult
0X0
100
111
261 0 $cols = [ @{$self->{_desired_cols_tbl_orig}} ];
262 }
263 elsif ( $self->{choose_columns} == 1 ) {
264 # Choose
265 0 $cols = $tcu->choose_a_subset( $tbl_orig->[0], { cs_label => 'Chosen columns:' } );
266 0 ▶ if ( ! defined $cols ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cols) 0 0 0
267 0 return;
268 }
269 }
270 else {
271 0 $cols = [ 0 .. $#{$tbl_orig->[0]} ];
272 }
273 0 ▶ my $min_col_w_th = $self->{choose_columns} ? 3 : 2; # min_col_width_treshold
Branch: 1 branch
BranchTrueFalseTotal
$self->{'choose_columns'} ? : 0 0 0
274 0 my $desired_cols;
275  
276 0 ▶ while ( ( $width->{tab} + $min_col_w_th ) * $#$cols + $min_col_w_th + $width->{edge} * 2 > $width->{term} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($width->{"tab"} + $min_col_w_th) * $cols->$#* + $min_col_w_th + $width->{"edge"} * 2 > $width->{"term"}) 0 0 0
277 0 $width->{tab} -= 2;
278 0 ▶ if ( $width->{tab} < 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"tab"} < 1) 0 0 0
279 0 ▶ if ( $self->{choose_columns} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'choose_columns'}) { } 0 0 0
280 0 ▶ if ( ! $desired_cols ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($desired_cols) 0 0 0
281 0 $desired_cols = [ @$cols ];
282 }
283 0 $width->{tab} = $self->{tab_width};
284 0 ▶ if ( ! ( $self->{tab_width} % 2 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tab_width"} % 2) 0 0 0
285 0 ++$width->{tab};
286 }
287 0 my $avail_w = $width->{term} - ( $width->{edge} * 2 + $min_col_w_th );
288 0 my $max_cols = 1 + int( $avail_w / ( 1 + $min_col_w_th ) );
289 0 my $cs_label = "Current window width only supports $max_cols columns.";
290 0 $cs_label .= "\nPlease reduce your selection or widen the terminal:";
291 # Choose
292 0 my $new_cols = $tcu->choose_a_subset( [ @{$tbl_orig->[0]}[@$cols] ], { cs_label => $cs_label } );
293 0 ▶ if ( ! defined $new_cols ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $new_cols) 0 0 0
294 0 return;
295 }
296 0 $width->{term} = get_term_width() + EXTRA_W;
297 0 $cols = [ @{$cols}[@$new_cols] ];
298 }
299 else {
300 0 my $info = 'Too many columns; the terminal window is not wide enough.';
301 0 my $prompt = 'Close with ENTER.';
302 # Choose
303 choose(
304 $tbl_orig->[0],
305 # [ @{$tbl_orig->[0]}[@$cols] ],
306 { info => $info, prompt => $prompt, clear_screen => 1, mouse => $self->{mouse}, hide_cursor => 0,
307 search => $self->{search} }
308 0 );
309 0 return;
310 }
311 }
312 }
313 0 ▶ if ( ! $desired_cols ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($desired_cols) 0 0 0
314 0 $desired_cols = $cols;
315 }
316 0 return $desired_cols, $cols;
317 }
318  
319  
320  
321 sub __get_data {
322 0 ▶ my ( $self, $tbl_orig, $width, $next ) = @_;
Subroutine __get_data: not called CC=8 SCAR=42.8
323 0 $width->{term}= get_term_width() + EXTRA_W;
324 0 $width->{tab} = $self->{tab_width};
325 0 ▶ if ( ! ( $self->{tab_width} % 2 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tab_width"} % 2) 0 0 0
326 0 ++$width->{tab}; # include the `|`
327 }
328 0 my ( $desired_cols, $possible_cols ) = $self->__used_columns( $tbl_orig, $width, $next );
329 0 ▶ if ( ! defined $desired_cols ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $desired_cols) 0 0 0
330 0 return;
331 }
332 0 $self->{_used_cols_tbl_orig} = $possible_cols;
333 0 $self->{_desired_cols_tbl_orig} = $desired_cols;
334 0 my $items_count = $self->{_last_index} * @{$tbl_orig->[0]}; ##
335 my $progress = Term::TablePrint::ProgressBar->new( {
336 total => $self->{_last_index} * 3 + 2, # + 2: 2 out of 3 loops include the header.
337 0 show_progress_bar => $self->{progress_bar} < $items_count,
338 } );
339 0 my $tbl_copy = $self->__copy_table( $tbl_orig, $progress );
340 0 $self->__calc_col_width( $tbl_copy, $width, $progress );
341 0 $self->__calc_avail_col_width( $tbl_copy, $width );
342 0 $width->{table} = sum( @{$width->{cols_calc}}, $width->{tab} * $#{$width->{cols_calc}}, 2 * $width->{edge} );
343 0 my $tbl_print = $self->__cols_to_string( $tbl_orig, $tbl_copy, $width, $progress );
344 0 my @tmp_header_rows;
345 0 ▶ if ( length $self->{prompt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"prompt"}) 0 0 0
346 0 push @tmp_header_rows, $self->{prompt};
347 }
348 0 ▶ if ( length $self->{info} || length $self->{prompt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"info"} or length $self->{"prompt"}) 0 0 0
Condition0%0/3
length $self->{"info"} or length $self->{"prompt"}
l!l&&r!l&&!r
000
MC/DC0%0/2
length $self->{"info"} or length $self->{"prompt"}
length $self->{"info"} length $self->{"prompt"}
Truth table0%0/3
A or B
A= length $self->{"info"}B= length $self->{"prompt"}
ABresult
1X1
011
000
349 0 push @tmp_header_rows, $self->__header_sep( $width );
350 }
351 0 my $col_names = shift @{$tbl_print};
352 0 push @tmp_header_rows, $col_names, $self->__header_sep( $width );
353 0 my $header_rows = join "\n", @tmp_header_rows;
354 0 ▶ if ( $self->{_info_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_info_row"}) 0 0 0
355 0 ▶ if ( print_columns( $self->{_info_row} ) > $width->{table} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (print_columns($self->{'_info_row'}) > $width->{'table'}) { } 0 0 0
356 0 push @{$tbl_print}, cut_to_printwidth( $self->{_info_row}, $width->{table} - 3 ) . '...';
357 }
358 else {
359 0 push @{$tbl_print}, $self->{_info_row};
360 }
361 }
362 0 return $tbl_print, $header_rows;
363 }
364  
365  
366 sub __write_table {
367 0 ▶ my ( $self, $tbl_orig, $tbl_print, $header_rows, $width ) = @_;
Subroutine __write_table: not called CC=24 SCAR=64.0
368 0 my @idxs_tbl_print;
369 my $return;
370 0 ▶ if ( $self->{_search_regex} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_search_regex'}) { } 0 0 0
elsif ($self->{'choose_columns'} == 1) { } 0 0 0
371 0 @idxs_tbl_print = map { $_ - 1 } @{$self->{_idx_search_matches}}; # because of the removed tbl_print header
372 0 $return = $from_filtered_table;
373 }
374 elsif ( $self->{choose_columns} == 1 ) {
375 0 $return = $choose_and_print;
376 }
377 else {
378 0 $return = $last_write_table;
379 }
380 0 my $footer;
381 0 ▶ if ( $self->{footer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"footer"}) 0 0 0
382 0 $footer = $self->{footer};
383 0 ▶ if ( $self->{_search_regex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_search_regex"}) 0 0 0
384 0 $footer .= "[$self->{_search_regex}]";
385 }
386 }
387 0 ▶ my $old_row = exists $ENV{TC_POS_AT_SEARCH} && ! $self->{_search_regex} ? delete( $ENV{TC_POS_AT_SEARCH} ) : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $ENV{'TC_POS_AT_SEARCH'} && !$self->{'_search_regex'} ? : 0 0 0
Condition0%0/3
exists $ENV{"TC_POS_AT_SEARCH"} and not $self->{"_search_regex"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"TC_POS_AT_SEARCH"} and not $self->{"_search_regex"}
exists $ENV{"TC_POS_AT_SEARCH"} not $self->{"_search_regex"}
Truth table0%0/3
A and not(B)
A= exists $ENV{"TC_POS_AT_SEARCH"}B= not $self->{"_search_regex"}
ABresult
0X0
100
111
388 0 my $auto_jumped_to_row_0 = 0;
389 0 my $row_was_expanded = 0;
390  
391 0 while ( 1 ) {
392 0 ▶ if ( $width->{term} != get_term_width() + EXTRA_W ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"term"} != get_term_width() + 1) 0 0 0
393 0 return $window_width_changed;
394 }
395 0 ▶ if ( ! @{$tbl_print} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$tbl_print;}) 0 0 0
396 0 push @{$tbl_print}, ''; # so that going back requires always the same amount of keystrokes
397 }
398 0 $ENV{TC_RESET_AUTO_UP} = 0;
399 # Choose
400 my $row = choose(
401 0 @idxs_tbl_print ? [ @{$tbl_print}[@idxs_tbl_print] ]
402 : $tbl_print,
403 { info => $self->{info}, prompt => $header_rows, index => 1, default => $old_row, ll => $width->{table}, layout => 2,
404 clear_screen => 1, mouse => $self->{mouse}, hide_cursor => 0, footer => $footer, color => $self->{color},
405 codepage_mapping => $self->{codepage_mapping}, search => $self->{search}, keep => $self->{keep},
406 page => $self->{page} }
407 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
@idxs_tbl_print ? : 0 0 0
408 0 ▶ if ( ! defined $row ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $row) { } 0 0 0
elsif ($row < 0) { } 0 0 0
409 0 return $return;
410 }
411 elsif ( $row < 0 ) {
412 0 ▶ if ( $row == -1 ) { # with option `ll` set and changed window width `choose` returns -1;
Branch: 2 branches
BranchTrueFalseTotal
if ($row == -1) { } 0 0 0
elsif ($row == -13) { } 0 0 0
413 0 return $window_width_changed;
414 }
415 elsif ( $row == -13 ) { # with option `ll` set `choose` returns -13 if `Ctrl-F` was pressed
416 0 ▶ if ( $self->{_search_regex} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_search_regex"}) 0 0 0
417 0 $self->__reset_search();
418 }
419 0 return $enter_search_string;
420 }
421 else {
422 0 return $last_write_table;
423 }
424 }
425 0 ▶ if ( ! $self->{table_expand} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"table_expand"}) 0 0 0
426 0 ▶ return $return if $row == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $row == 0 0 0 0
427 0 next;
428 }
429 0 ▶ if ( $ENV{TC_RESET_AUTO_UP} ) { # true if any key other than Return/Enter was pressed
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"TC_RESET_AUTO_UP"}) 0 0 0
430 0 $auto_jumped_to_row_0 = 0;
431 0 $row_was_expanded = 0;
432 }
433 #if ( $old_row == $row ) {
434 0 ▶ if ( $row_was_expanded ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row_was_expanded) 0 0 0
435 0 ▶ if ( $row == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row == 0) 0 0 0
436 0 return $return;
437 }
438 0 $old_row = 0;
439 0 $auto_jumped_to_row_0 = 1;
440 0 $row_was_expanded = 0;
441 0 next;
442 }
443 0 ▶ if ( $auto_jumped_to_row_0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auto_jumped_to_row_0) 0 0 0
444 0 return $return;
445 }
446 #}
447 0 $old_row = $row;
448 0 $row_was_expanded = 1;
449 0 ▶ if ( $self->{_info_row} && $row == $#{$tbl_print} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_info_row"} and $row == $#{$tbl_print;}) 0 0 0
Condition0%0/3
$self->{"_info_row"} and $row == $#{$tbl_print;}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"_info_row"} and $row == $#{$tbl_print;}
$self->{"_info_row"} $row == $#{$tbl_print;}
Truth table0%0/3
A and B
A= $self->{"_info_row"}B= $row == $#{$tbl_print;}
ABresult
0X0
100
111
450 # Choose
451 choose(
452 [ 'Close' ],
453 0 { prompt => $self->{_info_row}, clear_screen => 1, mouse => $self->{mouse}, hide_cursor => 0 }
454 );
455 0 next;
456 }
457 0 my $orig_row;
458 0 ▶ if ( @{$self->{_idx_search_matches}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'_idx_search_matches'};}) { } 0 0 0
459 0 $orig_row = $self->{_idx_search_matches}[$row];
460 }
461 else {
462 0 $orig_row = $row + 1; # because $tbl_print has no header row while $tbl_orig has a header row
463 }
464 0 $self->__print_single_row( $tbl_orig, $orig_row, $width, $footer );
465 0 delete $ENV{TC_RESET_AUTO_UP};
466 }
467 }
468  
469  
470 sub __copy_table {
471 0 ▶ my ( $self, $tbl_orig, $progress ) = @_;
Subroutine __copy_table: not called CC=14 SCAR=53.5
472 0 my $tbl_copy = [];
473 0 $progress->set_progress_bar();
474 0 my $str;
475  
476 0 ROW: for my $i ( 0 .. $self->{_last_index} ) {
477 0 my $tmp_row = [];
478  
479 0 COL: for my $j ( @{$self->{_used_cols_tbl_orig}} ) {
480 0 ▶ $str = $tbl_orig->[$i][$j] // $self->{undef}; # this is where the copying happens
Condition0%0/3
$tbl_orig->[$i][$j] // $self->{"undef"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tbl_orig->[$i][$j] // $self->{"undef"}
$tbl_orig->[$i][$j] $self->{"undef"}
Truth table0%0/3
A // B
A= $tbl_orig->[$i][$j]B= $self->{"undef"}
ABresult
1X1
011
000
481 0 ▶ $str = _handle_reference( $str ) if ref $str;
Branch: 1 branch
BranchTrueFalseTotal
if ref $str 0 0 0
482 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"color"}) 0 0 0
483 0 $str =~ s/${\PH}//g;
484 0 $str =~ s/${\SGR_ES}/${\PH}/g;
485 }
486 0 ▶ if ( $self->{binary_filter} && substr( $str, 0, 100 ) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"binary_filter"} and substr($str, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u) 0 0 0
Condition0%0/3
$self->{"binary_filter"} and substr($str, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"binary_filter"} and substr($str, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
$self->{"binary_filter"} substr($str, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
Truth table0%0/3
A and B
A= $self->{"binary_filter"}B= substr($str, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
ABresult
0X0
100
111
487 0 ▶ if ( $self->{binary_filter} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'binary_filter'} == 2) { } 0 0 0
488 0 ▶ push @$tmp_row, sprintf( '%*v02X', ' ', $tbl_orig->[$i][$j] // $self->{undef} );
Condition0%0/3
$tbl_orig->[$i][$j] // $self->{"undef"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tbl_orig->[$i][$j] // $self->{"undef"}
$tbl_orig->[$i][$j] $self->{"undef"}
Truth table0%0/3
A // B
A= $tbl_orig->[$i][$j]B= $self->{"undef"}
ABresult
1X1
011
000
489 }
490 else {
491 0 push @$tmp_row, $self->{binary_string};
492 }
493 0 next COL;
494 }
495 0 ▶ if ( $str =~ /[\p{Cc}\p{Noncharacter_Code_Point}\p{Cs}]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /[\p{Cc}\p{Noncharacter_Code_Point}\p{Cs}]/u) 0 0 0
496 0 $str =~ s/\t/ /g;
497 0 $str =~ s/\v+/\ \ /g;
498 0 $str =~ s/[\p{Cc}\p{Noncharacter_Code_Point}\p{Cs}]//g;
499 }
500 0 ▶ if ( $self->{squash_spaces} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"squash_spaces"}) 0 0 0
501 0 $str =~ s/^\p{Space}+//;
502 0 $str =~ s/\p{Space}+\z//;
503 0 $str =~ s/\p{Space}+/ /g;
504 }
505 0 push @$tmp_row, $str;
506 }
507 0 push @$tbl_copy, $tmp_row;
508 0 ▶ if ( $progress->{show_progress_bar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($progress->{"show_progress_bar"}) 0 0 0
509 0 ▶ if ( ++$progress->{count} > $progress->{next_update} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$progress->{"count"} > $progress->{"next_update"}) 0 0 0
510 0 $progress->update_progress_bar();
511 }
512 }
513 }
514 0 return $tbl_copy
515 }
516  
517  
518 sub __calc_col_width {
519 0 ▶ my ( $self, $tbl_copy, $width, $progress ) = @_;
Subroutine __calc_col_width: not called CC=17 SCAR=57.2
520 0 $progress->set_progress_bar(); #
521 0 my $ds = $self->{decimal_separator};
522 0 my $regex_int_fract = "^([^${ds}Ee]*)(\Q${ds}\E[0-9]+)?\\z";
523 0 my @col_idx = ( 0 .. $#{$tbl_copy->[0]} );
524 0 my $col_count = @col_idx;
525 0 $width->{col_names} = [];
526 0 $width->{cols} = [ ( 1 ) x $col_count ];
527 0 $width->{int} = [ ( 0 ) x $col_count ];
528 0 $width->{fract} = [ ( 0 ) x $col_count ];
529 0 for my $col ( @col_idx ) {
530 0 $width->{col_names}[$col] = print_columns( $tbl_copy->[0][$col] );
531 }
532  
533 0 for my $row ( 1 .. $#$tbl_copy ) {
534  
535 0 for my $col ( @col_idx ) {
536 0 ▶ if ( ! length $tbl_copy->[$row][$col] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not length $tbl_copy->[$row][$col]) { } 0 0 0
elsif (&looks_like_number($tbl_copy->[$row][$col])) { } 0 0 0
537 # nothing to do
538 }
539 elsif ( looks_like_number $tbl_copy->[$row][$col] ) {
540 0 ▶ if ( $tbl_copy->[$row][$col] =~ /$regex_int_fract/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tbl_copy->[$row][$col] =~ /$regex_int_fract/u) { } 0 0 0
541 0 ▶ if ( ( length $1 // 0 ) > $width->{int}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((length $1 // 0) > $width->{"int"}[$col]) 0 0 0
Condition0%0/2
length $1 // 0
l!l
00
MC/DC0%0/1
length $1 // 0
length $1
Truth table0%0/2
A
A= length $1
Aresult
11
00
542 0 $width->{int}[$col] = length $1;
543 }
544 0 ▶ if ( ( length $2 // 0 ) > $width->{fract}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ((length $2 // 0) > $width->{"fract"}[$col]) 0 0 0
Condition0%0/2
length $2 // 0
l!l
00
MC/DC0%0/1
length $2 // 0
length $2
Truth table0%0/2
A
A= length $2
Aresult
11
00
545 0 $width->{fract}[$col] = length $2;
546 }
547 }
548 else {
549 # scientific notation
550 0 ▶ if ( length $tbl_copy->[$row][$col] > $width->{cols}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $tbl_copy->[$row][$col] > $width->{"cols"}[$col]) 0 0 0
551 0 $width->{cols}[$col] = length $tbl_copy->[$row][$col];
552 }
553 }
554 }
555 else {
556 0 my $str_w = print_columns( $tbl_copy->[$row][$col] );
557 0 ▶ if ( $str_w > $width->{cols}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str_w > $width->{"cols"}[$col]) 0 0 0
558 0 $width->{cols}[$col] = $str_w;
559 }
560 }
561 }
562 0 ▶ if ( $progress->{show_progress_bar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($progress->{"show_progress_bar"}) 0 0 0
563 0 ▶ if ( ++$progress->{count} > $progress->{next_update} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$progress->{"count"} > $progress->{"next_update"}) 0 0 0
564 0 $progress->update_progress_bar();
565 }
566 }
567 }
568  
569 0 for my $col ( @col_idx ) {
570 0 ▶ if ( $width->{int}[$col] + $width->{fract}[$col] > $width->{cols}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"int"}[$col] + $width->{"fract"}[$col] > $width->{"cols"}[$col]) 0 0 0
571 0 $width->{cols}[$col] = $width->{int}[$col] + $width->{fract}[$col];
572 }
573 }
574 0 return;
575 }
576  
577  
578 sub __calc_avail_col_width {
579 0 ▶ my ( $self, $tbl_copy, $width ) = @_;
Subroutine __calc_avail_col_width: not called CC=29 SCAR=67.7
580 0 $width->{cols_calc} = [ @{$width->{cols}} ];
581 0 $width->{fract_calc} = [ @{$width->{fract}} ];
582 0 my $avail_w = $width->{term} - ( $width->{tab} * $#{$width->{cols_calc}} + 2 * $width->{edge} );
583 0 my $sum = sum( @{$width->{cols_calc}} );
584 0 my @col_idx = ( 0 .. $#{$width->{cols_calc}} );
585 0 ▶ if ( $sum < $avail_w ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sum < $avail_w) { } 0 0 0
elsif ($sum > $avail_w) { } 0 0 0
586  
587 0 HEAD: while ( 1 ) {
588 0 my $prev_sum = $sum;
589 0 for my $col ( @col_idx ) {
590 0 ▶ if ( $width->{col_names}[$col] > $width->{cols_calc}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"col_names"}[$col] > $width->{"cols_calc"}[$col]) 0 0 0
591 0 ++$width->{cols_calc}[$col];
592 0 ++$sum;
593 0 ▶ if ( $sum == $avail_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sum == $avail_w) 0 0 0
594 0 last HEAD;
595 }
596 }
597 }
598 0 ▶ if ( $sum == $prev_sum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sum == $prev_sum) 0 0 0
599 0 last HEAD;
600 }
601 }
602 }
603 elsif ( $sum > $avail_w ) {
604 0 ▶ if ( $self->{trunc_fract_first} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"trunc_fract_first"}) 0 0 0
605  
606 0 TRUNC_FRACT: while ( 1 ) {
607 0 my $prev_sum = $sum;
608 0 for my $col ( @col_idx ) {
609 0 ▶ if ( $width->{fract_calc}[$col] && $width->{fract_calc}[$col] > 3 # 3 == 1 decimal separator + 2 decimal places
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"fract_calc"}[$col] and $width->{"fract_calc"}[$col] > 3) 0 0 0
Condition0%0/3
$width->{"fract_calc"}[$col] and $width->{"fract_calc"}[$col] > 3
!ll&&!rl&&r
000
MC/DC0%0/2
$width->{"fract_calc"}[$col] and $width->{"fract_calc"}[$col] > 3
$width->{"fract_calc"}[$col] $width->{"fract_calc"}[$col] > 3
Truth table0%0/3
A and B
A= $width->{"fract_calc"}[$col]B= $width->{"fract_calc"}[$col] > 3
ABresult
0X0
100
111
610 #&& $width->{int}[$col] + $width->{fract_calc}[$col] == $width->{cols_calc}[$col] #
611 ## the column width could be larger than width int + width fract_calc, if the column contains non-digit strings
612 ) {
613 0 --$width->{fract_calc}[$col];
614 0 --$width->{cols_calc}[$col];
615 0 --$sum;
616 0 ▶ if ( $sum == $avail_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sum == $avail_w) 0 0 0
617 0 last TRUNC_FRACT;
618 }
619 }
620 }
621 0 ▶ if ( $sum == $prev_sum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sum == $prev_sum) 0 0 0
622 0 last TRUNC_FRACT;
623 }
624 }
625 }
626 0 ▶ my $min_col_width = $self->{col_trim_threshold} < 2 ? 2 : $self->{col_trim_threshold};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'col_trim_threshold'} < 2 ? : 0 0 0
627 0 my $percent = 4;
628  
629 0 ▶ TRUNC_COLS: while ( $sum > $avail_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sum > $avail_w) 0 0 0
630 0 ++$percent;
631  
632 0 for my $col ( @col_idx ) {
633 0 ▶ if ( $width->{cols_calc}[$col] > $min_col_width ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"cols_calc"}[$col] > $min_col_width) 0 0 0
634 0 my $reduced_col_w = _minus_x_percent( $width->{cols_calc}[$col], $percent );
635 0 ▶ if ( $reduced_col_w < $min_col_width ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reduced_col_w < $min_col_width) 0 0 0
636 0 $reduced_col_w = $min_col_width;
637 }
638 0 ▶ if ( $width->{fract_calc}[$col] > 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"fract_calc"}[$col] > 2) 0 0 0
639 0 $width->{fract_calc}[$col] -= $width->{cols_calc}[$col] - $reduced_col_w;
640 0 ▶ if ( $width->{fract_calc}[$col] < 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"fract_calc"}[$col] < 2) 0 0 0
641 0 $width->{fract_calc}[$col] = 2;
642 }
643 }
644 #if ( $width->{fract_calc}[$col] > 0 ) {
645 # $width->{fract_calc}[$col] -= $width->{cols_calc}[$col] - $reduced_col_w;
646 # if ( $width->{fract_calc}[$col] < 1 ) {
647 # $width->{fract_calc}[$col] = "0 but true";
648 # # keep it true eaven if it is 0 for __cols_to_string to work properly.
649 # }
650 #}
651 0 $width->{cols_calc}[$col] = $reduced_col_w;
652 }
653 }
654 0 my $prev_sum = $sum;
655 0 $sum = sum( @{$width->{cols_calc}} );
656 0 ▶ if ( $sum == $prev_sum ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sum == $prev_sum) 0 0 0
657 0 --$min_col_width;
658 0 ▶ if ( $min_col_width < 2 ) { # never
Branch: 1 branch
BranchTrueFalseTotal
if ($min_col_width < 2) 0 0 0
659 0 die "Value less than 1";
660 }
661 }
662 }
663 0 my $remainder_w = $avail_w - $sum;
664 0 ▶ if ( $remainder_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remainder_w) 0 0 0
665  
666 0 REMAINDER_W: while ( 1 ) {
667 0 my $prev_remainder_w = $remainder_w;
668 0 for my $col ( @col_idx ) {
669 0 ▶ if ( $width->{cols_calc}[$col] < $width->{cols}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"cols_calc"}[$col] < $width->{"cols"}[$col]) 0 0 0
670 0 ++$width->{cols_calc}[$col];
671 0 ▶ if ( $width->{fract_calc}[$col] < $width->{fract}[$col]
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"fract_calc"}[$col] < $width->{"fract"}[$col] and $width->{"int"}[$col] + $width->{"fract_calc"}[$col] < $width->{"cols_calc"}[$col]) 0 0 0
Condition0%0/3
$width->{"fract_calc"}[$col] < $width->{"fract"}[$col] and $width->{"int"}[$col] + $width->{"fract_calc"}[$col] < $width->{"cols_calc"}[$col]
!ll&&!rl&&r
000
MC/DC0%0/2
$width->{"fract_calc"}[$col] < $width->{"fract"}[$col] and $width->{"int"}[$col] + $width->{"fract_calc"}[$col] < $width->{"cols_calc"}[$col]
$width->{"fract_calc"}[$col] < $width->{"fract"}[$col] $width->{"int"}[$col] + $width->{"fract_calc"}[$col] < $width->{"cols_calc"}[$col]
Truth table0%0/3
A and B
A= $width->{"fract_calc"}[$col] < $width->{"fract"}[$col]B= $width->{"int"}[$col] + $width->{"fract_calc"}[$col] < $width->{"cols_calc"}[$col]
ABresult
0X0
100
111
672 && $width->{int}[$col] + $width->{fract_calc}[$col] < $width->{cols_calc}[$col] ##
673 ) {
674 0 ++$width->{fract_calc}[$col]
675 }
676 0 --$remainder_w;
677 0 ▶ if ( $remainder_w == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remainder_w == 0) 0 0 0
678 0 last REMAINDER_W;
679 }
680 }
681 }
682 0 ▶ if ( $remainder_w == $prev_remainder_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($remainder_w == $prev_remainder_w) 0 0 0
683 0 last REMAINDER_W;
684 }
685 }
686 }
687 }
688 #else {
689 # #$sum == $avail_w, nothing to do
690 #}
691 0 return;
692 }
693  
694  
695 sub __cols_to_string {
696 0 ▶ my ( $self, $tbl_orig, $tbl_copy, $width, $progress ) = @_;
Subroutine __cols_to_string: not called CC=29 SCAR=67.7
697 0 $progress->set_progress_bar();
698 0 my $tab = ( ' ' x int( $width->{tab} / 2 ) ) . '|' . ( ' ' x int( $width->{tab} / 2 ) );
699 0 my $one_precision_w = length sprintf "%.1e", 123;
700 0 my $ds = $self->{decimal_separator};
701 0 my $regex_fract = "(\Q${ds}\E[0-9]+)\\z";
702 0 my $lrb = ' ' x $width->{edge};
703 0 my $str;
704  
705 0 ROW: for my $row ( 0 .. $#{$tbl_copy} ) {
706 0 $str = $lrb;
707  
708 0 COL: for my $col ( 0 .. $#{$width->{cols_calc}} ) {
709 0 ▶ if ( ! length $tbl_copy->[$row][$col] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not length $tbl_copy->[$row][$col]) { } 0 0 0
elsif (&looks_like_number($tbl_copy->[$row][$col])) { } 0 0 0
710 0 $str .= ' ' x $width->{cols_calc}[$col];
711 }
712 elsif ( looks_like_number $tbl_copy->[$row][$col] ) {
713 0 ▶ if ( $width->{fract_calc}[$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($width->{"fract_calc"}[$col]) 0 0 0
714 0 ▶ if ( $tbl_copy->[$row][$col] =~ /$regex_fract/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($tbl_copy->[$row][$col] =~ /$regex_fract/u) { } 0 0 0
elsif (not $tbl_copy->[$row][$col] =~ /[eE]/u) { } 0 0 0
elsif ($tbl_copy->[$row][$col] =~ /[eE]-/u and $width->{'fract'}[$col] != $width->{'fract_calc'}[$col]) { } 0 0 0
715 0 ▶ if ( length $1 > $width->{fract_calc}[$col] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $1 > $width->{'fract_calc'}[$col]) { } 0 0 0
elsif (length $1 < $width->{'fract_calc'}[$col]) { } 0 0 0
716 0 $tbl_copy->[$row][$col] = substr( $tbl_copy->[$row][$col], 0, -( length( $1 ) - $width->{fract_calc}[$col] ) );
717 }
718 elsif ( length $1 < $width->{fract_calc}[$col] ) {
719 0 $tbl_copy->[$row][$col] .= ' ' x ( $width->{fract_calc}[$col] - length $1 );
720 }
721 }
722 elsif ( $tbl_copy->[$row][$col] !~ /[eE]/ ) {
723 0 $tbl_copy->[$row][$col] .= ' ' x $width->{fract_calc}[$col];
724 }
725 ▶ elsif ( $tbl_copy->[$row][$col] =~ /[eE]-/ && $width->{fract}[$col] != $width->{fract_calc}[$col] ) {
Condition0%0/3
$tbl_copy->[$row][$col] =~ /[eE]-/u and $width->{"fract"}[$col] != $width->{"fract_calc"}[$col]
!ll&&!rl&&r
000
MC/DC0%0/2
$tbl_copy->[$row][$col] =~ /[eE]-/u and $width->{"fract"}[$col] != $width->{"fract_calc"}[$col]
$tbl_copy->[$row][$col] =~ /[eE]-/u $width->{"fract"}[$col] != $width->{"fract_calc"}[$col]
Truth table0%0/3
A and B
A= $tbl_copy->[$row][$col] =~ /[eE]-/uB= $width->{"fract"}[$col] != $width->{"fract_calc"}[$col]
ABresult
0X0
100
111
726 0 $tbl_copy->[$row][$col] = sprintf "%.*f", $width->{fract_calc}[$col] - 1, $tbl_copy->[$row][$col];
727 }
728 }
729 0 ▶ if ( length $tbl_copy->[$row][$col] > $width->{cols_calc}[$col] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $tbl_copy->[$row][$col] > $width->{'cols_calc'}[$col]) { } 0 0 0
elsif (length $tbl_copy->[$row][$col] < $width->{'cols_calc'}[$col]) { } 0 0 0
730 0 ▶ my $precision = $width->{cols_calc}[$col] - ( $one_precision_w + ( $tbl_copy->[$row][$col] < 0 ? 1 : 0 ) ) + 1;
Branch: 1 branch
BranchTrueFalseTotal
$tbl_copy->[$row][$col] < 0 ? : 0 0 0
731 # $one_precision_w + 1 if the number is signed (-)
732 # $precision + 1 because $one_precision_w contains already one precision
733 0 ▶ if ( $precision == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($precision == -1) 0 0 0
734 0 $precision = 0;
735 # Difference between one-precision-width and zero-precision-width is 2 because zero precision has no dot.
736 }
737 0 ▶ if ( $precision >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($precision >= 0) 0 0 0
738 0 ▶ while ( length( $tbl_copy->[$row][$col] = sprintf "%.*e", $precision, $tbl_copy->[$row][$col] ) > $width->{cols_calc}[$col] ) { ##
Branch: 1 branch
BranchTrueFalseTotal
if (length($tbl_copy->[$row][$col] = sprintf("%.*e", $precision, $tbl_copy->[$row][$col])) > $width->{"cols_calc"}[$col]) 0 0 0
739 0 --$precision;
740 0 ▶ last if $precision < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $precision < 0 0 0 0
741 }
742  
743 }
744 0 ▶ if ( $precision < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($precision < 0) { } 0 0 0
elsif ($precision == 0 and length $tbl_copy->[$row][$col] < $width->{'cols_calc'}[$col]) { } 0 0 0
745 0 $str .= ( '-' x $width->{cols_calc}[$col] );
746 }
747 ▶ elsif ( $precision == 0 && length $tbl_copy->[$row][$col] < $width->{cols_calc}[$col] ) {
Condition0%0/3
$precision == 0 and length $tbl_copy->[$row][$col] < $width->{"cols_calc"}[$col]
!ll&&!rl&&r
000
MC/DC0%0/2
$precision == 0 and length $tbl_copy->[$row][$col] < $width->{"cols_calc"}[$col]
$precision == 0 length $tbl_copy->[$row][$col] < $width->{"cols_calc"}[$col]
Truth table0%0/3
A and B
A= $precision == 0B= length $tbl_copy->[$row][$col] < $width->{"cols_calc"}[$col]
ABresult
0X0
100
111
748 0 $str .= ' ' . $tbl_copy->[$row][$col];
749 }
750 else {
751 0 $str .= $tbl_copy->[$row][$col];
752 }
753 }
754 elsif ( length $tbl_copy->[$row][$col] < $width->{cols_calc}[$col] ) {
755 0 $str .= ' ' x ( $width->{cols_calc}[$col] - length $tbl_copy->[$row][$col] ) . $tbl_copy->[$row][$col];
756 }
757 else {
758 0 $str .= $tbl_copy->[$row][$col];
759 }
760 }
761 else {
762 0 $str .= adjust_to_printwidth( $tbl_copy->[$row][$col], $width->{cols_calc}[$col] );
763 }
764 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"color"}) 0 0 0
765 0 my $orig_col = $self->{_used_cols_tbl_orig}[$col];
766 0 ▶ if ( defined $tbl_orig->[$row][$orig_col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tbl_orig->[$row][$orig_col]) 0 0 0
767 0 my @color = $tbl_orig->[$row][$orig_col] =~ /(${\SGR_ES})/g;
768 0 ▶ if ( @color ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@color) 0 0 0
769 0 $str =~ s/${\PH}/shift @color/ge;
770 0 $str .= "\e[0m";
771 }
772 #if ( @color ) {
773 # if ( $color[-1] !~ /^\e\[0?m/ ) {
774 # push @color, "\e[0m";
775 # }
776 # $str =~ s/${\PH}/shift @color/ge;
777 # if ( @color ) {
778 # $str .= $color[-1];
779 # }
780 #}
781 }
782 }
783 0 ▶ $str .= $col == $#{$width->{cols_calc}} ? $lrb : $tab;
Branch: 1 branch
BranchTrueFalseTotal
$col == $#{$$width{'cols_calc'};} ? : 0 0 0
784 }
785 0 $tbl_copy->[$row] = $str; # overwrite $tbl_copy to save memory
786 0 ▶ if ( $progress->{show_progress_bar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($progress->{"show_progress_bar"}) 0 0 0
787 0 ▶ if ( ++$progress->{count} > $progress->{next_update} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$progress->{"count"} > $progress->{"next_update"}) 0 0 0
788 0 $progress->update_progress_bar();
789 }
790 }
791 }
792 0 ▶ if ( $progress->{show_progress_bar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($progress->{"show_progress_bar"}) 0 0 0
793 0 $progress->update_progress_bar();
794 }
795 0 return $tbl_copy; # $tbl_copy is now $tbl_print
796 }
797  
798  
799 sub __print_single_row {
800 0 ▶ my ( $self, $tbl_orig, $row, $width, $footer ) = @_;
Subroutine __print_single_row: not called CC=23 SCAR=63.1
801 0 my $avail_w = get_term_width() - 1; ##
802 0 ▶ if ( $self->{expanded_max_width} && $self->{expanded_max_width} < $avail_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"expanded_max_width"} and $self->{"expanded_max_width"} < $avail_w) 0 0 0
Condition0%0/3
$self->{"expanded_max_width"} and $self->{"expanded_max_width"} < $avail_w
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"expanded_max_width"} and $self->{"expanded_max_width"} < $avail_w
$self->{"expanded_max_width"} $self->{"expanded_max_width"} < $avail_w
Truth table0%0/3
A and B
A= $self->{"expanded_max_width"}B= $self->{"expanded_max_width"} < $avail_w
ABresult
0X0
100
111
803 0 $avail_w = $self->{expanded_max_width};
804 }
805 0 my $max_key_w = max( @{$width->{col_names}} ) + 1;
806 0 ▶ if ( $max_key_w > int( $avail_w / 3 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max_key_w > int $avail_w / 3) 0 0 0
807 0 $max_key_w = int( $avail_w / 3 );
808 }
809 0 my $separator = ' : ';
810 0 my $sep_w = length( $separator );
811 0 my $max_value_w = $avail_w - ( $max_key_w + $sep_w );
812 0 my $separator_row = ' ';
813 0 my $row_data = [ ' Close with ENTER' ];
814  
815 0 for my $col ( @{$self->{_desired_cols_tbl_orig}} ) {
816 0 ▶ if ( $self->{expanded_line_spacing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"expanded_line_spacing"}) 0 0 0
817 0 push @$row_data, $separator_row;
818 }
819 0 ▶ my $key = $tbl_orig->[0][$col] // $self->{undef};
Condition0%0/3
$tbl_orig->[0][$col] // $self->{"undef"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tbl_orig->[0][$col] // $self->{"undef"}
$tbl_orig->[0][$col] $self->{"undef"}
Truth table0%0/3
A // B
A= $tbl_orig->[0][$col]B= $self->{"undef"}
ABresult
1X1
011
000
820 0 my @key_color;
821 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"color"}) 0 0 0
822 0 $key =~ s/${\PH}//g;
823 0 ▶ $key =~ s/(${\SGR_ES})/push( @key_color, $1 ) && ${\PH}/ge;
Branch: 1 branch
BranchTrueFalseTotal
push @key_color, $1 and ${\"\x{feff}";} 0 0 0
824 }
825 0 ▶ if ( $self->{binary_filter} && substr( $key, 0, 100 ) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'binary_filter'} and substr($key, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u) { } 0 0 0
elsif ($key =~ /[\p{Cc}\p{Noncharacter_Code_Point}\p{Cs}]/u) { } 0 0 0
Condition0%0/3
$self->{"binary_filter"} and substr($key, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"binary_filter"} and substr($key, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
$self->{"binary_filter"} substr($key, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
Truth table0%0/3
A and B
A= $self->{"binary_filter"}B= substr($key, 0, 100) =~ /[\x00-\x08\x0B-\x0C\x0E-\x1F]/u
ABresult
0X0
100
111
826 0 ▶ if ( $self->{binary_filter} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'binary_filter'} == 2) { } 0 0 0
827 0 ▶ $key = sprintf( '%*v02X', ' ', $tbl_orig->[0][$col] // $self->{undef} );
Condition0%0/3
$tbl_orig->[0][$col] // $self->{"undef"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tbl_orig->[0][$col] // $self->{"undef"}
$tbl_orig->[0][$col] $self->{"undef"}
Truth table0%0/3
A // B
A= $tbl_orig->[0][$col]B= $self->{"undef"}
ABresult
1X1
011
000
828 }
829 else {
830 0 $key = $self->{binary_string};
831 }
832 0 ▶ if ( @key_color ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@key_color) 0 0 0
833 0 @key_color = ();
834 }
835 }
836 elsif ( $key =~ /[\p{Cc}\p{Noncharacter_Code_Point}\p{Cs}]/ ) {
837 0 $key =~ s/\t/ /g;
838 0 $key =~ s/\v+/\ \ /g;
839 0 $key =~ s/[\p{Cc}\p{Noncharacter_Code_Point}\p{Cs}]//g;
840 }
841 0 my $key_w = print_columns( $key );
842 0 ▶ if ( $key_w > $max_key_w ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key_w > $max_key_w) { } 0 0 0
elsif ($key_w < $max_key_w) { } 0 0 0
843 0 $key = cut_to_printwidth( $key, $max_key_w );
844 }
845 elsif ( $key_w < $max_key_w ) {
846 0 $key = ( ' ' x ( $max_key_w - $key_w ) ) . $key;
847 }
848 0 ▶ if ( @key_color ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@key_color) 0 0 0
849 0 $key =~ s/${\PH}/shift @key_color/ge;
850 0 $key .= "\e[0m";
851 }
852 0 ▶ my $value = $tbl_orig->[$row][$col] // $self->{undef};
Condition0%0/3
$tbl_orig->[$row][$col] // $self->{"undef"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tbl_orig->[$row][$col] // $self->{"undef"}
$tbl_orig->[$row][$col] $self->{"undef"}
Truth table0%0/3
A // B
A= $tbl_orig->[$row][$col]B= $self->{"undef"}
ABresult
1X1
011
000
853 # $value: color and invalid char handling in `line_fold`
854 0 ▶ if ( ref $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 0 0 0
855 0 $value = _handle_reference( $value );
856 }
857 0 my $subseq_tab = ' ' x ( $max_key_w + $sep_w );
858 0 my $count;
859  
860 0 for my $line ( line_fold( $value, { width => $max_value_w, color => $self->{color}, binary_filter => $self->{binary_filter}, join => 0 } ) ) {
861 0 ▶ if ( ! $count++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $count++) { } 0 0 0
862 0 push @$row_data, $key . $separator . $line;
863 }
864 else {
865 0 push @$row_data, $subseq_tab . $line;
866 }
867 }
868 }
869 0 my $regex;
870 0 ▶ if ( $self->{expanded_line_spacing} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"expanded_line_spacing"}) 0 0 0
871 0 $regex = qr/^\Q$separator_row\E\z/;
872 }
873 # Choose
874 choose(
875 $row_data,
876 { prompt => '', layout => 2, clear_screen => 1, mouse => $self->{mouse}, hide_cursor => 0, empty => ' ',
877 search => $self->{search}, skip_items => $regex, footer => $footer, page => $self->{page},
878 color => $self->{color} }
879 0 );
880 }
881  
882  
883 sub __search {
884 0 ▶ my ( $self, $tbl_orig ) = @_;
Subroutine __search: not called CC=11 SCAR=47.3
885 0 ▶ if ( ! $self->{search} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"search"}) 0 0 0
886 0 return;
887 }
888 0 require Term::Form::ReadLine;
889 0 Term::Form::ReadLine->VERSION(0.544);
890 0 my $term = Term::Form::ReadLine->new();
891 0 my $error_message;
892 0 my $prompt = "> \e[4msearch\e[0m: ";
893 0 my $default = '';
894  
895 0 READ: while ( 1 ) {
896 0 ▶ my $string = $term->readline(
Branch: 1 branch
BranchTrueFalseTotal
defined $error_message ? : 0 0 0
897 $prompt,
898 { info => $error_message, hide_cursor => 2, clear_screen => defined $error_message ? 1 : 2,
899 default => $default, color => 1 }
900 );
901 0 ▶ if ( ! length $string ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $string) 0 0 0
902 0 return;
903 }
904 0 print "\r${prompt}${string}";
905 0 ▶ if ( ! eval {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { $self->{"_search_regex"} = $self->{"search"} == 1 ? "(?i:$string)" : $string; "Teststring" =~ /$self->{"_search_regex"}/u; 1 } }) 0 0 0
906 0 ▶ $self->{_search_regex} = $self->{search} == 1 ? "(?i:$string)" : $string;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'search'} == 1 ? : 0 0 0
907 0 'Teststring' =~ $self->{_search_regex};
908 0 1
909 } ) {
910 0 ▶ $default = $default eq $string ? '' : $string;
Branch: 1 branch
BranchTrueFalseTotal
$default eq $string ? : 0 0 0
911 0 $error_message = "$@";
912 0 next READ;
913 }
914 0 last READ;
915 }
916 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
917  
918 # skip the header row
919 0 for my $idx_row ( 1 .. $self->{_last_index} ) {
920 0 for ( @{$self->{_desired_cols_tbl_orig}} ) {
921 0 ▶ if ( $tbl_orig->[$idx_row][$_] =~ /$self->{_search_regex}/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tbl_orig->[$idx_row][$_] =~ /$self->{"_search_regex"}/u) 0 0 0
922 0 push @{$self->{_idx_search_matches}}, $idx_row;
923 0 last;
924 }
925 }
926 }
927 0 ▶ if ( ! @{$self->{_idx_search_matches}} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$self->{"_idx_search_matches"};}) 0 0 0
928 0 my $message = '/' . $self->{_search_regex} . '/: No matches found.';
929 # Choose
930 0 choose(
931 [ 'Continue with ENTER' ],
932 { prompt => $message, layout => 0, clear_screen => 1, hide_cursor => 0 }
933 );
934 0 $self->{_search_regex} = '';
935 0 return;
936 }
937 0 return;
938 }
939  
940  
941 sub __reset_search {
942 0 ▶ my ( $self ) = @_;
Subroutine __reset_search: not called CC=1 SCAR=6.9
943 0 $self->{_idx_search_matches} = [];
944 0 $self->{_search_regex} = '';
945 }
946  
947  
948 sub __header_sep {
949 0 ▶ my ( $self, $width ) = @_;
Subroutine __header_sep: not called CC=2 SCAR=17.9
950 0 my $tab = ( '-' x int( $width->{tab} / 2 ) ) . '|' . ( '-' x int( $width->{tab} / 2 ) );
951 0 my $lrb = '-' x $width->{edge};
952 0 my $header_sep = $lrb;
953 0 for my $col ( 0 .. $#{$width->{cols_calc}} - 1 ) {
954 0 $header_sep .= '-' x $width->{cols_calc}[$col] . $tab;
955 }
956 0 $header_sep .= '-' x $width->{cols_calc}[$#{$width->{cols_calc}}] . $lrb;
957 0 return $header_sep;
958 }
959  
960  
961 sub _handle_reference {
962 0 ▶ require Data::Dumper;
Subroutine _handle_reference: not called CC=1 SCAR=6.9
963 0 local $Data::Dumper::Useqq = 1;
964 0 local $Data::Dumper::Indent = 0;
965 0 local $Data::Dumper::Terse = 1;
966 0 local $Data::Dumper::Maxdepth = 2;
967 0 return Data::Dumper::Dumper( $_[0] );
968 }
969  
970  
971 sub _minus_x_percent {
972 #my ( $value, $percent ) = @_;
973 0 ▶ return int( $_[0] - ( $_[0] / 100 * $_[1] ) ) || 1;
Subroutine _minus_x_percent: not called CC=2 SCAR=17.9
Condition0%0/2
int $_[0] - $_[0] / 100 * $_[1] || 1
l!l
00
MC/DC0%0/1
int $_[0] - $_[0] / 100 * $_[1] || 1
int $_[0] - $_[0] / 100 * $_[1]
Truth table0%0/2
A
A= int $_[0] - $_[0] / 100 * $_[1]
Aresult
11
00
974 }
975  
976  
977  
978 1 1;
979  
980 __END__
↑ Summary TablePrint/ProgressBar.pm »