Choose.pm

filter: Statementstmt 4.7% 49 / 1034 Branchbran 1.3% 8 / 614 Conditioncond 0.0% 0 / 256 MC/DCmcdc 0.0% 0 / 157 Subroutinesub 32.5% 14 / 43 Podpod 100% 2 / 2 totaltotal 3.4% 73 / 2106 CC 435 SCAR 89.1
CC
435
Cov
3%
__choose
22350.0
__avail_height_to_keep
2862.0
__avail_screen_size
650.0
CRAP 7437.7
↑ Summary Choose/Linux.pm »
1 package Term::Choose;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use 5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $VERSION = '1.783';
8 3 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 our @EXPORT_OK = qw( choose );
10  
11 3 ▶use Carp qw( croak carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Term::Choose::Constants qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Term::Choose::LineFold qw( line_fold print_columns cut_to_printwidth );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use Term::Choose::Screen qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use Term::Choose::ValidateOptions qw( validate_options );
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3 my $Plugin;
19  
20 3 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=9.2
21 3 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 3 3
22 0 require Win32::Console::ANSI;
23 0 require Term::Choose::Win32;
24 0 $Plugin = 'Term::Choose::Win32';
25 }
26 else {
27 3 require Term::Choose::Linux;
28 3 $Plugin = 'Term::Choose::Linux';
29 }
30 }
31  
32 3 ▶END {
Subroutine END: called CC=4 SCAR=26.7
33 3 ▶ if ( $? == 255 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? == 255) 0 3 3
34 0 ▶ if( $^O eq 'MSWin32' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 0 0
elsif (&TERM_READKEY()) { } 0 0 0
35 0 my $input = Win32::Console->new( Win32::Console::constant( "STD_INPUT_HANDLE", 0 ) );
36 0 $input->Mode( 0x0001|0x0002|0x0004 );
37 0 $input->Flush;
38 }
39 elsif ( TERM_READKEY ) {
40 0 Term::ReadKey::ReadMode( 'restore' );
41 }
42 else {
43 0 system( "stty sane" );
44 }
45 0 print "\n", clear_to_end_of_screen;
46 0 print show_cursor;
47 }
48 }
49  
50  
51 113 ▶sub new {
Subroutine new: called CC=6 SCAR=18.0
Pod documented
52 113 my $class = shift;
53 113 my ( $opt ) = @_;
54 113 ▶ croak "new: called with " . @_ . " arguments - 0 or 1 arguments expected" if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 113 113
55 113 my $instance_defaults = _defaults();
56 113 ▶ if ( defined $opt ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt) 111 2 113
57 111 ▶ croak "new: the (optional) argument must be a HASH reference" if ref $opt ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opt ne "HASH" 0 111 111
58 111 validate_options( _valid_options(), $opt, 'new' );
59 111 for my $key ( keys %$opt ) {
60 150 ▶ $instance_defaults->{$key} = $opt->{$key} if defined $opt->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->{$key} 113 37 150
61 }
62 }
63 113 my $self = bless $instance_defaults, $class;
64 113 $self->{backup_instance_defaults} = { %$instance_defaults };
65 113 $self->{plugin} = $Plugin->new();
66 113 return $self;
67 }
68  
69  
70 111 ▶sub _valid_options {
Subroutine _valid_options: called CC=1 SCAR=0.0
71 return {
72 111 beep => '[ 0 1 ]',
73 clear_screen => '[ 0 1 ]',
74 codepage_mapping => '[ 0 1 ]',
75 hide_cursor => '[ 0 1 ]',
76 index => '[ 0 1 ]',
77 mouse => '[ 0 1 ]',
78 order => '[ 0 1 ]',
79 alignment => '[ 0 1 2 ]',
80 color => '[ 0 1 2 ]',
81 include_highlighted => '[ 0 1 2 ]',
82 layout => '[ 0 1 2 ]',
83 page => '[ 0 1 2 ]',
84 search => '[ 0 1 2 ]',
85 keep => '[ 1-9 ][ 0-9 ]*',
86 ll => '[ 1-9 ][ 0-9 ]*',
87 max_cols => '[ 1-9 ][ 0-9 ]*',
88 max_height => '(?:[2-9]|[ 1-9 ][ 0-9 ]+)', # rename to max_rows
89 max_width => '(?:[2-9]|[ 1-9 ][ 0-9 ]+)',
90 default => '[ 0-9 ]+',
91 pad => '[ 0-9 ]+',
92 margin => 'Array_Int',
93 mark => 'Array_Int_Idx',
94 meta_items => 'Array_Int_Idx',
95 no_spacebar => 'Array_Int_Idx',
96 tabs_bottom_text => 'Array_Int',
97 tabs_info => 'Array_Int',
98 tabs_prompt => 'Array_Int',
99 skip_items => 'Regexp',
100 bottom_text => 'Str',
101 empty => 'Str',
102 footer => 'Str',
103 info => 'Str',
104 prompt => 'Str',
105 undef => 'Str',
106 busy_string => 'Str',
107 };
108 };
109  
110  
111 113 ▶sub _defaults {
Subroutine _defaults: called CC=1 SCAR=0.0
112 return {
113 113 alignment => 0,
114 beep => 0,
115 #bottom_text => undef,
116 clear_screen => 0,
117 codepage_mapping => 0,
118 color => 0,
119 #default => undef,
120 empty => '<empty>',
121 #footer => undef,
122 hide_cursor => 1,
123 include_highlighted => 0,
124 index => 0,
125 #info => undef,
126 keep => 5,
127 layout => 1,
128 #ll => undef,
129 #margin => undef,
130 #mark => undef,
131 #max_cols => undef,
132 #max_height => undef,
133 #max_width => undef,
134 #meta_items => undef,
135 mouse => 0,
136 #no_spacebar => undef,
137 order => 1, ##
138 pad => 2,
139 page => 1,
140 #prompt => undef,
141 search => 1,
142 #skip_items => undef,
143 #tabs_bottom_text => undef,
144 #tabs_info => undef,
145 #tabs_prompt => undef,
146 undef => '<undef>',
147 #busy_string => undef,
148 };
149 }
150  
151  
152 0 ▶sub __copy_orig_list {
Subroutine __copy_orig_list: not called CC=8 SCAR=42.8
153 0 my ( $self, $orig_list_ref ) = @_;
154 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ll'}) { } 0 0 0
155 0 $self->{list} = $orig_list_ref;
156 }
157 else {
158 0 $self->{list} = [ @$orig_list_ref ];
159 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"color"}) 0 0 0
160 0 $self->{orig_list} = $orig_list_ref;
161 }
162 0 for ( @{$self->{list}} ) {
163 0 ▶ if ( ! $_ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_) 0 0 0
164 0 ▶ $_ = $self->{undef} if ! defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
165 0 ▶ $_ = $self->{empty} if ! length $_;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_ 0 0 0
166 }
167 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"color"}) 0 0 0
168 0 s/${\PH}//g;
169 0 s/${\SGR_ES}/${\PH}/g;
170 }
171 0 s/\t/ /g;
172 0 s/\v+/\ \ /g;
173 # \p{Cn} might not be up to date and remove assigned codepoints
174 # therefore only \p{Noncharacter_Code_Point}
175 0 s/[\p{Cc}\p{Noncharacter_Code_Point}\p{Cs}]//g;
176 }
177 }
178 }
179  
180  
181 0 ▶sub __length_list_elements {
Subroutine __length_list_elements: not called CC=4 SCAR=30.0
182 0 my ( $self ) = @_;
183 0 my $list = $self->{list};
184 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ll'}) { } 0 0 0
185 0 $self->{col_width} = $self->{ll};
186 }
187 else {
188 0 my $length_elements = [];
189 0 my $longest = 0;
190 0 for my $i ( 0 .. $#$list ) {
191 0 $length_elements->[$i] = print_columns( $list->[$i] );
192 0 ▶ $longest = $length_elements->[$i] if $length_elements->[$i] > $longest;
Branch: 1 branch
BranchTrueFalseTotal
if $length_elements->[$i] > $longest 0 0 0
193 }
194 0 $self->{width_elements} = $length_elements;
195 0 $self->{col_width} = $longest;
196 }
197 0 $self->{bu_col_width} = $self->{col_width};
198 }
199  
200  
201 0 ▶sub __init_term {
Subroutine __init_term: not called CC=1 SCAR=6.9
202 0 my ( $self ) = @_;
203 my $config = {
204 mode => 'ultra-raw',
205 mouse => $self->{mouse},
206 hide_cursor => $self->{hide_cursor},
207 0 };
208 0 $self->{mouse} = $self->{plugin}->__set_mode( $config );
209 }
210  
211  
212 0 ▶sub __reset_term {
Subroutine __reset_term: not called CC=9 SCAR=45.0
213 0 my ( $self, $clear_choose ) = @_;
214 0 ▶ if ( defined $self->{plugin} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"plugin"}) 0 0 0
215 0 $self->{plugin}->__reset_mode( { mouse => $self->{mouse}, hide_cursor => $self->{hide_cursor} } );
216 }
217 0 ▶ if ( $clear_choose ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($clear_choose) 0 0 0
218 0 my $up = $self->{i_row} + $self->{count_pre_rows};
219 0 ▶ print up( $up ) if $up;
Branch: 1 branch
BranchTrueFalseTotal
if $up 0 0 0
220 0 print "\r" . clear_to_end_of_screen();
221 }
222 0 ▶ if ( exists $self->{backup_instance_defaults} ) { # backup_instance_defaults exists if ObjectOriented
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"backup_instance_defaults"}) 0 0 0
223 0 my $instance_defaults = $self->{backup_instance_defaults};
224 0 for my $key ( keys %$self ) {
225 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
226 0 next;
227 }
228 elsif ( exists $instance_defaults->{$key} ) {
229 0 $self->{$key} = $instance_defaults->{$key};
230 }
231 else {
232 0 delete $self->{$key};
233 }
234 }
235 }
236 }
237  
238  
239 0 ▶sub __invalid_term_size {
Subroutine __invalid_term_size: not called CC=1 SCAR=6.9
240 0 my ( $self, $min_term_width, $min_term_height, $clear_choose ) = @_;
241 0 $self->__reset_term( $clear_choose );
242 0 warn "Minimum terminal size: " . ++$min_term_width . " x $min_term_height";
243 0 exit;
244 }
245  
246  
247 0 ▶sub __get_key {
Subroutine __get_key: not called CC=5 SCAR=34.0
248 0 my ( $self ) = @_;
249 0 my $key;
250 0 ▶ if ( defined $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"skip_items"}) 0 0 0
251 0 my $idx = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
252 0 ▶ if ( $self->{list}[$idx] =~ $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"list"}[$idx] =~ /$self->{"skip_items"}/) 0 0 0
253 0 $key = $self->Term::Choose::Opt::SkipItems::__key_skipped();
254 }
255 }
256 0 ▶ if ( ! defined $key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $key) 0 0 0
257 0 $key = $self->{plugin}->__get_key_OS( $self->{mouse} );
258 }
259 0 ▶ return $key if ref $key ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $key ne "ARRAY" 0 0 0
260 0 return $self->Term::Choose::Opt::Mouse::__mouse_info_to_key( @$key );
261 }
262  
263  
264 0 ▶sub __modify_options {
Subroutine __modify_options: not called CC=18 SCAR=58.3
265 0 my ( $self ) = @_;
266 0 ▶ if ( defined $self->{max_cols} && $self->{max_cols} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"max_cols"} and $self->{"max_cols"} == 1) 0 0 0
Condition0%0/3
defined $self->{"max_cols"} and $self->{"max_cols"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"max_cols"} and $self->{"max_cols"} == 1
defined $self->{"max_cols"} $self->{"max_cols"} == 1
Truth table0%0/3
A and B
A= defined $self->{"max_cols"}B= $self->{"max_cols"} == 1
ABresult
0X0
100
111
267 0 $self->{layout} = 2;
268 }
269 0 ▶ if ( $self->{max_height} && $self->{max_height} < $self->{keep} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"max_height"} and $self->{"max_height"} < $self->{"keep"}) 0 0 0
Condition0%0/3
$self->{"max_height"} and $self->{"max_height"} < $self->{"keep"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"max_height"} and $self->{"max_height"} < $self->{"keep"}
$self->{"max_height"} $self->{"max_height"} < $self->{"keep"}
Truth table0%0/3
A and B
A= $self->{"max_height"}B= $self->{"max_height"} < $self->{"keep"}
ABresult
0X0
100
111
270 0 $self->{keep} = $self->{max_height};
271 }
272 0 ▶ if ( length $self->{footer} && $self->{page} != 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"footer"} and $self->{"page"} != 2) 0 0 0
Condition0%0/3
length $self->{"footer"} and $self->{"page"} != 2
!ll&&!rl&&r
000
MC/DC0%0/2
length $self->{"footer"} and $self->{"page"} != 2
length $self->{"footer"} $self->{"page"} != 2
Truth table0%0/3
A and B
A= length $self->{"footer"}B= $self->{"page"} != 2
ABresult
0X0
100
111
273 0 $self->{page} = 2;
274 }
275 0 ▶ if ( $self->{page} == 2 && ! $self->{clear_screen} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"page"} == 2 and not $self->{"clear_screen"}) 0 0 0
Condition0%0/3
$self->{"page"} == 2 and not $self->{"clear_screen"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"page"} == 2 and not $self->{"clear_screen"}
$self->{"page"} == 2 not $self->{"clear_screen"}
Truth table0%0/3
A and not(B)
A= $self->{"page"} == 2B= not $self->{"clear_screen"}
ABresult
0X0
100
111
276 0 $self->{clear_screen} = 1;
277 }
278 0 ▶ if ( $self->{max_cols} && $self->{layout} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"max_cols"} and $self->{"layout"} == 1) 0 0 0
Condition0%0/3
$self->{"max_cols"} and $self->{"layout"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"max_cols"} and $self->{"layout"} == 1
$self->{"max_cols"} $self->{"layout"} == 1
Truth table0%0/3
A and B
A= $self->{"max_cols"}B= $self->{"layout"} == 1
ABresult
0X0
100
111
279 0 $self->{layout} = 0;
280 }
281 0 ▶ if ( ! defined $self->{prompt} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"prompt"}) 0 0 0
282 0 ▶ $self->{prompt} = defined $self->{wantarray} ? 'Your choice:' : 'Close with ENTER';
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'wantarray'} ? : 0 0 0
283 }
284 0 ▶ if ( defined $self->{margin} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"margin"}) 0 0 0
285 0 ( $self->{margin_top}, $self->{margin_right}, $self->{margin_bottom}, $self->{margin_left} ) = @{$self->{margin}};
286 }
287 0 ▶ $self->{margin_top} //= 0;
Condition0%0/2
$self->{"margin_top"} //= 0
l!l
00
MC/DC0%0/1
$self->{"margin_top"} //= 0
$self->{"margin_top"}
Truth table0%0/2
A
A= $self->{"margin_top"}
Aresult
11
00
288 0 ▶ $self->{margin_right} //= 0;
Condition0%0/2
$self->{"margin_right"} //= 0
l!l
00
MC/DC0%0/1
$self->{"margin_right"} //= 0
$self->{"margin_right"}
Truth table0%0/2
A
A= $self->{"margin_right"}
Aresult
11
00
289 0 ▶ $self->{margin_bottom} //= 0;
Condition0%0/2
$self->{"margin_bottom"} //= 0
l!l
00
MC/DC0%0/1
$self->{"margin_bottom"} //= 0
$self->{"margin_bottom"}
Truth table0%0/2
A
A= $self->{"margin_bottom"}
Aresult
11
00
290 0 ▶ $self->{margin_left} //= 0;
Condition0%0/2
$self->{"margin_left"} //= 0
l!l
00
MC/DC0%0/1
$self->{"margin_left"} //= 0
$self->{"margin_left"}
Truth table0%0/2
A
A= $self->{"margin_left"}
Aresult
11
00
291 }
292  
293  
294 0 ▶sub choose {
Subroutine choose: not called CC=2 SCAR=17.9
Pod documented
295 0 ▶ if ( ref $_[0] ne __PACKAGE__ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] ne __PACKAGE__) 0 0 0
296 0 my $ob = __PACKAGE__->new();
297 0 delete $ob->{backup_instance_defaults};
298 0 return $ob->__choose( @_ );
299 }
300 0 my $self = shift;
301 0 return $self->__choose( @_ );
302 }
303  
304  
305 0 ▶sub __choose {
Subroutine __choose: not called CC=149 SCAR=100.1
306 0 my $self = shift;
307 0 my ( $orig_list_ref, $opt ) = @_;
308 0 ▶ croak "choose: 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
309 0 ▶ croak "choose: the first argument must be an ARRAY reference" if ref $orig_list_ref ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $orig_list_ref ne "ARRAY" 0 0 0
310 0 ▶ if ( defined $opt ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt) 0 0 0
311 0 ▶ croak "choose: the (optional) second argument must be a HASH reference" if ref $opt ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opt ne "HASH" 0 0 0
312 0 validate_options( _valid_options(), $opt, 'choose' );
313 0 for my $key ( keys %$opt ) {
314 0 ▶ $self->{$key} = $opt->{$key} if defined $opt->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->{$key} 0 0 0
315 }
316 }
317 0 ▶ if ( ! @$orig_list_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$orig_list_ref) 0 0 0
318 0 return;
319 }
320 0 local $\ = undef;
321 0 local $, = undef;
322 0 local $| = 1;
323 0 ▶ if ( defined $self->{busy_string} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"busy_string"}) 0 0 0
324 0 print "\r" . clear_to_end_of_line();
325 0 print $self->{busy_string};
326 }
327 0 $self->{wantarray} = wantarray;
328 0 $self->__modify_options();
329 0 ▶ if ( $self->{mouse} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"mouse"}) 0 0 0
330 0 require Term::Choose::Opt::Mouse;
331 }
332 0 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 0 0
333 0 ▶ print $opt->{codepage_mapping} ? "\e(K" : "\e(U";
Branch: 1 branch
BranchTrueFalseTotal
$opt->{'codepage_mapping'} ? : 0 0 0
334 }
335 0 $self->__copy_orig_list( $orig_list_ref );
336 0 $self->__length_list_elements();
337 0 ▶ if ( defined $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"skip_items"}) 0 0 0
338 0 require Term::Choose::Opt::SkipItems;
339 0 $self->Term::Choose::Opt::SkipItems::__prepare_default();
340 }
341 0 ▶ if ( exists $ENV{TC_RESET_AUTO_UP} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"TC_RESET_AUTO_UP"}) 0 0 0
342 0 $ENV{TC_RESET_AUTO_UP} = 0;
343 }
344 0 ▶ local $SIG{INT} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
345 0 $self->__reset_term();
346 0 exit;
347 0 };
348 0 $self->__init_term();
349 0 ( $self->{term_width}, $self->{term_height} ) = get_term_size();
350 0 my $min_term_width = 3; # + 1
351 0 my $min_term_height = 2;
352 0 ▶ if ( $self->{term_width} < $min_term_width || $self->{term_height} < $min_term_height ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"term_width"} < $min_term_width or $self->{"term_height"} < $min_term_height) 0 0 0
Condition0%0/3
$self->{"term_width"} < $min_term_width or $self->{"term_height"} < $min_term_height
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"term_width"} < $min_term_width or $self->{"term_height"} < $min_term_height
$self->{"term_width"} < $min_term_width $self->{"term_height"} < $min_term_height
Truth table0%0/3
A or B
A= $self->{"term_width"} < $min_term_widthB= $self->{"term_height"} < $min_term_height
ABresult
1X1
011
000
353 0 $self->__invalid_term_size( $min_term_width, $min_term_height, 0 );
354 }
355 0 $self->__wr_first_screen();
356 0 my $fast_page = 10;
357 0 ▶ if ( $self->{pp_count} > 10_000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pp_count"} > 10000) 0 0 0
358 0 $fast_page = 20;
359 }
360 0 my $saved_pos;
361  
362 0 GET_KEY: while ( 1 ) {
363 0 my $key = $self->__get_key();
364 0 ▶ if ( ! defined $key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $key) 0 0 0
365 0 $self->__reset_term( 1 );
366 0 carp "EOT: $!";
367 0 return;
368 }
369 0 $self->{pressed_key} = $key;
370 0 my ( $new_term_width, $new_term_height ) = get_term_size();
371 0 ▶ if ( $new_term_width < $min_term_width || $new_term_height < $min_term_height ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_term_width < $min_term_width or $new_term_height < $min_term_height) 0 0 0
Condition0%0/3
$new_term_width < $min_term_width or $new_term_height < $min_term_height
l!l&&r!l&&!r
000
MC/DC0%0/2
$new_term_width < $min_term_width or $new_term_height < $min_term_height
$new_term_width < $min_term_width $new_term_height < $min_term_height
Truth table0%0/3
A or B
A= $new_term_width < $min_term_widthB= $new_term_height < $min_term_height
ABresult
1X1
011
000
372 0 $self->__invalid_term_size( $min_term_width, $min_term_height, 1 );
373 }
374 0 ▶ if ( $new_term_width != $self->{term_width} || $new_term_height != $self->{term_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_term_width != $self->{"term_width"} or $new_term_height != $self->{"term_height"}) 0 0 0
Condition0%0/3
$new_term_width != $self->{"term_width"} or $new_term_height != $self->{"term_height"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$new_term_width != $self->{"term_width"} or $new_term_height != $self->{"term_height"}
$new_term_width != $self->{"term_width"} $new_term_height != $self->{"term_height"}
Truth table0%0/3
A or B
A= $new_term_width != $self->{"term_width"}B= $new_term_height != $self->{"term_height"}
ABresult
1X1
011
000
375 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ll"}) 0 0 0
376 0 $self->__reset_term( 0 );
377 0 return -1;
378 }
379 0 ▶ if ( $new_term_width < $self->{term_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_term_width < $self->{"term_width"}) 0 0 0
380 0 ▶ my $up = $self->{i_row} + ( $self->{margin_top} // 0 );
Condition0%0/2
$self->{"margin_top"} // 0
l!l
00
MC/DC0%0/1
$self->{"margin_top"} // 0
$self->{"margin_top"}
Truth table0%0/2
A
A= $self->{"margin_top"}
Aresult
11
00
381 0 for my $opt ( qw( info prompt ) ) {
382 0 ▶ next if ! $self->{$opt};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{$opt} 0 0 0
383 0 for my $row ( @{$self->{$opt . '_rows'}} ) {
384 0 ▶ $up++ and next if ! length $row;
Branch: 1 branch
BranchTrueFalseTotal
unless length $row 0 0 0
Condition0%0/5
length $row || $up++ && (next)
l!l&&r!l&&!r
000
$up++ and next
!ll
00
MC/DC0%0/2
length $row || $up++ && (next)
length $row $up++
Truth table0%0/3
A || B
A= length $rowB= $up++
ABresult
1X1
011
000
385 0 ▶ $row =~ s/${\SGR_ES}//g if $self->{color}; # __modify_options() resets the rows
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"color"} 0 0 0
386 0 my $w = print_columns( $row );
387 0 $up += int( $w / ( $new_term_width + EXTRA_W ) );
388 0 ▶ $up++ if $w % ( $new_term_width + EXTRA_W );
Branch: 1 branch
BranchTrueFalseTotal
if $w % ($new_term_width + 1) 0 0 0
389 }
390 }
391 0 ▶ $up++ if length $self->{search_info};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"search_info"} 0 0 0
392 0 $self->{count_pre_rows} = $up;
393 }
394  
395 0 ( $self->{term_width}, $self->{term_height} ) = ( $new_term_width, $new_term_height );
396 0 $self->{col_width} = $self->{bu_col_width};
397 0 $self->__modify_options();
398 0 $self->{default} = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
399 0 ▶ if ( $self->{wantarray} && @{$self->{marked}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"wantarray"} and @{$self->{"marked"};}) 0 0 0
Condition0%0/3
$self->{"wantarray"} and @{$self->{"marked"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"wantarray"} and @{$self->{"marked"};}
$self->{"wantarray"} @{$self->{"marked"};}
Truth table0%0/3
A and B
A= $self->{"wantarray"}B= @{$self->{"marked"};}
ABresult
0X0
100
111
400 0 $self->{mark} = $self->__marked_rc2idx();
401 }
402 0 my $up = $self->{i_row} + $self->{count_pre_rows};
403 0 ▶ if ( $up ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($up) 0 0 0
404 0 print up( $up );
405 }
406 # print "\r" . clear_to_end_of_screen();
407 0 $self->__wr_first_screen();
408 0 next GET_KEY;
409 }
410 0 ▶ next GET_KEY if $key == NEXT_get_key;
Branch: 1 branch
BranchTrueFalseTotal
if $key == -1 0 0 0
411 0 ▶ next GET_KEY if $key == KEY_Tilde;
Branch: 1 branch
BranchTrueFalseTotal
if $key == 126 0 0 0
412 0 ▶ if ( exists $ENV{TC_RESET_AUTO_UP} && $ENV{TC_RESET_AUTO_UP} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"TC_RESET_AUTO_UP"} and $ENV{"TC_RESET_AUTO_UP"} == 0) 0 0 0
Condition0%0/3
exists $ENV{"TC_RESET_AUTO_UP"} and $ENV{"TC_RESET_AUTO_UP"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{"TC_RESET_AUTO_UP"} and $ENV{"TC_RESET_AUTO_UP"} == 0
exists $ENV{"TC_RESET_AUTO_UP"} $ENV{"TC_RESET_AUTO_UP"} == 0
Truth table0%0/3
A and B
A= exists $ENV{"TC_RESET_AUTO_UP"}B= $ENV{"TC_RESET_AUTO_UP"} == 0
ABresult
0X0
100
111
413 0 ▶ if ( $key != LINE_FEED && $key != CARRIAGE_RETURN ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key != 10 and $key != 13) 0 0 0
Condition0%0/3
$key != 10 and $key != 13
!ll&&!rl&&r
000
MC/DC0%0/2
$key != 10 and $key != 13
$key != 10 $key != 13
Truth table0%0/3
A and B
A= $key != 10B= $key != 13
ABresult
0X0
100
111
414 0 $ENV{TC_RESET_AUTO_UP} = 1;
415 }
416 }
417 0 my $page_step = 1;
418 0 ▶ if ( $key == VK_INSERT ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key == 345) { } 0 0 0
elsif ($key == 346) { } 0 0 0
419 0 ▶ $page_step = $fast_page if $self->{first_page_row} - $fast_page * $self->{avail_height} >= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"first_page_row"} - $fast_page * $self->{"avail_height"} >= 0 0 0 0
420 0 $key = VK_PAGE_UP;
421 }
422 elsif ( $key == VK_DELETE ) {
423 0 ▶ $page_step = $fast_page if $self->{last_page_row} + $fast_page * $self->{avail_height} <= $#{$self->{rc2idx}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"last_page_row"} + $fast_page * $self->{"avail_height"} <= $#{$$self{"rc2idx"};} 0 0 0
424 0 $key = VK_PAGE_DOWN;
425 }
426 0 ▶ if ( $saved_pos && $key != VK_PAGE_UP && $key != CONTROL_B && $key != VK_PAGE_DOWN && $key != CONTROL_F ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saved_pos and $key != 333 and $key != 2 and $key != 334 and $key != 6) 0 0 0
Condition0%0/12
$saved_pos and $key != 333 and $key != 2 and $key != 334 and $key != 6
!ll&&!rl&&r
000
$saved_pos and $key != 333 and $key != 2 and $key != 334
!ll&&!rl&&r
000
$saved_pos and $key != 333 and $key != 2
!ll&&!rl&&r
000
$saved_pos and $key != 333
!ll&&!rl&&r
000
MC/DC0%0/5
$saved_pos and $key != 333 and $key != 2 and $key != 334 and $key != 6
$saved_pos $key != 333 $key != 2 $key != 334 $key != 6
Truth table0%0/6
A and B and C and D and E
A= $saved_posB= $key != 333C= $key != 2D= $key != 334E= $key != 6
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
427 0 $saved_pos = undef;
428 }
429 # $self->{rc2idx} holds the new list (AoA) formatted in "__list_idx2rc" appropriate to the chosen layout.
430 # $self->{rc2idx} does not hold the values directly but the respective list indexes from the original list.
431 # If the original list would be ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ) and the new formatted list should be
432 # a d g
433 # b e h
434 # c f
435 # then the $self->{rc2idx} would look like this
436 # 0 3 6
437 # 1 4 7
438 # 2 5
439 # So e.g. the second value in the second row of the new list would be $self->{list}[ $self->{rc2idx}[1][1] ].
440 # On the other hand the index of the last row of the new list would be $#{$self->{rc2idx}}
441 # or the index of the last column in the first row would be $#{$self->{rc2idx}[0]}.
442  
443 0 ▶ if ( $key == VK_DOWN || $key == KEY_j ) {
Branch: 16 branches
BranchTrueFalseTotal
if ($key == 340 or $key == 106) { } 0 0 0
elsif ($key == 338 or $key == 107) { } 0 0 0
elsif ($key == 9 or $key == 9) { } 0 0 0
elsif ($key == 127 or $key == 8 or $key == 8) { } 0 0 0
elsif ($key == 339 or $key == 108) { } 0 0 0
elsif ($key == 337 or $key == 104) { } 0 0 0
elsif ($key == 333 or $key == 16) { } 0 0 0
elsif ($key == 334 or $key == 14) { } 0 0 0
elsif ($key == 336 or $key == 1) { } 0 0 0
elsif ($key == 335 or $key == 5) { } 0 0 0
elsif ($key == 113 or $key == 17) { } 0 0 0
elsif ($key == 3) { } 0 0 0
elsif ($key == 10 or $key == 13) { } 0 0 0
elsif ($key == 32) { } 0 0 0
elsif ($key == 0) { } 0 0 0
elsif ($key == 6 and $self->{'search'}) { } 0 0 0
Condition0%0/3
$key == 340 or $key == 106
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 340 or $key == 106
$key == 340 $key == 106
Truth table0%0/3
A or B
A= $key == 340B= $key == 106
ABresult
1X1
011
000
444 0 ▶ if ( ! $self->{rc2idx}[$self->{pos}[ROW]+1]
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'rc2idx'}[$self->{'pos'}[0] + 1] && $self->{'rc2idx'}[$self->{'pos'}[0] + 1][$self->{'pos'}[1]]) { } 0 0 0
Condition0%0/3
$self->{'rc2idx'}[$self->{'pos'}[0] + 1] && $self->{'rc2idx'}[$self->{'pos'}[0] + 1][$self->{'pos'}[1]]
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{'rc2idx'}[$self->{'pos'}[0] + 1] && $self->{'rc2idx'}[$self->{'pos'}[0] + 1][$self->{'pos'}[1]]
$self->{'rc2idx'}[$self->{'pos'}[0] + 1] $self->{'rc2idx'}[$self->{'pos'}[0] + 1][$self->{'pos'}[1]]
Truth table0%0/3
A && B
A= $self->{'rc2idx'}[$self->{'pos'}[0] + 1]B= $self->{'rc2idx'}[$self->{'pos'}[0] + 1][$self->{'pos'}[1]]
ABresult
0X0
100
111
445 || ! $self->{rc2idx}[$self->{pos}[ROW]+1][$self->{pos}[COL]]
446 ) {
447 0 $self->__beep();
448 }
449 else {
450 0 $self->{pos}[ROW]++;
451 0 ▶ if ( $self->{pos}[ROW] <= $self->{last_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] <= $self->{'last_page_row'}) { } 0 0 0
452 0 $self->__wr_cell( $self->{pos}[ROW] - 1, $self->{pos}[COL] );
453 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
454 }
455 else {
456 0 $self->{first_page_row} = $self->{last_page_row} + 1;
457 0 $self->{last_page_row} = $self->{last_page_row} + $self->{avail_height};
458 0 ▶ $self->{last_page_row} = $#{$self->{rc2idx}} if $self->{last_page_row} > $#{$self->{rc2idx}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"last_page_row"} > $#{$$self{"rc2idx"};} 0 0 0
459 0 $self->__wr_screen();
460 }
461 }
462 }
463 ▶ elsif ( $key == VK_UP || $key == KEY_k ) {
Condition0%0/3
$key == 338 or $key == 107
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 338 or $key == 107
$key == 338 $key == 107
Truth table0%0/3
A or B
A= $key == 338B= $key == 107
ABresult
1X1
011
000
464 0 ▶ if ( $self->{pos}[ROW] == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] == 0) { } 0 0 0
465 0 $self->__beep();
466 }
467 else {
468 0 $self->{pos}[ROW]--;
469 0 ▶ if ( $self->{pos}[ROW] >= $self->{first_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] >= $self->{'first_page_row'}) { } 0 0 0
470 0 $self->__wr_cell( $self->{pos}[ROW] + 1, $self->{pos}[COL] );
471 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
472 }
473 else {
474 0 $self->{last_page_row} = $self->{first_page_row} - 1;
475 0 $self->{first_page_row} = $self->{first_page_row} - $self->{avail_height};
476 0 ▶ $self->{first_page_row} = 0 if $self->{first_page_row} < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"first_page_row"} < 0 0 0 0
477 0 $self->__wr_screen();
478 }
479 }
480 }
481 ▶ elsif ( $key == KEY_TAB || $key == CONTROL_I ) { # KEY_TAB == CONTROL_I
Condition0%0/3
$key == 9 or $key == 9
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 9 or $key == 9
$key == 9 $key == 9
Truth table0%0/3
A or B
A= $key == 9B= $key == 9
ABresult
1X1
011
000
482 0 ▶ if ( $self->{pos}[ROW] == $#{$self->{rc2idx}}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] == $#{$$self{'rc2idx'};} and $self->{'pos'}[1] == $#{$self->{'rc2idx'}[$self->{'pos'}[0]];}) { } 0 0 0
Condition0%0/3
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} and $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} and $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
Truth table0%0/3
A and B
A= $self->{"pos"}[0] == $#{$$self{"rc2idx"};}B= $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
ABresult
0X0
100
111
483 0 && $self->{pos}[COL] == $#{$self->{rc2idx}[$self->{pos}[ROW]]}
484 ) {
485 0 $self->__beep();
486 }
487 else {
488 0 ▶ if ( $self->{pos}[COL] < $#{$self->{rc2idx}[$self->{pos}[ROW]]} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] < $#{$self->{'rc2idx'}[$self->{'pos'}[0]];}) { } 0 0 0
489 0 $self->{pos}[COL]++;
490 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] - 1 );
491 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
492 }
493 else {
494 0 $self->{pos}[ROW]++;
495 0 ▶ if ( $self->{pos}[ROW] <= $self->{last_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] <= $self->{'last_page_row'}) { } 0 0 0
496 0 $self->{pos}[COL] = 0;
497 0 $self->__wr_cell( $self->{pos}[ROW] - 1, $#{$self->{rc2idx}[$self->{pos}[ROW] - 1]} );
498 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
499 }
500 else {
501 0 $self->{first_page_row} = $self->{last_page_row} + 1;
502 0 $self->{last_page_row} = $self->{last_page_row} + $self->{avail_height};
503 0 ▶ $self->{last_page_row} = $#{$self->{rc2idx}} if $self->{last_page_row} > $#{$self->{rc2idx}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"last_page_row"} > $#{$$self{"rc2idx"};} 0 0 0
504 0 $self->{pos}[COL] = 0;
505 0 $self->__wr_screen();
506 }
507 }
508 }
509 }
510 ▶ elsif ( $key == KEY_BSPACE || $key == KEY_BTAB || $key == CONTROL_H ) { # KEY_BTAB == CONTROL_H
Condition0%0/6
$key == 127 or $key == 8 or $key == 8
l!l&&r!l&&!r
000
$key == 127 or $key == 8
l!l&&r!l&&!r
000
MC/DC0%0/3
$key == 127 or $key == 8 or $key == 8
$key == 127 $key == 8 $key == 8
Truth table0%0/4
A or B or C
A= $key == 127B= $key == 8C= $key == 8
ABCresult
1XX1
01X1
0011
0000
511 0 ▶ if ( $self->{pos}[COL] == 0 && $self->{pos}[ROW] == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] == 0 and $self->{'pos'}[0] == 0) { } 0 0 0
Condition0%0/3
$self->{"pos"}[1] == 0 and $self->{"pos"}[0] == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"pos"}[1] == 0 and $self->{"pos"}[0] == 0
$self->{"pos"}[1] == 0 $self->{"pos"}[0] == 0
Truth table0%0/3
A and B
A= $self->{"pos"}[1] == 0B= $self->{"pos"}[0] == 0
ABresult
0X0
100
111
512 0 $self->__beep();
513 }
514 else {
515 0 ▶ if ( $self->{pos}[COL] > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] > 0) { } 0 0 0
516 0 $self->{pos}[COL]--;
517 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] + 1 );
518 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
519 }
520 else {
521 0 $self->{pos}[ROW]--;
522 0 ▶ if ( $self->{pos}[ROW] >= $self->{first_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] >= $self->{'first_page_row'}) { } 0 0 0
523 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
524 0 $self->__wr_cell( $self->{pos}[ROW] + 1, 0 );
525 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
526 }
527 else {
528 0 $self->{last_page_row} = $self->{first_page_row} - 1;
529 0 $self->{first_page_row} = $self->{first_page_row} - $self->{avail_height};
530 0 ▶ $self->{first_page_row} = 0 if $self->{first_page_row} < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"first_page_row"} < 0 0 0 0
531 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
532 0 $self->__wr_screen();
533 }
534 }
535 }
536 }
537 ▶ elsif ( $key == VK_RIGHT || $key == KEY_l ) {
Condition0%0/3
$key == 339 or $key == 108
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 339 or $key == 108
$key == 339 $key == 108
Truth table0%0/3
A or B
A= $key == 339B= $key == 108
ABresult
1X1
011
000
538 0 ▶ if ( $self->{pos}[COL] == $#{$self->{rc2idx}[$self->{pos}[ROW]]} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] == $#{$self->{'rc2idx'}[$self->{'pos'}[0]];}) { } 0 0 0
539 0 $self->__beep();
540 }
541 else {
542 0 $self->{pos}[COL]++;
543 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] - 1 );
544 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
545 }
546 }
547 ▶ elsif ( $key == VK_LEFT || $key == KEY_h ) {
Condition0%0/3
$key == 337 or $key == 104
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 337 or $key == 104
$key == 337 $key == 104
Truth table0%0/3
A or B
A= $key == 337B= $key == 104
ABresult
1X1
011
000
548 0 ▶ if ( $self->{pos}[COL] == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] == 0) { } 0 0 0
549 0 $self->__beep();
550 }
551 else {
552 0 $self->{pos}[COL]--;
553 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] + 1 );
554 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
555 }
556 }
557 ▶ elsif ( $key == VK_PAGE_UP || $key == CONTROL_P ) {
Condition0%0/3
$key == 333 or $key == 16
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 333 or $key == 16
$key == 333 $key == 16
Truth table0%0/3
A or B
A= $key == 333B= $key == 16
ABresult
1X1
011
000
558 0 ▶ if ( $self->{first_page_row} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'first_page_row'} <= 0) { } 0 0 0
559 0 $self->__beep();
560 }
561 else {
562 0 $self->{first_page_row} = $self->{avail_height} * ( int( $self->{pos}[ROW] / $self->{avail_height} ) - $page_step );
563 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
564 0 ▶ if ( $saved_pos ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saved_pos) { } 0 0 0
565 0 $self->{pos}[ROW] = $saved_pos->[ROW] + $self->{first_page_row};
566 0 $self->{pos}[COL] = $saved_pos->[COL];
567 0 $saved_pos = undef;
568 }
569 else {
570 0 $self->{pos}[ROW] -= $self->{avail_height} * $page_step;
571 }
572 0 $self->__wr_screen();
573 }
574 }
575 ▶ elsif ( $key == VK_PAGE_DOWN || $key == CONTROL_N ) {
Condition0%0/3
$key == 334 or $key == 14
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 334 or $key == 14
$key == 334 $key == 14
Truth table0%0/3
A or B
A= $key == 334B= $key == 14
ABresult
1X1
011
000
576 0 ▶ if ( $self->{last_page_row} >= $#{$self->{rc2idx}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'last_page_row'} >= $#{$$self{'rc2idx'};}) { } 0 0 0
577 0 $self->__beep();
578 }
579 else {
580 0 my $backup_p_begin = $self->{first_page_row};
581 0 $self->{first_page_row} = $self->{avail_height} * ( int( $self->{pos}[ROW] / $self->{avail_height} ) + $page_step );
582 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
583 0 ▶ $self->{last_page_row} = $#{$self->{rc2idx}} if $self->{last_page_row} > $#{$self->{rc2idx}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"last_page_row"} > $#{$$self{"rc2idx"};} 0 0 0
584 0 ▶ if ( $self->{pos}[ROW] + $self->{avail_height} > $#{$self->{rc2idx}}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] + $self->{'avail_height'} > $#{$$self{'rc2idx'};} or $self->{'pos'}[1] > $#{$self->{'rc2idx'}[$self->{'pos'}[0] + $self->{'avail_height'}];}) { } 0 0 0
Condition0%0/3
$self->{"pos"}[0] + $self->{"avail_height"} > $#{$$self{"rc2idx"};} or $self->{"pos"}[1] > $#{$self->{"rc2idx"}[$self->{"pos"}[0] + $self->{"avail_height"}];}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"pos"}[0] + $self->{"avail_height"} > $#{$$self{"rc2idx"};} or $self->{"pos"}[1] > $#{$self->{"rc2idx"}[$self->{"pos"}[0] + $self->{"avail_height"}];}
$self->{"pos"}[0] + $self->{"avail_height"} > $#{$$self{"rc2idx"};} $self->{"pos"}[1] > $#{$self->{"rc2idx"}[$self->{"pos"}[0] + $self->{"avail_height"}];}
Truth table0%0/3
A or B
A= $self->{"pos"}[0] + $self->{"avail_height"} > $#{$$self{"rc2idx"};}B= $self->{"pos"}[1] > $#{$self->{"rc2idx"}[$self->{"pos"}[0] + $self->{"avail_height"}];}
ABresult
1X1
011
000
585 0 || $self->{pos}[COL] > $#{$self->{rc2idx}[$self->{pos}[ROW] + $self->{avail_height}]}
586 ) {
587 0 $saved_pos = [ $self->{pos}[ROW] - $backup_p_begin, $self->{pos}[COL] ];
588 0 $self->{pos}[ROW] = $#{$self->{rc2idx}};
589 0 ▶ if ( $self->{pos}[COL] > $#{$self->{rc2idx}[$self->{pos}[ROW]]} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pos"}[1] > $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}) 0 0 0
590 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
591 }
592 }
593 else {
594 0 $self->{pos}[ROW] += $self->{avail_height} * $page_step;
595 }
596 0 $self->__wr_screen();
597 }
598 }
599 ▶ elsif ( $key == VK_HOME || $key == CONTROL_A ) {
Condition0%0/3
$key == 336 or $key == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 336 or $key == 1
$key == 336 $key == 1
Truth table0%0/3
A or B
A= $key == 336B= $key == 1
ABresult
1X1
011
000
600 0 ▶ if ( $self->{pos}[COL] == 0 && $self->{pos}[ROW] == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] == 0 and $self->{'pos'}[0] == 0) { } 0 0 0
Condition0%0/3
$self->{"pos"}[1] == 0 and $self->{"pos"}[0] == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"pos"}[1] == 0 and $self->{"pos"}[0] == 0
$self->{"pos"}[1] == 0 $self->{"pos"}[0] == 0
Truth table0%0/3
A and B
A= $self->{"pos"}[1] == 0B= $self->{"pos"}[0] == 0
ABresult
0X0
100
111
601 0 $self->__beep();
602 }
603 else {
604 0 $self->{pos}[ROW] = 0;
605 0 $self->{pos}[COL] = 0;
606 0 $self->{first_page_row} = 0;
607 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
608 0 ▶ $self->{last_page_row} = $#{$self->{rc2idx}} if $self->{last_page_row} > $#{$self->{rc2idx}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"last_page_row"} > $#{$$self{"rc2idx"};} 0 0 0
609 0 $self->__wr_screen();
610 }
611 }
612 ▶ elsif ( $key == VK_END || $key == CONTROL_E ) {
Condition0%0/3
$key == 335 or $key == 5
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 335 or $key == 5
$key == 335 $key == 5
Truth table0%0/3
A or B
A= $key == 335B= $key == 5
ABresult
1X1
011
000
613 0 ▶ if ( $self->{order} == 1 && $self->{idx_of_last_col_in_last_row} < $#{$self->{rc2idx}[0]} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'order'} == 1 and $self->{'idx_of_last_col_in_last_row'} < $#{$$self{'rc2idx'}[0];}) { } 0 0 0
Condition0%0/3
$self->{"order"} == 1 and $self->{"idx_of_last_col_in_last_row"} < $#{$$self{"rc2idx"}[0];}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"order"} == 1 and $self->{"idx_of_last_col_in_last_row"} < $#{$$self{"rc2idx"}[0];}
$self->{"order"} == 1 $self->{"idx_of_last_col_in_last_row"} < $#{$$self{"rc2idx"}[0];}
Truth table0%0/3
A and B
A= $self->{"order"} == 1B= $self->{"idx_of_last_col_in_last_row"} < $#{$$self{"rc2idx"}[0];}
ABresult
0X0
100
111
614 0 ▶ if ( $self->{pos}[ROW] == $#{$self->{rc2idx}} - 1
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] == $#{$$self{'rc2idx'};} - 1 and $self->{'pos'}[1] == $#{$self->{'rc2idx'}[$self->{'pos'}[0]];}) { } 0 0 0
Condition0%0/3
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} - 1 and $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} - 1 and $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} - 1 $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
Truth table0%0/3
A and B
A= $self->{"pos"}[0] == $#{$$self{"rc2idx"};} - 1B= $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
ABresult
0X0
100
111
615 0 && $self->{pos}[COL] == $#{$self->{rc2idx}[$self->{pos}[ROW]]}
616 ) {
617 0 $self->__beep();
618 }
619 else {
620 0 ▶ $self->{first_page_row} = @{$self->{rc2idx}} - ( @{$self->{rc2idx}} % $self->{avail_height} || $self->{avail_height} );
Condition0%0/3
@{$self->{'rc2idx'};} % $self->{'avail_height'} || $self->{'avail_height'}
l!l&&r!l&&!r
000
MC/DC0%0/2
@{$self->{'rc2idx'};} % $self->{'avail_height'} || $self->{'avail_height'}
@{$self->{'rc2idx'};} % $self->{'avail_height'} $self->{'avail_height'}
Truth table0%0/3
A || B
A= @{$self->{'rc2idx'};} % $self->{'avail_height'}B= $self->{'avail_height'}
ABresult
1X1
011
000
621 0 $self->{pos}[ROW] = $#{$self->{rc2idx}} - 1;
622 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
623 0 ▶ if ( $self->{first_page_row} == $#{$self->{rc2idx}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'first_page_row'} == $#{$$self{'rc2idx'};}) { } 0 0 0
624 0 $self->{first_page_row} = $self->{first_page_row} - $self->{avail_height};
625 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
626 }
627 else {
628 0 $self->{last_page_row} = $#{$self->{rc2idx}};
629 }
630 0 $self->__wr_screen();
631 }
632 }
633 else {
634 0 ▶ if ( $self->{pos}[ROW] == $#{$self->{rc2idx}}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] == $#{$$self{'rc2idx'};} and $self->{'pos'}[1] == $#{$self->{'rc2idx'}[$self->{'pos'}[0]];}) { } 0 0 0
Condition0%0/3
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} and $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} and $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
$self->{"pos"}[0] == $#{$$self{"rc2idx"};} $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
Truth table0%0/3
A and B
A= $self->{"pos"}[0] == $#{$$self{"rc2idx"};}B= $self->{"pos"}[1] == $#{$self->{"rc2idx"}[$self->{"pos"}[0]];}
ABresult
0X0
100
111
635 0 && $self->{pos}[COL] == $#{$self->{rc2idx}[$self->{pos}[ROW]]}
636 ) {
637 0 $self->__beep();
638 }
639 else {
640 0 ▶ $self->{first_page_row} = @{$self->{rc2idx}} - ( @{$self->{rc2idx}} % $self->{avail_height} || $self->{avail_height} );
Condition0%0/3
@{$self->{'rc2idx'};} % $self->{'avail_height'} || $self->{'avail_height'}
l!l&&r!l&&!r
000
MC/DC0%0/2
@{$self->{'rc2idx'};} % $self->{'avail_height'} || $self->{'avail_height'}
@{$self->{'rc2idx'};} % $self->{'avail_height'} $self->{'avail_height'}
Truth table0%0/3
A || B
A= @{$self->{'rc2idx'};} % $self->{'avail_height'}B= $self->{'avail_height'}
ABresult
1X1
011
000
641 0 $self->{last_page_row} = $#{$self->{rc2idx}};
642 0 $self->{pos}[ROW] = $#{$self->{rc2idx}};
643 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
644 0 $self->__wr_screen();
645 }
646 }
647 }
648 ▶ elsif ( $key == KEY_q || $key == CONTROL_Q ) {
Condition0%0/3
$key == 113 or $key == 17
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 113 or $key == 17
$key == 113 $key == 17
Truth table0%0/3
A or B
A= $key == 113B= $key == 17
ABresult
1X1
011
000
649 0 $self->__reset_term( 1 );
650 0 return;
651 }
652 elsif ( $key == CONTROL_C ) {
653 0 $self->__reset_term( 1 );
654 0 print STDERR "^C\n";
655 0 exit 1;
656 }
657 ▶ elsif ( $key == LINE_FEED || $key == CARRIAGE_RETURN ) { # LINE_FEED == CONTROL_J, CARRIAGE_RETURN == CONTROL_M # ENTER key
Condition0%0/3
$key == 10 or $key == 13
l!l&&r!l&&!r
000
MC/DC0%0/2
$key == 10 or $key == 13
$key == 10 $key == 13
Truth table0%0/3
A or B
A= $key == 10B= $key == 13
ABresult
1X1
011
000
658 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
659 0 require Term::Choose::Opt::Search;
660 0 $self->Term::Choose::Opt::Search::__search_end();
661 0 next GET_KEY;
662 }
663 0 ▶ my $opt_index = $self->{index} || $self->{ll};
Condition0%0/3
$self->{'index'} || $self->{'ll'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'index'} || $self->{'ll'}
$self->{'index'} $self->{'ll'}
Truth table0%0/3
A || B
A= $self->{'index'}B= $self->{'ll'}
ABresult
1X1
011
000
664 0 my $list_idx = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
665 0 ▶ if ( ! defined $self->{wantarray} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $self->{'wantarray'}) { } 0 0 0
elsif ($self->{'wantarray'}) { } 0 0 0
666 0 $self->__reset_term( 1 );
667 0 return;
668 }
669 elsif ( $self->{wantarray} ) {
670 0 ▶ if ( $self->{include_highlighted} == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'include_highlighted'} == 1) { } 0 0 0
elsif ($self->{'include_highlighted'} == 2) { } 0 0 0
671 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = 1;
672 }
673 elsif ( $self->{include_highlighted} == 2 ) {
674 0 my $chosen = $self->__marked_rc2idx();
675 0 ▶ if ( ! @$chosen ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$chosen) 0 0 0
676 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = 1;
677 }
678 }
679 0 ▶ if ( defined $self->{meta_items} && ! $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"meta_items"} and not $self->{"marked"}[$self->{"pos"}[0]][$self->{"pos"}[1]]) 0 0 0
Condition0%0/3
defined $self->{"meta_items"} and not $self->{"marked"}[$self->{"pos"}[0]][$self->{"pos"}[1]]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"meta_items"} and not $self->{"marked"}[$self->{"pos"}[0]][$self->{"pos"}[1]]
defined $self->{"meta_items"} not $self->{"marked"}[$self->{"pos"}[0]][$self->{"pos"}[1]]
Truth table0%0/3
A and not(B)
A= defined $self->{"meta_items"}B= not $self->{"marked"}[$self->{"pos"}[0]][$self->{"pos"}[1]]
ABresult
0X0
100
111
680 0 for my $meta_item ( @{$self->{meta_items}} ) {
681 0 ▶ if ( $meta_item == $list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta_item == $list_idx) 0 0 0
682 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = 1;
683 0 last;
684 }
685 }
686 }
687 0 my $chosen = $self->__marked_rc2idx();
688 0 $self->__reset_term( 1 );
689 0 ▶ return $opt_index ? @$chosen : @{$orig_list_ref}[@$chosen];
Branch: 1 branch
BranchTrueFalseTotal
$opt_index ? : 0 0 0
690 }
691 else {
692 0 ▶ my $chosen = $opt_index ? $list_idx : $orig_list_ref->[$list_idx];
Branch: 1 branch
BranchTrueFalseTotal
$opt_index ? : 0 0 0
693 0 $self->__reset_term( 1 );
694 0 return $chosen;
695 }
696 }
697 elsif ( $key == KEY_SPACE ) {
698 0 ▶ if ( $self->{wantarray} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'wantarray'}) { } 0 0 0
699 0 my $list_idx = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
700 0 my $locked = 0;
701 0 ▶ if ( defined $self->{no_spacebar} || defined $self->{meta_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"no_spacebar"} or defined $self->{"meta_items"}) 0 0 0
Condition0%0/3
defined $self->{"no_spacebar"} or defined $self->{"meta_items"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{"no_spacebar"} or defined $self->{"meta_items"}
defined $self->{"no_spacebar"} defined $self->{"meta_items"}
Truth table0%0/3
A or B
A= defined $self->{"no_spacebar"}B= defined $self->{"meta_items"}
ABresult
1X1
011
000
702 0 ▶ for my $no_spacebar ( @{$self->{no_spacebar}||[]}, @{$self->{meta_items}||[]} ) {
Condition0%0/4
$self->{'no_spacebar'} || []
l!l
00
$self->{'meta_items'} || []
l!l
00
MC/DC0%0/1
$self->{'no_spacebar'} || []
$self->{'no_spacebar'}
MC/DC0%0/1
$self->{'meta_items'} || []
$self->{'meta_items'}
Truth table0%0/2
A
A= $self->{'no_spacebar'}
Aresult
11
00
Truth table0%0/2
A
A= $self->{'meta_items'}
Aresult
11
00
703 0 ▶ if ( $list_idx == $no_spacebar ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx == $no_spacebar) 0 0 0
704 0 ++$locked;
705 0 last;
706 }
707 }
708 }
709 0 ▶ if ( $locked ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($locked) { } 0 0 0
710 0 $self->__beep();
711 }
712 else {
713 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = ! $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]];
714 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
715 }
716 }
717 else {
718 0 $self->__beep();
719 }
720 }
721 elsif ( $key == CONTROL_SPACE ) {
722 0 ▶ if ( $self->{wantarray} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'wantarray'}) { } 0 0 0
723 0 for my $i ( 0 .. $#{$self->{rc2idx}} ) {
724 0 for my $j ( 0 .. $#{$self->{rc2idx}[$i]} ) {
725 0 $self->{marked}[$i][$j] = ! $self->{marked}[$i][$j];
726 }
727 }
728 0 ▶ if ( $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"skip_items"}) 0 0 0
729 0 $self->Term::Choose::Opt::SkipItems::__unmark_skip_items();
730 }
731 0 ▶ if ( defined $self->{no_spacebar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"no_spacebar"}) 0 0 0
732 0 $self->__marked_idx2rc( $self->{no_spacebar}, 0 );
733 }
734 0 ▶ if ( defined $self->{meta_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"meta_items"}) 0 0 0
735 0 $self->__marked_idx2rc( $self->{meta_items}, 0 );
736 }
737  
738 0 $self->__wr_screen();
739 }
740 else {
741 0 $self->__beep();
742 }
743 }
744 ▶ elsif ( $key == CONTROL_F && $self->{search} ) {
Condition0%0/3
$key == 6 and $self->{"search"}
!ll&&!rl&&r
000
MC/DC0%0/2
$key == 6 and $self->{"search"}
$key == 6 $self->{"search"}
Truth table0%0/3
A and B
A= $key == 6B= $self->{"search"}
ABresult
0X0
100
111
745 0 require Term::Choose::Opt::Search;
746 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ll"}) 0 0 0
747 0 $ENV{TC_POS_AT_SEARCH} = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
748 0 $self->__reset_term( 0 );
749 0 return -13;
750 }
751 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
752 0 $self->Term::Choose::Opt::Search::__search_end();
753 }
754 0 $self->Term::Choose::Opt::Search::__search_begin();
755 }
756 else {
757 0 $self->__beep();
758 }
759 }
760 }
761  
762  
763 0 ▶sub __beep {
Subroutine __beep: not called CC=2 SCAR=17.9
764 0 my ( $self, $beep ) = @_;
765 0 ▶ if ( $beep ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($beep) 0 0 0
766 0 print bell();
767 }
768 }
769  
770  
771 0 ▶sub __wr_first_screen {
Subroutine __wr_first_screen: not called CC=14 SCAR=53.5
772 0 my ( $self ) = @_;
773 0 $self->__avail_screen_size();
774 0 $self->__current_layout();
775 0 $self->__list_idx2rc();
776 0 $self->__prepare_footer_line();
777 0 $self->{first_page_row} = 0;
778 0 ▶ if ( $#{$self->{rc2idx}} > $self->{avail_height} - 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$self{'rc2idx'};} > $self->{'avail_height'} - 1) { } 0 0 0
779 0 $self->{last_page_row} = $self->{avail_height} - 1;
780 }
781 else {
782 0 $self->{last_page_row} = $#{$self->{rc2idx}};
783 }
784 0 $self->{i_row} = 0;
785 0 $self->{i_col} = 0;
786 0 $self->{pos} = [ 0, 0 ];
787 0 $self->{marked} = [];
788 0 ▶ if ( $self->{wantarray} && defined $self->{mark} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"wantarray"} and defined $self->{"mark"}) 0 0 0
Condition0%0/3
$self->{"wantarray"} and defined $self->{"mark"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"wantarray"} and defined $self->{"mark"}
$self->{"wantarray"} defined $self->{"mark"}
Truth table0%0/3
A and B
A= $self->{"wantarray"}B= defined $self->{"mark"}
ABresult
0X0
100
111
789 0 $self->__marked_idx2rc( $self->{mark}, 1 );
790 }
791 0 ▶ if ( defined $self->{default} && $self->{default} <= $#{$self->{list}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"default"} and $self->{"default"} <= $#{$$self{"list"};}) 0 0 0
Condition0%0/3
defined $self->{"default"} and $self->{"default"} <= $#{$$self{"list"};}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"default"} and $self->{"default"} <= $#{$$self{"list"};}
defined $self->{"default"} $self->{"default"} <= $#{$$self{"list"};}
Truth table0%0/3
A and B
A= defined $self->{"default"}B= $self->{"default"} <= $#{$$self{"list"};}
ABresult
0X0
100
111
792 0 $self->__set_cell( $self->{default} );
793 }
794 0 ▶ if ( $self->{clear_screen} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'clear_screen'}) { } 0 0 0
795 0 print clear_screen();
796 }
797 else {
798 0 print "\r" . clear_to_end_of_screen();
799 }
800 0 my $pre_string;
801 0 ▶ $pre_string .= "\n" x $self->{margin_top} if $self->{margin_top};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_top"} 0 0 0
802 0 ▶ $pre_string .= join( "\n\r", @{$self->{info_rows}} ) . "\n\r" if $self->{info_rows};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"info_rows"} 0 0 0
803 0 ▶ $pre_string .= join( "\n\r", @{$self->{prompt_rows}} ) . "\n\r" if $self->{prompt_rows};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"prompt_rows"} 0 0 0
804 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
805 0 my $search_info = ( ' ' x $self->{margin_left} ) . $self->{search_info};
806 0 ▶ if ( print_columns( $search_info ) > $self->{term_width} + EXTRA_W ) {
Branch: 1 branch
BranchTrueFalseTotal
if (print_columns($search_info) > $self->{'term_width'} + 1) { } 0 0 0
807 0 $pre_string .= cut_to_printwidth( $search_info, $self->{term_width} + EXTRA_W - 3 ) . "...\n\r";
808 }
809 else {
810 0 $pre_string .= $search_info . "\n\r";
811 }
812 }
813 # \n\r -> stty 'raw' mode and Term::Readkey 'ultra-raw' mode don't translate newline to carriage_return/newline
814 0 ▶ if ( length $pre_string ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $pre_string) 0 0 0
815 0 print $pre_string;
816 }
817 0 $self->__wr_screen();
818 0 ▶ if ( $self->{mouse} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"mouse"}) 0 0 0
819 0 my $abs_cursor_y = $self->{plugin}->__get_cursor_row();
820 0 $self->{offset_rows} = $abs_cursor_y - 1 - $self->{i_row};
821 }
822 }
823  
824  
825 0 ▶sub __avail_screen_size {
Subroutine __avail_screen_size: not called CC=25 SCAR=64.8
826 0 my ( $self ) = @_;
827 0 $self->{avail_width} = $self->{term_width};
828 0 $self->{extra_w} = 0;
829 0 ▶ if ( $self->{margin_right} || $self->{col_width} > $self->{avail_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_right"} or $self->{"col_width"} > $self->{"avail_width"}) 0 0 0
Condition0%0/3
$self->{"margin_right"} or $self->{"col_width"} > $self->{"avail_width"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"margin_right"} or $self->{"col_width"} > $self->{"avail_width"}
$self->{"margin_right"} $self->{"col_width"} > $self->{"avail_width"}
Truth table0%0/3
A or B
A= $self->{"margin_right"}B= $self->{"col_width"} > $self->{"avail_width"}
ABresult
1X1
011
000
830 0 $self->{extra_w} = EXTRA_W;
831 0 $self->{avail_width} += $self->{extra_w};
832 # + EXTRA_W: use also the last terminal column if there is only one item-column;
833 # With only one item-column the output doesn't get messed up if an item reaches the right edge of the terminal
834 # on a non-MSWin32-OS (EXTRA_W is 0 if OS is MSWin32)
835 # If margin_right is 1 or greater adding EXTRA_W is also OK. When reducing the right margin, ensure that it does
836 # not go below 1 if it was originally set to 1 or greater, so that the EXTRA_W does not have to be removed.
837 }
838 0 my $reduce = $self->__check_horinzontal_margins();
839 0 ▶ if ( defined $reduce ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $reduce) 0 0 0
840 0 ▶ $self->{margin_left} = int( $self->{margin_left} * $reduce ) || 1 if $self->{margin_left};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_left"} 0 0 0
Condition0%0/2
int $self->{'margin_left'} * $reduce || 1
l!l
00
MC/DC0%0/1
int $self->{'margin_left'} * $reduce || 1
int $self->{'margin_left'} * $reduce
Truth table0%0/2
A
A= int $self->{'margin_left'} * $reduce
Aresult
11
00
841 0 ▶ $self->{margin_right} = int( $self->{margin_right} * $reduce ) || 1 if $self->{margin_right};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_right"} 0 0 0
Condition0%0/2
int $self->{'margin_right'} * $reduce || 1
l!l
00
MC/DC0%0/1
int $self->{'margin_right'} * $reduce || 1
int $self->{'margin_right'} * $reduce
Truth table0%0/2
A
A= int $self->{'margin_right'} * $reduce
Aresult
11
00
842 }
843 0 ▶ $self->{avail_width} -= $self->{margin_left} if $self->{margin_left};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_left"} 0 0 0
844 0 ▶ $self->{avail_width} -= $self->{margin_right} if $self->{margin_right};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_right"} 0 0 0
845 0 my $bu_max_width = $self->{max_width};
846 0 ▶ if ( $self->{max_width} && $self->{avail_width} > $self->{max_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'max_width'} and $self->{'avail_width'} > $self->{'max_width'}) { } 0 0 0
Condition0%0/3
$self->{"max_width"} and $self->{"avail_width"} > $self->{"max_width"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"max_width"} and $self->{"avail_width"} > $self->{"max_width"}
$self->{"max_width"} $self->{"avail_width"} > $self->{"max_width"}
Truth table0%0/3
A and B
A= $self->{"max_width"}B= $self->{"avail_width"} > $self->{"max_width"}
ABresult
0X0
100
111
847 0 $self->{avail_width} = $self->{max_width};
848 }
849 else {
850 0 delete $self->{max_width};
851 }
852 0 $self->__fold_text( $reduce, 1 );
853 0 $self->{avail_height} = $self->{term_height};
854 0 ▶ $self->{avail_height} -= $self->{margin_top} if $self->{margin_top};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_top"} 0 0 0
855 0 ▶ $self->{avail_height} -= @{$self->{info_rows}} if $self->{info_rows};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"info_rows"} 0 0 0
856 0 ▶ $self->{avail_height} -= @{$self->{prompt_rows}} if $self->{prompt_rows};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"prompt_rows"} 0 0 0
857 0 ▶ $self->{avail_height}-- if length $self->{search_info};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"search_info"} 0 0 0
858 0 ▶ $self->{avail_height}-- if $self->{page};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"page"} 0 0 0
859 0 ▶ $self->{avail_height} -= @{$self->{bottom_text_rows}} if $self->{bottom_text_rows};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"bottom_text_rows"} 0 0 0
860 0 ▶ $self->{avail_height} -= $self->{margin_bottom} if $self->{margin_bottom};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_bottom"} 0 0 0
861 0 ▶ if ( $self->{avail_height} < $self->{keep} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"avail_height"} < $self->{"keep"}) 0 0 0
862 0 $self->__avail_height_to_keep();
863 }
864 0 $self->{max_width} = $bu_max_width;
865 0 ▶ if ( $self->{max_height} && $self->{avail_height} > $self->{max_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"max_height"} and $self->{"avail_height"} > $self->{"max_height"}) 0 0 0
Condition0%0/3
$self->{"max_height"} and $self->{"avail_height"} > $self->{"max_height"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"max_height"} and $self->{"avail_height"} > $self->{"max_height"}
$self->{"max_height"} $self->{"avail_height"} > $self->{"max_height"}
Truth table0%0/3
A and B
A= $self->{"max_height"}B= $self->{"avail_height"} > $self->{"max_height"}
ABresult
0X0
100
111
866 0 $self->{avail_height} = $self->{max_height};
867 }
868 0 ▶ $self->{count_pre_rows} = $self->{margin_top} + @{$self->{info_rows}//[]} + @{$self->{prompt_rows}//[]};
Condition0%0/4
$self->{"info_rows"} // []
l!l
00
$self->{"prompt_rows"} // []
l!l
00
MC/DC0%0/1
$self->{"info_rows"} // []
$self->{"info_rows"}
MC/DC0%0/1
$self->{"prompt_rows"} // []
$self->{"prompt_rows"}
Truth table0%0/2
A
A= $self->{"info_rows"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"prompt_rows"}
Aresult
11
00
869 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
870 0 ++$self->{count_pre_rows};
871 }
872 }
873  
874  
875 0 ▶sub __reduce_horizontal_margin {
Subroutine __reduce_horizontal_margin: not called CC=10 SCAR=47.0
876 0 my ( $self, $avail_width ) = @_;
877 0 ▶ if ( $avail_width < 4 ) { return 0 }
Branch: 9 branches
BranchTrueFalseTotal
if ($avail_width < 4) { } 0 0 0
elsif ($avail_width < 9) { } 0 0 0
elsif ($avail_width < 16) { } 0 0 0
elsif ($avail_width < 23) { } 0 0 0
elsif ($avail_width < 30) { } 0 0 0
elsif ($avail_width < 37) { } 0 0 0
elsif ($avail_width < 44) { } 0 0 0
elsif ($avail_width < 51) { } 0 0 0
elsif ($avail_width < 58) { } 0 0 0
878 0 elsif ( $avail_width < 9 ) { return 0.10 }
879 0 elsif ( $avail_width < 16 ) { return 0.20 }
880 0 elsif ( $avail_width < 23 ) { return 0.30 }
881 0 elsif ( $avail_width < 30 ) { return 0.40 }
882 0 elsif ( $avail_width < 37 ) { return 0.50 }
883 0 elsif ( $avail_width < 44 ) { return 0.60 }
884 0 elsif ( $avail_width < 51 ) { return 0.70 }
885 0 elsif ( $avail_width < 58 ) { return 0.80 }
886 0 return 0.90;
887 }
888  
889  
890 0 ▶sub __check_horinzontal_margins {
Subroutine __check_horinzontal_margins: not called CC=17 SCAR=57.2
891 0 my ( $self ) = @_;
892 0 my $threshold = 65;
893 0 my $reduce = 1;
894 0 ▶ if ( $self->{margin_left} || $self->{margin_right} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_left"} or $self->{"margin_right"}) 0 0 0
Condition0%0/3
$self->{"margin_left"} or $self->{"margin_right"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"margin_left"} or $self->{"margin_right"}
$self->{"margin_left"} $self->{"margin_right"}
Truth table0%0/3
A or B
A= $self->{"margin_left"}B= $self->{"margin_right"}
ABresult
1X1
011
000
895 0 my $tmp_avail_width = $self->{avail_width} - ( $self->{margin_left} + $self->{margin_right} );
896 0 ▶ if ( $tmp_avail_width < $threshold ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmp_avail_width < $threshold) 0 0 0
897 0 $reduce = $self->__reduce_horizontal_margin( $tmp_avail_width );
898 }
899 }
900  
901 0 for my $opt ( qw( info prompt bottom_text ) ) {
902 0 ▶ if ( length $self->{$opt} && defined $self->{'tabs_' . $opt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{$opt} and defined $$self{'tabs_' . $opt}) 0 0 0
Condition0%0/3
length $self->{$opt} and defined $$self{'tabs_' . $opt}
!ll&&!rl&&r
000
MC/DC0%0/2
length $self->{$opt} and defined $$self{'tabs_' . $opt}
length $self->{$opt} defined $$self{'tabs_' . $opt}
Truth table0%0/3
A and B
A= length $self->{$opt}B= defined $$self{'tabs_' . $opt}
ABresult
0X0
100
111
903 0 my $orig_tabs = 'tabs_' . $opt;
904 0 my $tmp_tabs = 'tmp_tabs_' . $opt; ##
905 $self->{$tmp_tabs} = [
906 $self->{$orig_tabs}[0] // 0, $self->{$orig_tabs}[1] // 0,
907 $self->{$orig_tabs}[2] // 0, $self->{$orig_tabs}[3] // 0,
908 0 ▶ $self->{$orig_tabs}[4]
Condition0%0/8
$self->{$orig_tabs}[0] // 0
l!l
00
$self->{$orig_tabs}[1] // 0
l!l
00
$self->{$orig_tabs}[2] // 0
l!l
00
$self->{$orig_tabs}[3] // 0
l!l
00
MC/DC0%0/1
$self->{$orig_tabs}[0] // 0
$self->{$orig_tabs}[0]
MC/DC0%0/1
$self->{$orig_tabs}[1] // 0
$self->{$orig_tabs}[1]
MC/DC0%0/1
$self->{$orig_tabs}[2] // 0
$self->{$orig_tabs}[2]
MC/DC0%0/1
$self->{$orig_tabs}[3] // 0
$self->{$orig_tabs}[3]
Truth table0%0/2
A
A= $self->{$orig_tabs}[0]
Aresult
11
00
Truth table0%0/2
A
A= $self->{$orig_tabs}[1]
Aresult
11
00
Truth table0%0/2
A
A= $self->{$orig_tabs}[2]
Aresult
11
00
Truth table0%0/2
A
A= $self->{$orig_tabs}[3]
Aresult
11
00
909 ];
910 0 ▶ if ( $self->{$tmp_tabs}[4] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$tmp_tabs}[4]) 0 0 0
911 0 ++$self->{tabs_with_max_width};
912 }
913 0 ▶ if ( $self->{$tmp_tabs}[2] || $self->{$tmp_tabs}[3] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$tmp_tabs}[2] or $self->{$tmp_tabs}[3]) 0 0 0
Condition0%0/3
$self->{$tmp_tabs}[2] or $self->{$tmp_tabs}[3]
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{$tmp_tabs}[2] or $self->{$tmp_tabs}[3]
$self->{$tmp_tabs}[2] $self->{$tmp_tabs}[3]
Truth table0%0/3
A or B
A= $self->{$tmp_tabs}[2]B= $self->{$tmp_tabs}[3]
ABresult
1X1
011
000
914 0 my $avail_text_width = ( $self->{term_width} + EXTRA_W ) - ( $self->{$tmp_tabs}[2] + $self->{$tmp_tabs}[3] );
915 0 ▶ if ( $avail_text_width < $threshold ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($avail_text_width < $threshold) 0 0 0
916 0 my $new_reduce = $self->__reduce_horizontal_margin( $avail_text_width );
917 0 ▶ if ( $new_reduce < $reduce ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_reduce < $reduce) 0 0 0
918 0 $reduce = $new_reduce;
919 }
920 }
921 0 ++$self->{tabs_width_horizontal_margin};
922 }
923 }
924 }
925 0 ▶ if ( $reduce < 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reduce < 1) 0 0 0
926 0 return $reduce;
927 }
928 0 return;
929 }
930  
931  
932 0 ▶sub __fold_text {
Subroutine __fold_text: not called CC=17 SCAR=57.2
933 0 my ( $self, $reduce, $initialize_text_rows ) = @_;
934  
935 0 for my $opt ( qw( info prompt bottom_text ) ) {
936 0 ▶ if ( length $self->{$opt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{$opt}) 0 0 0
937 0 my ( $init, $subseq, $l_margin, $r_margin ) = ( 0, 0, 0, 0 );
938 0 my $max_width;
939 0 my $tmp_tabs = 'tmp_tabs_' . $opt;
940 0 ▶ if ( defined $self->{$tmp_tabs} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{$tmp_tabs}) { } 0 0 0
941 0 ▶ $init = $self->{$tmp_tabs}[0] if $self->{$tmp_tabs}[0];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$tmp_tabs}[0] 0 0 0
942 0 ▶ $subseq = $self->{$tmp_tabs}[1] if $self->{$tmp_tabs}[1];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$tmp_tabs}[1] 0 0 0
943 0 ▶ if ( ! defined $reduce ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $reduce) { } 0 0 0
944 0 $l_margin = $self->{$tmp_tabs}[2];
945 0 $r_margin = $self->{$tmp_tabs}[3];
946 }
947 else {
948 0 ▶ $l_margin = $self->{$tmp_tabs}[2] = int( $self->{$tmp_tabs}[2] * $reduce ) || 1 if $self->{$tmp_tabs}[2];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$tmp_tabs}[2] 0 0 0
Condition0%0/2
int $self->{$tmp_tabs}[2] * $reduce || 1
l!l
00
MC/DC0%0/1
int $self->{$tmp_tabs}[2] * $reduce || 1
int $self->{$tmp_tabs}[2] * $reduce
Truth table0%0/2
A
A= int $self->{$tmp_tabs}[2] * $reduce
Aresult
11
00
949 0 ▶ $r_margin = $self->{$tmp_tabs}[3] = int( $self->{$tmp_tabs}[3] * $reduce ) || 1 if $self->{$tmp_tabs}[3];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$tmp_tabs}[3] 0 0 0
Condition0%0/2
int $self->{$tmp_tabs}[3] * $reduce || 1
l!l
00
MC/DC0%0/1
int $self->{$tmp_tabs}[3] * $reduce || 1
int $self->{$tmp_tabs}[3] * $reduce
Truth table0%0/2
A
A= int $self->{$tmp_tabs}[3] * $reduce
Aresult
11
00
950 }
951 0 ▶ if ( $self->{$tmp_tabs}[4] && $self->{$tmp_tabs}[4] < ( $self->{term_width} + EXTRA_W ) - ( $l_margin + $r_margin ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$tmp_tabs}[4] and $self->{$tmp_tabs}[4] < $self->{"term_width"} + 1 - ($l_margin + $r_margin)) 0 0 0
Condition0%0/3
$self->{$tmp_tabs}[4] and $self->{$tmp_tabs}[4] < $self->{"term_width"} + 1 - ($l_margin + $r_margin)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{$tmp_tabs}[4] and $self->{$tmp_tabs}[4] < $self->{"term_width"} + 1 - ($l_margin + $r_margin)
$self->{$tmp_tabs}[4] $self->{$tmp_tabs}[4] < $self->{"term_width"} + 1 - ($l_margin + $r_margin)
Truth table0%0/3
A and B
A= $self->{$tmp_tabs}[4]B= $self->{$tmp_tabs}[4] < $self->{"term_width"} + 1 - ($l_margin + $r_margin)
ABresult
0X0
100
111
952 0 $max_width = $self->{$tmp_tabs}[4];
953 }
954 }
955 else {
956 0 $l_margin = $self->{margin_left};
957 0 $r_margin = $self->{margin_right};
958 0 $max_width = $self->{max_width};
959 }
960 0 my $width;
961 0 ▶ if ( $max_width ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($max_width) { } 0 0 0
962 0 $width = $l_margin + $max_width;
963 }
964 else {
965 0 $width = $self->{term_width} + EXTRA_W - $r_margin;
966 }
967 0 $init += $l_margin;
968 0 $subseq += $l_margin;
969 0 ▶ if ( $init > $width - 5 || $subseq > $width - 5 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($init > $width - 5 or $subseq > $width - 5) 0 0 0
Condition0%0/3
$init > $width - 5 or $subseq > $width - 5
l!l&&r!l&&!r
000
MC/DC0%0/2
$init > $width - 5 or $subseq > $width - 5
$init > $width - 5 $subseq > $width - 5
Truth table0%0/3
A or B
A= $init > $width - 5B= $subseq > $width - 5
ABresult
1X1
011
000
970 0 ( $init, $subseq ) = ( 0, 0 );
971 }
972 my $fold_opt = {
973 0 width => $width, init_tab => $init, subseq_tab => $subseq, color => $self->{color}, join => 0, truncate_long_tabs => 0
974 };
975 0 my $text_opt_rows = $opt . '_rows';
976 0 ▶ if ( $initialize_text_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($initialize_text_rows) { } 0 0 0
977 0 $self->{$text_opt_rows} = [ line_fold( $self->{$opt}, $fold_opt ) ];
978 }
979 else {
980 0 my $prev_row_count = @{$self->{$text_opt_rows}};
981 0 $self->{$text_opt_rows} = [ line_fold( $self->{$opt}, $fold_opt ) ];
982 0 $self->{avail_height} += $prev_row_count - @{$self->{$text_opt_rows}};
983 }
984  
985 }
986 }
987 }
988  
989  
990 0 ▶sub __avail_height_to_keep {
Subroutine __avail_height_to_keep: not called CC=53 SCAR=79.6
991 0 my ( $self ) = @_;
992 0 my $keep = $self->{keep};
993 0 ▶ if ( $self->{layout} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'layout'} == 2) { } 0 0 0
994 0 ▶ if ( $keep > @{$self->{list}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep > @{$self->{"list"};}) 0 0 0
995 0 $keep = @{$self->{list}};
996 }
997 }
998 else {
999 0 $keep = $self->__keep_to_row_count( $keep );
1000 }
1001 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1002 0 return;
1003 }
1004 0 ▶ if ( $self->{margin_top} || $self->{margin_bottom} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_top"} or $self->{"margin_bottom"}) 0 0 0
Condition0%0/3
$self->{"margin_top"} or $self->{"margin_bottom"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"margin_top"} or $self->{"margin_bottom"}
$self->{"margin_top"} $self->{"margin_bottom"}
Truth table0%0/3
A or B
A= $self->{"margin_top"}B= $self->{"margin_bottom"}
ABresult
1X1
011
000
1005  
1006 0 REDUCE: while ( 1 ) {
1007 0 my $prev_avail_height = $self->{avail_height};
1008  
1009 0 for my $margin_type ( qw( margin_top margin_bottom ) ) {
1010 0 ▶ if ( $self->{$margin_type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$margin_type}) 0 0 0
1011 0 --$self->{$margin_type};
1012 0 ++$self->{avail_height};
1013 0 ▶ last REDUCE if $self->{avail_height} == $keep;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"avail_height"} == $keep 0 0 0
1014 }
1015 }
1016 0 ▶ last REDUCE if $prev_avail_height == $self->{avail_height};
Branch: 1 branch
BranchTrueFalseTotal
if $prev_avail_height == $self->{"avail_height"} 0 0 0
1017 }
1018 }
1019 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1020 0 return;
1021 }
1022 0 ▶ if ( $self->{max_width} || $self->{tabs_with_max_width} ) { ##
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"max_width"} or $self->{"tabs_with_max_width"}) 0 0 0
Condition0%0/3
$self->{"max_width"} or $self->{"tabs_with_max_width"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"max_width"} or $self->{"tabs_with_max_width"}
$self->{"max_width"} $self->{"tabs_with_max_width"}
Truth table0%0/3
A or B
A= $self->{"max_width"}B= $self->{"tabs_with_max_width"}
ABresult
1X1
011
000
1023 0 my $increase = {};
1024 0 my $steps = 10;
1025 0 my $avail_width_main = ( $self->{term_width} + $self->{extra_w} ) - ( $self->{margin_left} + $self->{margin_right} );
1026 0 ▶ if ( $self->{max_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"max_width"}) 0 0 0
1027 0 $increase->{main} = int( ( $avail_width_main - $self->{max_width} ) / $steps );
1028 }
1029  
1030 0 for my $opt ( qw( info prompt bottom_text ) ) {
1031 0 my $tmp_tabs = 'tmp_tabs_' . $opt;
1032 0 ▶ if ( defined $self->{$tmp_tabs} && $self->{$tmp_tabs}[4] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{$tmp_tabs} and $self->{$tmp_tabs}[4]) 0 0 0
Condition0%0/3
defined $self->{$tmp_tabs} and $self->{$tmp_tabs}[4]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{$tmp_tabs} and $self->{$tmp_tabs}[4]
defined $self->{$tmp_tabs} $self->{$tmp_tabs}[4]
Truth table0%0/3
A and B
A= defined $self->{$tmp_tabs}B= $self->{$tmp_tabs}[4]
ABresult
0X0
100
111
1033 0 my $avail_width_text = ( $self->{term_width} + EXTRA_W ) - ( $self->{$tmp_tabs}[2] + $self->{$tmp_tabs}[3] );
1034 0 $increase->{$opt} = int( ( $avail_width_text - $self->{$tmp_tabs}[4] ) / $steps );
1035 }
1036 }
1037  
1038 0 for my $s ( 1 .. $steps ) {
1039 0 for my $opt ( keys %$increase ) {
1040 0 ▶ if ( $opt eq 'main' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt eq 'main') { } 0 0 0
1041 0 ▶ if ( $increase->{main} > 0 && $s < $steps ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($increase->{'main'} > 0 and $s < $steps) { } 0 0 0
Condition0%0/3
$increase->{"main"} > 0 and $s < $steps
!ll&&!rl&&r
000
MC/DC0%0/2
$increase->{"main"} > 0 and $s < $steps
$increase->{"main"} > 0 $s < $steps
Truth table0%0/3
A and B
A= $increase->{"main"} > 0B= $s < $steps
ABresult
0X0
100
111
1042 0 $self->{max_width} += $increase->{main};
1043 0 $self->{avail_width} = $self->{max_width};
1044 }
1045 else {
1046 0 $self->{max_width} = undef;
1047 0 $self->{avail_width} = $avail_width_main;
1048 }
1049 }
1050 else {
1051 0 ▶ if ( $increase->{$opt} > 0 && $s < $steps ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($increase->{$opt} > 0 and $s < $steps) { } 0 0 0
Condition0%0/3
$increase->{$opt} > 0 and $s < $steps
!ll&&!rl&&r
000
MC/DC0%0/2
$increase->{$opt} > 0 and $s < $steps
$increase->{$opt} > 0 $s < $steps
Truth table0%0/3
A and B
A= $increase->{$opt} > 0B= $s < $steps
ABresult
0X0
100
111
1052 0 $self->{'tmp_tabs_' . $opt}[4] += $increase->{$opt};
1053 }
1054 else {
1055 0 $self->{'tmp_tabs_' . $opt}[4] = undef;
1056 }
1057 }
1058 }
1059 0 $self->__fold_text();
1060 0 $keep = $self->__keep_to_row_count( $keep );
1061 0 ▶ last if $keep <= $self->{avail_height};
Branch: 1 branch
BranchTrueFalseTotal
if $keep <= $self->{"avail_height"} 0 0 0
1062 }
1063 }
1064 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1065 0 return;
1066 }
1067 0 ▶ if ( $self->{margin_right} || $self->{margin_left} || $self->{tabs_width_horizontal_margin} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_right"} or $self->{"margin_left"} or $self->{"tabs_width_horizontal_margin"}) 0 0 0
Condition0%0/6
$self->{"margin_right"} or $self->{"margin_left"} or $self->{"tabs_width_horizontal_margin"}
l!l&&r!l&&!r
000
$self->{"margin_right"} or $self->{"margin_left"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->{"margin_right"} or $self->{"margin_left"} or $self->{"tabs_width_horizontal_margin"}
$self->{"margin_right"} $self->{"margin_left"} $self->{"tabs_width_horizontal_margin"}
Truth table0%0/4
A or B or C
A= $self->{"margin_right"}B= $self->{"margin_left"}C= $self->{"tabs_width_horizontal_margin"}
ABCresult
1XX1
01X1
0011
0000
1068 0 my $orig_margin_right = $self->{margin_right};
1069 0 my $orig_margin_left = $self->{margin_left};
1070 0 my $orig_avail_width = $self->{avail_width};
1071  
1072 0 for my $reduce ( 0.80, 0.75, 0.6667, 0.5, 0 ) { # 4/5, 3/4, 2/3, 1/2, 0
1073 0 ▶ if ( $self->{margin_right} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_right"}) 0 0 0
1074 0 ▶ $self->{margin_right} = int( $self->{margin_right} * $reduce ) || 1;
Condition0%0/2
int $self->{'margin_right'} * $reduce || 1
l!l
00
MC/DC0%0/1
int $self->{'margin_right'} * $reduce || 1
int $self->{'margin_right'} * $reduce
Truth table0%0/2
A
A= int $self->{'margin_right'} * $reduce
Aresult
11
00
1075 }
1076 0 ▶ if ( $self->{margin_left} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_left"}) 0 0 0
1077 0 ▶ $self->{margin_left} = int( $self->{margin_left} * $reduce ) || 1;
Condition0%0/2
int $self->{'margin_left'} * $reduce || 1
l!l
00
MC/DC0%0/1
int $self->{'margin_left'} * $reduce || 1
int $self->{'margin_left'} * $reduce
Truth table0%0/2
A
A= int $self->{'margin_left'} * $reduce
Aresult
11
00
1078 }
1079 0 $self->{avail_width} = $orig_avail_width + ( $orig_margin_right - $self->{margin_right} ) + ( $orig_margin_left - $self->{margin_left} );
1080 0 $self->__fold_text( $reduce );
1081 0 $keep = $self->__keep_to_row_count( $keep );
1082 0 ▶ last if $keep <= $self->{avail_height}; ##
Branch: 1 branch
BranchTrueFalseTotal
if $keep <= $self->{"avail_height"} 0 0 0
1083 }
1084 }
1085 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1086 0 return;
1087 }
1088 0 ▶ if ( $self->{info_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"info_rows"}) 0 0 0
1089 # Text rows above the menu (info_rows, prompt_rows, search_info) are not deleted. They are pushed upwards
1090 # out of the terminal when the space reserved for them is deleted.
1091 0 ▶ if ( @{$self->{info_rows}} >= $keep - $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'info_rows'};} >= $keep - $self->{'avail_height'}) { } 0 0 0
1092 0 $self->{avail_height} = $keep;
1093 }
1094 else {
1095 0 $self->{avail_height} += @{$self->{info_rows}};
1096 }
1097 }
1098 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1099 0 return;
1100 }
1101 0 ▶ if ( $self->{bottom_text_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"bottom_text_rows"}) 0 0 0
1102 # bottom_text_rows are deleted because they are below the menu.
1103 0 ▶ if ( @{$self->{bottom_text_rows}} > $keep - $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'bottom_text_rows'};} > $keep - $self->{'avail_height'}) { } 0 0 0
1104 0 splice( @{$self->{bottom_text_rows}}, -( $keep - $self->{avail_height} ) );
1105 0 $self->{avail_height} = $keep;
1106 0 my $avail_w;
1107 0 ▶ if ( defined $self->{tmp_tabs_bottom_text} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'tmp_tabs_bottom_text'}) { } 0 0 0
1108 0 $avail_w = $self->{term_width} + EXTRA_W - $self->{tmp_tabs_bottom_text}[3];
1109 }
1110 else {
1111 0 $avail_w = $self->{margin_left} + $self->{avail_width};
1112 }
1113 0 my $ellipsis = '...';
1114 0 my $ellipsis_w = length $ellipsis;
1115 0 ▶ if ( $avail_w >= $ellipsis_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($avail_w >= $ellipsis_w) 0 0 0
1116 0 ▶ while ( print_columns( $self->{bottom_text_rows}[-1] ) + $ellipsis_w > $avail_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if (print_columns($self->{"bottom_text_rows"}[-1]) + $ellipsis_w > $avail_w) 0 0 0
1117 0 $self->{bottom_text_rows}[-1] =~ s/.\z//;
1118 }
1119 0 $self->{bottom_text_rows}[-1] .= $ellipsis;
1120 }
1121 }
1122 else {
1123 0 $self->{avail_height} += @{$self->{bottom_text_rows}};
1124 0 delete $self->{bottom_text_rows};
1125 }
1126 }
1127 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1128 0 return;
1129 }
1130 0 ▶ if ( $self->{prompt_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"prompt_rows"}) 0 0 0
1131 0 ▶ if ( @{$self->{prompt_rows}} > $keep - $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'prompt_rows'};} > $keep - $self->{'avail_height'}) { } 0 0 0
1132 0 $self->{avail_height} = $keep;
1133 }
1134 else {
1135 0 ▶ if ( $self->{avail_height} + @{$self->{prompt_rows}} > 4 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'avail_height'} + @{$self->{'prompt_rows'};} > 4) { } 0 0 0
1136 # keep the last prompt line
1137 0 $self->{avail_height} += @{$self->{prompt_rows}} - 1;
1138 0 --$keep;
1139 }
1140 else {
1141 0 $self->{avail_height} += @{$self->{prompt_rows}};
1142 }
1143 }
1144 }
1145 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1146 0 return;
1147 }
1148 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
1149 0 ▶ if ( $self->{avail_height} > 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'avail_height'} > 2) { } 0 0 0
1150 0 --$keep;
1151 }
1152 else {
1153 0 ++$self->{avail_height};
1154 }
1155 }
1156 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
1157 0 return;
1158 }
1159 0 ▶ if ( $self->{page} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"page"}) 0 0 0
1160 0 --$keep;
1161 }
1162 #if ( $self->{page} ) {
1163 # if ( $self->{avail_height} > 1 ) {
1164 # --$keep;
1165 # }
1166 # else {
1167 # ++$self->{avail_height};
1168 # delete $self->{footer_fmt};
1169 # }
1170 #}
1171 }
1172  
1173  
1174 0 ▶sub __keep_to_row_count {
Subroutine __keep_to_row_count: not called CC=4 SCAR=30.0
1175 0 my ( $self, $keep ) = @_;
1176 0 my $row_w = $self->{col_width};
1177 0 my $count = 1;
1178  
1179 0 while ( 1 ) { ##
1180 0 $row_w += $self->{pad} + $self->{col_width};
1181 0 ▶ if ( $row_w >= $self->{avail_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row_w >= $self->{"avail_width"}) 0 0 0
1182 0 last;
1183 }
1184 0 ++$count;
1185 }
1186 0 my $rows = int( @{$self->{list}} / $count );
1187 0 ▶ if ( @{$self->{list}} % $count ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"list"};} % $count) 0 0 0
1188 0 ++$rows;
1189 }
1190 0 ▶ if ( $keep > $rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep > $rows) 0 0 0
1191 0 $keep = $rows;
1192 }
1193 0 return $keep;
1194 }
1195  
1196  
1197 0 ▶sub __current_layout {
Subroutine __current_layout: not called CC=8 SCAR=42.8
1198 0 my ( $self ) = @_;
1199 0 my $all_in_first_row;
1200 0 ▶ if ( $self->{layout} <= 1 && ! $self->{ll} && ! $self->{max_cols} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"layout"} <= 1 and not $self->{"ll"} and not $self->{"max_cols"}) 0 0 0
Condition0%0/6
$self->{"layout"} <= 1 and not $self->{"ll"} and not $self->{"max_cols"}
!ll&&!rl&&r
000
$self->{"layout"} <= 1 and not $self->{"ll"}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"layout"} <= 1 and not $self->{"ll"} and not $self->{"max_cols"}
$self->{"layout"} <= 1 not $self->{"ll"} not $self->{"max_cols"}
Truth table0%0/4
A and not(B) and not(C)
A= $self->{"layout"} <= 1B= not $self->{"ll"}C= not $self->{"max_cols"}
ABCresult
0XX0
10X0
1100
1111
1201 0 my $firstrow_width = 0;
1202 0 for my $list_idx ( 0 .. $#{$self->{list}} ) {
1203 0 $firstrow_width += $self->{width_elements}[$list_idx] + $self->{pad};
1204 0 ▶ if ( $firstrow_width - $self->{pad} > $self->{avail_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($firstrow_width - $self->{"pad"} > $self->{"avail_width"}) 0 0 0
1205 0 $firstrow_width = 0;
1206 0 last;
1207 }
1208 }
1209 0 $all_in_first_row = $firstrow_width;
1210 }
1211 0 ▶ if ( $all_in_first_row ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($all_in_first_row) { } 0 0 0
elsif ($self->{'col_width'} >= $self->{'avail_width'}) { } 0 0 0
1212 0 $self->{current_layout} = -1;
1213 }
1214 elsif ( $self->{col_width} >= $self->{avail_width} ) {
1215 0 $self->{current_layout} = 2;
1216 0 $self->{col_width} = $self->{avail_width};
1217 }
1218 else {
1219 0 $self->{current_layout} = $self->{layout};
1220 }
1221 0 $self->{col_width_plus} = $self->{col_width} + $self->{pad};
1222 # 'col_width_plus' no effects if layout == 2
1223 }
1224  
1225  
1226 0 ▶sub __list_idx2rc {
Subroutine __list_idx2rc: not called CC=21 SCAR=61.4
1227 0 my ( $self ) = @_;
1228 0 $self->{rc2idx} = [];
1229 0 ▶ if ( $self->{current_layout} == -1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'current_layout'} == -1) { } 0 0 0
elsif ($self->{'current_layout'} == 2) { } 0 0 0
1230 0 $self->{rc2idx}[0] = [ 0 .. $#{$self->{list}} ];
1231 0 $self->{idx_of_last_col_in_last_row} = $#{$self->{list}};
1232 }
1233 elsif ( $self->{current_layout} == 2 ) {
1234 0 for my $list_idx ( 0 .. $#{$self->{list}} ) {
1235 0 $self->{rc2idx}[$list_idx][0] = $list_idx;
1236 0 $self->{idx_of_last_col_in_last_row} = 0;
1237 }
1238 }
1239 else {
1240 0 my $tmp_avail_width = $self->{avail_width} + $self->{pad};
1241 # auto_format
1242 0 ▶ if ( $self->{current_layout} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current_layout"} == 1) 0 0 0
1243 0 my $tmc = int( @{$self->{list}} / $self->{avail_height} );
1244 0 ▶ $tmc++ if @{$self->{list}} % $self->{avail_height};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"list"};} % $self->{"avail_height"} 0 0 0
1245 0 $tmc *= $self->{col_width_plus};
1246 0 ▶ if ( $tmc < $tmp_avail_width ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmc < $tmp_avail_width) 0 0 0
1247 0 $tmc = int( $tmc + ( ( $tmp_avail_width - $tmc ) / 1.5 ) );
1248 0 $tmp_avail_width = $tmc;
1249 }
1250 }
1251 # order
1252 0 my $cols_per_row = int( $tmp_avail_width / $self->{col_width_plus} );
1253 0 ▶ if ( $self->{max_cols} && $cols_per_row > $self->{max_cols} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"max_cols"} and $cols_per_row > $self->{"max_cols"}) 0 0 0
Condition0%0/3
$self->{"max_cols"} and $cols_per_row > $self->{"max_cols"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"max_cols"} and $cols_per_row > $self->{"max_cols"}
$self->{"max_cols"} $cols_per_row > $self->{"max_cols"}
Truth table0%0/3
A and B
A= $self->{"max_cols"}B= $cols_per_row > $self->{"max_cols"}
ABresult
0X0
100
111
1254 0 $cols_per_row = $self->{max_cols};
1255 }
1256 0 ▶ $cols_per_row = 1 if $cols_per_row < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $cols_per_row < 1 0 0 0
1257 0 ▶ $self->{idx_of_last_col_in_last_row} = ( @{$self->{list}} % $cols_per_row || $cols_per_row ) - 1;
Condition0%0/3
@{$self->{'list'};} % $cols_per_row || $cols_per_row
l!l&&r!l&&!r
000
MC/DC0%0/2
@{$self->{'list'};} % $cols_per_row || $cols_per_row
@{$self->{'list'};} % $cols_per_row $cols_per_row
Truth table0%0/3
A || B
A= @{$self->{'list'};} % $cols_per_rowB= $cols_per_row
ABresult
1X1
011
000
1258 0 ▶ if ( $self->{order} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'order'} == 1) { } 0 0 0
1259 0 my $rows = int( ( @{$self->{list}} - 1 + $cols_per_row ) / $cols_per_row );
1260 0 my @rearranged_idx;
1261 0 my $begin = 0;
1262 0 my $end = $rows - 1 ;
1263 0 for my $c ( 0 .. $cols_per_row - 1 ) {
1264 0 ▶ --$end if $c > $self->{idx_of_last_col_in_last_row};
Branch: 1 branch
BranchTrueFalseTotal
if $c > $self->{"idx_of_last_col_in_last_row"} 0 0 0
1265 0 $rearranged_idx[$c] = [ $begin .. $end ];
1266 0 $begin = $end + 1;
1267 0 $end = $begin + $rows - 1;
1268 }
1269 0 for my $r ( 0 .. $rows - 1 ) {
1270 0 my @temp_idx;
1271 0 for my $c ( 0 .. $cols_per_row - 1 ) {
1272 0 ▶ next if $r == $rows - 1 && $c > $self->{idx_of_last_col_in_last_row};
Branch: 1 branch
BranchTrueFalseTotal
if $r == $rows - 1 and $c > $self->{"idx_of_last_col_in_last_row"} 0 0 0
Condition0%0/3
$r == $rows - 1 and $c > $self->{"idx_of_last_col_in_last_row"}
!ll&&!rl&&r
000
MC/DC0%0/2
$r == $rows - 1 and $c > $self->{"idx_of_last_col_in_last_row"}
$r == $rows - 1 $c > $self->{"idx_of_last_col_in_last_row"}
Truth table0%0/3
A and B
A= $r == $rows - 1B= $c > $self->{"idx_of_last_col_in_last_row"}
ABresult
0X0
100
111
1273 0 push @temp_idx, $rearranged_idx[$c][$r];
1274 }
1275 0 push @{$self->{rc2idx}}, \@temp_idx;
1276 }
1277 }
1278 else {
1279 0 my $begin = 0;
1280 0 my $end = $cols_per_row - 1;
1281 0 ▶ $end = $#{$self->{list}} if $end > $#{$self->{list}};
Branch: 1 branch
BranchTrueFalseTotal
if $end > $#{$$self{"list"};} 0 0 0
1282 0 push @{$self->{rc2idx}}, [ $begin .. $end ];
1283 0 ▶ while ( $end < $#{$self->{list}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($end < $#{$$self{"list"};}) 0 0 0
1284 0 $begin += $cols_per_row;
1285 0 $end += $cols_per_row;
1286 0 ▶ $end = $#{$self->{list}} if $end > $#{$self->{list}};
Branch: 1 branch
BranchTrueFalseTotal
if $end > $#{$$self{"list"};} 0 0 0
1287 0 push @{$self->{rc2idx}}, [ $begin .. $end ];
1288 }
1289 }
1290 }
1291 }
1292  
1293  
1294 0 ▶sub __prepare_footer_line {
Subroutine __prepare_footer_line: not called CC=10 SCAR=47.0
1295 0 my ( $self ) = @_;
1296 0 ▶ if ( exists $self->{footer_fmt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"footer_fmt"}) 0 0 0
1297 0 delete $self->{footer_fmt};
1298 }
1299 0 my $pp_total = int( $#{$self->{rc2idx}} / $self->{avail_height} ) + 1; ##
1300 0 ▶ if ( $self->{page} == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'page'} == 0) { } 0 0 0
elsif ($self->{'page'} == 1 and $pp_total == 1) { } 0 0 0
1301 # nothing to do
1302 }
1303 ▶ elsif ( $self->{page} == 1 && $pp_total == 1 ) {
Condition0%0/3
$self->{"page"} == 1 and $pp_total == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"page"} == 1 and $pp_total == 1
$self->{"page"} == 1 $pp_total == 1
Truth table0%0/3
A and B
A= $self->{"page"} == 1B= $pp_total == 1
ABresult
0X0
100
111
1304 0 $self->{avail_height}++;
1305 }
1306 else {
1307 0 my $pp_total_width = length $pp_total;
1308 0 $self->{footer_fmt} = '--- %0' . $pp_total_width . 'd/' . $pp_total . ' --- ';
1309 0 ▶ if ( defined $self->{footer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"footer"}) 0 0 0
1310 0 $self->{footer_fmt} .= $self->{footer};
1311 }
1312 0 ▶ if ( print_columns( sprintf $self->{footer_fmt}, $pp_total ) > $self->{avail_width} ) { # color
Branch: 1 branch
BranchTrueFalseTotal
if (print_columns(sprintf($self->{"footer_fmt"}, $pp_total)) > $self->{"avail_width"}) 0 0 0
1313 0 $self->{footer_fmt} = '%0' . $pp_total_width . 'd/' . $pp_total;
1314 0 ▶ if ( length( sprintf $self->{footer_fmt}, $pp_total ) > $self->{avail_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length sprintf($self->{"footer_fmt"}, $pp_total) > $self->{"avail_width"}) 0 0 0
1315 0 ▶ $pp_total_width = $self->{avail_width} if $pp_total_width > $self->{avail_width};
Branch: 1 branch
BranchTrueFalseTotal
if $pp_total_width > $self->{"avail_width"} 0 0 0
1316 0 $self->{footer_fmt} = '%0' . $pp_total_width . '.' . $pp_total_width . 's';
1317 }
1318 }
1319 0 ▶ if ( $self->{margin_left} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_left"}) 0 0 0
1320 0 $self->{footer_fmt} = ( ' ' x $self->{margin_left} ) . $self->{footer_fmt};
1321 }
1322 }
1323 0 $self->{pp_count} = $pp_total;
1324 }
1325  
1326  
1327 0 ▶sub __marked_idx2rc {
Subroutine __marked_idx2rc: not called CC=11 SCAR=48.8
1328 0 my ( $self, $indexes, $boolean ) = @_;
1329 0 my $last_list_idx = $#{$self->{list}};
1330 0 ▶ if ( $self->{current_layout} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current_layout"} == 2) 0 0 0
1331 0 for my $list_idx ( @$indexes ) {
1332 0 ▶ if ( $list_idx > $last_list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx > $last_list_idx) 0 0 0
1333 0 next;
1334 }
1335 0 $self->{marked}[$list_idx][0] = $boolean;
1336 }
1337 0 return;
1338 }
1339 0 my ( $row, $col );
1340 0 my $cols_per_row = @{$self->{rc2idx}[0]};
1341 0 ▶ if ( $self->{order} == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'order'} == 0) { } 0 0 0
elsif ($self->{'order'} == 1) { } 0 0 0
1342 0 for my $list_idx ( @$indexes ) {
1343 0 ▶ if ( $list_idx > $last_list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx > $last_list_idx) 0 0 0
1344 0 next;
1345 }
1346 0 $row = int( $list_idx / $cols_per_row );
1347 0 $col = $list_idx % $cols_per_row;
1348 0 $self->{marked}[$row][$col] = $boolean;
1349 }
1350 }
1351 elsif ( $self->{order} == 1 ) {
1352 0 my $rows_per_col = @{$self->{rc2idx}};
1353 0 my $col_count_last_row = $self->{idx_of_last_col_in_last_row} + 1;
1354 0 my $last_list_idx_in_cols_full = $rows_per_col * $col_count_last_row - 1;
1355 0 my $first_list_idx_in_cols_short = $last_list_idx_in_cols_full + 1;
1356  
1357 0 for my $list_idx ( @$indexes ) {
1358 0 ▶ if ( $list_idx > $last_list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx > $last_list_idx) 0 0 0
1359 0 next;
1360 }
1361 0 ▶ if ( $list_idx <= $last_list_idx_in_cols_full ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx <= $last_list_idx_in_cols_full) { } 0 0 0
1362 0 $row = $list_idx % $rows_per_col;
1363 0 $col = int( $list_idx / $rows_per_col );
1364 }
1365 else {
1366 0 my $rows_per_col_short = $rows_per_col - 1;
1367 0 $row = ( $list_idx - $first_list_idx_in_cols_short ) % $rows_per_col_short;
1368 0 $col = int( ( $list_idx - $col_count_last_row ) / $rows_per_col_short );
1369 }
1370 0 $self->{marked}[$row][$col] = $boolean;
1371 }
1372 }
1373 }
1374  
1375  
1376 0 ▶sub __set_cell {
Subroutine __set_cell: not called CC=6 SCAR=37.4
1377 0 my ( $self, $list_idx ) = @_;
1378 0 ▶ if ( $self->{current_layout} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current_layout'} == 2) { } 0 0 0
1379 0 $self->{pos} = [ $list_idx, 0 ];
1380 }
1381 else {
1382 0 LOOP: for my $i ( 0 .. $#{$self->{rc2idx}} ) {
1383 0 for my $j ( 0 .. $#{$self->{rc2idx}[$i]} ) {
1384 0 ▶ if ( $list_idx == $self->{rc2idx}[$i][$j] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx == $self->{"rc2idx"}[$i][$j]) 0 0 0
1385 0 $self->{pos} = [ $i, $j ];
1386 0 last LOOP;
1387 }
1388 }
1389 }
1390 }
1391 0 $self->{first_page_row} = $self->{avail_height} * int( $self->{pos}[ROW] / $self->{avail_height} );
1392 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
1393 0 ▶ $self->{last_page_row} = $#{$self->{rc2idx}} if $self->{last_page_row} > $#{$self->{rc2idx}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"last_page_row"} > $#{$$self{"rc2idx"};} 0 0 0
1394 }
1395  
1396  
1397 0 ▶sub __marked_rc2idx {
Subroutine __marked_rc2idx: not called CC=8 SCAR=42.8
1398 0 my ( $self ) = @_;
1399 0 my $list_idx = [];
1400 0 ▶ if ( $self->{order} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'order'} == 1) { } 0 0 0
1401 0 for my $col ( 0 .. $#{$self->{rc2idx}[0]} ) {
1402 0 for my $row ( 0 .. $#{$self->{rc2idx}} ) {
1403 0 ▶ if ( $self->{marked}[$row][$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"marked"}[$row][$col]) 0 0 0
1404 0 push @$list_idx, $self->{rc2idx}[$row][$col];
1405 }
1406 }
1407 }
1408 }
1409 else {
1410 0 for my $row ( 0 .. $#{$self->{rc2idx}} ) {
1411 0 for my $col ( 0 .. $#{$self->{rc2idx}[$row]} ) {
1412 0 ▶ if ( $self->{marked}[$row][$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"marked"}[$row][$col]) 0 0 0
1413 0 push @$list_idx, $self->{rc2idx}[$row][$col];
1414 }
1415 }
1416 }
1417 }
1418 0 return $list_idx;
1419 }
1420  
1421  
1422 0 ▶sub __wr_screen {
Subroutine __wr_screen: not called CC=12 SCAR=50.5
1423 0 my ( $self ) = @_;
1424 0 $self->__goto( 0, 0 );
1425 0 print "\r" . clear_to_end_of_screen();
1426 0 my $line_feeds;
1427 #if ( $self->{footer_fmt} ) {
1428 0 ▶ if ( $self->{footer_fmt} || $self->{pp_count} > 1 ) { ##
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'footer_fmt'} or $self->{'pp_count'} > 1) { } 0 0 0
Condition0%0/3
$self->{"footer_fmt"} or $self->{"pp_count"} > 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"footer_fmt"} or $self->{"pp_count"} > 1
$self->{"footer_fmt"} $self->{"pp_count"} > 1
Truth table0%0/3
A or B
A= $self->{"footer_fmt"}B= $self->{"pp_count"} > 1
ABresult
1X1
011
000
1429 0 $line_feeds = $self->{avail_height};
1430 }
1431 else {
1432 0 $line_feeds = $self->{last_page_row} - $self->{first_page_row} + 1;
1433 }
1434 0 my $up = $line_feeds;
1435 0 my @post_rows;
1436 0 ▶ if ( $self->{footer_fmt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"footer_fmt"}) 0 0 0
1437 0 @post_rows = ( sprintf $self->{footer_fmt}, int( $self->{first_page_row} / $self->{avail_height} ) + 1 );
1438 0 $up += 1;
1439 }
1440 0 ▶ if ( $self->{bottom_text_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"bottom_text_rows"}) 0 0 0
1441 0 push @post_rows, @{$self->{bottom_text_rows}};
1442 0 $up += @{$self->{bottom_text_rows}};
1443 }
1444 0 ▶ if ( $self->{margin_bottom} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_bottom"}) 0 0 0
1445 0 push @post_rows, ( '' ) x $self->{margin_bottom};
1446 0 $up += $self->{margin_bottom};
1447 }
1448 0 print "\n" x $line_feeds;
1449 0 ▶ if ( @post_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@post_rows) 0 0 0
1450 # no leading line-feed because the menu has a trailing line-feed.
1451 0 print join( "\n\r", @post_rows ) . "\r";
1452 0 --$up; # last @post_rows row has no trailing line-feed.
1453 }
1454 0 print up( $up );
1455 0 my $pad_str = ' ' x $self->{pad};
1456 0 my $left_margin = ' ' x $self->{margin_left};
1457  
1458 0 for my $row ( $self->{first_page_row} .. $self->{last_page_row} ) {
1459 0 my $line = $self->__prepare_cell( $row, 0 );
1460 0 ▶ if ( $#{$self->{rc2idx}[$row]} ) { #
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$self{"rc2idx"}[$row];}) 0 0 0
1461 0 for my $col ( 1 .. $#{$self->{rc2idx}[$row]} ) {
1462 0 $line = $line . $pad_str . $self->__prepare_cell( $row, $col );
1463 }
1464 }
1465 0 ▶ if ( $left_margin ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_margin) { } 0 0 0
1466 0 print $left_margin . $line . "\n\r";
1467 }
1468 else {
1469 0 print $line . "\n\r";
1470 }
1471 }
1472 0 print up( $self->{last_page_row} - $self->{first_page_row} + 1 );
1473 # relativ cursor pos: 0, 0
1474 0 ▶ if ( $self->{margin_left} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_left"}) 0 0 0
1475 0 print right( $self->{margin_left} ); # set left margin after "\r"
1476 }
1477 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
1478 }
1479  
1480  
1481 0 ▶sub __prepare_cell {
Subroutine __prepare_cell: not called CC=22 SCAR=62.3
1482 0 my( $self, $row, $col ) = @_;
1483 0 ▶ my $is_current_pos = $row == $self->{pos}[ROW] && $col == $self->{pos}[COL];
Condition0%0/3
$row == $self->{'pos'}[0] && $col == $self->{'pos'}[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$row == $self->{'pos'}[0] && $col == $self->{'pos'}[1]
$row == $self->{'pos'}[0] $col == $self->{'pos'}[1]
Truth table0%0/3
A && B
A= $row == $self->{'pos'}[0]B= $col == $self->{'pos'}[1]
ABresult
0X0
100
111
1484 0 ▶ my $emphasised = ( $self->{marked}[$row][$col] ? bold_underline() : '' ) . ( $is_current_pos ? reverse_video() : '' );
Branch: 2 branches
BranchTrueFalseTotal
$self->{'marked'}[$row][$col] ? : 0 0 0
$is_current_pos ? : 0 0 0
1485 0 my $idx = $self->{rc2idx}[$row][$col];
1486 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ll'}) { } 0 0 0
1487 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'color'}) { } 0 0 0
1488 0 my $str = $self->{list}[$idx];
1489 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) 0 0 0
1490 0 ▶ if ( $is_current_pos && $self->{color} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_current_pos and $self->{'color'} == 1) { } 0 0 0
Condition0%0/3
$is_current_pos and $self->{"color"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$is_current_pos and $self->{"color"} == 1
$is_current_pos $self->{"color"} == 1
Truth table0%0/3
A and B
A= $is_current_posB= $self->{"color"} == 1
ABresult
0X0
100
111
1491 # no color for the selected cell if color == 1
1492 0 $str =~ s/${\SGR_ES}//g;
1493 }
1494 else {
1495 # keep marked cells marked after color escapes
1496 0 $str =~ s/(${\SGR_ES})/${1}$emphasised/g;
1497 }
1498 0 $str = $emphasised . $str;
1499 }
1500 0 return $str . normal();
1501 }
1502 else {
1503 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) { } 0 0 0
1504 0 return $emphasised . $self->{list}[$idx] . normal();
1505 }
1506 else {
1507 0 return $self->{list}[$idx];
1508 }
1509 }
1510 }
1511 else {
1512 0 ▶ my $str = $self->{current_layout} == -1 ? $self->{list}[$idx] : $self->__pad_str_to_colwidth( $idx );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'current_layout'} == -1 ? : 0 0 0
1513 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'color'}) { } 0 0 0
1514 0 my @color;
1515 0 ▶ if ( ! $self->{orig_list}[$idx] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'orig_list'}[$idx]) { } 0 0 0
1516 0 ▶ if ( ! defined $self->{orig_list}[$idx] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $self->{'orig_list'}[$idx]) { } 0 0 0
elsif (not length $self->{'orig_list'}[$idx]) { } 0 0 0
1517 0 @color = $self->{undef} =~ /(${\SGR_ES})/g;
1518 }
1519 elsif ( ! length $self->{orig_list}[$idx] ) {
1520 0 @color = $self->{empty} =~ /(${\SGR_ES})/g;
1521 }
1522 }
1523 else {
1524 0 @color = $self->{orig_list}[$idx] =~ /(${\SGR_ES})/g;
1525 }
1526 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) 0 0 0
1527 0 for ( @color ) {
1528 # keep marked cells marked after color escapes
1529 0 $_ .= $emphasised;
1530 }
1531 0 $str = $emphasised . $str . normal();
1532 0 ▶ if ( $is_current_pos && $self->{color} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_current_pos and $self->{"color"} == 1) 0 0 0
Condition0%0/3
$is_current_pos and $self->{"color"} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$is_current_pos and $self->{"color"} == 1
$is_current_pos $self->{"color"} == 1
Truth table0%0/3
A and B
A= $is_current_posB= $self->{"color"} == 1
ABresult
0X0
100
111
1533 # no color for the selected cell if color == 1
1534 0 @color = ();
1535 0 $str =~ s/${\PH}//g;
1536 }
1537 }
1538 0 ▶ if ( @color ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@color) 0 0 0
1539 0 $str =~ s/${\PH}/shift @color/ge;
1540 0 ▶ if ( ! $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($emphasised) 0 0 0
1541 0 $str .= normal();
1542 }
1543 }
1544 0 return $str;
1545 }
1546 else {
1547 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) 0 0 0
1548 0 $str = $emphasised . $str . normal();
1549 }
1550 0 return $str;
1551 }
1552 }
1553 }
1554  
1555  
1556 0 ▶sub __wr_cell {
Subroutine __wr_cell: not called CC=4 SCAR=30.0
1557 0 my( $self, $row, $col ) = @_;
1558 0 my $idx = $self->{rc2idx}[$row][$col];
1559 0 ▶ if ( $self->{current_layout} == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current_layout'} == -1) { } 0 0 0
1560 0 my $x = 0;
1561 0 ▶ if ( $col > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($col > 0) 0 0 0
1562 0 for my $cl ( 0 .. $col - 1 ) {
1563 0 my $i = $self->{rc2idx}[$row][$cl];
1564 0 $x += $self->{width_elements}[$i] + $self->{pad};
1565 }
1566 }
1567 0 $self->__goto( $row - $self->{first_page_row}, $x );
1568 0 $self->{i_col} = $self->{i_col} + $self->{width_elements}[$idx];
1569 }
1570 else {
1571 0 $self->__goto( $row - $self->{first_page_row}, $col * $self->{col_width_plus} );
1572 0 $self->{i_col} = $self->{i_col} + $self->{col_width};
1573 }
1574 0 print $self->__prepare_cell( $row, $col );
1575 }
1576  
1577  
1578 0 ▶sub __pad_str_to_colwidth {
Subroutine __pad_str_to_colwidth: not called CC=7 SCAR=40.3
1579 0 my ( $self, $idx ) = @_;
1580 0 ▶ if ( $self->{width_elements}[$idx] < $self->{col_width} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'width_elements'}[$idx] < $self->{'col_width'}) { } 0 0 0
elsif ($self->{'width_elements'}[$idx] > $self->{'col_width'}) { } 0 0 0
1581 0 ▶ if ( $self->{alignment} == 0 ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'alignment'} == 0) { } 0 0 0
elsif ($self->{'alignment'} == 1) { } 0 0 0
elsif ($self->{'alignment'} == 2) { } 0 0 0
1582 0 return $self->{list}[$idx] . ( " " x ( $self->{col_width} - $self->{width_elements}[$idx] ) );
1583 }
1584 elsif ( $self->{alignment} == 1 ) {
1585 0 return " " x ( $self->{col_width} - $self->{width_elements}[$idx] ) . $self->{list}[$idx];
1586 }
1587 elsif ( $self->{alignment} == 2 ) {
1588 0 my $all = $self->{col_width} - $self->{width_elements}[$idx];
1589 0 my $half = int( $all / 2 );
1590 0 return ( " " x $half ) . $self->{list}[$idx] . ( " " x ( $all - $half ) );
1591 }
1592 }
1593 elsif ( $self->{width_elements}[$idx] > $self->{col_width} ) {
1594 0 ▶ if ( $self->{col_width} > 6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'col_width'} > 6) { } 0 0 0
1595 0 return cut_to_printwidth( $self->{list}[$idx], $self->{col_width} - 3 ) . '...';
1596 }
1597 else {
1598 0 return cut_to_printwidth( $self->{list}[$idx], $self->{col_width} );
1599 }
1600 }
1601 else {
1602 0 return $self->{list}[$idx];
1603 }
1604 }
1605  
1606  
1607 0 ▶sub __goto {
Subroutine __goto: not called CC=5 SCAR=34.0
1608 0 my ( $self, $newrow, $newcol ) = @_;
1609 # requires up, down, left or right to be 1 or greater
1610 0 ▶ if ( $newrow > $self->{i_row} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($newrow > $self->{'i_row'}) { } 0 0 0
elsif ($newrow < $self->{'i_row'}) { } 0 0 0
1611 0 print down( $newrow - $self->{i_row} );
1612 0 $self->{i_row} = $newrow;
1613 }
1614 elsif ( $newrow < $self->{i_row} ) {
1615 0 print up( $self->{i_row} - $newrow );
1616 0 $self->{i_row} = $newrow;
1617 }
1618 0 ▶ if ( $newcol > $self->{i_col} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($newcol > $self->{'i_col'}) { } 0 0 0
elsif ($newcol < $self->{'i_col'}) { } 0 0 0
1619 0 print right( $newcol - $self->{i_col} );
1620 0 $self->{i_col} = $newcol;
1621 }
1622 elsif ( $newcol < $self->{i_col} ) {
1623 0 print left( $self->{i_col} - $newcol );
1624 0 $self->{i_col} = $newcol;
1625 }
1626 }
1627  
1628  
1629  
1630  
1631 3 1;
1632  
1633  
1634 __END__
↑ Summary Choose/Linux.pm »