| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package UI::Dialog::Console; |
|
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
|
1
|
|
|
1
|
|
12462
|
use 5.006; |
|
|
1
|
|
|
|
|
3
|
|
|
20
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
15
|
|
|
21
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
22
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
60
|
|
|
23
|
1
|
|
|
1
|
|
338
|
use UI::Dialog; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
29
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
BEGIN { |
|
26
|
1
|
|
|
1
|
|
3
|
use vars qw( $VERSION @ISA ); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
43
|
|
|
27
|
1
|
|
|
1
|
|
6
|
@ISA = qw( UI::Dialog ); |
|
28
|
1
|
|
|
|
|
511
|
$VERSION = '1.21'; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
|
32
|
|
|
|
|
|
|
#: Constructor Method |
|
33
|
|
|
|
|
|
|
#: |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
2
|
|
|
2
|
1
|
327
|
my $proto = shift(); |
|
37
|
2
|
|
33
|
|
|
10
|
my $class = ref($proto) || $proto; |
|
38
|
2
|
|
50
|
|
|
7
|
my $cfg = {@_} || {}; |
|
39
|
2
|
|
|
|
|
3
|
my $self = {}; |
|
40
|
2
|
|
|
|
|
2
|
bless($self, $class); |
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
|
50
|
|
|
14
|
$self->{'debug'} = $cfg->{'debug'} || 0; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#: Dynamic path discovery... |
|
45
|
2
|
|
|
|
|
2
|
my $CFG_PATH = $cfg->{'PATH'}; |
|
46
|
2
|
50
|
|
|
|
7
|
if ($CFG_PATH) { |
|
|
|
50
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
0
|
if (ref($CFG_PATH) eq "ARRAY") { $self->{'PATHS'} = $CFG_PATH; } |
|
|
0
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
elsif ($CFG_PATH =~ m!:!) { $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ]; } |
|
49
|
0
|
|
|
|
|
0
|
elsif (-d $CFG_PATH) { $self->{'PATHS'} = [ $CFG_PATH ]; } |
|
50
|
2
|
|
|
|
|
10
|
} elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; } |
|
51
|
0
|
|
|
|
|
0
|
else { $self->{'PATHS'} = ''; } |
|
52
|
|
|
|
|
|
|
|
|
53
|
2
|
|
50
|
|
|
9
|
$cfg->{'order'} ||= [ 'dialog', 'whiptail', 'ascii' ]; |
|
54
|
|
|
|
|
|
|
|
|
55
|
2
|
|
50
|
|
|
14
|
$self->_debug("ENV->UI_DIALOGS: ".($ENV{'UI_DIALOGS'}||'NULL'),2); |
|
56
|
2
|
50
|
|
|
|
3
|
$cfg->{'order'} = [ split(/\:/,$ENV{'UI_DIALOGS'}) ] if $ENV{'UI_DIALOGS'}; |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
|
50
|
|
|
11
|
$self->_debug("ENV->UI_DIALOG: ".($ENV{'UI_DIALOG'}||'NULL'),2); |
|
59
|
2
|
50
|
|
|
|
5
|
unshift(@{$cfg->{'order'}},$ENV{'UI_DIALOG'}) if $ENV{'UI_DIALOG'}; |
|
|
0
|
|
|
|
|
0
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$cfg->{'trust-input'} = |
|
62
|
|
|
|
|
|
|
( exists $cfg->{'trust-input'} |
|
63
|
2
|
50
|
33
|
|
|
6
|
&& $cfg->{'trust-input'}==1 |
|
64
|
|
|
|
|
|
|
) ? 1 : 0; |
|
65
|
|
|
|
|
|
|
|
|
66
|
2
|
|
|
|
|
4
|
my @opts = (); |
|
67
|
2
|
|
|
|
|
20
|
foreach my $opt (keys(%$cfg)) { push(@opts,$opt,$cfg->{$opt}); } |
|
|
5
|
|
|
|
|
8
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
2
|
|
|
|
|
2
|
foreach my $try (@{$cfg->{'order'}}) { |
|
|
2
|
|
|
|
|
4
|
|
|
70
|
6
|
100
|
|
|
|
40
|
if ($try =~ /^(?:cdialog||dialog)$/i) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
71
|
2
|
|
|
|
|
5
|
$self->_debug("trying cdialog",2); |
|
72
|
2
|
50
|
33
|
|
|
98
|
if (eval "require UI::Dialog::Backend::CDialog; 1" && $self->_has_variant('dialog')) { |
|
73
|
0
|
|
|
|
|
0
|
require UI::Dialog::Backend::CDialog; |
|
74
|
0
|
|
|
|
|
0
|
$self->{'_ui_dialog'} = new UI::Dialog::Backend::CDialog (@opts); |
|
75
|
0
|
|
|
|
|
0
|
$self->_debug("using cdialog",2); |
|
76
|
0
|
|
|
|
|
0
|
last; |
|
77
|
2
|
|
|
|
|
7
|
} else { next; } |
|
78
|
|
|
|
|
|
|
} elsif ($try =~ /^(?:gdialog||gdialog\.real)$/i) { |
|
79
|
0
|
|
|
|
|
0
|
$self->_debug("trying gdialog",2); |
|
80
|
0
|
0
|
0
|
|
|
0
|
if (eval "require UI::Dialog::Backend::GDialog; 1" && ($self->_has_variant('gdialog.real') || |
|
|
|
|
0
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$self->_has_variant('gdialog'))) { |
|
82
|
0
|
|
|
|
|
0
|
require UI::Dialog::Backend::GDialog; |
|
83
|
0
|
|
|
|
|
0
|
$self->{'_ui_dialog'} = new UI::Dialog::Backend::GDialog (@opts); |
|
84
|
0
|
|
|
|
|
0
|
$self->_debug("using gdialog",2); |
|
85
|
0
|
|
|
|
|
0
|
last; |
|
86
|
0
|
|
|
|
|
0
|
} else { next; } |
|
87
|
|
|
|
|
|
|
} elsif ($try =~ /^whiptail$/i) { |
|
88
|
2
|
|
|
|
|
7
|
$self->_debug("trying whiptail",2); |
|
89
|
2
|
50
|
33
|
|
|
85
|
if (eval "require UI::Dialog::Backend::Whiptail; 1" && $self->_has_variant('Whiptail')) { |
|
90
|
0
|
|
|
|
|
0
|
require UI::Dialog::Backend::Whiptail; |
|
91
|
0
|
|
|
|
|
0
|
$self->{'_ui_dialog'} = new UI::Dialog::Backend::Whiptail (@opts); |
|
92
|
0
|
|
|
|
|
0
|
$self->_debug("using whiptail",2); |
|
93
|
0
|
|
|
|
|
0
|
last; |
|
94
|
2
|
|
|
|
|
5
|
} else { next; } |
|
95
|
|
|
|
|
|
|
} elsif ($try =~ /^(?:ascii||native)$/i) { |
|
96
|
2
|
|
|
|
|
4
|
$self->_debug("trying ascii",2); |
|
97
|
2
|
50
|
|
|
|
82
|
if (eval "require UI::Dialog::Backend::ASCII; 1") { |
|
98
|
2
|
|
|
|
|
6
|
require UI::Dialog::Backend::ASCII; |
|
99
|
2
|
|
|
|
|
8
|
$self->{'_ui_dialog'} = new UI::Dialog::Backend::ASCII (@opts); |
|
100
|
2
|
|
|
|
|
5
|
$self->_debug("using ascii",2); |
|
101
|
2
|
|
|
|
|
2
|
last; |
|
102
|
0
|
|
|
|
|
0
|
} else { next; } |
|
103
|
|
|
|
|
|
|
} else { |
|
104
|
|
|
|
|
|
|
# we don't know what they're asking for... try UI::Dialog... |
|
105
|
0
|
0
|
|
|
|
0
|
if (eval "require UI::Dialog; 1") { |
|
106
|
0
|
|
|
|
|
0
|
require UI::Dialog; |
|
107
|
0
|
|
|
|
|
0
|
$self->{'_ui_dialog'} = new UI::Dialog (@opts); |
|
108
|
0
|
|
|
|
|
0
|
$self->_debug(ref($self)." unknown backend: '".$try."', using UI::Dialog instead.",2); |
|
109
|
0
|
|
|
|
|
0
|
last; |
|
110
|
0
|
|
|
|
|
0
|
} else { next; } |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
2
|
50
|
|
|
|
8
|
ref($self->{'_ui_dialog'}) or croak("unable to load suitable backend."); |
|
115
|
|
|
|
|
|
|
|
|
116
|
2
|
|
|
|
|
18
|
return($self); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |