File Coverage

blib/lib/UI/Various/RichTerm/Input.pm
Criterion Covered Total %
statement 23 30 76.6
branch n/a
condition n/a
subroutine 8 11 72.7
pod n/a
total 31 41 75.6


line stmt bran cond sub pod time code
1             package UI::Various::RichTerm::Input;
2              
3             # Author, Copyright and License: see end of file
4              
5             =head1 NAME
6              
7             UI::Various::RichTerm::Input - 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::Input;
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   55 use v5.14;
  6         16  
30 6     6   23 use strictures;
  6         11  
  6         20  
31 6     6   827 no indirect 'fatal';
  6         19  
  6         23  
32 6     6   252 no multidimensional;
  6         17  
  6         31  
33 6     6   200 use warnings 'once';
  6         9  
  6         275  
34              
35             our $VERSION = '0.23';
36              
37 6     6   28 use UI::Various::core;
  6         10  
  6         25  
38 6     6   44 use UI::Various::Input;
  6         9  
  6         204  
39 6     6   25 use UI::Various::RichTerm::base qw(%D);
  6         9  
  6         1938  
40              
41             require Exporter;
42             our @ISA = qw(UI::Various::Input 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             # Note that the accessor automatically dereferences the SCALAR here:
86 0           return $self->_size($self->textvar, $content_width);
87             }
88              
89             #########################################################################
90              
91             =head2 B<_show> - return formatted UI element
92              
93             $string = $ui_element->_show($prefix, $width, $height);
94              
95             =head3 example:
96              
97             my ($w, $h) = $_->_prepare($content_width);
98             ...
99             $_->_show('(1) ', $w, $h);
100              
101             =head3 parameters:
102              
103             $prefix text in front of first line
104             $width the width returned by _prepare above
105             $height the height returned by _prepare above
106              
107             =head3 description:
108              
109             Return the formatted (rectangular) text box of the UI element. Its height
110             will be exactly as specified, unless there hasn't been enough space. The
111             weight is similarly as specified plus the width needed for the prefix.
112             I
113             elements!>
114              
115             =head3 returns:
116              
117             the rectangular text box for UI element
118              
119             =cut
120              
121             # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
122              
123             sub _show($$$$)
124             {
125 0     0     my ($self, $prefix, $width, $height) = @_;
126             # Note that the accessor automatically dereferences the SCALAR here:
127 0           return $self->_format($prefix, '', $D{UL1}, $self->textvar, $D{UL0}, '',
128             $width, $height);
129             }
130              
131             #########################################################################
132              
133             =head2 B<_process> - handle action of UI element
134              
135             $ui_element->_process;
136              
137             =head3 description:
138              
139             Handle the action of the UI element aka I.
140              
141             =cut
142              
143             # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
144              
145             sub _process($)
146             {
147 0     0     my ($self) = @_;
148              
149             # do not automatically dereference the SCALAR here:
150 0           ${$self->{textvar}} = $self->top->readline(msg('new_value') . '? ',
  0            
151             '.*',
152             $self->textvar);
153             }
154              
155             1;
156              
157             #########################################################################
158             #########################################################################
159              
160             =head1 SEE ALSO
161              
162             L, L
163              
164             =head1 LICENSE
165              
166             Copyright (C) Thomas Dorner.
167              
168             This library is free software; you can redistribute it and/or modify it
169             under the same terms as Perl itself. See LICENSE file for more details.
170              
171             =head1 AUTHOR
172              
173             Thomas Dorner Edorner (at) cpan (dot) orgE
174              
175             =cut