Dialog/Backend/Whiptail.pm

filter: Statementstmt 19.0% 57 / 300 Branchbran 4.3% 5 / 116 Conditioncond 14.6% 21 / 143 MC/DCmcdc 0.0% 0 / 77 Subroutinesub 37.0% 10 / 27 Podpod 94.1% 16 / 17 totaltotal 16.0% 109 / 680 CC 122 SCAR 48.6
CC
122
Cov
15%
msgbox
380.0
gauge_start
182.0
checklist
156.0
CRAP 128.8
« Dialog/Console.pm ↑ Summary Dialog/Backend/Zenity.pm »
1 package UI::Dialog::Backend::Whiptail;
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 6 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 6 ▶use FileHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 6 ▶use Time::HiRes qw( sleep );
Subroutine BEGIN: called CC=1 SCAR=0.0
25 6 ▶use UI::Dialog::Backend;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 BEGIN {
28 6 ▶ use vars qw( $VERSION @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
29 6 ▶ @ISA = qw( UI::Dialog::Backend );
Subroutine BEGIN: called CC=1 SCAR=0.0
30 6 $VERSION = '1.20';
31 }
32  
33 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
34 #: Constructor Method
35 #:
36  
37 sub new {
38 1 ▶ my $proto = shift();
Subroutine new: called CC=32 SCAR=49.1
Pod documented
39 1 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
40 1 ▶ my $cfg = ((ref($_[0]) eq "HASH") ? $_[0] : (@_) ? { @_ } : {});
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 1 1
@_ ? : 1 0 1
41 1 my $self = {};
42 1 bless($self, $class);
43 1 $self->{'_state'} = {};
44 1 $self->{'_opts'} = {};
45  
46 #: Dynamic path discovery...
47 1 my $CFG_PATH = $cfg->{'PATH'};
48 1 ▶ if ($CFG_PATH) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CFG_PATH) { } 0 1 1
elsif ($ENV{'PATH'}) { } 1 0 1
49 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
50 0 $self->{'PATHS'} = $CFG_PATH;
51 }
52 elsif ($CFG_PATH =~ m!:!) {
53 0 $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ];
54 }
55 elsif (-d $CFG_PATH) {
56 0 $self->{'PATHS'} = [ $CFG_PATH ];
57 }
58 }
59 elsif ($ENV{'PATH'}) {
60 1 $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ];
61 }
62 else {
63 0 $self->{'PATHS'} = '';
64 }
65  
66 1 ▶ $self->{'_opts'}->{'literal'} = $cfg->{'literal'} || 0;
Condition50%1/2
$cfg->{'literal'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'literal'} || 0
$cfg->{'literal'}
Truth table50%1/2
A
A= $cfg->{'literal'}
Aresult
11
00
67 1 ▶ $self->{'_opts'}->{'callbacks'} = $cfg->{'callbacks'} || undef();
Condition50%1/2
$cfg->{'callbacks'} || undef()
l!l
01
MC/DC0%0/1
$cfg->{'callbacks'} || undef()
$cfg->{'callbacks'}
Truth table50%1/2
A
A= $cfg->{'callbacks'}
Aresult
11
00
68 1 ▶ $self->{'_opts'}->{'debug'} = $cfg->{'debug'} || undef();
Condition50%1/2
$cfg->{'debug'} || undef()
l!l
01
MC/DC0%0/1
$cfg->{'debug'} || undef()
$cfg->{'debug'}
Truth table50%1/2
A
A= $cfg->{'debug'}
Aresult
11
00
69 1 ▶ $self->{'_opts'}->{'title'} = $cfg->{'title'} || undef();
Condition50%1/2
$cfg->{'title'} || undef()
l!l
01
MC/DC0%0/1
$cfg->{'title'} || undef()
$cfg->{'title'}
Truth table50%1/2
A
A= $cfg->{'title'}
Aresult
11
00
70 1 ▶ $self->{'_opts'}->{'backtitle'} = $cfg->{'backtitle'} || undef();
Condition50%1/2
$cfg->{'backtitle'} || undef()
l!l
01
MC/DC0%0/1
$cfg->{'backtitle'} || undef()
$cfg->{'backtitle'}
Truth table50%1/2
A
A= $cfg->{'backtitle'}
Aresult
11
00
71 1 ▶ $self->{'_opts'}->{'width'} = $cfg->{'width'} || 65;
Condition50%1/2
$cfg->{'width'} || 65
l!l
01
MC/DC0%0/1
$cfg->{'width'} || 65
$cfg->{'width'}
Truth table50%1/2
A
A= $cfg->{'width'}
Aresult
11
00
72 1 ▶ $self->{'_opts'}->{'height'} = $cfg->{'height'} || 10;
Condition50%1/2
$cfg->{'height'} || 10
l!l
01
MC/DC0%0/1
$cfg->{'height'} || 10
$cfg->{'height'}
Truth table50%1/2
A
A= $cfg->{'height'}
Aresult
11
00
73 1 ▶ $self->{'_opts'}->{'listheight'} = $cfg->{'listheight'} || $cfg->{'menuheight'} || 10;
Condition40%2/5
$cfg->{'listheight'} || $cfg->{'menuheight'} || 10
l!l
01
$cfg->{"listheight"} or $cfg->{"menuheight"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$cfg->{'listheight'} || $cfg->{'menuheight'} || 10
$cfg->{"listheight"} $cfg->{"menuheight"}
Truth table33%1/3
A or B
A= $cfg->{"listheight"}B= $cfg->{"menuheight"}
ABresult
1X1
011
000
74 1 ▶ $self->{'_opts'}->{'percentage'} = $cfg->{'percentage'} || 1;
Condition50%1/2
$cfg->{'percentage'} || 1
l!l
01
MC/DC0%0/1
$cfg->{'percentage'} || 1
$cfg->{'percentage'}
Truth table50%1/2
A
A= $cfg->{'percentage'}
Aresult
11
00
75 1 ▶ $self->{'_opts'}->{'bin'} ||= $self->_find_bin('whiptail');
Condition33%1/3
$self->{"_opts"}{"bin"} ||= $self->_find_bin("whiptail")
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->{"_opts"}{"bin"} ||= $self->_find_bin("whiptail")
$self->{"_opts"}{"bin"} $self->_find_bin("whiptail")
Truth table33%1/3
A ||= B
A= $self->{"_opts"}{"bin"}B= $self->_find_bin("whiptail")
ABresult
1X1
011
000
76 1 ▶ $self->{'_opts'}->{'autoclear'} = $cfg->{'autoclear'} || 0;
Condition50%1/2
$cfg->{'autoclear'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'autoclear'} || 0
$cfg->{'autoclear'}
Truth table50%1/2
A
A= $cfg->{'autoclear'}
Aresult
11
00
77 1 ▶ $self->{'_opts'}->{'clearbefore'} = $cfg->{'clearbefore'} || 0;
Condition50%1/2
$cfg->{'clearbefore'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'clearbefore'} || 0
$cfg->{'clearbefore'}
Truth table50%1/2
A
A= $cfg->{'clearbefore'}
Aresult
11
00
78 1 ▶ $self->{'_opts'}->{'clearafter'} = $cfg->{'clearafter'} || 0;
Condition50%1/2
$cfg->{'clearafter'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'clearafter'} || 0
$cfg->{'clearafter'}
Truth table50%1/2
A
A= $cfg->{'clearafter'}
Aresult
11
00
79 1 ▶ $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
01
$cfg->{"beepbin"} or $self->_find_bin("beep")
l!l&&r!l&&!r
001
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
80 1 ▶ $self->{'_opts'}->{'beepbefore'} = $cfg->{'beepbefore'} || 0;
Condition50%1/2
$cfg->{'beepbefore'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'beepbefore'} || 0
$cfg->{'beepbefore'}
Truth table50%1/2
A
A= $cfg->{'beepbefore'}
Aresult
11
00
81 1 ▶ $self->{'_opts'}->{'beepafter'} = $cfg->{'beepafter'} || 0;
Condition50%1/2
$cfg->{'beepafter'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'beepafter'} || 0
$cfg->{'beepafter'}
Truth table50%1/2
A
A= $cfg->{'beepafter'}
Aresult
11
00
82 1 ▶ $self->{'_opts'}->{'timeout'} = $cfg->{'timeout'} || 0;
Condition50%1/2
$cfg->{'timeout'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'timeout'} || 0
$cfg->{'timeout'}
Truth table50%1/2
A
A= $cfg->{'timeout'}
Aresult
11
00
83 1 ▶ $self->{'_opts'}->{'wait'} = $cfg->{'wait'} || 0;
Condition50%1/2
$cfg->{'wait'} || 0
l!l
01
MC/DC0%0/1
$cfg->{'wait'} || 0
$cfg->{'wait'}
Truth table50%1/2
A
A= $cfg->{'wait'}
Aresult
11
00
84 1 ▶ unless (-x $self->{'_opts'}->{'bin'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-x $self->{"_opts"}{"bin"}) 1 0 1
85 1 croak("the whiptail binary could not be found at: ".$self->{'_opts'}->{'bin'});
86 }
87  
88 0 ▶ $self->{'_opts'}->{'trust-input'} = $cfg->{'trust-input'} || 0;
Condition0%0/2
$cfg->{'trust-input'} || 0
l!l
00
MC/DC0%0/1
$cfg->{'trust-input'} || 0
$cfg->{'trust-input'}
Truth table0%0/2
A
A= $cfg->{'trust-input'}
Aresult
11
00
89  
90 0 ▶ $self->{'test_mode'} = $cfg->{'test_mode'} if exists $cfg->{'test_mode'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $cfg->{"test_mode"} 0 0 0
91 0 $self->{'test_mode_result'} = '';
92  
93 0 return($self);
94 }
95  
96  
97 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
98 #: Private Methods
99 #:
100 6 my $SIG_CODE = {};
101 sub _del_gauge {
102 0 ▶ my $CODE = $SIG_CODE->{$$};
Subroutine _del_gauge: not called CC=2 SCAR=17.9
103 0 ▶ unless (not ref($CODE)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not ref $CODE) 0 0 0
104 0 delete($CODE->{'_GAUGE'});
105 0 $CODE->rv('1');
106 0 $CODE->rs('null');
107 0 $CODE->ra('null');
108 0 $SIG_CODE->{$$} = "";
109 }
110 }
111  
112 sub append_format_base {
113 0 ▶ my ($self,$args,$fmt) = @_;
Subroutine append_format_base: not called CC=2 SCAR=17.9
Pod undocumented
114 0 $fmt = $self->append_format_check($args,$fmt,'backtitle','--backtitle {{backtitle}}');
115 0 $fmt = $self->append_format_check($args,$fmt,"defaultno","--defaultno");
116 0 $fmt = $self->append_format_check($args,$fmt,"default-item","--default-item {{default-item}}");
117 0 $fmt = $self->append_format_check($args,$fmt,"fullbuttons","--fullbuttons");
118 0 $fmt = $self->append_format_check($args,$fmt,"nocancel","--nocancel");
119 0 $fmt = $self->append_format_check($args,$fmt,"yes-button","--yes-button {{yes-button}}");
120 0 $fmt = $self->append_format_check($args,$fmt,"no-button","--no-button {{no-button}}");
121 0 $fmt = $self->append_format_check($args,$fmt,"ok-button","--ok-button {{ok-button}}");
122 0 $fmt = $self->append_format_check($args,$fmt,"cancel-button","--cancel-button {{cancel-button}}");
123 0 $fmt = $self->append_format_check($args,$fmt,"notags","--notags");
124 0 $fmt = $self->append_format_check($args,$fmt,"scrolltext","--scrolltext");
125 0 $fmt = $self->append_format_check($args,$fmt,"top-left","--top-left");
126 0 ▶ if ($self->{'_opts'}->{'force-no-separate-output'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_opts'}{'force-no-separate-output'}) { } 0 0 0
127 0 delete $args->{'separate-output'};
128 } else {
129 0 $fmt = $self->append_format_check($args,$fmt,"separate-output","--separate-output");
130 }
131 0 return $fmt;
132 }
133  
134 #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
135 #: Public Methods
136 #:
137  
138 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
139 #: Ask a binary question (Yes/No)
140 sub yesno {
141 0 ▶ my $self = shift();
Subroutine yesno: not called CC=9 SCAR=45.0
Pod documented
142 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
143 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
144 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
145 0 shift(); $caller = shift();
146 }
147 0 my $args = $self->_pre($caller,@_);
148  
149 0 my $fmt = $self->prepare_format($args);
150 0 $fmt = $self->append_format_base($args,$fmt);
151 0 $fmt = $self->append_format($fmt,'--yesno {{text}} {{height}} {{width}}');
152 my $command = $self->prepare_command
153 ( $args, $fmt,
154 0 text => $self->make_kvt($args,$args->{'text'}),
155 );
156  
157 0 my $rv = $self->command_state($command);
158 0 ▶ if ($rv && $rv >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv and $rv >= 1) { } 0 0 0
Condition0%0/3
$rv and $rv >= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$rv and $rv >= 1
$rv $rv >= 1
Truth table0%0/3
A and B
A= $rvB= $rv >= 1
ABresult
0X0
100
111
159 0 $self->ra("NO");
160 0 $self->rs("NO");
161 0 $self->rv($rv);
162 }
163 else {
164 0 $self->ra("YES");
165 0 $self->rs("YES");
166 0 $self->rv('null');
167 }
168 0 $self->_post($args);
169 0 ▶ return($rv == 0 ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$rv == 0 ? : 0 0 0
170 }
171  
172 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
173 #: Text entry
174 sub inputbox {
175 0 ▶ my $self = shift();
Subroutine inputbox: not called CC=9 SCAR=45.0
Pod documented
176 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
177 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
178 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
179 0 shift(); $caller = shift();
180 }
181 0 my $args = $self->_pre($caller,@_);
182  
183 0 my $fmt = $self->prepare_format($args);
184 0 $fmt = $self->append_format_base($args,$fmt);
185 0 ▶ if ($args->{'password'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'password'}) { } 0 0 0
186 0 $fmt = $self->append_format($fmt,'--passwordbox');
187 } else {
188 0 $fmt = $self->append_format($fmt,'--inputbox');
189 }
190 0 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{entry}}');
191 my $command = $self->prepare_command
192 ( $args, $fmt,
193 text => $self->make_kvt($args,$args->{'text'}),
194 0 ▶ entry => $self->make_kvl($args,($args->{'init'}||$args->{'entry'})),
Condition0%0/3
$args->{'init'} || $args->{'entry'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{'init'} || $args->{'entry'}
$args->{'init'} $args->{'entry'}
Truth table0%0/3
A || B
A= $args->{'init'}B= $args->{'entry'}
ABresult
1X1
011
000
195 );
196  
197 0 my ($rv,$text) = $self->command_string($command);
198 0 $self->_post($args);
199 0 ▶ return($rv == 0 ? $text : 0);
Branch: 1 branch
BranchTrueFalseTotal
$rv == 0 ? : 0 0 0
200 }
201 #: password boxes aren't supported by gdialog
202 sub password {
203 0 ▶ my $self = shift();
Subroutine password: not called CC=2 SCAR=17.9
Pod documented
204 0 ▶ return($self->inputbox('caller',((caller(1))[3]||'main'),@_,'password',1));
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
205 }
206  
207 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
208 #: Text box
209 sub msgbox {
210 0 ▶ my $self = shift();
Subroutine msgbox: not called CC=19 SCAR=59.4
Pod documented
211 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
212 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
213 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
214 0 shift(); $caller = shift();
215 }
216 0 my $args = $self->_pre($caller,@_);
217 0 ▶ $args->{'msgbox'} ||= 'msgbox';
Condition0%0/2
$args->{"msgbox"} ||= "msgbox"
l!l
00
MC/DC0%0/1
$args->{"msgbox"} ||= "msgbox"
$args->{"msgbox"}
Truth table0%0/2
A
A= $args->{"msgbox"}
Aresult
11
00
218  
219 0 my $fmt = $self->prepare_format($args);
220 0 $fmt = $self->append_format_base($args,$fmt);
221 0 ▶ if ($args->{'infobox'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'infobox'}) { } 0 0 0
222 0 $fmt = $self->append_format($fmt,'--infobox');
223 }
224 else {
225 0 $fmt = $self->append_format($fmt,'--msgbox');
226 }
227 0 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}}');
228 my $command = $self->prepare_command
229 ( $args, $fmt,
230 0 text => $self->make_kvt($args,$args->{'text'}),
231 );
232  
233 $args->{'timeout'} ||= $args->{'wait'}
234 0 ▶ if exists $args->{'wait'} and $args->{'wait'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"wait"} and $args->{"wait"} 0 0 0
Condition0%0/6
exists $args->{"wait"} and $args->{"wait"}
!ll&&!rl&&r
000
$args->{"timeout"} ||= $args->{"wait"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $args->{"wait"} and $args->{"wait"}
exists $args->{"wait"} $args->{"wait"}
MC/DC0%0/2
$args->{"timeout"} ||= $args->{"wait"}
$args->{"timeout"} $args->{"wait"}
Truth table0%0/3
A and B
A= exists $args->{"wait"}B= $args->{"wait"}
ABresult
0X0
100
111
Truth table0%0/3
A ||= B
A= $args->{"timeout"}B= $args->{"wait"}
ABresult
1X1
011
000
235  
236 0 my $tmp_term = $ENV{TERM};
237 $ENV{TERM} = 'vt220' # wow, really folks?
238 0 ▶ if ($args->{'infobox'});
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"infobox"} 0 0 0
239 0 my $rv = $self->command_state($command);
240 0 ▶ if ($args->{'infobox'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"infobox"}) 0 0 0
241 0 $ENV{TERM} = $tmp_term; # yep, really.
242 0 my $sec = 0;
243 0 ▶ if ($args->{'timeout'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($args->{'timeout'}) { } 0 0 0
elsif ($args->{'wait'}) { } 0 0 0
244 0 ▶ $sec = int($args->{'timeout'} ? ($args->{'timeout'} / 1000.0) : 1.0);
Branch: 1 branch
BranchTrueFalseTotal
$args->{'timeout'} ? : 0 0 0
245 0 $self->_debug("Will sleep for timeout=".$sec);
246 } elsif ($args->{'wait'}) {
247 0 ▶ $sec = int($args->{'wait'} ? $args->{'wait'} : 1);
Branch: 1 branch
BranchTrueFalseTotal
$args->{'wait'} ? : 0 0 0
248 0 $self->_debug("Will sleep for wait=".$sec);
249 }
250 0 ▶ sleep($sec) if $sec;
Branch: 1 branch
BranchTrueFalseTotal
if $sec 0 0 0
251 }
252 0 $self->_post($args);
253 0 ▶ return($rv == 0 ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$rv == 0 ? : 0 0 0
254 }
255 sub infobox {
256 0 ▶ my $self = shift();
Subroutine infobox: not called CC=2 SCAR=17.9
Pod documented
257 0 ▶ return($self->msgbox('caller',((caller(1))[3]||'main'),@_,'infobox',1));
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
258 }
259  
260 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
261 #: File box
262 sub textbox {
263 0 ▶ my $self = shift();
Subroutine textbox: not called CC=8 SCAR=42.8
Pod documented
264 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
265 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
266 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
267 0 shift(); $caller = shift();
268 }
269 0 my $args = $self->_pre($caller,@_);
270  
271 0 my $fmt = $self->prepare_format($args);
272 0 $fmt = $self->append_format_base($args,$fmt);
273 0 $fmt = $self->append_format($fmt,'--textbox');
274 0 $fmt = $self->append_format($fmt,'{{path}} {{height}} {{width}}');
275 my $command = $self->prepare_command
276 ( $args, $fmt,
277 0 ▶ path => $self->make_kvl($args,($args->{'path'}||'.')),
Condition0%0/2
$args->{'path'} || '.'
l!l
00
MC/DC0%0/1
$args->{'path'} || '.'
$args->{'path'}
Truth table0%0/2
A
A= $args->{'path'}
Aresult
11
00
278 );
279  
280 0 my ($rv,$text) = $self->command_string($command);
281 0 $self->_post($args);
282 0 ▶ return($rv == 0 ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$rv == 0 ? : 0 0 0
283 }
284  
285 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
286 #: Lists
287 sub menu {
288 0 ▶ my $self = shift();
Subroutine menu: not called CC=8 SCAR=42.8
Pod documented
289 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
290 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
291 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
292 0 shift(); $caller = shift();
293 }
294 0 my $args = $self->_pre($caller,@_);
295  
296 $args->{'listheight'} = $args->{'menuheight'}
297 0 ▶ if exists $args->{'menuheight'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"menuheight"} 0 0 0
298  
299 0 my $fmt = $self->prepare_format($args);
300 0 $fmt = $self->append_format_base($args,$fmt);
301 0 $fmt = $self->append_format($fmt,'--separate-output');
302 0 $fmt = $self->append_format($fmt,'--menu');
303 0 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{listheight}} {{list}}');
304 my $command = $self->prepare_command
305 ( $args, $fmt,
306 0 text => $self->make_kvt($args,$args->{'text'}),
307 );
308  
309 0 my ($rv,$selected) = $self->command_string($command);
310 0 $self->_post($args);
311 0 ▶ return($rv == 0 ? $selected : 0);
Branch: 1 branch
BranchTrueFalseTotal
$rv == 0 ? : 0 0 0
312 }
313  
314 sub checklist {
315 0 ▶ my $self = shift();
Subroutine checklist: not called CC=12 SCAR=50.5
Pod documented
316 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
317 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
318 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
319 0 shift(); $caller = shift();
320 }
321 0 my $args = $self->_pre($caller,@_);
322  
323 $args->{'listheight'} = $args->{'menuheight'}
324 0 ▶ if exists $args->{'menuheight'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"menuheight"} 0 0 0
325  
326 0 my $fmt = $self->prepare_format($args);
327 0 $fmt = $self->append_format_base($args,$fmt);
328 0 $fmt = $self->append_format($fmt,'--separate-output');
329 0 ▶ $args->{radiolist} ||= 0;
Condition0%0/2
$args->{"radiolist"} ||= 0
l!l
00
MC/DC0%0/1
$args->{"radiolist"} ||= 0
$args->{"radiolist"}
Truth table0%0/2
A
A= $args->{"radiolist"}
Aresult
11
00
330 0 ▶ if ($args->{radiolist}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{'radiolist'}) { } 0 0 0
331 0 $fmt = $self->append_format($fmt,'--radiolist');
332 } else {
333 0 $fmt = $self->append_format($fmt,'--checklist');
334 }
335 0 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{listheight}} {{list}}');
336 my $command = $self->prepare_command
337 ( $args, $fmt,
338 0 text => $self->make_kvt($args,$args->{'text'}),
339 );
340  
341 0 ▶ if ($args->{radiolist}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"radiolist"}) 0 0 0
342 0 my ($rv,$selected) = $self->command_string($command);
343 0 ▶ return($rv == 0 ? $selected : 0);
Branch: 1 branch
BranchTrueFalseTotal
$rv == 0 ? : 0 0 0
344 }
345 0 my ($rv,$selected) = $self->command_array($command);
346 0 ▶ return($rv == 0 ? @{$selected} : 0);
Branch: 1 branch
BranchTrueFalseTotal
$rv == 0 ? : 0 0 0
347 }
348 sub radiolist {
349 0 ▶ my $self = shift();
Subroutine radiolist: not called CC=2 SCAR=17.9
Pod documented
350 0 ▶ return($self->checklist('caller',((caller(1))[3]||'main'),@_,'radiolist',1));
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
351 }
352  
353 #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
354 #: progress meter
355 sub gauge_start {
356 0 ▶ my $self = shift();
Subroutine gauge_start: not called CC=13 SCAR=52.0
Pod documented
357 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
358 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
359 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
360 0 shift(); $caller = shift();
361 }
362 0 my $args = $self->_pre($caller,@_);
363  
364 0 ▶ $self->{'_GAUGE'} ||= {};
Condition0%0/2
$self->{"_GAUGE"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"_GAUGE"} ||= {}
$self->{"_GAUGE"}
Truth table0%0/2
A
A= $self->{"_GAUGE"}
Aresult
11
00
365 0 $self->{'_GAUGE'}->{'ARGS'} = $args;
366  
367 0 ▶ if (defined $self->{'_GAUGE'}->{'FH'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_GAUGE"}{"FH"}) 0 0 0
368 0 $self->rv(129);
369 0 $self->_post($args);
370 0 return(0);
371 }
372  
373 0 my $fmt = $self->prepare_format($args);
374 0 $fmt = $self->append_format($fmt,'--gauge');
375 0 $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{percentage}}');
376 my $command = $self->prepare_command
377 ( $args, $fmt,
378 text => $self->make_kvt($args,$args->{'text'}),
379 0 ▶ percentage => $self->make_kvl($args,$args->{'percentage'}||'0'),
Condition0%0/2
$args->{'percentage'} || '0'
l!l
00
MC/DC0%0/1
$args->{'percentage'} || '0'
$args->{'percentage'}
Truth table0%0/2
A
A= $args->{'percentage'}
Aresult
11
00
380 );
381  
382 0 ▶ $self->{'_GAUGE'}->{'PERCENT'} = ($args->{'percentage'} || '0');
Condition0%0/2
$args->{'percentage'} || '0'
l!l
00
MC/DC0%0/1
$args->{'percentage'} || '0'
$args->{'percentage'}
Truth table0%0/2
A
A= $args->{'percentage'}
Aresult
11
00
383 0 $self->{'_GAUGE'}->{'FH'} = new FileHandle;
384 0 $self->{'_GAUGE'}->{'FH'}->open("| $command");
385 0 my $rv = $? >> 8;
386 0 $self->{'_GAUGE'}->{'FH'}->autoflush(1);
387 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
388 0 $self->ra('null');
389 0 $self->rs('null');
390 0 my $this_rv;
391 0 ▶ if ($rv && $rv >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rv and $rv >= 1) { } 0 0 0
Condition0%0/3
$rv and $rv >= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$rv and $rv >= 1
$rv $rv >= 1
Truth table0%0/3
A and B
A= $rvB= $rv >= 1
ABresult
0X0
100
111
392 0 $this_rv = 0;
393 }
394 else {
395 0 $this_rv = 1;
396 }
397 0 return($this_rv);
398 }
399 sub gauge_inc {
400 0 ▶ my $self = $_[0];
Subroutine gauge_inc: not called CC=4 SCAR=30.0
Pod documented
401 0 ▶ my $incr = $_[1] || 1;
Condition0%0/2
$_[1] || 1
l!l
00
MC/DC0%0/1
$_[1] || 1
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
402  
403 0 ▶ return(0) unless defined $self->{'_GAUGE'}->{'FH'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_GAUGE"}{"FH"} 0 0 0
404  
405 0 my $fh = $self->{'_GAUGE'}->{'FH'};
406 0 $self->{'_GAUGE'}->{'PERCENT'} += $incr;
407 0 $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
408 0 print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n";
409 0 ▶ return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_GAUGE'}{'FH'} ? : 0 0 0
410 }
411 sub gauge_dec {
412 0 ▶ my $self = $_[0];
Subroutine gauge_dec: not called CC=4 SCAR=30.0
Pod documented
413 0 ▶ my $decr = $_[1] || 1;
Condition0%0/2
$_[1] || 1
l!l
00
MC/DC0%0/1
$_[1] || 1
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
414  
415 0 ▶ return(0) unless defined $self->{'_GAUGE'}->{'FH'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_GAUGE"}{"FH"} 0 0 0
416  
417 0 my $fh = $self->{'_GAUGE'}->{'FH'};
418 0 $self->{'_GAUGE'}->{'PERCENT'} -= $decr;
419 0 $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
420 0 print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n";
421 0 ▶ return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_GAUGE'}{'FH'} ? : 0 0 0
422 }
423 sub gauge_set {
424 0 ▶ my $self = $_[0];
Subroutine gauge_set: not called CC=5 SCAR=34.0
Pod documented
425 0 ▶ my $perc = $_[1] || $self->{'_GAUGE'}->{'PERCENT'} || 1;
Condition0%0/5
$_[1] || $self->{'_GAUGE'}{'PERCENT'} || 1
l!l
00
$_[1] or $self->{"_GAUGE"}{"PERCENT"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[1] || $self->{'_GAUGE'}{'PERCENT'} || 1
$_[1] $self->{"_GAUGE"}{"PERCENT"}
Truth table0%0/3
A or B
A= $_[1]B= $self->{"_GAUGE"}{"PERCENT"}
ABresult
1X1
011
000
426  
427 0 my $fh = $self->{'_GAUGE'}->{'FH'};
428 0 ▶ return(0) unless $self->{'_GAUGE'}->{'FH'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_GAUGE"}{"FH"} 0 0 0
429  
430 0 $self->{'_GAUGE'}->{'PERCENT'} = $perc;
431 0 $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
432 0 print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n";
433 0 ▶ return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_GAUGE'}{'FH'} ? : 0 0 0
434 }
435 sub gauge_text {
436 0 ▶ my $self = $_[0];
Subroutine gauge_text: not called CC=4 SCAR=30.0
Pod documented
437 0 ▶ my $mesg = $_[1] || return(0);
Condition0%0/2
$_[1] || (return 0)
l!l
00
MC/DC0%0/1
$_[1] || (return 0)
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
438  
439 0 my $fh = $self->{'_GAUGE'}->{'FH'};
440 0 ▶ return(0) unless $self->{'_GAUGE'}->{'FH'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_GAUGE"}{"FH"} 0 0 0
441  
442 0 $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
443 0 print $fh "\nXXX\n\n".$mesg."\n\nXXX\n\n".$self->{'_GAUGE'}->{'PERCENT'}."\n";
444 0 ▶ return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0));
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_GAUGE'}{'FH'} ? : 0 0 0
445 }
446 sub gauge_stop {
447 0 ▶ my $self = $_[0];
Subroutine gauge_stop: not called CC=2 SCAR=17.9
Pod documented
448  
449 0 ▶ return(0) unless $self->{'_GAUGE'}->{'FH'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_GAUGE"}{"FH"} 0 0 0
450  
451 0 my $args = $self->{'_GAUGE'}->{'ARGS'};
452 0 my $fh = $self->{'_GAUGE'}->{'FH'};
453 0 $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge;
454 0 $self->{'_GAUGE'}->{'FH'}->close();
455 0 delete($self->{'_GAUGE'}->{'FH'});
456 0 delete($self->{'_GAUGE'}->{'ARGS'});
457 0 delete($self->{'_GAUGE'}->{'PERCENT'});
458 0 delete($self->{'_GAUGE'});
459 0 $self->rv('null');
460 0 $self->rs('null');
461 0 $self->ra('null');
462 0 $self->_post($args);
463 0 return(1);
464 }
465  
466  
467 6 1;
« Dialog/Console.pm ↑ Summary Dialog/Backend/Zenity.pm »