Dialog/Backend/ASCII.pm

filter: Statementstmt 11.2% 77 / 684 Branchbran 1.8% 6 / 328 Conditioncond 9.2% 28 / 302 MC/DCmcdc 0.0% 0 / 165 Subroutinesub 42.8% 15 / 35 Podpod 100% 13 / 13 totaltotal 9.1% 139 / 1527 CC 292 SCAR 63.6
CC
292
Cov
8%
checklist
1560.0
radiolist
1406.0
menu
1122.0
CRAP 577.5
↑ Summary Dialog/Backend/XDialog.pm »
1 package UI::Dialog::Backend::ASCII;
2 ###############################################################################
3 # Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca>
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ###############################################################################
19 5 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use UI::Dialog::Backend;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶use Time::HiRes qw( sleep );
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 BEGIN {
27 5 ▶ use vars qw( $VERSION @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶ @ISA = qw( UI::Dialog::Backend );
Subroutine BEGIN: called CC=1 SCAR=0.0
29 5 $VERSION = '1.20';
30 }
31  
32 5 $| = 1; # turn on autoflush
33  
34 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
35 #: Constructor Method
36 #:
37  
38 sub new {
39 5 ▶ my $proto = shift();
Subroutine new: called CC=36 SCAR=48.3
Pod documented
40 5 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
050
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
41 5 ▶ my $cfg = ((ref($_[0]) eq "HASH") ? $_[0] : (@_) ? { @_ } : {});
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 5 5
@_ ? : 4 1 5
42 5 my $self = {};
43 5 bless($self, $class);
44 5 $self->{'_state'} = {};
45 5 $self->{'_opts'} = {};
46  
47 #: Dynamic path discovery...
48 5 my $CFG_PATH = $cfg->{'PATH'};
49 5 ▶ if ($CFG_PATH) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CFG_PATH) { } 0 5 5
elsif ($ENV{'PATH'}) { } 5 0 5
50 0 ▶ if (ref($CFG_PATH) eq "ARRAY") {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $CFG_PATH eq 'ARRAY') { } 0 0 0
elsif ($CFG_PATH =~ /:/) { } 0 0 0
elsif (-d $CFG_PATH) { } 0 0 0
51 0 $self->{'PATHS'} = $CFG_PATH;
52 }
53 elsif ($CFG_PATH =~ m!:!) {
54 0 $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ];
55 }
56 elsif (-d $CFG_PATH) {
57 0 $self->{'PATHS'} = [ $CFG_PATH ];
58 }
59 }
60 elsif ($ENV{'PATH'}) {
61 5 $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ];
62 }
63 else {
64 0 $self->{'PATHS'} = '';
65 }
66  
67 5 ▶ $self->{'_opts'}->{'callbacks'} = $cfg->{'callbacks'} || undef();
Condition50%1/2
$cfg->{'callbacks'} || undef()
l!l
05
MC/DC0%0/1
$cfg->{'callbacks'} || undef()
$cfg->{'callbacks'}
Truth table50%1/2
A
A= $cfg->{'callbacks'}
Aresult
11
00
68 5 ▶ $self->{'_opts'}->{'timeout'} = $cfg->{'timeout'} || 0;
Condition50%1/2
$cfg->{'timeout'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'timeout'} || 0
$cfg->{'timeout'}
Truth table50%1/2
A
A= $cfg->{'timeout'}
Aresult
11
00
69 5 ▶ $self->{'_opts'}->{'wait'} = $cfg->{'wait'} || 0;
Condition50%1/2
$cfg->{'wait'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'wait'} || 0
$cfg->{'wait'}
Truth table50%1/2
A
A= $cfg->{'wait'}
Aresult
11
00
70 5 ▶ $self->{'_opts'}->{'debug'} = $cfg->{'debug'} || undef();
Condition50%1/2
$cfg->{'debug'} || undef()
l!l
05
MC/DC0%0/1
$cfg->{'debug'} || undef()
$cfg->{'debug'}
Truth table50%1/2
A
A= $cfg->{'debug'}
Aresult
11
00
71 5 ▶ $self->{'_opts'}->{'title'} = $cfg->{'title'} || undef();
Condition50%1/2
$cfg->{'title'} || undef()
l!l
05
MC/DC0%0/1
$cfg->{'title'} || undef()
$cfg->{'title'}
Truth table50%1/2
A
A= $cfg->{'title'}
Aresult
11
00
72 5 ▶ $self->{'_opts'}->{'backtitle'} = $cfg->{'backtitle'} || undef();
Condition50%1/2
$cfg->{'backtitle'} || undef()
l!l
05
MC/DC0%0/1
$cfg->{'backtitle'} || undef()
$cfg->{'backtitle'}
Truth table50%1/2
A
A= $cfg->{'backtitle'}
Aresult
11
00
73 5 ▶ $self->{'_opts'}->{'usestderr'} = $cfg->{'usestderr'} || 0;
Condition50%1/2
$cfg->{'usestderr'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'usestderr'} || 0
$cfg->{'usestderr'}
Truth table50%1/2
A
A= $cfg->{'usestderr'}
Aresult
11
00
74 5 ▶ $self->{'_opts'}->{'extra-button'} = $cfg->{'extra-button'} || 0;
Condition50%1/2
$cfg->{'extra-button'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'extra-button'} || 0
$cfg->{'extra-button'}
Truth table50%1/2
A
A= $cfg->{'extra-button'}
Aresult
11
00
75 5 ▶ $self->{'_opts'}->{'extra-label'} = $cfg->{'extra-label'} || undef();
Condition50%1/2
$cfg->{'extra-label'} || undef()
l!l
05
MC/DC0%0/1
$cfg->{'extra-label'} || undef()
$cfg->{'extra-label'}
Truth table50%1/2
A
A= $cfg->{'extra-label'}
Aresult
11
00
76 5 ▶ $self->{'_opts'}->{'help-button'} = $cfg->{'help-button'} || 0;
Condition50%1/2
$cfg->{'help-button'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'help-button'} || 0
$cfg->{'help-button'}
Truth table50%1/2
A
A= $cfg->{'help-button'}
Aresult
11
00
77 5 ▶ $self->{'_opts'}->{'help-label'} = $cfg->{'help-label'} || undef();
Condition50%1/2
$cfg->{'help-label'} || undef()
l!l
05
MC/DC0%0/1
$cfg->{'help-label'} || undef()
$cfg->{'help-label'}
Truth table50%1/2
A
A= $cfg->{'help-label'}
Aresult
11
00
78 5 ▶ $self->{'_opts'}->{'nocancel'} = $cfg->{'nocancel'} || 0;
Condition50%1/2
$cfg->{'nocancel'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'nocancel'} || 0
$cfg->{'nocancel'}
Truth table50%1/2
A
A= $cfg->{'nocancel'}
Aresult
11
00
79 5 ▶ $self->{'_opts'}->{'maxinput'} = $cfg->{'maxinput'} || 0;
Condition50%1/2
$cfg->{'maxinput'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'maxinput'} || 0
$cfg->{'maxinput'}
Truth table50%1/2
A
A= $cfg->{'maxinput'}
Aresult
11
00
80 5 ▶ $self->{'_opts'}->{'defaultno'} = $cfg->{'defaultno'} || 0;
Condition50%1/2
$cfg->{'defaultno'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'defaultno'} || 0
$cfg->{'defaultno'}
Truth table50%1/2
A
A= $cfg->{'defaultno'}
Aresult
11
00
81 5 ▶ $self->{'_opts'}->{'autoclear'} = $cfg->{'autoclear'} || 0;
Condition50%1/2
$cfg->{'autoclear'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'autoclear'} || 0
$cfg->{'autoclear'}
Truth table50%1/2
A
A= $cfg->{'autoclear'}
Aresult
11
00
82 5 ▶ $self->{'_opts'}->{'clearbefore'} = $cfg->{'clearbefore'} || 0;
Condition50%1/2
$cfg->{'clearbefore'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'clearbefore'} || 0
$cfg->{'clearbefore'}
Truth table50%1/2
A
A= $cfg->{'clearbefore'}
Aresult
11
00
83 5 ▶ $self->{'_opts'}->{'clearafter'} = $cfg->{'clearafter'} || 0;
Condition50%1/2
$cfg->{'clearafter'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'clearafter'} || 0
$cfg->{'clearafter'}
Truth table50%1/2
A
A= $cfg->{'clearafter'}
Aresult
11
00
84 5 ▶ $self->{'_opts'}->{'beepbin'} = $cfg->{'beepbin'} || $self->_find_bin('beep') || '/usr/bin/beep';
Condition40%2/5
$cfg->{'beepbin'} || $self->_find_bin('beep') || '/usr/bin/beep'
l!l
05
$cfg->{"beepbin"} or $self->_find_bin("beep")
l!l&&r!l&&!r
005
MC/DC0%0/2
$cfg->{'beepbin'} || $self->_find_bin('beep') || '/usr/bin/beep'
$cfg->{"beepbin"} $self->_find_bin("beep")
Truth table33%1/3
A or B
A= $cfg->{"beepbin"}B= $self->_find_bin("beep")
ABresult
1X1
011
000
85 5 ▶ $self->{'_opts'}->{'beepbefore'} = $cfg->{'beepbefore'} || 0;
Condition50%1/2
$cfg->{'beepbefore'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'beepbefore'} || 0
$cfg->{'beepbefore'}
Truth table50%1/2
A
A= $cfg->{'beepbefore'}
Aresult
11
00
86 5 ▶ $self->{'_opts'}->{'beepafter'} = $cfg->{'beepafter'} || 0;
Condition50%1/2
$cfg->{'beepafter'} || 0
l!l
05
MC/DC0%0/1
$cfg->{'beepafter'} || 0
$cfg->{'beepafter'}
Truth table50%1/2
A
A= $cfg->{'beepafter'}
Aresult
11
00
87 5 ▶ $self->{'_opts'}->{'pager'} = ( $cfg->{'pager'} ||
Condition33%3/9
$cfg->{'pager'} || $self->_find_bin('pager') || $self->_find_bin('less') || $self->_find_bin('more')
l!l&&r!l&&!r
500
$cfg->{"pager"} or $self->_find_bin("pager") or $self->_find_bin("less")
l!l&&r!l&&!r
500
$cfg->{"pager"} or $self->_find_bin("pager")
l!l&&r!l&&!r
050
MC/DC0%0/4
$cfg->{'pager'} || $self->_find_bin('pager') || $self->_find_bin('less') || $self->_find_bin('more')
$cfg->{"pager"} $self->_find_bin("pager") $self->_find_bin("less") $self->_find_bin('more')
Truth table20%1/5
A or B or C || D
A= $cfg->{"pager"}B= $self->_find_bin("pager")C= $self->_find_bin("less")D= $self->_find_bin('more')
ABCDresult
1XXX1
01XX1
001X1
00011
00000
88 $self->_find_bin('pager') ||
89 $self->_find_bin('less') ||
90 $self->_find_bin('more') );
91 5 ▶ $self->{'_opts'}->{'stty'} = $cfg->{'stty'} || $self->_find_bin('stty');
Condition33%1/3
$cfg->{'stty'} || $self->_find_bin('stty')
l!l&&r!l&&!r
050
MC/DC0%0/2
$cfg->{'stty'} || $self->_find_bin('stty')
$cfg->{'stty'} $self->_find_bin('stty')
Truth table33%1/3
A || B
A= $cfg->{'stty'}B= $self->_find_bin('stty')
ABresult
1X1
011
000
92  
93 $self->{'_opts'}->{'trust-input'} =
94 ( exists $cfg->{'trust-input'}
95 5 ▶ && $cfg->{'trust-input'}==1
Branch: 1 branch
BranchTrueFalseTotal
exists $cfg->{'trust-input'} && $cfg->{'trust-input'} == 1 ? : 0 5 5
Condition66%2/3
exists $cfg->{"trust-input"} and $cfg->{"trust-input"} == 1
!ll&&!rl&&r
140
MC/DC0%0/2
exists $cfg->{"trust-input"} and $cfg->{"trust-input"} == 1
exists $cfg->{"trust-input"} $cfg->{"trust-input"} == 1
Truth table66%2/3
A and B
A= exists $cfg->{"trust-input"}B= $cfg->{"trust-input"} == 1
ABresult
0X0
100
111
96 ) ? 1 : 0;
97  
98 5 $self->{'_state'} = {'rv'=>0};
99  
100 5 return($self);
101 }
102  
103 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
104 #: Iherited Overrides
105 #:
106  
107 sub _organize_text {
108 0 ▶ my $self = shift();
Subroutine _organize_text: not called CC=4 SCAR=30.0
109 0 ▶ my $text = shift() || return();
Condition0%0/2
shift() || (return ())
l!l
00
MC/DC0%0/1
shift() || (return ())
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
110 0 my @array;
111 0 ▶ if (ref($text) eq "ARRAY") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $text eq 'ARRAY') { } 0 0 0
elsif ($text =~ /\\n/) { } 0 0 0
112 0 push(@array,@{$text});
113 }
114 elsif ($text =~ /\\n/) {
115 0 @array = split(/\\n/,$text);
116 }
117 else {
118 0 @array = split(/\n/,$text);
119 }
120 0 $text = undef();
121 0 $text = join("\n",@array);
122 0 return($self->_strip_text($text));
123 }
124 sub _merge_attrs {
125 0 ▶ my $self = shift();
Subroutine _merge_attrs: not called CC=13 SCAR=52.0
126 0 ▶ my $args = (@_ % 2) ? { @_, '_odd' } : { @_ };
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 0 0 0
127 0 my $defs = $self->{'_opts'};
128 0 foreach my $def (keys(%$defs)) {
129 0 ▶ $args->{$def} = $defs->{$def} unless $args->{$def};
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{$def} 0 0 0
130 }
131 # alias 'filename' and 'file' to path
132 $args->{'path'} = (($args->{'filename'}) ? $args->{'filename'} :
133 ($args->{'file'}) ? $args->{'file'} :
134 0 ▶ ($args->{'path'}) ? $args->{'path'} : "");
Branch: 3 branches
BranchTrueFalseTotal
$args->{'filename'} ? : 0 0 0
$args->{'file'} ? : 0 0 0
$args->{'path'} ? : 0 0 0
135 0 ▶ $args->{'clear'} = $args->{'clearbefore'} || $args->{'clearafter'} || $args->{'autoclear'} || 0;
Condition0%0/8
$args->{'clearbefore'} || $args->{'clearafter'} || $args->{'autoclear'} || 0
l!l
00
$args->{"clearbefore"} or $args->{"clearafter"} or $args->{"autoclear"}
l!l&&r!l&&!r
000
$args->{"clearbefore"} or $args->{"clearafter"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'clearbefore'} || $args->{'clearafter'} || $args->{'autoclear'} || 0
$args->{"clearbefore"} $args->{"clearafter"} $args->{"autoclear"}
Truth table0%0/4
A or B or C
A= $args->{"clearbefore"}B= $args->{"clearafter"}C= $args->{"autoclear"}
ABCresult
1XX1
01X1
0011
0000
136 0 ▶ $args->{'beep'} = $args->{'beepbefore'} || $args->{'beepafter'} || $args->{'autobeep'} || 0;
Condition0%0/8
$args->{'beepbefore'} || $args->{'beepafter'} || $args->{'autobeep'} || 0
l!l
00
$args->{"beepbefore"} or $args->{"beepafter"} or $args->{"autobeep"}
l!l&&r!l&&!r
000
$args->{"beepbefore"} or $args->{"beepafter"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{'beepbefore'} || $args->{'beepafter'} || $args->{'autobeep'} || 0
$args->{"beepbefore"} $args->{"beepafter"} $args->{"autobeep"}
Truth table0%0/4
A or B or C
A= $args->{"beepbefore"}B= $args->{"beepafter"}C= $args->{"autobeep"}
ABCresult
1XX1
01X1
0011
0000
137 0 return($args);
138 }
139  
140 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
141 #: Private Methods
142 #:
143  
144 #: this is the dynamic 'Colon Command Help'
145 sub _WRITE_HELP_TEXT {
146 0 ▶ my $self = shift();
Subroutine _WRITE_HELP_TEXT: not called CC=6 SCAR=37.4
147 0 my ($head,$foot);
148 0 my $body = "
149 Colon Commands: [':?' (This help message)], [':pg <N>' (Go to page 'N')],
150 [':n'|':next' (Go to the next page)], [':p'|':prev' (Go to the previous page)],
151 [':esc'|':escape' (Send the [Esc] signal)].
152 ";
153 # $head .= ("~" x 79);
154 0 ▶ if ($self->{'_opts'}->{'extra-button'} || $self->{'_opts'}->{'extra-label'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_opts"}{"extra-button"} or $self->{"_opts"}{"extra-label"}) 0 0 0
Condition0%0/3
$self->{"_opts"}{"extra-button"} or $self->{"_opts"}{"extra-label"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_opts"}{"extra-button"} or $self->{"_opts"}{"extra-label"}
$self->{"_opts"}{"extra-button"} $self->{"_opts"}{"extra-label"}
Truth table0%0/3
A or B
A= $self->{"_opts"}{"extra-button"}B= $self->{"_opts"}{"extra-label"}
ABresult
1X1
011
000
155 0 $foot .= "[':e'|':extra' (Send the [Extra] signal)]\n";
156 }
157 0 ▶ if (!$self->{'_opts'}->{'nocancel'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_opts"}{"nocancel"}) 0 0 0
158 0 $foot .= "[':c'|':cancel' (Send the [Cancel] signal)]\n";
159 }
160 0 ▶ if ($self->{'_opts'}->{'help-button'} || $self->{'_opts'}->{'help-label'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_opts"}{"help-button"} or $self->{"_opts"}{"help-label"}) 0 0 0
Condition0%0/3
$self->{"_opts"}{"help-button"} or $self->{"_opts"}{"help-label"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_opts"}{"help-button"} or $self->{"_opts"}{"help-label"}
$self->{"_opts"}{"help-button"} $self->{"_opts"}{"help-label"}
Truth table0%0/3
A or B
A= $self->{"_opts"}{"help-button"}B= $self->{"_opts"}{"help-label"}
ABresult
1X1
011
000
161 0 $foot .= "[':h'|':help' (Send the [Help] signal)]\n";
162 }
163 # $foot .= ("~" x 79)."\n";
164 # $self->msgbox(title=>'Colon Command Help',text=>$head.$body.$foot);
165 0 $self->msgbox(title=>'Colon Command Help',text=>$body.$foot);
166 }
167  
168 #: this returns the labels (or ' ') for the "extra", "help" and
169 #: "cancel" buttons.
170 sub _BUTTONS {
171 0 ▶ my $self = shift();
Subroutine _BUTTONS: not called CC=13 SCAR=52.0
172 0 my $cfg = $self->_merge_attrs(@_);
173 0 my ($help,$cancel,$extra) = (' ',' ',' ');
174 0 ▶ $extra = "Extra" if $cfg->{'extra-button'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"extra-button"} 0 0 0
175 0 ▶ $extra = $cfg->{'extra-label'} if $cfg->{'extra-label'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"extra-label"} 0 0 0
176 0 ▶ $extra = "':e'=[".$extra."]" if $extra and $extra ne ' ';
Branch: 1 branch
BranchTrueFalseTotal
if $extra and $extra ne " " 0 0 0
Condition0%0/3
$extra and $extra ne " "
!ll&&!rl&&r
000
MC/DC0%0/2
$extra and $extra ne " "
$extra $extra ne " "
Truth table0%0/3
A and B
A= $extraB= $extra ne " "
ABresult
0X0
100
111
177 0 ▶ $help = "Help" if $cfg->{'help-button'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"help-button"} 0 0 0
178 0 ▶ $help = $self->{'help-label'} if $cfg->{'help-label'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"help-label"} 0 0 0
179 0 ▶ $help = "':h'=[".$help."]" if $help and $help ne ' ';
Branch: 1 branch
BranchTrueFalseTotal
if $help and $help ne " " 0 0 0
Condition0%0/3
$help and $help ne " "
!ll&&!rl&&r
000
MC/DC0%0/2
$help and $help ne " "
$help $help ne " "
Truth table0%0/3
A and B
A= $helpB= $help ne " "
ABresult
0X0
100
111
180 0 ▶ $cancel = "Cancel" unless $cfg->{'nocancel'};
Branch: 1 branch
BranchTrueFalseTotal
unless $cfg->{"nocancel"} 0 0 0
181 0 ▶ $cancel = $cfg->{'cancellabel'} if $cfg->{'cancellabel'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"cancellabel"} 0 0 0
182 0 ▶ $cancel = "':c'=[".$cancel."]" if $cancel and $cancel ne ' ';
Branch: 1 branch
BranchTrueFalseTotal
if $cancel and $cancel ne " " 0 0 0
Condition0%0/3
$cancel and $cancel ne " "
!ll&&!rl&&r
000
MC/DC0%0/2
$cancel and $cancel ne " "
$cancel $cancel ne " "
Truth table0%0/3
A and B
A= $cancelB= $cancel ne " "
ABresult
0X0
100
111
183 0 return($help,$cancel,$extra);
184 }
185  
186  
187 #: this writes a standard ascii interface to STDOUT. This is intended for use
188 #: with any non-list native ascii mode widgets.
189 sub _WRITE_TEXT {
190 0 ▶ my $self = shift();
Subroutine _WRITE_TEXT: not called CC=8 SCAR=40.3
191 0 my $cfg = $self->_merge_attrs(@_);
192 0 my $text = "";
193 0 ▶ if ($cfg->{'literal'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{'literal'}) { } 0 0 0
194 0 ▶ $text = $cfg->{'text'} || '';
Condition0%0/2
$cfg->{'text'} || ''
l!l
00
MC/DC0%0/1
$cfg->{'text'} || ''
$cfg->{'text'}
Truth table0%0/2
A
A= $cfg->{'text'}
Aresult
11
00
195 }
196 else {
197 0 ▶ $text = $self->_organize_text($cfg->{'text'}) || "";
Condition0%0/2
$self->_organize_text($cfg->{'text'}) || ''
l!l
00
MC/DC0%0/1
$self->_organize_text($cfg->{'text'}) || ''
$self->_organize_text($cfg->{'text'})
Truth table0%0/2
A
A= $self->_organize_text($cfg->{'text'})
Aresult
11
00
198 }
199 0 $self->clean_format($cfg->{'trust-input'},\$text);
200 0 ▶ my $backtitle = $cfg->{'backtitle'} || " ";
Condition0%0/2
$cfg->{'backtitle'} || ' '
l!l
00
MC/DC0%0/1
$cfg->{'backtitle'} || ' '
$cfg->{'backtitle'}
Truth table0%0/2
A
A= $cfg->{'backtitle'}
Aresult
11
00
201 0 ▶ my $title = $cfg->{'title'} || " ";
Condition0%0/2
$cfg->{'title'} || ' '
l!l
00
MC/DC0%0/1
$cfg->{'title'} || ' '
$cfg->{'title'}
Truth table0%0/2
A
A= $cfg->{'title'}
Aresult
11
00
202 format ASCIIPGTXT =
203 +-----------------------------------------------------------------------------+
204 | @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
205 $backtitle
206 +-----------------------------------------------------------------------------+
207 | |
208 | +-------------------------------------------------------------------------+ |
209 | | @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | |
210 $title
211 | +-------------------------------------------------------------------------+ |
212 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
213 $text
214 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
215 $text
216 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
217 $text
218 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
219 $text
220 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
221 $text
222 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
223 $text
224 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
225 $text
226 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
227 $text
228 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
229 $text
230 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
231 $text
232 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
233 $text
234 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
235 $text
236 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
237 $text
238 | +-------------------------------------------------------------------------+ |
239 | |
240 +-----------------------------------------------------------------------------+
241 .
242 5 ▶ no strict 'subs';
Subroutine BEGIN: called CC=1 SCAR=0.0
243 0 my $_fh = select();
244 0 ▶ select(STDERR) unless not $cfg->{'usestderr'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"usestderr"} 0 0 0
245 0 my $LFMT = $~;
246 0 $~ = ASCIIPGTXT;
247 0 write();
248 0 $~= $LFMT;
249 0 ▶ select($_fh) unless not $cfg->{'usestderr'};
Branch: 1 branch
BranchTrueFalseTotal
unless not $cfg->{"usestderr"} 0 0 0
250 5 ▶ use strict 'subs';
Subroutine BEGIN: called CC=1 SCAR=0.0
251 }
252  
253 #: very much like _WRITE_TEXT() except that this is specifically for
254 #: the menu() widget only.
255 sub _WRITE_MENU {
256 0 ▶ my $self = shift();
Subroutine _WRITE_MENU: not called CC=10 SCAR=45.0
257 0 my $cfg = $self->_merge_attrs(@_);
258 0 my $text = "";
259 0 ▶ if ($cfg->{'literal'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{'literal'}) { } 0 0 0
260 0 ▶ $text = $cfg->{'text'} || '';
Condition0%0/2
$cfg->{'text'} || ''
l!l
00
MC/DC0%0/1
$cfg->{'text'} || ''
$cfg->{'text'}
Truth table0%0/2
A
A= $cfg->{'text'}
Aresult
11
00
261 }
262 else {
263 0 ▶ $text = $self->_organize_text($cfg->{'text'}) || "";
Condition0%0/2
$self->_organize_text($cfg->{'text'}) || ''
l!l
00
MC/DC0%0/1
$self->_organize_text($cfg->{'text'}) || ''
$self->_organize_text($cfg->{'text'})
Truth table0%0/2
A
A= $self->_organize_text($cfg->{'text'})
Aresult
11
00
264 }
265 0 $self->clean_format($cfg->{'trust-input'},\$text);
266 0 ▶ my $backtitle = $cfg->{'backtitle'} || " ";
Condition0%0/2
$cfg->{'backtitle'} || ' '
l!l
00
MC/DC0%0/1
$cfg->{'backtitle'} || ' '
$cfg->{'backtitle'}
Truth table0%0/2
A
A= $cfg->{'backtitle'}
Aresult
11
00
267 0 ▶ my $title = $cfg->{'title'} || " ";
Condition0%0/2
$cfg->{'title'} || ' '
l!l
00
MC/DC0%0/1
$cfg->{'title'} || ' '
$cfg->{'title'}
Truth table0%0/2
A
A= $cfg->{'title'}
Aresult
11
00
268 0 ▶ my $menu = $cfg->{'menu'} || [];
Condition0%0/2
$cfg->{'menu'} || []
l!l
00
MC/DC0%0/1
$cfg->{'menu'} || []
$cfg->{'menu'}
Truth table0%0/2
A
A= $cfg->{'menu'}
Aresult
11
00
269 0 my ($help,$cancel,$extra) = $self->_BUTTONS(@_);
270 0 ▶ for (my $i=0;$i<@{$menu};$i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$menu;}) 0 0 0
271 0 $self->clean_format($cfg->{'trust-input'},\$menu->[$i]);
272 }
273 format ASCIIPGMNU =
274 +-----------------------------------------------------------------------------+
275 | @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
276 $backtitle
277 +-----------------------------------------------------------------------------+
278 | |
279 | +-------------------------------------------------------------------------+ |
280 | | @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | |
281 $title
282 | +-------------------------------------------------------------------------+ |
283 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
284 $text
285 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
286 $text
287 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
288 $text
289 | +-------------------------------------------------------------------------+ |
290 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
291 ($menu->[0]||' '),($menu->[1]||' '),($menu->[2]||' '),($menu->[3]||' '),($menu->[4]||' '),($menu->[5]||' ')
292 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
293 ($menu->[6]||' '),($menu->[7]||' '),($menu->[8]||' '),($menu->[9]||' '),($menu->[10]||' '),($menu->[11]||' ')
294 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
295 ($menu->[12]||' '),($menu->[13]||' '),($menu->[14]||' '),($menu->[15]||' '),($menu->[16]||' '),($menu->[17]||' ')
296 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
297 ($menu->[18]||' '),($menu->[19]||' '),($menu->[20]||' '),($menu->[21]||' '),($menu->[22]||' '),($menu->[23]||' ')
298 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
299 ($menu->[24]||' '),($menu->[25]||' '),($menu->[26]||' '),($menu->[27]||' '),($menu->[28]||' '),($menu->[29]||' ')
300 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
301 ($menu->[30]||' '),($menu->[31]||' '),($menu->[32]||' '),($menu->[33]||' '),($menu->[34]||' '),($menu->[35]||' ')
302 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
303 ($menu->[36]||' '),($menu->[37]||' '),($menu->[38]||' '),($menu->[39]||' '),($menu->[42]||' '),($menu->[43]||' ')
304 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
305 ($menu->[42]||' '),($menu->[43]||' '),($menu->[44]||' '),($menu->[45]||' '),($menu->[46]||' '),($menu->[47]||' ')
306 | @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<<< @<<<< @<<<<<<<<<<<<<< |
307 ($menu->[48]||' '),($menu->[49]||' '),($menu->[50]||' '),($menu->[51]||' '),($menu->[52]||' '),($menu->[53]||' ')
308 | @|||||||||||||||||||| @||||||||||||||||||| @||||||||||||||||||| |
309 $extra,$cancel,$help
310 | ':?' = [Colon Command Help] |
311 +-----------------------------------------------------------------------------+
312 .
313 5 ▶ no strict 'subs';
Subroutine BEGIN: called CC=1 SCAR=0.0
314 0 my $_fh = select();
315 0 ▶ select(STDERR) unless not $cfg->{'usestderr'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"usestderr"} 0 0 0
316 0 my $LFMT = $~;
317 0 $~ = ASCIIPGMNU;
318 0 write();
319 0 $~= $LFMT;
320 0 ▶ select($_fh) unless not $cfg->{'usestderr'};
Branch: 1 branch
BranchTrueFalseTotal
unless not $cfg->{"usestderr"} 0 0 0
321 5 ▶ use strict 'subs';
Subroutine BEGIN: called CC=1 SCAR=0.0
322 }
323  
324 #: very much like _WRITE_MENU() except that this is specifically for
325 #: the radiolist() and checklist() widgets only.
326 sub _WRITE_LIST {
327 0 ▶ my $self = shift();
Subroutine _WRITE_LIST: not called CC=16 SCAR=54.8
328 0 my $cfg = $self->_merge_attrs(@_);
329 0 my $text = "";
330 0 ▶ if ($cfg->{'literal'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{'literal'}) { } 0 0 0
331 0 ▶ $text = $cfg->{'text'} || '';
Condition0%0/2
$cfg->{'text'} || ''
l!l
00
MC/DC0%0/1
$cfg->{'text'} || ''
$cfg->{'text'}
Truth table0%0/2
A
A= $cfg->{'text'}
Aresult
11
00
332 }
333 else {
334 0 ▶ $text = $self->_organize_text($cfg->{'text'}) || "";
Condition0%0/2
$self->_organize_text($cfg->{'text'}) || ''
l!l
00
MC/DC0%0/1
$self->_organize_text($cfg->{'text'}) || ''
$self->_organize_text($cfg->{'text'})
Truth table0%0/2
A
A= $self->_organize_text($cfg->{'text'})
Aresult
11
00
335 }
336 0 $self->clean_format($cfg->{'trust-input'},\$text);
337  
338 0 ▶ my $backtitle = $cfg->{'backtitle'} || " ";
Condition0%0/2
$cfg->{'backtitle'} || ' '
l!l
00
MC/DC0%0/1
$cfg->{'backtitle'} || ' '
$cfg->{'backtitle'}
Truth table0%0/2
A
A= $cfg->{'backtitle'}
Aresult
11
00
339 0 ▶ my $title = $cfg->{'title'} || " ";
Condition0%0/2
$cfg->{'title'} || ' '
l!l
00
MC/DC0%0/1
$cfg->{'title'} || ' '
$cfg->{'title'}
Truth table0%0/2
A
A= $cfg->{'title'}
Aresult
11
00
340 0 my $menu = [];
341 0 push(@{$menu},@{$cfg->{'menu'}});
342 0 my ($help,$cancel,$extra) = $self->_BUTTONS(@_);
343 0 my $m = @{$menu};
344  
345 0 ▶ if ($cfg->{'wm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cfg->{'wm'}) { } 0 0 0
346 0 ▶ for (my $i = 2; $i < $m; $i += 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $m) 0 0 0
347 0 ▶ if ($menu->[$i] && $menu->[$i] =~ /on/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($menu->[$i] and $menu->[$i] =~ /on/i) { } 0 0 0
Condition0%0/3
$menu->[$i] and $menu->[$i] =~ /on/i
!ll&&!rl&&r
000
MC/DC0%0/2
$menu->[$i] and $menu->[$i] =~ /on/i
$menu->[$i] $menu->[$i] =~ /on/i
Truth table0%0/3
A and B
A= $menu->[$i]B= $menu->[$i] =~ /on/i
ABresult
0X0
100
111
348 0 $menu->[$i] = '->';
349 }
350 else {
351 0 $menu->[$i] = ' ';
352 }
353 }
354 }
355 else {
356 0 my $mark;
357 0 ▶ for (my $i = 2; $i < $m; $i += 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $m) 0 0 0
358 0 ▶ if (!$mark && $menu->[$i] && $menu->[$i] =~ /on/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $mark and $menu->[$i] and $menu->[$i] =~ /on/i) { } 0 0 0
Condition0%0/6
not $mark and $menu->[$i] and $menu->[$i] =~ /on/i
!ll&&!rl&&r
000
not $mark and $menu->[$i]
!ll&&!rl&&r
000
MC/DC0%0/3
not $mark and $menu->[$i] and $menu->[$i] =~ /on/i
not $mark $menu->[$i] $menu->[$i] =~ /on/i
Truth table0%0/4
not(A) and B and C
A= not $markB= $menu->[$i]C= $menu->[$i] =~ /on/i
ABCresult
0XX0
10X0
1100
1111
359 0 $menu->[$i] = '->'; $mark = 1;
360 }
361 else {
362 0 $menu->[$i] = ' ';
363 }
364 }
365 }
366  
367 format ASCIIPGLST =
368 +-----------------------------------------------------------------------------+
369 | @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
370 $backtitle
371 +-----------------------------------------------------------------------------+
372 | |
373 | +-------------------------------------------------------------------------+ |
374 | | @|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| | |
375 $title
376 | +-------------------------------------------------------------------------+ |
377 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
378 $text
379 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
380 $text
381 | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
382 $text
383 | +-------------------------------------------------------------------------+ |
384 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
385 ($menu->[2]||' '),($menu->[0]||' '),($menu->[1]||' '), ($menu->[5]||' '),($menu->[3]||' '),($menu->[4]||' '), ($menu->[8]||' '),($menu->[6]||' '),($menu->[7]||' ')
386 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
387 ($menu->[11]||' '),($menu->[9]||' '),($menu->[10]||' '), ($menu->[14]||' '),($menu->[12]||' '),($menu->[13]||' '), ($menu->[17]||' '),($menu->[15]||' '),($menu->[16]||' ')
388 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
389 ($menu->[20]||' '),($menu->[18]||' '),($menu->[19]||' '), ($menu->[23]||' '),($menu->[21]||' '),($menu->[22]||' '), ($menu->[26]||' '),($menu->[24]||' '),($menu->[25]||' ')
390 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
391 ($menu->[29]||' '),($menu->[27]||' '),($menu->[28]||' '), ($menu->[32]||' '),($menu->[30]||' '),($menu->[31]||' '), ($menu->[35]||' '),($menu->[33]||' '),($menu->[34]||' ')
392 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
393 ($menu->[38]||' '),($menu->[36]||' '),($menu->[37]||' '), ($menu->[41]||' '),($menu->[39]||' '),($menu->[40]||' '), ($menu->[44]||' '),($menu->[42]||' '),($menu->[43]||' ')
394 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
395 ($menu->[47]||' '),($menu->[45]||' '),($menu->[46]||' '), ($menu->[50]||' '),($menu->[48]||' '),($menu->[49]||' '), ($menu->[53]||' '),($menu->[51]||' '),($menu->[52]||' ')
396 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
397 ($menu->[56]||' '),($menu->[54]||' '),($menu->[55]||' '), ($menu->[59]||' '),($menu->[57]||' '),($menu->[58]||' '), ($menu->[62]||' '),($menu->[60]||' '),($menu->[61]||' ')
398 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
399 ($menu->[65]||' '),($menu->[63]||' '),($menu->[64]||' '), ($menu->[68]||' '),($menu->[66]||' '),($menu->[67]||' '), ($menu->[71]||' '),($menu->[69]||' '),($menu->[70]||' ')
400 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
401 ($menu->[74]||' '),($menu->[72]||' '),($menu->[73]||' '), ($menu->[77]||' '),($menu->[75]||' '),($menu->[76]||' '), ($menu->[80]||' '),($menu->[78]||' '),($menu->[79]||' ')
402 |@<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<<< @<<@<<<< @<<<<<<<<<<<<<< |
403 ($menu->[83]||' '),($menu->[81]||' '),($menu->[82]||' '), ($menu->[86]||' '),($menu->[84]||' '),($menu->[85]||' '), ($menu->[89]||' '),($menu->[87]||' '),($menu->[88]||' ')
404 | @|||||||||||||||||||| @||||||||||||||||||| @||||||||||||||||||| |
405 $extra,$cancel,$help
406 | ':?' = [Colon Command Help] |
407 +-----------------------------------------------------------------------------+
408 .
409 5 ▶ no strict 'subs';
Subroutine BEGIN: called CC=1 SCAR=0.0
410 0 my $_fh = select();
411 0 ▶ select(STDERR) unless not $cfg->{'usestderr'};
Branch: 1 branch
BranchTrueFalseTotal
if $cfg->{"usestderr"} 0 0 0
412 0 my $LFMT = $~;
413 0 $~ = ASCIIPGLST;
414 0 write();
415 0 $~= $LFMT;
416 0 ▶ select($_fh) unless not $cfg->{'usestderr'};
Branch: 1 branch
BranchTrueFalseTotal
unless not $cfg->{"usestderr"} 0 0 0
417 5 ▶ use strict 'subs';
Subroutine BEGIN: called CC=1 SCAR=0.0
418 }
419  
420 sub _PRINT {
421 0 ▶ my $self = shift();
Subroutine _PRINT: not called CC=2 SCAR=17.9
422 0 my $stderr = shift();
423 0 ▶ if ($stderr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stderr) { } 0 0 0
424 0 print STDERR @_;
425 }
426 else {
427 0 print STDOUT @_;
428 }
429 }
430  
431 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
432 #: Public Methods
433 #:
434  
435 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
436 #: Ask a binary question (Yes/No)
437 sub yesno {
438 0 ▶ my $self = shift();
Subroutine yesno: not called CC=14 SCAR=53.5
Pod documented
439 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
440 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
441 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
442 0 shift(); $caller = shift();
443 }
444 0 my $args = $self->_pre($caller,@_);
445 0 my ($YN,$RESP) = ('Yes|no','YES_OR_NO');
446 0 ▶ $YN = "yes|No" if $self->{'defaultno'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"defaultno"} 0 0 0
447 0 ▶ while ($RESP !~ /^(y|yes|n|no)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($RESP =~ /^(y|yes|n|no)$/i) 0 0 0
448 0 $self->_clear($args->{'clear'});
449 0 $self->_WRITE_TEXT(@_,text=>$args->{'text'});
450 0 $self->_PRINT($args->{'usestderr'},"(".$YN."): ");
451 0 chomp($RESP = <STDIN>);
452 0 ▶ if (!$RESP && $args->{'defaultno'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $RESP and $args->{'defaultno'}) { } 0 0 0
elsif (not $RESP || $args->{'defaultno'}) { } 0 0 0
Condition0%0/3
not $RESP and $args->{"defaultno"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $RESP and $args->{"defaultno"}
not $RESP $args->{"defaultno"}
Truth table0%0/3
not(A) and B
A= not $RESPB= $args->{"defaultno"}
ABresult
0X0
100
111
453 0 $RESP = "no";
454 }
455 ▶ elsif (!$RESP && !$args->{'defaultno'}) {
Condition0%0/3
$RESP || $args->{'defaultno'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$RESP || $args->{'defaultno'}
$RESP $args->{'defaultno'}
Truth table0%0/3
A || B
A= $RESPB= $args->{'defaultno'}
ABresult
1X1
011
000
456 0 $RESP = "yes";
457 }
458 0 ▶ if ($RESP =~ /^(y|yes)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($RESP =~ /^(y|yes)$/i) { } 0 0 0
459 0 $self->ra("YES");
460 0 $self->rs("YES");
461 0 $self->rv('null');
462 }
463 else {
464 0 $self->ra("NO");
465 0 $self->rs("NO");
466 0 $self->rv(1);
467 }
468 }
469 0 $self->_post($args);
470 0 ▶ return(1) if $self->state() eq "OK";
Branch: 1 branch
BranchTrueFalseTotal
if $self->state eq "OK" 0 0 0
471 0 return(0);
472 }
473  
474 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
475 #: Text entry
476 sub inputbox {
477 0 ▶ my $self = shift();
Subroutine inputbox: not called CC=9 SCAR=45.0
Pod documented
478 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
479 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
480 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
481 0 shift(); $caller = shift();
482 }
483 0 my $args = $self->_pre($caller,@_);
484 0 my $length = $args->{'maxinput'} + 1;
485 0 my $text = $args->{'text'};
486 0 my $string;
487 0 chomp($text);
488 0 ▶ while ($length > $args->{'maxinput'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > $args->{"maxinput"}) 0 0 0
489 0 $self->_clear($args->{'clear'});
490 0 $self->_WRITE_TEXT(@_,'text'=>$args->{'text'});
491 0 $self->_PRINT($args->{'usestderr'},"input: ");
492 0 chomp($string = <STDIN>);
493 0 ▶ if ($args->{'maxinput'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'maxinput'}) { } 0 0 0
494 0 $length = length($string);
495 }
496 else {
497 0 $length = 0;
498 }
499 0 ▶ if ($length > $args->{'maxinput'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > $args->{"maxinput"}) 0 0 0
500 $self->_PRINT($args->{'usestderr'},"error: too many charaters input,".
501 0 " the maximum is: ".$args->{'maxinput'}."\n");
502 }
503 }
504 0 $self->rv('null');
505 0 $self->ra($string);
506 0 $self->rs($string);
507 0 $self->_post($args);
508 0 return($string);
509 }
510  
511 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
512 #: Password entry
513 sub password {
514 0 ▶ my $self = shift();
Subroutine password: not called CC=22 SCAR=62.3
Pod documented
515 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
516 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
517 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
518 0 shift(); $caller = shift();
519 }
520 0 my $args = $self->_pre($caller,@_);
521 croak("The UI::Dialog::Backend::ASCII password widget depends on the stty ".
522 "binary. This was not found or is not executable.")
523 0 ▶ unless -x $args->{'stty'};
Branch: 1 branch
BranchTrueFalseTotal
unless -x $args->{"stty"} 0 0 0
524 0 my ($length,$key) = ($args->{'maxinput'} + 1,'');
525 0 my $string;
526 0 my $text = $args->{'text'};
527 0 chomp($text);
528 0 my $ENV_PATH = $ENV{'PATH'};
529 0 $ENV{'PATH'} = "";
530 0 ▶ while ($length > $args->{'maxinput'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > $args->{"maxinput"}) 0 0 0
531 0 $self->_clear($args->{'clear'});
532 0 $self->_WRITE_TEXT(@_,'text'=>$args->{'text'});
533 0 $self->_PRINT($args->{'usestderr'},"input: ");
534 0 ▶ if ($self->_is_bsd()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_bsd) { } 0 0 0
535 0 system "$args->{'stty'} cbreak </dev/tty >/dev/tty 2>&1";
536 }
537 else {
538 0 system $args->{'stty'}, '-icanon', 'eol', "\001";
539 }
540 0 ▶ while ($key = getc(STDIN)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key = getc STDIN) 0 0 0
541 0 ▶ last if $key =~ /\n/;
Branch: 1 branch
BranchTrueFalseTotal
if $key =~ /\n/ 0 0 0
542 0 ▶ if ($key =~ /^\x1b$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($key =~ /^\x1b$/) { } 0 0 0
elsif ($key =~ /^(?:\x08|\x7f)$/) { } 0 0 0
543 #this could be the DELETE key (not BS or ^H)
544 # ^[[3~ or \x1b\x5b\x33\x7e (aka: ESC + [ + 3 + ~)
545 0 my $key2 = getc(STDIN);
546 0 ▶ if ($key2 =~ /^\x5b$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key2 =~ /^\x5b$/) { } 0 0 0
547 0 my $key3 = getc(STDIN);
548 0 ▶ if ($key3 =~ /^\x33$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key3 =~ /^\x33$/) { } 0 0 0
549 0 my $key4 = getc(STDIN);
550 0 ▶ if ($key4 =~ /^\x7e$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key4 =~ /^\x7e$/) { } 0 0 0
551 0 chop($string);
552 # go back five spaces and print five spaces (erase ^[[3~)
553 # go back five spaces again (backtrack),
554 # go back one space, print a space and go back (erase *)
555 0 ▶ if ($args->{'usestderr'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'usestderr'}) { } 0 0 0
556 0 print STDERR "\b\b\b\b\b"." "."\b\b\b\b\b"."\b \b";
557 }
558 else {
559 0 print STDOUT "\b\b\b\b\b"." "."\b\b\b\b\b"."\b \b";
560 }
561 }
562 else {
563 0 $key = $key.$key2.$key3.$key4;
564 }
565 }
566 else {
567 0 $key = $key.$key2.$key3;
568 }
569 }
570 else {
571 0 $key = $key.$key2;
572 }
573 }
574 elsif ($key =~ /^(?:\x08|\x7f)$/) {
575 # this is either a BS or ^H
576 0 chop($string);
577 # go back two spaces and print two spaces (erase ^H)
578 # go back two spaces again (backtrack),
579 # go back one space, print a space and go back (erase *)
580 0 ▶ if ($args->{'usestderr'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'usestderr'}) { } 0 0 0
581 0 print STDERR "\b\b"." "."\b\b"."\b \b";
582 }
583 else {
584 0 print STDOUT "\b\b"." "."\b\b"."\b \b";
585 }
586 }
587 else {
588 0 ▶ if ($args->{'usestderr'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'usestderr'}) { } 0 0 0
589 0 print STDERR "\b*";
590 }
591 else {
592 0 print STDOUT "\b*";
593 }
594 0 $string .= $key;
595 }
596 }
597 0 ▶ if ($self->_is_bsd()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_bsd) { } 0 0 0
598 0 system "$args->{'stty'} -cbreak </dev/tty >/dev/tty 2>&1";
599 }
600 else {
601 0 system $args->{'stty'}, 'icanon', 'eol', '^@';
602 }
603 0 ▶ if ($args->{'maxinput'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'maxinput'}) { } 0 0 0
604 0 $length = length($string);
605 }
606 else {
607 0 $length = 0;
608 }
609 0 ▶ if ($length > $args->{'maxinput'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > $args->{"maxinput"}) 0 0 0
610 $self->_PRINT($args->{'usestderr'},"error: too many charaters input,".
611 0 " the maximum is: ".$args->{'maxinput'}."\n");
612 }
613 }
614 0 $ENV{'PATH'} = $ENV_PATH;
615 0 $self->rv('null');
616 0 $self->ra($string);
617 0 $self->rs($string);
618 0 $self->_post($args);
619 0 return($string);
620 }
621  
622 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
623 #: Information box
624 sub infobox {
625 0 ▶ my $self = shift();
Subroutine infobox: not called CC=8 SCAR=42.8
Pod documented
626 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
627 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
628 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
629 0 shift(); $caller = shift();
630 }
631 0 my $args = $self->_pre($caller,@_);
632 0 $self->_WRITE_TEXT(@_,'text'=>$args->{'text'});
633 0 $self->_PRINT($args->{'usestderr'});
634 my $s = int(($args->{'wait'}) ? $args->{'wait'} :
635 0 ▶ ($args->{'timeout'}) ? ($args->{'timeout'} / 1000.0) : 1.0);
Branch: 2 branches
BranchTrueFalseTotal
$args->{'wait'} ? : 0 0 0
$args->{'timeout'} ? : 0 0 0
636 0 sleep($s);
637 0 $self->rv('null');
638 0 $self->ra('null');
639 0 $self->rs('null');
640 0 $self->_post($args);
641 0 return(1);
642 }
643  
644 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
645 #: Message box
646 sub msgbox {
647 0 ▶ my $self = shift();
Subroutine msgbox: not called CC=6 SCAR=37.4
Pod documented
648 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
649 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
650 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
651 0 shift(); $caller = shift();
652 }
653 0 my $args = $self->_pre($caller,@_);
654 0 $self->_WRITE_TEXT(@_,'text'=>$args->{'text'});
655 0 $self->_PRINT($args->{'usestderr'},(" " x 25)."[ Press Enter to Continue ]");
656 0 my $junk = <STDIN>;
657 0 $self->rv('null');
658 0 $self->ra('null');
659 0 $self->rs('null');
660 0 $self->_post($args);
661 0 return(1);
662 }
663  
664  
665 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
666 #: Text box
667 sub textbox {
668 0 ▶ my $self = shift();
Subroutine textbox: not called CC=11 SCAR=48.8
Pod documented
669 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
670 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
671 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
672 0 shift(); $caller = shift();
673 }
674 0 my $args = $self->_pre($caller,@_);
675 0 my $rv = 0;
676 0 ▶ if (-r $args->{'path'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (-r $args->{'path'}) { } 0 0 0
677 0 my $ENV_PATH = $ENV{'PATH'};
678 0 $ENV{'PATH'} = "";
679 0 ▶ if ($ENV{'PAGER'} && -x $ENV{'PAGER'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ENV{'PAGER'} and -x $ENV{'PAGER'}) { } 0 0 0
elsif (-x $args->{'pager'}) { } 0 0 0
Condition0%0/3
$ENV{"PAGER"} and -x $ENV{"PAGER"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"PAGER"} and -x $ENV{"PAGER"}
$ENV{"PAGER"} -x $ENV{"PAGER"}
Truth table0%0/3
A and B
A= $ENV{"PAGER"}B= -x $ENV{"PAGER"}
ABresult
0X0
100
111
680 0 system($ENV{'PAGER'}." ".$args->{'path'});
681 0 $rv = $? >> 8;
682 }
683 elsif (-x $args->{'pager'}) {
684 0 system($args->{'pager'}." ".$args->{'path'});
685 0 $rv = $? >> 8;
686 }
687 else {
688 0 open(ATBFILE,"<".$args->{'path'});
689 0 local $/;
690 0 my $data = <ATBFILE>;
691 0 close(ATBFILE);
692 0 $self->_PRINT($args->{'usestderr'},$data);
693 }
694 0 $ENV{'PATH'} = $ENV_PATH;
695 }
696 else {
697 0 return($self->msgbox('title'=>'error','text'=>$args->{'path'}.' is not a readable text file.'));
698 }
699 0 ▶ $self->rv($rv||'null');
Condition0%0/2
$rv || 'null'
l!l
00
MC/DC0%0/1
$rv || 'null'
$rv
Truth table0%0/2
A
A= $rv
Aresult
11
00
700 0 $self->ra('null');
701 0 $self->rs('null');
702 0 $self->_post($args);
703 0 return($rv);
704 }
705  
706 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
707 #: A simple menu
708 sub menu {
709 0 ▶ my $self = shift();
Subroutine menu: not called CC=33 SCAR=70.2
Pod documented
710 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
711 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
712 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
713 0 shift(); $caller = shift();
714 }
715 0 my $args = $self->_pre($caller,@_);
716 0 ▶ $args->{'menu'} ||= ref($args->{'list'}) ? $args->{'list'} : [$args->{'list'}];
Branch: 1 branch
BranchTrueFalseTotal
ref $args->{'list'} ? : 0 0 0
Condition0%0/3
$args->{"menu"} ||= ref $args->{"list"} ? $args->{"list"} : [$args->{"list"}]
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"menu"} ||= ref $args->{"list"} ? $args->{"list"} : [$args->{"list"}]
$args->{"menu"} ref $args->{"list"} ? $args->{"list"} : [$args->{"list"}]
Truth table0%0/3
A ||= B
A= $args->{"menu"}B= ref $args->{"list"} ? $args->{"list"} : [$args->{"list"}]
ABresult
1X1
011
000
717 0 ▶ $args->{'menu'} ||= [];
Condition0%0/2
$args->{"menu"} ||= []
l!l
00
MC/DC0%0/1
$args->{"menu"} ||= []
$args->{"menu"}
Truth table0%0/2
A
A= $args->{"menu"}
Aresult
11
00
718 0 my $string;
719 0 my $rs = '';
720 0 my $m = 0;
721 0 $m = @{$args->{'menu'}};
722 0 my ($valid,$menu,$realm) = ([],[],[]);
723 0 ▶ push(@{$menu},@{$args->{'menu'}}) if ref($args->{'menu'}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $args->{"menu"} eq "ARRAY" 0 0 0
724  
725 0 ▶ for (my $i = 0; $i < $m; $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $m) 0 0 0
726 0 push(@{$valid},$menu->[$i]);
727 }
728  
729 0 ▶ if (@{$menu} >= 60) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$menu;} >= 60) { } 0 0 0
730 0 my $c = 0;
731 0 ▶ while (@{$menu}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$menu;}) 0 0 0
732 0 $realm->[$c] = [];
733 0 ▶ for (my $i = 0; $i < 60; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 60) 0 0 0
734 0 push(@{$realm->[$c]},shift(@{$menu}));
735 }
736 0 $c++;
737 }
738 }
739 else {
740 0 $realm->[0] = [];
741 0 push(@{$realm->[0]},@{$menu});
742 }
743 0 my $pg = 1;
744 0 ▶ while (!$rs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rs) 0 0 0
745 0 ▶ $self->_WRITE_MENU(@_,'text'=>$args->{'text'},
Condition0%0/2
$pg - 1 || 0
l!l
00
MC/DC0%0/1
$pg - 1 || 0
$pg - 1
Truth table0%0/2
A
A= $pg - 1
Aresult
11
00
746 'menu'=>$realm->[($pg - 1||0)]);
747 0 $self->_PRINT($args->{'usestderr'},"(".$pg."/".@{$realm}."): ");
748 0 chomp($rs = <STDIN>);
749 0 ▶ if ($rs =~ /^:\?$/i) {
Branch: 8 branches
BranchTrueFalseTotal
if ($rs =~ /^:\?$/i) { } 0 0 0
elsif ($rs =~ /^:(esc|escape)$/i) { } 0 0 0
elsif ($args->{'extra-button'} || $args->{'extra-label'} and $rs =~ /^:(e|extra)$/i) { } 0 0 0
elsif ($args->{'help-button'} and $rs =~ /^:(h|help)$/i) { } 0 0 0
elsif (not $args->{'nocancel'} and $rs =~ /^:(c|cancel)$/i) { } 0 0 0
elsif ($rs =~ /^:pg\s*(\d+)$/i) { } 0 0 0
elsif ($rs =~ /^:(n|next)$/i) { } 0 0 0
elsif ($rs =~ /^:(p|prev)$/i) { } 0 0 0
750 0 $self->_clear($args->{'clear'});
751 0 $self->_WRITE_HELP_TEXT();
752 0 undef($rs);
753 0 next;
754 }
755 elsif ($rs =~ /^:(esc|escape)$/i) {
756 0 $self->_clear($args->{'clear'});
757 0 undef($rs);
758 0 $self->rv(255);
759 0 return(0);
760 }
761 ▶ elsif (($args->{'extra-button'} || $args->{'extra-label'}) && $rs =~ /^:(e|extra)$/i) {
Condition0%0/6
$args->{"extra-button"} || $args->{"extra-label"} and $rs =~ /^:(e|extra)$/i
!ll&&!rl&&r
000
$args->{"extra-button"} or $args->{"extra-label"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{"extra-button"} || $args->{"extra-label"} and $rs =~ /^:(e|extra)$/i
$args->{"extra-button"} $args->{"extra-label"} $rs =~ /^:(e|extra)$/i
Truth table0%0/5
A or B and C
A= $args->{"extra-button"}B= $args->{"extra-label"}C= $rs =~ /^:(e|extra)$/i
ABCresult
00X0
1X00
0100
1X11
0111
762 0 $self->rv(3);
763 0 return('EXTRA');
764 }
765 ▶ elsif ($args->{'help-button'} && $rs =~ /^:(h|help)$/i) {
Condition0%0/3
$args->{"help-button"} and $rs =~ /^:(h|help)$/i
!ll&&!rl&&r
000
MC/DC0%0/2
$args->{"help-button"} and $rs =~ /^:(h|help)$/i
$args->{"help-button"} $rs =~ /^:(h|help)$/i
Truth table0%0/3
A and B
A= $args->{"help-button"}B= $rs =~ /^:(h|help)$/i
ABresult
0X0
100
111
766 0 $self->_clear($args->{'clear'});
767 0 undef($rs);
768 0 $self->rv(2);
769 0 return($self->state());
770 }
771 ▶ elsif (!$args->{'nocancel'} && $rs =~ /^:(c|cancel)$/i) {
Condition0%0/3
not $args->{"nocancel"} and $rs =~ /^:(c|cancel)$/i
!ll&&!rl&&r
000
MC/DC0%0/2
not $args->{"nocancel"} and $rs =~ /^:(c|cancel)$/i
not $args->{"nocancel"} $rs =~ /^:(c|cancel)$/i
Truth table0%0/3
not(A) and B
A= not $args->{"nocancel"}B= $rs =~ /^:(c|cancel)$/i
ABresult
0X0
100
111
772 0 $self->_clear($args->{'clear'});
773 0 undef($rs);
774 0 $self->rv(1);
775 0 return($self->state());
776 }
777 elsif ($rs =~ /^:pg\s*(\d+)$/i) {
778 0 my $p = $1;
779 0 ▶ if ($p <= @{$realm} && $p > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p <= @{$realm;} and $p > 0) 0 0 0
Condition0%0/3
$p <= @{$realm;} and $p > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$p <= @{$realm;} and $p > 0
$p <= @{$realm;} $p > 0
Truth table0%0/3
A and B
A= $p <= @{$realm;}B= $p > 0
ABresult
0X0
100
111
780 0 $pg = $p;
781 }
782 0 undef($rs);
783 }
784 elsif ($rs =~ /^:(n|next)$/i) {
785 0 ▶ if ($pg < @{$realm}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pg < @{$realm;}) { } 0 0 0
786 0 $pg++;
787 }
788 else {
789 0 $pg = 1;
790 }
791 0 undef($rs);
792 }
793 elsif ($rs =~ /^:(p|prev)$/i) {
794 0 ▶ if ($pg > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pg > 1) { } 0 0 0
795 0 $pg--;
796 }
797 else {
798 0 $pg = @{$realm};
799 }
800 0 undef($rs);
801 }
802 else {
803 0 ▶ if (@_ = grep { /^\Q$rs\E$/i } @{$valid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ = grep({/^\Q$rs\E$/i;} @{$valid;})) { } 0 0 0
804 0 $rs = $_[0];
805 }
806 else {
807 0 undef($rs);
808 }
809 }
810 0 $self->_clear($args->{'clear'});
811 }
812  
813 0 $self->rv('null');
814 0 $self->ra($rs);
815 0 $self->rs($rs);
816 0 $self->_post($args);
817 0 return($rs);
818 }
819  
820 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
821 #: A multi-selectable list
822 sub checklist {
823 0 ▶ my $self = shift();
Subroutine checklist: not called CC=39 SCAR=73.5
Pod documented
824 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
825 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
826 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
827 0 shift(); $caller = shift();
828 }
829 0 my $args = $self->_pre($caller,@_);
830 0 ▶ my $menulist = ($args->{'menu'} || $args->{'list'});
Condition0%0/3
$args->{'menu'} || $args->{'list'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{'menu'} || $args->{'list'}
$args->{'menu'} $args->{'list'}
Truth table0%0/3
A || B
A= $args->{'menu'}B= $args->{'list'}
ABresult
1X1
011
000
831 0 my $menufix = [];
832 0 ▶ if (ref($menulist) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $menulist eq "ARRAY") 0 0 0
833 #: flatten our multidimensional array
834 0 foreach my $item (@$menulist) {
835 0 ▶ if (ref($item) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item eq 'ARRAY') { } 0 0 0
836 0 ▶ pop(@{$item}) if @$item == 3;
Branch: 1 branch
BranchTrueFalseTotal
if @$item == 3 0 0 0
837 0 push(@$menufix,@{$item});
838 }
839 else {
840 0 push(@$menufix,$item);
841 }
842 }
843 }
844 0 $args->{'menu'} = $menufix;
845  
846 0 my $ra = [];
847 0 my $rs = '';
848 0 my $m;
849 0 ▶ $m = @{$args->{'menu'}} if ref($args->{'menu'}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $args->{"menu"} eq "ARRAY" 0 0 0
850 0 my ($valid,$menu,$realm) = ([],[],[]);
851 0 ▶ push(@{$menu},@{$args->{'menu'}}) if ref($args->{'menu'}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $args->{"menu"} eq "ARRAY" 0 0 0
852  
853 0 ▶ for (my $i = 0; $i < $m; $i += 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $m) 0 0 0
854 0 push(@{$valid},$menu->[$i]);
855 }
856  
857 0 ▶ if (@{$menu} >= 90) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$menu;} >= 90) { } 0 0 0
858 0 my $c = 0;
859 0 ▶ while (@{$menu}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$menu;}) 0 0 0
860 0 $realm->[$c] = [];
861 0 ▶ for (my $i = 0; $i < 90; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 90) 0 0 0
862 0 push(@{$realm->[$c]},shift(@{$menu}));
863 }
864 0 $c++;
865 }
866 }
867 else {
868 0 $realm->[0] = [];
869 0 push(@{$realm->[0]},@{$menu});
870 }
871 0 my $go = "GO";
872 0 my $pg = 1;
873 0 ▶ while ($go) {
Branch: 1 branch
BranchTrueFalseTotal
if ($go) 0 0 0
874 0 ▶ $self->_WRITE_LIST(@_,'wm'=>'check','text'=>$args->{'text'},'menu'=>$realm->[($pg - 1||0)]);
Condition0%0/2
$pg - 1 || 0
l!l
00
MC/DC0%0/1
$pg - 1 || 0
$pg - 1
Truth table0%0/2
A
A= $pg - 1
Aresult
11
00
875 0 $self->_PRINT($args->{'usestderr'},"(".$pg."/".@{$realm}."): ");
876 0 chomp($rs = <STDIN>);
877 0 ▶ if ($rs =~ /^:\?$/i) {
Branch: 8 branches
BranchTrueFalseTotal
if ($rs =~ /^:\?$/i) { } 0 0 0
elsif ($rs =~ /^:(esc|escape)$/i) { } 0 0 0
elsif ($args->{'extra-button'} || $args->{'extra-label'} and $rs =~ /^:(e|extra)$/i) { } 0 0 0
elsif ($args->{'help-button'} || $args->{'help-label'} and $rs =~ /^:(h|help)$/i) { } 0 0 0
elsif (not $args->{'nocancel'} and $rs =~ /^:(c|cancel)$/i) { } 0 0 0
elsif ($rs =~ /^:pg\s*(\d+)$/i) { } 0 0 0
elsif ($rs =~ /^:(n|next)$/i) { } 0 0 0
elsif ($rs =~ /^:(p|prev)$/i) { } 0 0 0
878 0 $self->_clear($args->{'clear'});
879 0 $self->_WRITE_HELP_TEXT();
880 0 undef($rs);
881 0 next;
882 }
883 elsif ($rs =~ /^:(esc|escape)$/i) {
884 0 $self->_clear($args->{'clear'});
885 0 undef($rs);
886 0 $self->rv(255);
887 0 return($self->state());
888 }
889 ▶ elsif (($args->{'extra-button'} || $args->{'extra-label'}) && $rs =~ /^:(e|extra)$/i) {
Condition0%0/6
$args->{"extra-button"} || $args->{"extra-label"} and $rs =~ /^:(e|extra)$/i
!ll&&!rl&&r
000
$args->{"extra-button"} or $args->{"extra-label"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{"extra-button"} || $args->{"extra-label"} and $rs =~ /^:(e|extra)$/i
$args->{"extra-button"} $args->{"extra-label"} $rs =~ /^:(e|extra)$/i
Truth table0%0/5
A or B and C
A= $args->{"extra-button"}B= $args->{"extra-label"}C= $rs =~ /^:(e|extra)$/i
ABCresult
00X0
1X00
0100
1X11
0111
890 0 $self->_clear($args->{'clear'});
891 0 $self->rv(3);
892 0 return($self->state());
893 }
894 ▶ elsif (($args->{'help-button'} || $args->{'help-label'}) && $rs =~ /^:(h|help)$/i) {
Condition0%0/6
$args->{"help-button"} || $args->{"help-label"} and $rs =~ /^:(h|help)$/i
!ll&&!rl&&r
000
$args->{"help-button"} or $args->{"help-label"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{"help-button"} || $args->{"help-label"} and $rs =~ /^:(h|help)$/i
$args->{"help-button"} $args->{"help-label"} $rs =~ /^:(h|help)$/i
Truth table0%0/5
A or B and C
A= $args->{"help-button"}B= $args->{"help-label"}C= $rs =~ /^:(h|help)$/i
ABCresult
00X0
1X00
0100
1X11
0111
895 0 $self->_clear($args->{'clear'});
896 0 undef($rs);
897 0 $self->rv(2);
898 0 return($self->rv());
899 }
900 ▶ elsif (!$args->{'nocancel'} && $rs =~ /^:(c|cancel)$/i) {
Condition0%0/3
not $args->{"nocancel"} and $rs =~ /^:(c|cancel)$/i
!ll&&!rl&&r
000
MC/DC0%0/2
not $args->{"nocancel"} and $rs =~ /^:(c|cancel)$/i
not $args->{"nocancel"} $rs =~ /^:(c|cancel)$/i
Truth table0%0/3
not(A) and B
A= not $args->{"nocancel"}B= $rs =~ /^:(c|cancel)$/i
ABresult
0X0
100
111
901 0 $self->_clear($args->{'clear'});
902 0 undef($rs);
903 0 $self->rv(1);
904 0 return($self->state());
905 }
906 elsif ($rs =~ /^:pg\s*(\d+)$/i) {
907 0 my $p = $1;
908 0 ▶ if ($p <= @{$realm} && $p > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p <= @{$realm;} and $p > 0) 0 0 0
Condition0%0/3
$p <= @{$realm;} and $p > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$p <= @{$realm;} and $p > 0
$p <= @{$realm;} $p > 0
Truth table0%0/3
A and B
A= $p <= @{$realm;}B= $p > 0
ABresult
0X0
100
111
909 0 $pg = $p;
910 }
911 }
912 elsif ($rs =~ /^:(n|next)$/i) {
913 0 ▶ if ($pg < @{$realm}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pg < @{$realm;}) { } 0 0 0
914 0 $pg++;
915 }
916 else {
917 0 $pg = 1;
918 }
919 }
920 elsif ($rs =~ /^:(p|prev)$/i) {
921 0 ▶ if ($pg > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pg > 1) { } 0 0 0
922 0 $pg--;
923 }
924 else {
925 0 $pg = @{$realm};
926 }
927 }
928 else {
929 0 my @opts = split(/\,\s|\,|\s/,$rs);
930 0 my @good;
931 0 foreach my $opt (@opts) {
932 0 ▶ if (@_ = grep { /^\Q$opt\E$/i } @{$valid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ = grep({/^\Q$opt\E$/i;} @{$valid;})) 0 0 0
933 0 push(@good,$_[0]);
934 }
935 }
936 0 ▶ if (@opts == @good) {
Branch: 1 branch
BranchTrueFalseTotal
if (@opts == @good) 0 0 0
937 0 undef($go);
938 0 $ra = [];
939 0 push(@{$ra},@good);
940 }
941 }
942 0 $self->_clear($args->{'clear'});
943 0 undef($rs);
944 }
945  
946 0 $self->rv('null');
947 0 $self->ra($ra);
948 0 $self->rs(join("\n",@$ra));
949 0 $self->_post($args);
950 0 return(@{$ra});
951 }
952  
953 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
954 #: A radio button based list. very much like the menu widget.
955 sub radiolist {
956 0 ▶ my $self = shift();
Subroutine radiolist: not called CC=37 SCAR=72.5
Pod documented
957 0 ▶ my $caller = (caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
958 0 ▶ $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller;
Branch: 1 branch
BranchTrueFalseTotal
$caller =~ /^UI\:\:Dialog\:\:Backend\:\:/ ? : 0 0 0
Condition0%0/2
(caller 2)[3] or "main"
l!l
00
MC/DC0%0/1
(caller 2)[3] or "main"
(caller 2)[3]
Truth table0%0/2
A
A= (caller 2)[3]
Aresult
11
00
959 0 ▶ if ($_[0] && $_[0] eq 'caller') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] and $_[0] eq "caller") 0 0 0
Condition0%0/3
$_[0] and $_[0] eq "caller"
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0] and $_[0] eq "caller"
$_[0] $_[0] eq "caller"
Truth table0%0/3
A and B
A= $_[0]B= $_[0] eq "caller"
ABresult
0X0
100
111
960 0 shift(); $caller = shift();
961 }
962 0 my $args = $self->_pre($caller,@_);
963 0 ▶ my $menulist = ($args->{'menu'} || $args->{'list'});
Condition0%0/3
$args->{'menu'} || $args->{'list'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{'menu'} || $args->{'list'}
$args->{'menu'} $args->{'list'}
Truth table0%0/3
A || B
A= $args->{'menu'}B= $args->{'list'}
ABresult
1X1
011
000
964 0 my $menufix = [];
965 0 ▶ if (ref($menulist) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $menulist eq "ARRAY") 0 0 0
966 #: flatten our multidimensional array
967 0 foreach my $item (@$menulist) {
968 0 ▶ if (ref($item) eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item eq 'ARRAY') { } 0 0 0
969 0 ▶ pop(@{$item}) if @$item == 3;
Branch: 1 branch
BranchTrueFalseTotal
if @$item == 3 0 0 0
970 0 push(@$menufix,@{$item});
971 }
972 else {
973 0 push(@$menufix,$item);
974 }
975 }
976 }
977 0 $args->{'menu'} = $menufix;
978 0 my $rs = '';
979 0 my $m;
980 0 ▶ $m = @{$args->{'menu'}} if ref($args->{'menu'}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $args->{"menu"} eq "ARRAY" 0 0 0
981 0 my ($valid,$menu,$realm) = ([],[],[]);
982 0 ▶ push(@{$menu},@{$args->{'menu'}}) if ref($args->{'menu'}) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
if ref $args->{"menu"} eq "ARRAY" 0 0 0
983  
984 0 ▶ for (my $i = 0; $i < $m; $i += 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $m) 0 0 0
985 0 push(@{$valid},$menu->[$i]);
986 }
987  
988 0 ▶ if (@{$menu} >= 90) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$menu;} >= 90) { } 0 0 0
989 0 my $c = 0;
990 0 ▶ while (@{$menu}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$menu;}) 0 0 0
991 0 $realm->[$c] = [];
992 0 ▶ for (my $i = 0; $i < 90; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 90) 0 0 0
993 0 push(@{$realm->[$c]},shift(@{$menu}));
994 }
995 0 $c++;
996 }
997 }
998 else {
999 0 $realm->[0] = [];
1000 0 push(@{$realm->[0]},@{$menu});
1001 }
1002 0 my $pg = 1;
1003 0 ▶ while (!$rs) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($rs) 0 0 0
1004 0 ▶ $self->_WRITE_LIST(@_,'text'=>$args->{'text'},'menu'=>$realm->[($pg - 1||0)]);
Condition0%0/2
$pg - 1 || 0
l!l
00
MC/DC0%0/1
$pg - 1 || 0
$pg - 1
Truth table0%0/2
A
A= $pg - 1
Aresult
11
00
1005 0 $self->_PRINT($args->{'usestderr'},"(".$pg."/".@{$realm}."): ");
1006 0 chomp($rs = <STDIN>);
1007 0 ▶ if ($rs =~ /^:\?$/i) {
Branch: 8 branches
BranchTrueFalseTotal
if ($rs =~ /^:\?$/i) { } 0 0 0
elsif ($rs =~ /^:(esc|escape)$/i) { } 0 0 0
elsif ($args->{'extra-button'} || $args->{'extra-label'} and $rs =~ /^:(e|extra)$/i) { } 0 0 0
elsif ($args->{'help-button'} || $args->{'help-label'} and $rs =~ /^:(h|help)$/i) { } 0 0 0
elsif (not $args->{'nocancel'} and $rs =~ /^:(c|cancel)$/i) { } 0 0 0
elsif ($rs =~ /^:pg\s*(\d+)$/i) { } 0 0 0
elsif ($rs =~ /^:(n|next)$/i) { } 0 0 0
elsif ($rs =~ /^:(p|prev)$/i) { } 0 0 0
1008 0 $self->_clear($args->{'clear'});
1009 0 $self->_WRITE_HELP_TEXT();
1010 0 undef($rs);
1011 0 next;
1012 }
1013 elsif ($rs =~ /^:(esc|escape)$/i) {
1014 0 $self->_clear($args->{'clear'});
1015 0 undef($rs);
1016 0 $self->rv(255);
1017 0 return($self->rv());
1018 }
1019 ▶ elsif (($args->{'extra-button'} || $args->{'extra-label'}) && $rs =~ /^:(e|extra)$/i) {
Condition0%0/6
$args->{"extra-button"} || $args->{"extra-label"} and $rs =~ /^:(e|extra)$/i
!ll&&!rl&&r
000
$args->{"extra-button"} or $args->{"extra-label"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{"extra-button"} || $args->{"extra-label"} and $rs =~ /^:(e|extra)$/i
$args->{"extra-button"} $args->{"extra-label"} $rs =~ /^:(e|extra)$/i
Truth table0%0/5
A or B and C
A= $args->{"extra-button"}B= $args->{"extra-label"}C= $rs =~ /^:(e|extra)$/i
ABCresult
00X0
1X00
0100
1X11
0111
1020 0 $self->rv(3);
1021 0 return($self->state());
1022 }
1023 ▶ elsif (($args->{'help-button'} || $args->{'help-label'}) && $rs =~ /^:(h|help)$/i) {
Condition0%0/6
$args->{"help-button"} || $args->{"help-label"} and $rs =~ /^:(h|help)$/i
!ll&&!rl&&r
000
$args->{"help-button"} or $args->{"help-label"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args->{"help-button"} || $args->{"help-label"} and $rs =~ /^:(h|help)$/i
$args->{"help-button"} $args->{"help-label"} $rs =~ /^:(h|help)$/i
Truth table0%0/5
A or B and C
A= $args->{"help-button"}B= $args->{"help-label"}C= $rs =~ /^:(h|help)$/i
ABCresult
00X0
1X00
0100
1X11
0111
1024 0 $self->_clear($args->{'clear'});
1025 0 undef($rs);
1026 0 $self->rv(2);
1027 0 return($self->state());
1028 }
1029 ▶ elsif (!$args->{'nocancel'} && $rs =~ /^:(c|cancel)$/i) {
Condition0%0/3
not $args->{"nocancel"} and $rs =~ /^:(c|cancel)$/i
!ll&&!rl&&r
000
MC/DC0%0/2
not $args->{"nocancel"} and $rs =~ /^:(c|cancel)$/i
not $args->{"nocancel"} $rs =~ /^:(c|cancel)$/i
Truth table0%0/3
not(A) and B
A= not $args->{"nocancel"}B= $rs =~ /^:(c|cancel)$/i
ABresult
0X0
100
111
1030 0 $self->_clear($args->{'clear'});
1031 0 undef($rs);
1032 0 $self->rv(1);
1033 0 return($self->state());
1034 }
1035 elsif ($rs =~ /^:pg\s*(\d+)$/i) {
1036 0 my $p = $1;
1037 0 ▶ if ($p <= @{$realm} && $p > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p <= @{$realm;} and $p > 0) 0 0 0
Condition0%0/3
$p <= @{$realm;} and $p > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$p <= @{$realm;} and $p > 0
$p <= @{$realm;} $p > 0
Truth table0%0/3
A and B
A= $p <= @{$realm;}B= $p > 0
ABresult
0X0
100
111
1038 0 $pg = $p;
1039 }
1040 0 undef($rs);
1041 }
1042 elsif ($rs =~ /^:(n|next)$/i) {
1043 0 ▶ if ($pg < @{$realm}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pg < @{$realm;}) { } 0 0 0
1044 0 $pg++;
1045 }
1046 else {
1047 0 $pg = 1;
1048 }
1049 0 undef($rs);
1050 }
1051 elsif ($rs =~ /^:(p|prev)$/i) {
1052 0 ▶ if ($pg > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pg > 1) { } 0 0 0
1053 0 $pg--;
1054 }
1055 else {
1056 0 $pg = @{$realm};
1057 }
1058 0 undef($rs);
1059 }
1060 else {
1061 0 ▶ if (@_ = grep { /^\Q$rs\E$/i } @{$valid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ = grep({/^\Q$rs\E$/i;} @{$valid;})) { } 0 0 0
1062 0 $rs = $_[0];
1063 }
1064 else {
1065 0 undef($rs);
1066 }
1067 }
1068 0 $self->_clear($args->{'clear'});
1069 }
1070  
1071 0 $self->rv('null');
1072 0 $self->ra($rs);
1073 0 $self->rs($rs);
1074 0 $self->_post($args);
1075 0 return($rs);
1076 }
1077  
1078  
1079 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1080 #: Simple ASCII progress indicator :)
1081 sub spinner {
1082 0 ▶ my $self = shift();
Subroutine spinner: not called CC=6 SCAR=37.4
Pod documented
1083 0 ▶ if (!$self->{'__SPIN'} || $self->{'__SPIN'} == 1) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $self->{'__SPIN'} or $self->{'__SPIN'} == 1) { } 0 0 0
elsif ($self->{'__SPIN'} == 2) { } 0 0 0
elsif ($self->{'__SPIN'} == 3) { } 0 0 0
elsif ($self->{'__SPIN'} == 4) { } 0 0 0
Condition0%0/3
not $self->{"__SPIN"} or $self->{"__SPIN"} == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
not $self->{"__SPIN"} or $self->{"__SPIN"} == 1
not $self->{"__SPIN"} $self->{"__SPIN"} == 1
Truth table0%0/3
not(A) or B
A= not $self->{"__SPIN"}B= $self->{"__SPIN"} == 1
ABresult
1X1
011
000
1084 0 $self->{'__SPIN'} = 2; return("\b|");
1085 }
1086 elsif ($self->{'__SPIN'} == 2) {
1087 0 $self->{'__SPIN'} = 3; return("\b/");
1088 }
1089 elsif ($self->{'__SPIN'} == 3) {
1090 0 $self->{'__SPIN'} = 4; return("\b-");
1091 }
1092 elsif ($self->{'__SPIN'} == 4) {
1093 0 $self->{'__SPIN'} = 1; return("\b\\");
1094 }
1095 }
1096  
1097 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1098 #: Simple ASCII meter bar
1099 # the idea of a "true" dialog like gauge widget with ASCII is not that bad and
1100 # as such, I've named these methods differently so as to keep the namespace
1101 # open for gauge_*() widgets.
1102 sub draw_gauge {
1103 0 ▶ my $self = shift();
Subroutine draw_gauge: not called CC=18 SCAR=58.3
Pod documented
1104 0 my $args = $self->_merge_attrs(@_);
1105 0 ▶ my $length = $args->{'length'} || $args->{'width'} || 74;
Condition0%0/5
$args->{'length'} || $args->{'width'} || 74
l!l
00
$args->{"length"} or $args->{"width"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{'length'} || $args->{'width'} || 74
$args->{"length"} $args->{"width"}
Truth table0%0/3
A or B
A= $args->{"length"}B= $args->{"width"}
ABresult
1X1
011
000
1106 0 ▶ my $bar = ($args->{'bar'} || "-") x $length;
Condition0%0/2
$args->{'bar'} || '-'
l!l
00
MC/DC0%0/1
$args->{'bar'} || '-'
$args->{'bar'}
Truth table0%0/2
A
A= $args->{'bar'}
Aresult
11
00
1107 0 ▶ my $current = $args->{'current'} || 0;
Condition0%0/2
$args->{'current'} || 0
l!l
00
MC/DC0%0/1
$args->{'current'} || 0
$args->{'current'}
Truth table0%0/2
A
A= $args->{'current'}
Aresult
11
00
1108 0 ▶ my $total = $args->{'total'} || 0;
Condition0%0/2
$args->{'total'} || 0
l!l
00
MC/DC0%0/1
$args->{'total'} || 0
$args->{'total'}
Truth table0%0/2
A
A= $args->{'total'}
Aresult
11
00
1109 my $percent = (($current && $total) ? int($current / ($total / 100)) :
1110 0 ▶ ($args->{'percent'} || '0'));
Branch: 1 branch
BranchTrueFalseTotal
$current && $total ? : 0 0 0
Condition0%0/5
$current and $total
!ll&&!rl&&r
000
$args->{"percent"} or 0
l!l
00
MC/DC0%0/2
$current and $total
$current $total
MC/DC0%0/1
$args->{"percent"} or 0
$args->{"percent"}
Truth table0%0/3
A and B
A= $currentB= $total
ABresult
0X0
100
111
Truth table0%0/2
A
A= $args->{"percent"}
Aresult
11
00
1111 0 ▶ $percent = int(($percent <= 100 && $percent >= 0) ? $percent : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$percent <= 100 && $percent >= 0 ? : 0 0 0
Condition0%0/3
$percent <= 100 and $percent >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$percent <= 100 and $percent >= 0
$percent <= 100 $percent >= 0
Truth table0%0/3
A and B
A= $percent <= 100B= $percent >= 0
ABresult
0X0
100
111
1112 0 my $perc = int((($length / 100) * $percent));
1113 0 ▶ substr($bar,($perc||0),1,($args->{'mark'}||"|"));
Condition0%0/4
$perc || 0
l!l
00
$args->{'mark'} || '|'
l!l
00
MC/DC0%0/1
$perc || 0
$perc
MC/DC0%0/1
$args->{'mark'} || '|'
$args->{'mark'}
Truth table0%0/2
A
A= $perc
Aresult
11
00
Truth table0%0/2
A
A= $args->{'mark'}
Aresult
11
00
1114 0 ▶ my $text = (($percent =~ /^\d$/) ? " " :
Branch: 2 branches
BranchTrueFalseTotal
$percent =~ /^\d$/ ? : 0 0 0
$percent =~ /^\d\d$/ ? : 0 0 0
1115 ($percent =~ /^\d\d$/) ? " " : "").$percent."% ".$bar;
1116 0 ▶ $self->_PRINT($args->{'usestderr'},(($args->{'noCR'} && not $args->{'CR'}) ? "" : "\x0D").$text);
Branch: 1 branch
BranchTrueFalseTotal
$args->{'noCR'} && !$args->{'CR'} ? : 0 0 0
Condition0%0/3
$args->{"noCR"} and not $args->{"CR"}
!ll&&!rl&&r
000
MC/DC0%0/2
$args->{"noCR"} and not $args->{"CR"}
$args->{"noCR"} not $args->{"CR"}
Truth table0%0/3
A and not(B)
A= $args->{"noCR"}B= not $args->{"CR"}
ABresult
0X0
100
111
1117 0 ▶ return($percent||1);
Condition0%0/2
$percent || 1
l!l
00
MC/DC0%0/1
$percent || 1
$percent
Truth table0%0/2
A
A= $percent
Aresult
11
00
1118 }
1119 sub end_gauge {
1120 0 ▶ my $self = shift();
Subroutine end_gauge: not called CC=1 SCAR=6.9
Pod documented
1121 0 my $args = $self->_merge_attrs(@_);
1122 0 $self->_PRINT($args->{'usestderr'},"\n");
1123 }
1124  
1125 5 1;
↑ Summary Dialog/Backend/XDialog.pm »