| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package UI::Various::PoorTerm::Dialog; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Author, Copyright and License: see end of file |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
UI::Various::PoorTerm::Dialog - concrete implementation of L |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# This module should never be used directly! |
|
12
|
|
|
|
|
|
|
# It is used indirectly via the following: |
|
13
|
|
|
|
|
|
|
use UI::Various::Dialog; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This module is the specific minimal fallback implementation of |
|
18
|
|
|
|
|
|
|
L. It manages and hides everything specific to the last |
|
19
|
|
|
|
|
|
|
resort UI. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The documentation of this module is only intended for developers of the |
|
24
|
|
|
|
|
|
|
package itself. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
######################################################################### |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
22
|
use v5.14; |
|
|
2
|
|
|
|
|
6
|
|
|
31
|
2
|
|
|
2
|
|
9
|
use strictures; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
10
|
|
|
32
|
2
|
|
|
2
|
|
274
|
no indirect 'fatal'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
7
|
|
|
33
|
2
|
|
|
2
|
|
115
|
no multidimensional; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
9
|
|
|
34
|
2
|
|
|
2
|
|
76
|
use warnings 'once'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
118
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
|
37
|
|
|
|
|
|
|
|
|
38
|
2
|
|
|
2
|
|
11
|
use UI::Various::core; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
12
|
|
|
39
|
2
|
|
|
2
|
|
16
|
use UI::Various::Dialog; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
82
|
|
|
40
|
2
|
|
|
2
|
|
365
|
use UI::Various::PoorTerm::container; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1761
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
require Exporter; |
|
43
|
|
|
|
|
|
|
our @ISA = qw(UI::Various::Dialog UI::Various::PoorTerm::container); |
|
44
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
######################################################################### |
|
47
|
|
|
|
|
|
|
######################################################################### |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
######################################################################### |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 B<_show> - print UI element |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$ui_element->_show; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head3 description: |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Show the complete dialogue by printing its title and all its elements. Active |
|
62
|
|
|
|
|
|
|
elements (basically everything not just simple C>) |
|
63
|
|
|
|
|
|
|
are numbered to allow later interaction with them. I
|
|
64
|
|
|
|
|
|
|
be called from C>!> |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _show($) |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
16
|
|
|
16
|
|
4180
|
debug(3, __PACKAGE__, '::_show'); |
|
73
|
16
|
|
|
|
|
26
|
my ($self) = @_; |
|
74
|
16
|
|
|
|
|
23
|
local $_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
16
|
|
|
|
|
47
|
print $self->_wrap('========== ', $self->title), "\n"; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# 1st gather active children and get width of prefix: |
|
79
|
16
|
|
|
|
|
75
|
$self->{_active} = []; |
|
80
|
16
|
|
|
|
|
63
|
while ($_ = $self->child) |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
47
|
100
|
|
|
|
150
|
$_->can('_process') and push @{$self->{_active}}, $_; |
|
|
31
|
|
|
|
|
77
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
16
|
|
|
|
|
21
|
$_ = @{$self->{_active}}; |
|
|
16
|
|
|
|
|
26
|
|
|
85
|
16
|
|
|
|
|
25
|
$_ = length($_); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# print children: |
|
88
|
16
|
|
|
|
|
35
|
my $pre_active = '<%' . $_ . 'd> '; |
|
89
|
16
|
|
|
|
|
37
|
my $pre_passive = ' ' x ($_ + 3); |
|
90
|
16
|
|
|
|
|
21
|
my $i = 1; |
|
91
|
16
|
|
|
|
|
31
|
while ($_ = $self->child) |
|
92
|
|
|
|
|
|
|
{ |
|
93
|
47
|
100
|
|
|
|
133
|
if ($_->can('_process')) |
|
94
|
31
|
|
|
|
|
130
|
{ $_->_show(sprintf($pre_active, $i++)); } |
|
95
|
|
|
|
|
|
|
else |
|
96
|
16
|
|
|
|
|
48
|
{ $_->_show($pre_passive); } |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# print standard selection strings: |
|
100
|
16
|
|
|
|
|
72
|
print $self->_wrap(sprintf($pre_active, 0), msg('leave_dialog')), "\n\n"; |
|
101
|
16
|
|
|
|
|
84
|
print $self->_wrap('----- ', msg('enter_number_to_choose_next_step')), ': '; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
######################################################################### |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 B<_process> - handle action of UI element |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$ui_element->_process; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head3 description: |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Handle the action of the UI element. For a C's dialogue this |
|
113
|
|
|
|
|
|
|
means a loop of printing the dialogue's elements and allowing to select one |
|
114
|
|
|
|
|
|
|
of the active ones for processing until the dialogue is exited or destroyed. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _process($) |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
7
|
|
|
7
|
|
4020
|
debug(3, __PACKAGE__, '::_process'); |
|
123
|
7
|
|
|
|
|
13
|
my ($self) = @_; |
|
124
|
7
|
|
|
|
|
12
|
local $_ = -1; |
|
125
|
|
|
|
|
|
|
|
|
126
|
7
|
|
|
|
|
9
|
while (1) |
|
127
|
|
|
|
|
|
|
{ |
|
128
|
16
|
100
|
|
|
|
106
|
if (defined $self->{_self_destruct}) |
|
129
|
5
|
|
|
|
|
21
|
{ $self->_self_destruct; return undef; } |
|
|
5
|
|
|
|
|
13
|
|
|
130
|
11
|
|
|
|
|
29
|
$self->_show; |
|
131
|
11
|
|
|
|
|
48
|
$_ = ; |
|
132
|
11
|
|
|
|
|
112
|
print $_; |
|
133
|
11
|
|
|
|
|
96
|
s/\r?\n$//; |
|
134
|
11
|
100
|
|
|
|
32
|
if ($_ eq '0') |
|
135
|
2
|
|
|
|
|
12
|
{ $self->destroy; return $_; } |
|
|
2
|
|
|
|
|
5
|
|
|
136
|
9
|
100
|
100
|
|
|
37
|
unless ($_ =~ m/^\d+$/ and $_ <= @{$self->{_active}}) |
|
|
6
|
|
|
|
|
25
|
|
|
137
|
4
|
|
|
|
|
13
|
{ error('invalid_selection'); $_ = -1; next; } |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
6
|
|
|
138
|
5
|
|
|
|
|
22
|
$self->{_active}->[$_-1]->_process; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
######################################################################### |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 B - remove dialogue from application |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
C's concrete implementation of |
|
147
|
|
|
|
|
|
|
L
|
|
148
|
|
|
|
|
|
|
from application> sets a flag for auto-destruction in C
|
|
149
|
|
|
|
|
|
|
- handle action of UI element>>. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub destroy($) |
|
156
|
|
|
|
|
|
|
{ |
|
157
|
6
|
|
|
6
|
1
|
820
|
debug(2, __PACKAGE__, '::destroy'); |
|
158
|
6
|
|
|
|
|
9
|
my ($self) = @_; |
|
159
|
6
|
|
|
|
|
14
|
$self->{_self_destruct} = 1; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
######################################################################### |
|
165
|
|
|
|
|
|
|
######################################################################### |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L, L |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 LICENSE |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Copyright (C) Thomas Dorner. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
|
176
|
|
|
|
|
|
|
under the same terms as Perl itself. See LICENSE file for more details. |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Thomas Dorner Edorner (at) cpan (dot) orgE |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |