line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UI::Various::RichTerm::container; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Author, Copyright and License: see end of file |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
UI::Various::RichTerm::container - abstract helper class for RichTerm's container UI elements |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# This module should only be used by the container UI element classes of |
12
|
|
|
|
|
|
|
# UI::Various::RichTerm! |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 ABSTRACT |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This module provides some helper functions for the container UI elements of |
17
|
|
|
|
|
|
|
the rich terminal UI. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
The documentation of this module is only intended for developers of the |
22
|
|
|
|
|
|
|
package itself. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
All functions of the module will be included as second "base class" (in |
25
|
|
|
|
|
|
|
C<@ISA>) like (and instead of) C>. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 Attributes |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item _active [ro, global] |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Top-level container elements (windows or dialogues) may contain a reference |
34
|
|
|
|
|
|
|
to an array containing the references to all their active UI elements (those |
35
|
|
|
|
|
|
|
that are accessible, basically everything not just a simple text output). |
36
|
|
|
|
|
|
|
This allows accessing the functions behind the active UI elements. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item _active_index [ro, global] |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
In addition the top-level container elements may also contain a reference to |
41
|
|
|
|
|
|
|
a hash containing the reverse index of that array. This allows any |
42
|
|
|
|
|
|
|
container to access the indices of their own children. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=back |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
######################################################################### |
49
|
|
|
|
|
|
|
|
50
|
6
|
|
|
6
|
|
64
|
use v5.14; |
|
6
|
|
|
|
|
18
|
|
51
|
6
|
|
|
6
|
|
28
|
use strictures; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
27
|
|
52
|
6
|
|
|
6
|
|
833
|
no indirect 'fatal'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
23
|
|
53
|
6
|
|
|
6
|
|
308
|
no multidimensional; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
34
|
|
54
|
6
|
|
|
6
|
|
190
|
use warnings 'once'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
365
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
our $VERSION = '0.22'; |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
6
|
|
35
|
use UI::Various::core; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
45
|
|
59
|
6
|
|
|
6
|
|
2434
|
use UI::Various::RichTerm::base; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
2788
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
require Exporter; |
62
|
|
|
|
|
|
|
our @ISA = qw(UI::Various::RichTerm::base); |
63
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
######################################################################### |
66
|
|
|
|
|
|
|
######################################################################### |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 METHODS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The module provides the following common (internal) methods for all |
71
|
|
|
|
|
|
|
UI::Various::RichTerm container UI element classes: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
######################################################################### |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 B<_all_active> - gather and return list of active children |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my @active = $ui_element->_all_active; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head3 description: |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Recursively gather all active children in an array and return it. The |
84
|
|
|
|
|
|
|
top-level window or dialogue will store the final full array and its reverse |
85
|
|
|
|
|
|
|
hash, see C> and |
86
|
|
|
|
|
|
|
C> above. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head3 returns: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
array with active children |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _all_active($) |
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
99
|
0
|
|
|
|
|
|
my @active = (); |
100
|
0
|
|
|
|
|
|
local $_; |
101
|
0
|
|
|
|
|
|
while ($_ = $self->child) |
102
|
|
|
|
|
|
|
{ |
103
|
0
|
0
|
|
|
|
|
if ($_->can('_process')) |
|
|
0
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
{ push @active, $_; } |
105
|
|
|
|
|
|
|
elsif ($_->can('_all_active')) |
106
|
0
|
|
|
|
|
|
{ push @active, $_->_all_active(); } |
107
|
0
|
0
|
|
|
|
|
if ($_->can('_additional_active')) |
108
|
0
|
|
|
|
|
|
{ push @active, $_->_additional_active(); } |
109
|
|
|
|
|
|
|
} |
110
|
0
|
|
|
|
|
|
return @active; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
######################################################################### |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 B<_self_destruct> - remove children and self-destruct |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$ui_element->_self_destruct; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head3 description: |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Remove all children (to get rid of possible circular references) and remove |
122
|
|
|
|
|
|
|
itself from "Window Manager" C>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub _self_destruct($) |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
131
|
0
|
|
|
|
|
|
local $_; |
132
|
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if (defined $self->{_active}) |
134
|
0
|
|
|
|
|
|
{ delete $self->{_active}; delete $self->{_active_index}; } |
|
0
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
while ($_ = $self->child) |
136
|
|
|
|
|
|
|
{ |
137
|
0
|
0
|
|
|
|
|
if ($_->can('_self_destruct')) |
138
|
0
|
|
|
|
|
|
{ $_->_self_destruct; } |
139
|
|
|
|
|
|
|
else |
140
|
0
|
|
|
|
|
|
{ $self->remove($_); } |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} |
143
|
0
|
|
|
|
|
|
$self->parent->remove($self); |
144
|
0
|
|
|
|
|
|
$self = undef; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
######################################################################### |
150
|
|
|
|
|
|
|
######################################################################### |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SEE ALSO |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 LICENSE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Copyright (C) Thomas Dorner. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
161
|
|
|
|
|
|
|
under the same terms as Perl itself. See LICENSE file for more details. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Thomas Dorner Edorner (at) cpan (dot) orgE |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |