line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UI::Various::RichTerm::Check; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Author, Copyright and License: see end of file |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
UI::Various::RichTerm::Check - 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::Check; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 ABSTRACT |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This module is the specific implementation of L using |
18
|
|
|
|
|
|
|
the rich terminal UI. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The documentation of this module is only intended for developers of the |
23
|
|
|
|
|
|
|
package itself. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
######################################################################### |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
6
|
|
60
|
use v5.14; |
|
6
|
|
|
|
|
16
|
|
30
|
6
|
|
|
6
|
|
26
|
use strictures; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
36
|
|
31
|
6
|
|
|
6
|
|
808
|
no indirect 'fatal'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
21
|
|
32
|
6
|
|
|
6
|
|
265
|
no multidimensional; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
24
|
|
33
|
6
|
|
|
6
|
|
212
|
use warnings 'once'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
306
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
6
|
|
31
|
use UI::Various::core; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
28
|
|
38
|
6
|
|
|
6
|
|
30
|
use UI::Various::Check; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
213
|
|
39
|
6
|
|
|
6
|
|
30
|
use UI::Various::RichTerm::base qw(%D); |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
2302
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
require Exporter; |
42
|
|
|
|
|
|
|
our @ISA = qw(UI::Various::Check UI::Various::RichTerm::base); |
43
|
|
|
|
|
|
|
our @EXPORT_OK = qw(); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
######################################################################### |
46
|
|
|
|
|
|
|
######################################################################### |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
######################################################################### |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 B<_prepare> - prepare UI element |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
($width, $height) = $ui_element->_prepare($content_width); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head3 example: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my ($w, $h) = $_->_prepare($content_width); |
61
|
|
|
|
|
|
|
$width < $w and $width = $w; |
62
|
|
|
|
|
|
|
$height += $h; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head3 parameters: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$content_width preferred width of content |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head3 description: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Prepare output of the UI element by determining and returning the space it |
71
|
|
|
|
|
|
|
wants or needs. I
|
72
|
|
|
|
|
|
|
C container elements!> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head3 returns: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
width and height the UI element will require or need when printed |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _prepare($$) |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
0
|
|
|
my ($self, $content_width) = @_; |
85
|
0
|
|
|
|
|
|
return $self->_size($self->text, $content_width); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
######################################################################### |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 B<_show> - return formatted UI element |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$string = $ui_element->_show($prefix, $width, $height); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 example: |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my ($w, $h) = $_->_prepare($content_width); |
97
|
|
|
|
|
|
|
... |
98
|
|
|
|
|
|
|
$_->_show('(1) ', $w, $h); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head3 parameters: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
$prefix text in front of first line |
103
|
|
|
|
|
|
|
$width the width returned by _prepare above |
104
|
|
|
|
|
|
|
$height the height returned by _prepare above |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head3 description: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Return the formatted (rectangular) text box of the UI element. Its height |
109
|
|
|
|
|
|
|
will be exactly as specified, unless there hasn't been enough space. The |
110
|
|
|
|
|
|
|
weight is similarly as specified plus the width needed for the prefix. |
111
|
|
|
|
|
|
|
I
|
112
|
|
|
|
|
|
|
elements!> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head3 returns: |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
the rectangular text box for UI element |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub _show($$$$) |
123
|
|
|
|
|
|
|
{ |
124
|
0
|
|
|
0
|
|
|
my ($self, $prefix, $width, $height) = @_; |
125
|
|
|
|
|
|
|
# Note that the accessors automatically dereference the SCALARs here: |
126
|
0
|
0
|
|
|
|
|
local $_ = $prefix . $D{CL} . ($self->var ? 'X' : ' ') . $D{CR} . ' '; |
127
|
0
|
|
|
|
|
|
return $self->_format($_, '', '', $self->text, '', '', $width, $height); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
######################################################################### |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 B<_process> - handle action of UI element |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$ui_element->_process; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head3 description: |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Handle the action of the UI element (invert the checkbox). |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub _process($) |
145
|
|
|
|
|
|
|
{ |
146
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# only dereference reading the SCALAR: |
149
|
0
|
0
|
|
|
|
|
${$self->{var}} = $self->var ? 0 : 1; # invert value |
|
0
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
######################################################################### |
155
|
|
|
|
|
|
|
######################################################################### |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SEE ALSO |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L, L |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 LICENSE |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Copyright (C) Thomas Dorner. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
166
|
|
|
|
|
|
|
under the same terms as Perl itself. See LICENSE file for more details. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Thomas Dorner Edorner (at) cpan (dot) orgE |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |