Choose.pm

filter: Statementstmt 5.3% 49 / 911 Branchbran 1.4% 8 / 546 Conditioncond 0.0% 0 / 213 MC/DCmcdc 0.0% 0 / 132 Subroutinesub 35.9% 14 / 39 Podpod 100% 2 / 2 totaltotal 3.9% 73 / 1843 CC 380 SCAR 89.4
CC
380
Cov
3%
__choose
21170.0
__avail_height_to_keep
1722.0
__avail_screen_size
506.0
CRAP 7641.9
↑ 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.780';
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 BEGIN {
21 3 ▶ if ( $^O eq 'MSWin32' ) {
Subroutine BEGIN: called CC=2 SCAR=9.2
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 END {
33 3 ▶ if ( $? == 255 ) {
Subroutine END: called CC=4 SCAR=26.7
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 sub new {
52 115 ▶ my $class = shift;
Subroutine new: called CC=6 SCAR=18.0
Pod documented
53 115 my ( $opt ) = @_;
54 115 ▶ croak "new: called with " . @_ . " arguments - 0 or 1 arguments expected" if @_ > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 1 0 115 115
55 115 my $instance_defaults = _defaults();
56 115 ▶ if ( defined $opt ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt) 113 2 115
57 113 ▶ 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 113 113
58 113 validate_options( _valid_options(), $opt, 'new' );
59 113 for my $key ( keys %$opt ) {
60 152 ▶ $instance_defaults->{$key} = $opt->{$key} if defined $opt->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->{$key} 115 37 152
61 }
62 }
63 115 my $self = bless $instance_defaults, $class;
64 115 $self->{backup_instance_defaults} = { %$instance_defaults };
65 115 $self->{plugin} = $Plugin->new();
66 115 return $self;
67 }
68  
69  
70 sub _valid_options {
71 return {
72 113 ▶ beep => '[ 0 1 ]',
Subroutine _valid_options: called CC=1 SCAR=0.0
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 => '[ 1-9 ][ 0-9 ]*',
89 max_width => '[ 1-9 ][ 0-9 ]*',
90 default => '[ 0-9 ]+',
91 pad => '[ 0-9 ]+',
92 margin => 'Array_Int',
93 mark => 'Array_Int',
94 meta_items => 'Array_Int',
95 no_spacebar => 'Array_Int',
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 sub _defaults {
112 return {
113 115 ▶ alignment => 0,
Subroutine _defaults: called CC=1 SCAR=0.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 sub __copy_orig_list {
153 0 ▶ my ( $self, $orig_list_ref ) = @_;
Subroutine __copy_orig_list: not called CC=8 SCAR=42.8
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 sub __length_list_elements {
182 0 ▶ my ( $self ) = @_;
Subroutine __length_list_elements: not called CC=4 SCAR=30.0
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 sub __init_term {
202 0 ▶ my ( $self ) = @_;
Subroutine __init_term: not called CC=1 SCAR=6.9
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 sub __reset_term {
213 0 ▶ my ( $self, $clear_choose ) = @_;
Subroutine __reset_term: not called CC=9 SCAR=45.0
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 sub __get_key {
240 0 ▶ my ( $self ) = @_;
Subroutine __get_key: not called CC=5 SCAR=34.0
241 0 my $key;
242 0 ▶ if ( defined $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"skip_items"}) 0 0 0
243 0 my $idx = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
244 0 ▶ if ( $self->{list}[$idx] =~ $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"list"}[$idx] =~ /$self->{"skip_items"}/) 0 0 0
245 0 $key = $self->Term::Choose::Opt::SkipItems::__key_skipped();
246 }
247 }
248 0 ▶ if ( ! defined $key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $key) 0 0 0
249 0 $key = $self->{plugin}->__get_key_OS( $self->{mouse} );
250 }
251 0 ▶ return $key if ref $key ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $key ne "ARRAY" 0 0 0
252 0 return $self->Term::Choose::Opt::Mouse::__mouse_info_to_key( @$key );
253 }
254  
255  
256 sub __modify_options {
257 0 ▶ my ( $self ) = @_;
Subroutine __modify_options: not called CC=15 SCAR=54.8
258 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
259 0 $self->{layout} = 2;
260 }
261 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
262 0 $self->{page} = 2;
263 }
264 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
265 0 $self->{clear_screen} = 1;
266 }
267 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
268 0 $self->{layout} = 0;
269 }
270 0 ▶ if ( ! defined $self->{prompt} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"prompt"}) 0 0 0
271 0 ▶ $self->{prompt} = defined $self->{wantarray} ? 'Your choice:' : 'Close with ENTER';
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'wantarray'} ? : 0 0 0
272 }
273 0 ▶ if ( defined $self->{margin} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"margin"}) 0 0 0
274 0 ( $self->{margin_top}, $self->{margin_right}, $self->{margin_bottom}, $self->{margin_left} ) = @{$self->{margin}};
275 0 ▶ if ( ! defined $self->{tabs_prompt} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"tabs_prompt"}) 0 0 0
276 0 $self->{tabs_prompt} = [ $self->{margin_left}, $self->{margin_left}, $self->{margin_right} ];
277 }
278 0 ▶ if ( ! defined $self->{tabs_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"tabs_info"}) 0 0 0
279 0 $self->{tabs_info} = [ $self->{margin_left}, $self->{margin_left}, $self->{margin_right} ];
280 }
281 0 ▶ if ( ! defined $self->{tabs_bottom_text} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"tabs_bottom_text"}) 0 0 0
282 0 $self->{tabs_bottom_text} = [ $self->{margin_left}, $self->{margin_left}, $self->{margin_right} ];
283 }
284 }
285 }
286  
287  
288 sub choose {
289 0 ▶ if ( ref $_[0] ne __PACKAGE__ ) {
Subroutine choose: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] ne __PACKAGE__) 0 0 0
290 0 my $ob = __PACKAGE__->new();
291 0 delete $ob->{backup_instance_defaults};
292 0 return $ob->__choose( @_ );
293 }
294 0 my $self = shift;
295 0 return $self->__choose( @_ );
296 }
297  
298  
299 sub __choose {
300 0 ▶ my $self = shift;
Subroutine __choose: not called CC=145 SCAR=99.6
301 0 my ( $orig_list_ref, $opt ) = @_;
302 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
303 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
304 0 ▶ if ( defined $opt ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt) 0 0 0
305 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
306 0 validate_options( _valid_options(), $opt, 'choose' );
307 0 for my $key ( keys %$opt ) {
308 0 ▶ $self->{$key} = $opt->{$key} if defined $opt->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opt->{$key} 0 0 0
309 }
310 }
311 0 ▶ if ( ! @$orig_list_ref ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$orig_list_ref) 0 0 0
312 0 return;
313 }
314 0 local $\ = undef;
315 0 local $, = undef;
316 0 local $| = 1;
317 0 ▶ if ( defined $self->{busy_string} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"busy_string"}) 0 0 0
318 0 print "\r" . clear_to_end_of_line();
319 0 print $self->{busy_string};
320 }
321 0 $self->{wantarray} = wantarray;
322 0 $self->__modify_options();
323 0 ▶ if ( $self->{mouse} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"mouse"}) 0 0 0
324 0 require Term::Choose::Opt::Mouse;
325 }
326 0 ▶ if ( $^O eq 'MSWin32' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 0 0
327 0 ▶ print $opt->{codepage_mapping} ? "\e(K" : "\e(U";
Branch: 1 branch
BranchTrueFalseTotal
$opt->{'codepage_mapping'} ? : 0 0 0
328 }
329 0 $self->__copy_orig_list( $orig_list_ref );
330 0 $self->__length_list_elements();
331 0 ▶ if ( defined $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"skip_items"}) 0 0 0
332 0 require Term::Choose::Opt::SkipItems;
333 0 $self->Term::Choose::Opt::SkipItems::__prepare_default();
334 }
335 0 ▶ if ( exists $ENV{TC_RESET_AUTO_UP} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"TC_RESET_AUTO_UP"}) 0 0 0
336 0 $ENV{TC_RESET_AUTO_UP} = 0;
337 }
338 local $SIG{INT} = sub {
339 0 ▶ $self->__reset_term();
Subroutine __ANON__: not called CC=1 SCAR=6.9
340 0 exit;
341 0 };
342 0 $self->__init_term();
343 0 ( $self->{term_width}, $self->{term_height} ) = get_term_size();
344 0 $self->__wr_first_screen();
345 0 my $fast_page = 10;
346 0 ▶ if ( $self->{pp_count} > 10_000 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"pp_count"} > 10000) 0 0 0
347 0 $fast_page = 20;
348 }
349 0 my $saved_pos;
350  
351 0 GET_KEY: while ( 1 ) {
352 0 my $key = $self->__get_key();
353 0 ▶ if ( ! defined $key ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $key) 0 0 0
354 0 $self->__reset_term( 1 );
355 0 carp "EOT: $!";
356 0 return;
357 }
358 0 $self->{pressed_key} = $key;
359 0 my ( $new_width, $new_height ) = get_term_size();
360 0 ▶ if ( $new_width != $self->{term_width} || $new_height != $self->{term_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_width != $self->{"term_width"} or $new_height != $self->{"term_height"}) 0 0 0
Condition0%0/3
$new_width != $self->{"term_width"} or $new_height != $self->{"term_height"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$new_width != $self->{"term_width"} or $new_height != $self->{"term_height"}
$new_width != $self->{"term_width"} $new_height != $self->{"term_height"}
Truth table0%0/3
A or B
A= $new_width != $self->{"term_width"}B= $new_height != $self->{"term_height"}
ABresult
1X1
011
000
361 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ll"}) 0 0 0
362 0 $self->__reset_term( 0 );
363 0 return -1;
364 }
365 0 ▶ if ( $new_width < $self->{term_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_width < $self->{"term_width"}) 0 0 0
366 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
367 0 for my $opt ( qw( info prompt ) ) {
368 0 ▶ next if ! $self->{$opt};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{$opt} 0 0 0
369 0 for my $row ( @{$self->{$opt . '_rows'}} ) {
370 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
371 0 ▶ $row =~ s/${\SGR_ES}//g if $self->{color}; # __modify_options() resets the rows
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"color"} 0 0 0
372 0 my $w = print_columns( $row );
373 0 $up += int( $w / ( $new_width + EXTRA_W ) );
374 0 ▶ $up++ if $w % ( $new_width + EXTRA_W );
Branch: 1 branch
BranchTrueFalseTotal
if $w % ($new_width + 1) 0 0 0
375 }
376 }
377 0 ▶ $up++ if length $self->{search_info};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"search_info"} 0 0 0
378 0 $self->{count_pre_rows} = $up;
379 }
380  
381 0 ( $self->{term_width}, $self->{term_height} ) = ( $new_width, $new_height );
382 0 $self->{col_width} = $self->{bu_col_width};
383 0 $self->__modify_options();
384 0 $self->{default} = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
385 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
386 0 $self->{mark} = $self->__marked_rc2idx();
387 }
388 0 my $up = $self->{i_row} + $self->{count_pre_rows};
389 0 ▶ if ( $up ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($up) 0 0 0
390 0 print up( $up );
391 }
392 # print "\r" . clear_to_end_of_screen();
393 0 $self->__wr_first_screen();
394 0 next GET_KEY;
395 }
396 0 ▶ next GET_KEY if $key == NEXT_get_key;
Branch: 1 branch
BranchTrueFalseTotal
if $key == -1 0 0 0
397 0 ▶ next GET_KEY if $key == KEY_Tilde;
Branch: 1 branch
BranchTrueFalseTotal
if $key == 126 0 0 0
398 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
399 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
400 0 $ENV{TC_RESET_AUTO_UP} = 1;
401 }
402 }
403 0 my $page_step = 1;
404 0 ▶ if ( $key == VK_INSERT ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key == 345) { } 0 0 0
elsif ($key == 346) { } 0 0 0
405 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
406 0 $key = VK_PAGE_UP;
407 }
408 elsif ( $key == VK_DELETE ) {
409 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
410 0 $key = VK_PAGE_DOWN;
411 }
412 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
413 0 $saved_pos = undef;
414 }
415 # $self->{rc2idx} holds the new list (AoA) formatted in "__list_idx2rc" appropriate to the chosen layout.
416 # $self->{rc2idx} does not hold the values directly but the respective list indexes from the original list.
417 # If the original list would be ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ) and the new formatted list should be
418 # a d g
419 # b e h
420 # c f
421 # then the $self->{rc2idx} would look like this
422 # 0 3 6
423 # 1 4 7
424 # 2 5
425 # So e.g. the second value in the second row of the new list would be $self->{list}[ $self->{rc2idx}[1][1] ].
426 # On the other hand the index of the last row of the new list would be $#{$self->{rc2idx}}
427 # or the index of the last column in the first row would be $#{$self->{rc2idx}[0]}.
428  
429 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
430 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
431 || ! $self->{rc2idx}[$self->{pos}[ROW]+1][$self->{pos}[COL]]
432 ) {
433 0 $self->__beep();
434 }
435 else {
436 0 $self->{pos}[ROW]++;
437 0 ▶ if ( $self->{pos}[ROW] <= $self->{last_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] <= $self->{'last_page_row'}) { } 0 0 0
438 0 $self->__wr_cell( $self->{pos}[ROW] - 1, $self->{pos}[COL] );
439 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
440 }
441 else {
442 0 $self->{first_page_row} = $self->{last_page_row} + 1;
443 0 $self->{last_page_row} = $self->{last_page_row} + $self->{avail_height};
444 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
445 0 $self->__wr_screen();
446 }
447 }
448 }
449 ▶ 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
450 0 ▶ if ( $self->{pos}[ROW] == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] == 0) { } 0 0 0
451 0 $self->__beep();
452 }
453 else {
454 0 $self->{pos}[ROW]--;
455 0 ▶ if ( $self->{pos}[ROW] >= $self->{first_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] >= $self->{'first_page_row'}) { } 0 0 0
456 0 $self->__wr_cell( $self->{pos}[ROW] + 1, $self->{pos}[COL] );
457 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
458 }
459 else {
460 0 $self->{last_page_row} = $self->{first_page_row} - 1;
461 0 $self->{first_page_row} = $self->{first_page_row} - $self->{avail_height};
462 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
463 0 $self->__wr_screen();
464 }
465 }
466 }
467 ▶ 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
468 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
469 0 && $self->{pos}[COL] == $#{$self->{rc2idx}[$self->{pos}[ROW]]}
470 ) {
471 0 $self->__beep();
472 }
473 else {
474 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
475 0 $self->{pos}[COL]++;
476 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] - 1 );
477 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
478 }
479 else {
480 0 $self->{pos}[ROW]++;
481 0 ▶ if ( $self->{pos}[ROW] <= $self->{last_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] <= $self->{'last_page_row'}) { } 0 0 0
482 0 $self->{pos}[COL] = 0;
483 0 $self->__wr_cell( $self->{pos}[ROW] - 1, $#{$self->{rc2idx}[$self->{pos}[ROW] - 1]} );
484 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
485 }
486 else {
487 0 $self->{first_page_row} = $self->{last_page_row} + 1;
488 0 $self->{last_page_row} = $self->{last_page_row} + $self->{avail_height};
489 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
490 0 $self->{pos}[COL] = 0;
491 0 $self->__wr_screen();
492 }
493 }
494 }
495 }
496 ▶ 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
497 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
498 0 $self->__beep();
499 }
500 else {
501 0 ▶ if ( $self->{pos}[COL] > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] > 0) { } 0 0 0
502 0 $self->{pos}[COL]--;
503 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] + 1 );
504 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
505 }
506 else {
507 0 $self->{pos}[ROW]--;
508 0 ▶ if ( $self->{pos}[ROW] >= $self->{first_page_row} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[0] >= $self->{'first_page_row'}) { } 0 0 0
509 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
510 0 $self->__wr_cell( $self->{pos}[ROW] + 1, 0 );
511 0 $self->__wr_cell( $self->{pos}[ROW] , $self->{pos}[COL] );
512 }
513 else {
514 0 $self->{last_page_row} = $self->{first_page_row} - 1;
515 0 $self->{first_page_row} = $self->{first_page_row} - $self->{avail_height};
516 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
517 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
518 0 $self->__wr_screen();
519 }
520 }
521 }
522 }
523 ▶ 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
524 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
525 0 $self->__beep();
526 }
527 else {
528 0 $self->{pos}[COL]++;
529 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] - 1 );
530 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
531 }
532 }
533 ▶ 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
534 0 ▶ if ( $self->{pos}[COL] == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pos'}[1] == 0) { } 0 0 0
535 0 $self->__beep();
536 }
537 else {
538 0 $self->{pos}[COL]--;
539 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] + 1 );
540 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
541 }
542 }
543 ▶ 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
544 0 ▶ if ( $self->{first_page_row} <= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'first_page_row'} <= 0) { } 0 0 0
545 0 $self->__beep();
546 }
547 else {
548 0 $self->{first_page_row} = $self->{avail_height} * ( int( $self->{pos}[ROW] / $self->{avail_height} ) - $page_step );
549 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
550 0 ▶ if ( $saved_pos ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saved_pos) { } 0 0 0
551 0 $self->{pos}[ROW] = $saved_pos->[ROW] + $self->{first_page_row};
552 0 $self->{pos}[COL] = $saved_pos->[COL];
553 0 $saved_pos = undef;
554 }
555 else {
556 0 $self->{pos}[ROW] -= $self->{avail_height} * $page_step;
557 }
558 0 $self->__wr_screen();
559 }
560 }
561 ▶ 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
562 0 ▶ if ( $self->{last_page_row} >= $#{$self->{rc2idx}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'last_page_row'} >= $#{$$self{'rc2idx'};}) { } 0 0 0
563 0 $self->__beep();
564 }
565 else {
566 0 my $backup_p_begin = $self->{first_page_row};
567 0 $self->{first_page_row} = $self->{avail_height} * ( int( $self->{pos}[ROW] / $self->{avail_height} ) + $page_step );
568 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
569 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
570 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
571 0 || $self->{pos}[COL] > $#{$self->{rc2idx}[$self->{pos}[ROW] + $self->{avail_height}]}
572 ) {
573 0 $saved_pos = [ $self->{pos}[ROW] - $backup_p_begin, $self->{pos}[COL] ];
574 0 $self->{pos}[ROW] = $#{$self->{rc2idx}};
575 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
576 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
577 }
578 }
579 else {
580 0 $self->{pos}[ROW] += $self->{avail_height} * $page_step;
581 }
582 0 $self->__wr_screen();
583 }
584 }
585 ▶ 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
586 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
587 0 $self->__beep();
588 }
589 else {
590 0 $self->{pos}[ROW] = 0;
591 0 $self->{pos}[COL] = 0;
592 0 $self->{first_page_row} = 0;
593 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
594 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
595 0 $self->__wr_screen();
596 }
597 }
598 ▶ 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
599 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
600 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
601 0 && $self->{pos}[COL] == $#{$self->{rc2idx}[$self->{pos}[ROW]]}
602 ) {
603 0 $self->__beep();
604 }
605 else {
606 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
607 0 $self->{pos}[ROW] = $#{$self->{rc2idx}} - 1;
608 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
609 0 ▶ if ( $self->{first_page_row} == $#{$self->{rc2idx}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'first_page_row'} == $#{$$self{'rc2idx'};}) { } 0 0 0
610 0 $self->{first_page_row} = $self->{first_page_row} - $self->{avail_height};
611 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
612 }
613 else {
614 0 $self->{last_page_row} = $#{$self->{rc2idx}};
615 }
616 0 $self->__wr_screen();
617 }
618 }
619 else {
620 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
621 0 && $self->{pos}[COL] == $#{$self->{rc2idx}[$self->{pos}[ROW]]}
622 ) {
623 0 $self->__beep();
624 }
625 else {
626 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
627 0 $self->{last_page_row} = $#{$self->{rc2idx}};
628 0 $self->{pos}[ROW] = $#{$self->{rc2idx}};
629 0 $self->{pos}[COL] = $#{$self->{rc2idx}[$self->{pos}[ROW]]};
630 0 $self->__wr_screen();
631 }
632 }
633 }
634 ▶ 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
635 0 $self->__reset_term( 1 );
636 0 return;
637 }
638 elsif ( $key == CONTROL_C ) {
639 0 $self->__reset_term( 1 );
640 0 print STDERR "^C\n";
641 0 exit 1;
642 }
643 ▶ 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
644 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
645 0 require Term::Choose::Opt::Search;
646 0 $self->Term::Choose::Opt::Search::__search_end();
647 0 next GET_KEY;
648 }
649 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
650 0 my $list_idx = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
651 0 ▶ if ( ! defined $self->{wantarray} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $self->{'wantarray'}) { } 0 0 0
elsif ($self->{'wantarray'}) { } 0 0 0
652 0 $self->__reset_term( 1 );
653 0 return;
654 }
655 elsif ( $self->{wantarray} ) {
656 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
657 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = 1;
658 }
659 elsif ( $self->{include_highlighted} == 2 ) {
660 0 my $chosen = $self->__marked_rc2idx();
661 0 ▶ if ( ! @$chosen ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$chosen) 0 0 0
662 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = 1;
663 }
664 }
665 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
666 0 for my $meta_item ( @{$self->{meta_items}} ) {
667 0 ▶ if ( $meta_item == $list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta_item == $list_idx) 0 0 0
668 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = 1;
669 0 last;
670 }
671 }
672 }
673 0 my $chosen = $self->__marked_rc2idx();
674 0 $self->__reset_term( 1 );
675 0 ▶ return $opt_index ? @$chosen : @{$orig_list_ref}[@$chosen];
Branch: 1 branch
BranchTrueFalseTotal
$opt_index ? : 0 0 0
676 }
677 else {
678 0 ▶ my $chosen = $opt_index ? $list_idx : $orig_list_ref->[$list_idx];
Branch: 1 branch
BranchTrueFalseTotal
$opt_index ? : 0 0 0
679 0 $self->__reset_term( 1 );
680 0 return $chosen;
681 }
682 }
683 elsif ( $key == KEY_SPACE ) {
684 0 ▶ if ( $self->{wantarray} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'wantarray'}) { } 0 0 0
685 0 my $list_idx = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
686 0 my $locked = 0;
687 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
688 0 ▶ for my $no_spacebar ( @{$self->{no_spacebar}||[]}, @{$self->{meta_items}||[]} ) {
Branch: 2 branches
BranchTrueFalseTotal
$self->{"no_spacebar"} or [] 0 0 0
$self->{"meta_items"} or [] 0 0 0
689 0 ▶ if ( $list_idx == $no_spacebar ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx == $no_spacebar) 0 0 0
690 0 ++$locked;
691 0 last;
692 }
693 }
694 }
695 0 ▶ if ( $locked ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($locked) { } 0 0 0
696 0 $self->__beep();
697 }
698 else {
699 0 $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]] = ! $self->{marked}[$self->{pos}[ROW]][$self->{pos}[COL]];
700 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
701 }
702 }
703 else {
704 0 $self->__beep();
705 }
706 }
707 elsif ( $key == CONTROL_SPACE ) {
708 0 ▶ if ( $self->{wantarray} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'wantarray'}) { } 0 0 0
709 0 for my $i ( 0 .. $#{$self->{rc2idx}} ) {
710 0 for my $j ( 0 .. $#{$self->{rc2idx}[$i]} ) {
711 0 $self->{marked}[$i][$j] = ! $self->{marked}[$i][$j];
712 }
713 }
714 0 ▶ if ( $self->{skip_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"skip_items"}) 0 0 0
715 0 $self->Term::Choose::Opt::SkipItems::__unmark_skip_items();
716 }
717 0 ▶ if ( defined $self->{no_spacebar} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"no_spacebar"}) 0 0 0
718 0 $self->__marked_idx2rc( $self->{no_spacebar}, 0 );
719 }
720 0 ▶ if ( defined $self->{meta_items} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"meta_items"}) 0 0 0
721 0 $self->__marked_idx2rc( $self->{meta_items}, 0 );
722 }
723  
724 0 $self->__wr_screen();
725 }
726 else {
727 0 $self->__beep();
728 }
729 }
730 ▶ 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
731 0 require Term::Choose::Opt::Search;
732 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ll"}) 0 0 0
733 0 $ENV{TC_POS_AT_SEARCH} = $self->{rc2idx}[$self->{pos}[ROW]][$self->{pos}[COL]];
734 0 $self->__reset_term( 0 );
735 0 return -13;
736 }
737 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
738 0 $self->Term::Choose::Opt::Search::__search_end();
739 }
740 0 $self->Term::Choose::Opt::Search::__search_begin();
741 }
742 else {
743 0 $self->__beep();
744 }
745 }
746 }
747  
748  
749 sub __beep {
750 0 ▶ my ( $self, $beep ) = @_;
Subroutine __beep: not called CC=2 SCAR=17.9
751 0 ▶ if ( $beep ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($beep) 0 0 0
752 0 print bell();
753 }
754 }
755  
756  
757 sub __wr_first_screen {
758 0 ▶ my ( $self ) = @_;
Subroutine __wr_first_screen: not called CC=21 SCAR=61.4
759 0 my $info_w = $self->{term_width} + EXTRA_W;
760 0 ▶ $info_w = $self->{max_width} if $self->{max_width} && $info_w > $self->{max_width};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"max_width"} and $info_w > $self->{"max_width"} 0 0 0
Condition0%0/3
$self->{"max_width"} and $info_w > $self->{"max_width"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"max_width"} and $info_w > $self->{"max_width"}
$self->{"max_width"} $info_w > $self->{"max_width"}
Truth table0%0/3
A and B
A= $self->{"max_width"}B= $info_w > $self->{"max_width"}
ABresult
0X0
100
111
761  
762 0 for my $opt ( qw( info prompt bottom_text ) ) {
763 0 ▶ if ( length $self->{$opt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{$opt}) 0 0 0
764 0 ▶ my $init = $self->{'tabs_' . $opt}[0] // 0;
Condition0%0/2
$$self{'tabs_' . $opt}[0] // 0
l!l
00
MC/DC0%0/1
$$self{'tabs_' . $opt}[0] // 0
$$self{'tabs_' . $opt}[0]
Truth table0%0/2
A
A= $$self{'tabs_' . $opt}[0]
Aresult
11
00
765 0 ▶ my $subseq = $self->{'tabs_' . $opt}[1] // 0;
Condition0%0/2
$$self{'tabs_' . $opt}[1] // 0
l!l
00
MC/DC0%0/1
$$self{'tabs_' . $opt}[1] // 0
$$self{'tabs_' . $opt}[1]
Truth table0%0/2
A
A= $$self{'tabs_' . $opt}[1]
Aresult
11
00
766 0 ▶ my $r_margin = $self->{'tabs_' . $opt}[2] // 0;
Condition0%0/2
$$self{'tabs_' . $opt}[2] // 0
l!l
00
MC/DC0%0/1
$$self{'tabs_' . $opt}[2] // 0
$$self{'tabs_' . $opt}[2]
Truth table0%0/2
A
A= $$self{'tabs_' . $opt}[2]
Aresult
11
00
767 $self->{$opt . '_rows'} = [ line_fold(
768 $self->{$opt}, { width => $info_w - $r_margin, init_tab => $init, subseq_tab => $subseq,
769 0 color => $self->{color}, join => 0 }
770 ) ];
771 }
772 }
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 ▶ $pre_string .= ( $self->{margin_left} ? ' ' x $self->{margin_left} : '' ) . $self->{search_info} . "\n\r";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'margin_left'} ? : 0 0 0
806 }
807 # \n\r -> stty 'raw' mode and Term::Readkey 'ultra-raw' mode don't translate newline to carriage_return/newline
808 0 ▶ if ( length $pre_string ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $pre_string) 0 0 0
809 0 print $pre_string;
810 }
811 0 $self->__wr_screen();
812 0 ▶ if ( $self->{mouse} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"mouse"}) 0 0 0
813 0 my $abs_cursor_y = $self->{plugin}->__get_cursor_row();
814 0 $self->{offset_rows} = $abs_cursor_y - 1 - $self->{i_row};
815 }
816 }
817  
818  
819 sub __avail_screen_size {
820 0 ▶ my ( $self ) = @_;
Subroutine __avail_screen_size: not called CC=22 SCAR=62.3
821 0 ( $self->{avail_width}, $self->{avail_height} ) = ( $self->{term_width}, $self->{term_height} );
822 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
823 0 $self->{avail_width} += EXTRA_W;
824 # + EXTRA_W: use also the last terminal column if there is only one item-column;
825 # with only one item-column the output doesn't get messed up if an item
826 # reaches the right edge of the terminal on a non-MSWin32-OS (EXTRA_W is 0 if OS is MSWin32)
827 }
828 0 ▶ $self->{avail_width} -= $self->{margin_left} if $self->{margin_left};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_left"} 0 0 0
829 0 ▶ $self->{avail_width} -= $self->{margin_right} if $self->{margin_right};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_right"} 0 0 0
830 0 ▶ $self->{avail_width} = $self->{max_width} 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
831 0 ▶ $self->{avail_width} = 1 if $self->{avail_width} < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"avail_width"} < 1 0 0 0
832 #if ( $self->{ll} && $self->{ll} > $self->{avail_width} ) {
833 # return -2;
834 #}
835 0 ▶ $self->{avail_height} -= $self->{margin_top} if $self->{margin_top};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_top"} 0 0 0
836 0 ▶ $self->{avail_height} -= @{$self->{info_rows}} if $self->{info_rows};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"info_rows"} 0 0 0
837 0 ▶ $self->{avail_height} -= @{$self->{prompt_rows}} if $self->{prompt_rows};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"prompt_rows"} 0 0 0
838 0 ▶ $self->{avail_height}-- if length $self->{search_info};
Branch: 1 branch
BranchTrueFalseTotal
if length $self->{"search_info"} 0 0 0
839 0 ▶ $self->{avail_height}-- if $self->{page};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"page"} 0 0 0
840 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
841 0 ▶ $self->{avail_height} -= $self->{margin_bottom} if $self->{margin_bottom};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"margin_bottom"} 0 0 0
842 0 ▶ $self->{avail_height} = $self->{max_height} 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
843 0 ▶ if ( $self->{avail_height} < $self->{keep} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"avail_height"} < $self->{"keep"}) 0 0 0
844 0 $self->__avail_height_to_keep();
845 }
846 0 ▶ $self->{count_pre_rows} = ( $self->{margin_top} // 0 ) + @{$self->{info_rows}//[]} + @{$self->{prompt_rows}//[]};
Condition0%0/6
$self->{"margin_top"} // 0
l!l
00
$self->{"info_rows"} // []
l!l
00
$self->{"prompt_rows"} // []
l!l
00
MC/DC0%0/1
$self->{"margin_top"} // 0
$self->{"margin_top"}
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->{"margin_top"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"info_rows"}
Aresult
11
00
Truth table0%0/2
A
A= $self->{"prompt_rows"}
Aresult
11
00
847 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
848 0 ++$self->{count_pre_rows};
849 }
850 }
851  
852  
853 sub __avail_height_to_keep {
854 0 ▶ my ( $self ) = @_;
Subroutine __avail_height_to_keep: not called CC=41 SCAR=74.5
855 0 my $keep = $self->{keep};
856 0 ▶ if ( $self->{layout} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'layout'} == 2) { } 0 0 0
857 0 ▶ if ( $keep > @{$self->{list}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep > @{$self->{"list"};}) 0 0 0
858 0 $keep = @{$self->{list}};
859 }
860 }
861 else {
862 0 $keep = $self->__keep_to_row_count( $keep );
863 }
864 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
865 0 return;
866 }
867 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
868  
869 0 REDUCE: while ( 1 ) {
870 0 my $prev_avail_height = $self->{avail_height};
871  
872 0 for my $margin_type ( qw( margin_top margin_bottom ) ) {
873 0 ▶ if ( $self->{$margin_type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{$margin_type}) 0 0 0
874 0 --$self->{$margin_type};
875 0 ++$self->{avail_height};
876 0 ▶ last REDUCE if $self->{avail_height} == $keep;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"avail_height"} == $keep 0 0 0
877 }
878 }
879 0 ▶ last REDUCE if $prev_avail_height == $self->{avail_height};
Branch: 1 branch
BranchTrueFalseTotal
if $prev_avail_height == $self->{"avail_height"} 0 0 0
880 }
881 }
882 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
883 0 return;
884 }
885 0 ▶ if ( $self->{margin_right} || $self->{margin_left} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_right"} or $self->{"margin_left"}) 0 0 0
Condition0%0/3
$self->{"margin_right"} or $self->{"margin_left"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"margin_right"} or $self->{"margin_left"}
$self->{"margin_right"} $self->{"margin_left"}
Truth table0%0/3
A or B
A= $self->{"margin_right"}B= $self->{"margin_left"}
ABresult
1X1
011
000
886 0 ▶ my $orig_margin_right = $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
887 0 ▶ my $orig_margin_left = $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
888 0 ▶ $self->{margin_right} = $self->{margin_right} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'margin_right'} ? : 0 0 0
889 0 ▶ $self->{margin_left} = $self->{margin_left} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'margin_left'} ? : 0 0 0
890  
891 0 for my $opt ( qw( info prompt bottom_text ) ) {
892 0 ▶ if ( length $self->{$opt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{$opt}) 0 0 0
893 # don't change tab_prompt, tab_info and tab_text, because they are not restored on win resize.
894 0 my $ts = 'tabs_' . $opt;
895 0 ▶ my $init = defined $self->{$ts}[0] && $self->{$ts}[0] < $self->{margin_left} ? $self->{$ts}[0] : $self->{margin_left};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$ts}[0] && $self->{$ts}[0] < $self->{'margin_left'} ? : 0 0 0
Condition0%0/3
defined $self->{$ts}[0] and $self->{$ts}[0] < $self->{"margin_left"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{$ts}[0] and $self->{$ts}[0] < $self->{"margin_left"}
defined $self->{$ts}[0] $self->{$ts}[0] < $self->{"margin_left"}
Truth table0%0/3
A and B
A= defined $self->{$ts}[0]B= $self->{$ts}[0] < $self->{"margin_left"}
ABresult
0X0
100
111
896 0 ▶ my $subseq = defined $self->{$ts}[1] && $self->{$ts}[1] < $self->{margin_left} ? $self->{$ts}[1] : $self->{margin_left};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$ts}[1] && $self->{$ts}[1] < $self->{'margin_left'} ? : 0 0 0
Condition0%0/3
defined $self->{$ts}[1] and $self->{$ts}[1] < $self->{"margin_left"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{$ts}[1] and $self->{$ts}[1] < $self->{"margin_left"}
defined $self->{$ts}[1] $self->{$ts}[1] < $self->{"margin_left"}
Truth table0%0/3
A and B
A= defined $self->{$ts}[1]B= $self->{$ts}[1] < $self->{"margin_left"}
ABresult
0X0
100
111
897 0 ▶ my $r_margin = defined $self->{$ts}[2] && $self->{$ts}[2] < $self->{margin_right} ? $self->{$ts}[2] : $self->{margin_right};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$ts}[2] && $self->{$ts}[2] < $self->{'margin_right'} ? : 0 0 0
Condition0%0/3
defined $self->{$ts}[2] and $self->{$ts}[2] < $self->{"margin_right"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{$ts}[2] and $self->{$ts}[2] < $self->{"margin_right"}
defined $self->{$ts}[2] $self->{$ts}[2] < $self->{"margin_right"}
Truth table0%0/3
A and B
A= defined $self->{$ts}[2]B= $self->{$ts}[2] < $self->{"margin_right"}
ABresult
0X0
100
111
898 0 my $prev_row_count = @{$self->{$opt . '_rows'}};
899 $self->{$opt . '_rows'} = [ line_fold(
900 $self->{$opt}, { width => $self->{term_width} + EXTRA_W - $r_margin, init_tab => $init,
901 0 subseq_tab => $subseq, color => $self->{color}, join => 0 }
902 ) ];
903 0 $self->{avail_height} += $prev_row_count - @{$self->{$opt . '_rows'}};
904 }
905 }
906 0 $self->{avail_width} += ( $orig_margin_right - $self->{margin_right} ) + ( $orig_margin_left - $self->{margin_left} );
907 0 $keep = $self->__keep_to_row_count( $keep );
908  
909 }
910 0 ▶ if ( $keep <= $self->{avail_height} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep <= $self->{"avail_height"}) 0 0 0
911 0 return;
912 }
913 # Now change method:
914 0 my $available_rows = 0;
915 0 ▶ if ( $self->{term_height} > $keep ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"term_height"} > $keep) 0 0 0
916 0 $self->{avail_height} = $keep;
917 0 $available_rows = $self->{term_height} - $self->{avail_height};
918 }
919 0 ▶ if ( length $self->{search_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->{"search_info"}) 0 0 0
920 0 ▶ if ( $available_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($available_rows) { } 0 0 0
921 0 --$available_rows;
922 }
923 else {
924 0 --$self->{avail_height};
925 }
926 }
927 0 ▶ if ( $self->{page} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"page"}) 0 0 0
928 0 ▶ if ( $available_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($available_rows) { } 0 0 0
929 0 --$available_rows;
930 }
931 else {
932 0 --$self->{avail_height};
933 }
934 }
935 0 ▶ if ( $self->{prompt_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"prompt_rows"}) 0 0 0
936 0 ▶ if ( $available_rows ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($available_rows) { } 0 0 0
elsif ($self->{'avail_height'} > 4) { } 0 0 0
937 0 ▶ if ( @{$self->{prompt_rows}} > $available_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'prompt_rows'};} > $available_rows) { } 0 0 0
938 #splice @{$self->{prompt_rows}}, 0, @{$self->{prompt_rows}} - $available_rows;
939 0 $available_rows = 0;
940 }
941 else {
942 0 $available_rows -= @{$self->{prompt_rows}};
943 }
944 }
945 elsif ( $self->{avail_height} > 4 ) {
946 #$self->{prompt_rows} = [ $self->{prompt_rows}[-1] ];
947 0 --$self->{avail_height};
948 }
949 #else {
950 # delete $self->{prompt_rows};
951 #}
952 }
953 0 ▶ if ( ! $available_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($available_rows) 0 0 0
954 #delete $self->{info_rows};
955 0 delete $self->{bottom_text_rows};
956 0 return;
957 }
958 0 ▶ if ( $self->{bottom_text_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"bottom_text_rows"}) 0 0 0
959 0 ▶ if ( @{$self->{bottom_text_rows}} > $available_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'bottom_text_rows'};} > $available_rows) { } 0 0 0
960 0 $#{$self->{bottom_text_rows}} = $available_rows - 1;
961 0 my $ellipsis = '...';
962 0 my $ellipsis_w = length $ellipsis;
963 0 ▶ my $avail_w = $self->{avail_width} + EXTRA_W + ( $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
964 0 ▶ if ( $avail_w >= $ellipsis_w ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($avail_w >= $ellipsis_w) 0 0 0
965 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
966 0 $self->{bottom_text_rows}[-1] =~ s/.\z//;
967 }
968 0 $self->{bottom_text_rows}[-1] .= $ellipsis;
969 }
970 0 $available_rows = 0;
971 }
972 else {
973 0 $available_rows -= @{$self->{bottom_text_rows}};
974 }
975 }
976 #if ( ! $available_rows ) {
977 # delete $self->{info_rows};
978 # return;
979 #}
980 #if ( $self->{info_rows} ) {
981 # if ( @{$self->{info_rows}} > $available_rows ) { ##
982 # splice @{$self->{info_rows}}, 0, @{$self->{info_rows}} - $available_rows;
983 # }
984 #}
985 }
986  
987  
988 sub __keep_to_row_count {
989 0 ▶ my ( $self, $keep ) = @_;
Subroutine __keep_to_row_count: not called CC=4 SCAR=30.0
990 0 my $row_w = $self->{col_width};
991 0 my $count = 1;
992  
993 0 while ( 1 ) { ##
994 0 $row_w += $self->{pad} + $self->{col_width};
995 0 ▶ if ( $row_w >= $self->{avail_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($row_w >= $self->{"avail_width"}) 0 0 0
996 0 last;
997 }
998 0 ++$count;
999 }
1000 0 my $rows = int( @{$self->{list}} / $count );
1001 0 ▶ if ( @{$self->{list}} % $count ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"list"};} % $count) 0 0 0
1002 0 ++$rows;
1003 }
1004 0 ▶ if ( $keep > $rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep > $rows) 0 0 0
1005 0 $keep = $rows;
1006 }
1007 0 return $keep;
1008 }
1009  
1010  
1011 sub __current_layout {
1012 0 ▶ my ( $self ) = @_;
Subroutine __current_layout: not called CC=8 SCAR=42.8
1013 0 my $all_in_first_row;
1014 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
1015 0 my $firstrow_width = 0;
1016 0 for my $list_idx ( 0 .. $#{$self->{list}} ) {
1017 0 $firstrow_width += $self->{width_elements}[$list_idx] + $self->{pad};
1018 0 ▶ if ( $firstrow_width - $self->{pad} > $self->{avail_width} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($firstrow_width - $self->{"pad"} > $self->{"avail_width"}) 0 0 0
1019 0 $firstrow_width = 0;
1020 0 last;
1021 }
1022 }
1023 0 $all_in_first_row = $firstrow_width;
1024 }
1025 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
1026 0 $self->{current_layout} = -1;
1027 }
1028 elsif ( $self->{col_width} >= $self->{avail_width} ) {
1029 0 $self->{current_layout} = 2;
1030 0 $self->{col_width} = $self->{avail_width};
1031 }
1032 else {
1033 0 $self->{current_layout} = $self->{layout};
1034 }
1035 0 $self->{col_width_plus} = $self->{col_width} + $self->{pad};
1036 # 'col_width_plus' no effects if layout == 2
1037 }
1038  
1039  
1040 sub __list_idx2rc {
1041 0 ▶ my ( $self ) = @_;
Subroutine __list_idx2rc: not called CC=21 SCAR=61.4
1042 0 $self->{rc2idx} = [];
1043 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
1044 0 $self->{rc2idx}[0] = [ 0 .. $#{$self->{list}} ];
1045 0 $self->{idx_of_last_col_in_last_row} = $#{$self->{list}};
1046 }
1047 elsif ( $self->{current_layout} == 2 ) {
1048 0 for my $list_idx ( 0 .. $#{$self->{list}} ) {
1049 0 $self->{rc2idx}[$list_idx][0] = $list_idx;
1050 0 $self->{idx_of_last_col_in_last_row} = 0;
1051 }
1052 }
1053 else {
1054 0 my $tmp_avail_width = $self->{avail_width} + $self->{pad};
1055 # auto_format
1056 0 ▶ if ( $self->{current_layout} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current_layout"} == 1) 0 0 0
1057 0 my $tmc = int( @{$self->{list}} / $self->{avail_height} );
1058 0 ▶ $tmc++ if @{$self->{list}} % $self->{avail_height};
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"list"};} % $self->{"avail_height"} 0 0 0
1059 0 $tmc *= $self->{col_width_plus};
1060 0 ▶ if ( $tmc < $tmp_avail_width ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tmc < $tmp_avail_width) 0 0 0
1061 0 $tmc = int( $tmc + ( ( $tmp_avail_width - $tmc ) / 1.5 ) );
1062 0 $tmp_avail_width = $tmc;
1063 }
1064 }
1065 # order
1066 0 my $cols_per_row = int( $tmp_avail_width / $self->{col_width_plus} );
1067 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
1068 0 $cols_per_row = $self->{max_cols};
1069 }
1070 0 ▶ $cols_per_row = 1 if $cols_per_row < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $cols_per_row < 1 0 0 0
1071 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
1072 0 ▶ if ( $self->{order} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'order'} == 1) { } 0 0 0
1073 0 my $rows = int( ( @{$self->{list}} - 1 + $cols_per_row ) / $cols_per_row );
1074 0 my @rearranged_idx;
1075 0 my $begin = 0;
1076 0 my $end = $rows - 1 ;
1077 0 for my $c ( 0 .. $cols_per_row - 1 ) {
1078 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
1079 0 $rearranged_idx[$c] = [ $begin .. $end ];
1080 0 $begin = $end + 1;
1081 0 $end = $begin + $rows - 1;
1082 }
1083 0 for my $r ( 0 .. $rows - 1 ) {
1084 0 my @temp_idx;
1085 0 for my $c ( 0 .. $cols_per_row - 1 ) {
1086 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
1087 0 push @temp_idx, $rearranged_idx[$c][$r];
1088 }
1089 0 push @{$self->{rc2idx}}, \@temp_idx;
1090 }
1091 }
1092 else {
1093 0 my $begin = 0;
1094 0 my $end = $cols_per_row - 1;
1095 0 ▶ $end = $#{$self->{list}} if $end > $#{$self->{list}};
Branch: 1 branch
BranchTrueFalseTotal
if $end > $#{$$self{"list"};} 0 0 0
1096 0 push @{$self->{rc2idx}}, [ $begin .. $end ];
1097 0 ▶ while ( $end < $#{$self->{list}} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($end < $#{$$self{"list"};}) 0 0 0
1098 0 $begin += $cols_per_row;
1099 0 $end += $cols_per_row;
1100 0 ▶ $end = $#{$self->{list}} if $end > $#{$self->{list}};
Branch: 1 branch
BranchTrueFalseTotal
if $end > $#{$$self{"list"};} 0 0 0
1101 0 push @{$self->{rc2idx}}, [ $begin .. $end ];
1102 }
1103 }
1104 }
1105 }
1106  
1107  
1108 sub __prepare_footer_line {
1109 0 ▶ my ( $self ) = @_;
Subroutine __prepare_footer_line: not called CC=10 SCAR=47.0
1110 0 ▶ if ( exists $self->{footer_fmt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"footer_fmt"}) 0 0 0
1111 0 delete $self->{footer_fmt};
1112 }
1113 0 my $pp_total = int( $#{$self->{rc2idx}} / $self->{avail_height} ) + 1; ##
1114 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
1115 # nothing to do
1116 }
1117 ▶ 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
1118 0 $self->{avail_height}++;
1119 }
1120 else {
1121 0 my $pp_total_width = length $pp_total;
1122 0 $self->{footer_fmt} = '--- %0' . $pp_total_width . 'd/' . $pp_total . ' --- ';
1123 0 ▶ if ( defined $self->{footer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"footer"}) 0 0 0
1124 0 $self->{footer_fmt} .= $self->{footer};
1125 }
1126 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
1127 0 $self->{footer_fmt} = '%0' . $pp_total_width . 'd/' . $pp_total;
1128 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
1129 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
1130 0 $self->{footer_fmt} = '%0' . $pp_total_width . '.' . $pp_total_width . 's';
1131 }
1132 }
1133 0 ▶ if ( $self->{margin_left} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_left"}) 0 0 0
1134 0 $self->{footer_fmt} = ( ' ' x $self->{margin_left} ) . $self->{footer_fmt};
1135 }
1136 }
1137 0 $self->{pp_count} = $pp_total;
1138 }
1139  
1140  
1141 sub __marked_idx2rc {
1142 0 ▶ my ( $self, $list_of_indexes, $boolean ) = @_;
Subroutine __marked_idx2rc: not called CC=11 SCAR=48.8
1143 0 my $last_list_idx = $#{$self->{list}};
1144 0 ▶ if ( $self->{current_layout} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"current_layout"} == 2) 0 0 0
1145 0 for my $list_idx ( @$list_of_indexes ) {
1146 0 ▶ if ( $list_idx > $last_list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx > $last_list_idx) 0 0 0
1147 0 next;
1148 }
1149 0 $self->{marked}[$list_idx][0] = $boolean;
1150 }
1151 0 return;
1152 }
1153 0 my ( $row, $col );
1154 0 my $cols_per_row = @{$self->{rc2idx}[0]};
1155 0 ▶ if ( $self->{order} == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'order'} == 0) { } 0 0 0
elsif ($self->{'order'} == 1) { } 0 0 0
1156 0 for my $list_idx ( @$list_of_indexes ) {
1157 0 ▶ if ( $list_idx > $last_list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx > $last_list_idx) 0 0 0
1158 0 next;
1159 }
1160 0 $row = int( $list_idx / $cols_per_row );
1161 0 $col = $list_idx % $cols_per_row;
1162 0 $self->{marked}[$row][$col] = $boolean;
1163 }
1164 }
1165 elsif ( $self->{order} == 1 ) {
1166 0 my $rows_per_col = @{$self->{rc2idx}};
1167 0 my $col_count_last_row = $self->{idx_of_last_col_in_last_row} + 1;
1168 0 my $last_list_idx_in_cols_full = $rows_per_col * $col_count_last_row - 1;
1169 0 my $first_list_idx_in_cols_short = $last_list_idx_in_cols_full + 1;
1170  
1171 0 for my $list_idx ( @$list_of_indexes ) {
1172 0 ▶ if ( $list_idx > $last_list_idx ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx > $last_list_idx) 0 0 0
1173 0 next;
1174 }
1175 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
1176 0 $row = $list_idx % $rows_per_col;
1177 0 $col = int( $list_idx / $rows_per_col );
1178 }
1179 else {
1180 0 my $rows_per_col_short = $rows_per_col - 1;
1181 0 $row = ( $list_idx - $first_list_idx_in_cols_short ) % $rows_per_col_short;
1182 0 $col = int( ( $list_idx - $col_count_last_row ) / $rows_per_col_short );
1183 }
1184 0 $self->{marked}[$row][$col] = $boolean;
1185 }
1186 }
1187 }
1188  
1189  
1190 sub __set_cell {
1191 0 ▶ my ( $self, $list_idx ) = @_;
Subroutine __set_cell: not called CC=6 SCAR=37.4
1192 0 ▶ if ( $self->{current_layout} == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current_layout'} == 2) { } 0 0 0
1193 0 $self->{pos} = [ $list_idx, 0 ];
1194 }
1195 else {
1196 0 LOOP: for my $i ( 0 .. $#{$self->{rc2idx}} ) {
1197 0 for my $j ( 0 .. $#{$self->{rc2idx}[$i]} ) {
1198 0 ▶ if ( $list_idx == $self->{rc2idx}[$i][$j] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list_idx == $self->{"rc2idx"}[$i][$j]) 0 0 0
1199 0 $self->{pos} = [ $i, $j ];
1200 0 last LOOP;
1201 }
1202 }
1203 }
1204 }
1205 0 $self->{first_page_row} = $self->{avail_height} * int( $self->{pos}[ROW] / $self->{avail_height} );
1206 0 $self->{last_page_row} = $self->{first_page_row} + $self->{avail_height} - 1;
1207 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
1208 }
1209  
1210  
1211 sub __marked_rc2idx {
1212 0 ▶ my ( $self ) = @_;
Subroutine __marked_rc2idx: not called CC=8 SCAR=42.8
1213 0 my $list_idx = [];
1214 0 ▶ if ( $self->{order} == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'order'} == 1) { } 0 0 0
1215 0 for my $col ( 0 .. $#{$self->{rc2idx}[0]} ) {
1216 0 for my $row ( 0 .. $#{$self->{rc2idx}} ) {
1217 0 ▶ if ( $self->{marked}[$row][$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"marked"}[$row][$col]) 0 0 0
1218 0 push @$list_idx, $self->{rc2idx}[$row][$col];
1219 }
1220 }
1221 }
1222 }
1223 else {
1224 0 for my $row ( 0 .. $#{$self->{rc2idx}} ) {
1225 0 for my $col ( 0 .. $#{$self->{rc2idx}[$row]} ) {
1226 0 ▶ if ( $self->{marked}[$row][$col] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"marked"}[$row][$col]) 0 0 0
1227 0 push @$list_idx, $self->{rc2idx}[$row][$col];
1228 }
1229 }
1230 }
1231 }
1232 0 return $list_idx;
1233 }
1234  
1235  
1236 sub __wr_screen {
1237 0 ▶ my ( $self ) = @_;
Subroutine __wr_screen: not called CC=13 SCAR=52.0
1238 0 $self->__goto( 0, 0 );
1239 0 print "\r" . clear_to_end_of_screen();
1240 0 my $line_feeds;
1241 #if ( $self->{footer_fmt} ) {
1242 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
1243 0 $line_feeds = $self->{avail_height};
1244 }
1245 else {
1246 0 $line_feeds = $self->{last_page_row} - $self->{first_page_row} + 1;
1247 }
1248 0 my $up = $line_feeds;
1249 0 my @post_rows;
1250 0 ▶ if ( $self->{footer_fmt} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"footer_fmt"}) 0 0 0
1251 0 @post_rows = ( sprintf $self->{footer_fmt}, int( $self->{first_page_row} / $self->{avail_height} ) + 1 );
1252 0 $up += 1;
1253 }
1254 0 ▶ if ( $self->{bottom_text_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"bottom_text_rows"}) 0 0 0
1255 0 push @post_rows, @{$self->{bottom_text_rows}};
1256 0 $up += @{$self->{bottom_text_rows}};
1257 }
1258 0 ▶ if ( $self->{margin_bottom} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_bottom"}) 0 0 0
1259 0 push @post_rows, ( '' ) x $self->{margin_bottom};
1260 0 $up += $self->{margin_bottom};
1261 }
1262 0 print "\n" x $line_feeds;
1263 0 ▶ if ( @post_rows ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@post_rows) 0 0 0
1264 # no leading line-feed because the menu has a trailing line-feed.
1265 0 print join( "\n\r", @post_rows ) . "\r";
1266 0 --$up; # last @post_rows row has no trailing line-feed.
1267 }
1268 0 print up( $up );
1269 0 my $pad_str = ' ' x $self->{pad};
1270 0 ▶ my $left_margin = ' ' x ( $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
1271  
1272 0 for my $row ( $self->{first_page_row} .. $self->{last_page_row} ) {
1273 0 my $line = $self->__prepare_cell( $row, 0 );
1274 0 ▶ if ( $#{$self->{rc2idx}[$row]} ) { #
Branch: 1 branch
BranchTrueFalseTotal
if ($#{$$self{"rc2idx"}[$row];}) 0 0 0
1275 0 for my $col ( 1 .. $#{$self->{rc2idx}[$row]} ) {
1276 0 $line = $line . $pad_str . $self->__prepare_cell( $row, $col );
1277 }
1278 }
1279 0 ▶ if ( $left_margin ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($left_margin) { } 0 0 0
1280 0 print $left_margin . $line . "\n\r";
1281 }
1282 else {
1283 0 print $line . "\n\r";
1284 }
1285 }
1286 0 print up( $self->{last_page_row} - $self->{first_page_row} + 1 );
1287 # relativ cursor pos: 0, 0
1288 0 ▶ if ( $self->{margin_left} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"margin_left"}) 0 0 0
1289 0 print right( $self->{margin_left} ); # reset left margin after "\r"
1290 }
1291 0 $self->__wr_cell( $self->{pos}[ROW], $self->{pos}[COL] );
1292 }
1293  
1294  
1295 sub __prepare_cell {
1296 0 ▶ my( $self, $row, $col ) = @_;
Subroutine __prepare_cell: not called CC=22 SCAR=62.3
1297 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
1298 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
1299 0 my $idx = $self->{rc2idx}[$row][$col];
1300 0 ▶ if ( $self->{ll} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ll'}) { } 0 0 0
1301 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'color'}) { } 0 0 0
1302 0 my $str = $self->{list}[$idx];
1303 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) 0 0 0
1304 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
1305 # no color for the selected cell if color == 1
1306 0 $str =~ s/${\SGR_ES}//g;
1307 }
1308 else {
1309 # keep marked cells marked after color escapes
1310 0 $str =~ s/(${\SGR_ES})/${1}$emphasised/g;
1311 }
1312 0 $str = $emphasised . $str;
1313 }
1314 0 return $str . normal();
1315 }
1316 else {
1317 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) { } 0 0 0
1318 0 return $emphasised . $self->{list}[$idx] . normal();
1319 }
1320 else {
1321 0 return $self->{list}[$idx];
1322 }
1323 }
1324 }
1325 else {
1326 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
1327 0 ▶ if ( $self->{color} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'color'}) { } 0 0 0
1328 0 my @color;
1329 0 ▶ if ( ! $self->{orig_list}[$idx] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'orig_list'}[$idx]) { } 0 0 0
1330 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
1331 0 @color = $self->{undef} =~ /(${\SGR_ES})/g;
1332 }
1333 elsif ( ! length $self->{orig_list}[$idx] ) {
1334 0 @color = $self->{empty} =~ /(${\SGR_ES})/g;
1335 }
1336 }
1337 else {
1338 0 @color = $self->{orig_list}[$idx] =~ /(${\SGR_ES})/g;
1339 }
1340 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) 0 0 0
1341 0 for ( @color ) {
1342 # keep marked cells marked after color escapes
1343 0 $_ .= $emphasised;
1344 }
1345 0 $str = $emphasised . $str . normal();
1346 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
1347 # no color for the selected cell if color == 1
1348 0 @color = ();
1349 0 $str =~ s/${\PH}//g;
1350 }
1351 }
1352 0 ▶ if ( @color ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@color) 0 0 0
1353 0 $str =~ s/${\PH}/shift @color/ge;
1354 0 ▶ if ( ! $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($emphasised) 0 0 0
1355 0 $str .= normal();
1356 }
1357 }
1358 0 return $str;
1359 }
1360 else {
1361 0 ▶ if ( $emphasised ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($emphasised) 0 0 0
1362 0 $str = $emphasised . $str . normal();
1363 }
1364 0 return $str;
1365 }
1366 }
1367 }
1368  
1369  
1370 sub __wr_cell {
1371 0 ▶ my( $self, $row, $col ) = @_;
Subroutine __wr_cell: not called CC=4 SCAR=30.0
1372 0 my $idx = $self->{rc2idx}[$row][$col];
1373 0 ▶ if ( $self->{current_layout} == -1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'current_layout'} == -1) { } 0 0 0
1374 0 my $x = 0;
1375 0 ▶ if ( $col > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($col > 0) 0 0 0
1376 0 for my $cl ( 0 .. $col - 1 ) {
1377 0 my $i = $self->{rc2idx}[$row][$cl];
1378 0 $x += $self->{width_elements}[$i] + $self->{pad};
1379 }
1380 }
1381 0 $self->__goto( $row - $self->{first_page_row}, $x );
1382 0 $self->{i_col} = $self->{i_col} + $self->{width_elements}[$idx];
1383 }
1384 else {
1385 0 $self->__goto( $row - $self->{first_page_row}, $col * $self->{col_width_plus} );
1386 0 $self->{i_col} = $self->{i_col} + $self->{col_width};
1387 }
1388 0 print $self->__prepare_cell( $row, $col );
1389 }
1390  
1391  
1392 sub __pad_str_to_colwidth {
1393 0 ▶ my ( $self, $idx ) = @_;
Subroutine __pad_str_to_colwidth: not called CC=7 SCAR=40.3
1394 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
1395 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
1396 0 return $self->{list}[$idx] . ( " " x ( $self->{col_width} - $self->{width_elements}[$idx] ) );
1397 }
1398 elsif ( $self->{alignment} == 1 ) {
1399 0 return " " x ( $self->{col_width} - $self->{width_elements}[$idx] ) . $self->{list}[$idx];
1400 }
1401 elsif ( $self->{alignment} == 2 ) {
1402 0 my $all = $self->{col_width} - $self->{width_elements}[$idx];
1403 0 my $half = int( $all / 2 );
1404 0 return ( " " x $half ) . $self->{list}[$idx] . ( " " x ( $all - $half ) );
1405 }
1406 }
1407 elsif ( $self->{width_elements}[$idx] > $self->{col_width} ) {
1408 0 ▶ if ( $self->{col_width} > 6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'col_width'} > 6) { } 0 0 0
1409 0 return cut_to_printwidth( $self->{list}[$idx], $self->{col_width} - 3 ) . '...';
1410 }
1411 else {
1412 0 return cut_to_printwidth( $self->{list}[$idx], $self->{col_width} );
1413 }
1414 }
1415 else {
1416 0 return $self->{list}[$idx];
1417 }
1418 }
1419  
1420  
1421 sub __goto {
1422 0 ▶ my ( $self, $newrow, $newcol ) = @_;
Subroutine __goto: not called CC=5 SCAR=34.0
1423 # requires up, down, left or right to be 1 or greater
1424 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
1425 0 print down( $newrow - $self->{i_row} );
1426 0 $self->{i_row} = $newrow;
1427 }
1428 elsif ( $newrow < $self->{i_row} ) {
1429 0 print up( $self->{i_row} - $newrow );
1430 0 $self->{i_row} = $newrow;
1431 }
1432 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
1433 0 print right( $newcol - $self->{i_col} );
1434 0 $self->{i_col} = $newcol;
1435 }
1436 elsif ( $newcol < $self->{i_col} ) {
1437 0 print left( $self->{i_col} - $newcol );
1438 0 $self->{i_col} = $newcol;
1439 }
1440 }
1441  
1442  
1443  
1444  
1445 3 1;
1446  
1447  
1448 __END__
↑ Summary Choose/Linux.pm »