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