File Coverage

blib/lib/UI/Various/PoorTerm/Input.pm
Criterion Covered Total %
statement 33 33 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod n/a
total 43 43 100.0


line stmt bran cond sub pod time code
1             package UI::Various::PoorTerm::Input;
2              
3             # Author, Copyright and License: see end of file
4              
5             =head1 NAME
6              
7             UI::Various::PoorTerm::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 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   19 use v5.14;
  2         6  
31 2     2   9 use strictures;
  2         5  
  2         8  
32 2     2   265 no indirect 'fatal';
  2         7  
  2         8  
33 2     2   115 no multidimensional;
  2         2  
  2         8  
34 2     2   74 use warnings 'once';
  2         4  
  2         111  
35              
36             our $VERSION = '0.24';
37              
38 2     2   10 use UI::Various::core;
  2         3  
  2         18  
39 2     2   10 use UI::Various::Input;
  2         3  
  2         74  
40 2     2   339 use UI::Various::PoorTerm::base;
  2         3  
  2         593  
41              
42             require Exporter;
43             our @ISA = qw(UI::Various::Input UI::Various::PoorTerm::base);
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($prefix);
58              
59             =head3 example:
60              
61             $_->_show('(1) ');
62              
63             =head3 parameters:
64              
65             $prefix text in front of first line
66              
67             =head3 description:
68              
69             Show (print) the UI element. I
70             UI::Various::PoorTerm container elements!>
71              
72             =cut
73              
74             # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
75              
76             sub _show($$)
77             {
78 1     1   1431 my ($self, $prefix) = @_;
79             # Note that the accessor automatically dereferences the SCALAR here:
80 1         8 print $self->_wrap($prefix, $self->textvar), "\n";
81             }
82              
83             #########################################################################
84              
85             =head2 B<_process> - handle action of UI element
86              
87             $ui_element->_process;
88              
89             =head3 description:
90              
91             Handle the action of the UI element aka I.
92              
93             =cut
94              
95             # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
96              
97             sub _process($)
98             {
99 1     1   1498 my ($self) = @_;
100              
101             # do not automatically dereference the SCALAR here:
102 1         9 print $self->_wrap(msg('old_value') . ': ', ${$self->{textvar}}), "\n";
  1         5  
103 1         7 print msg('new_value'), '? ';
104 1         3 ${$self->{textvar}} = ;
  1         5  
105 1         2 ${$self->{textvar}} =~ s/\r?\n$//;
  1         14  
106             }
107              
108             1;
109              
110             #########################################################################
111             #########################################################################
112              
113             =head1 SEE ALSO
114              
115             L, L
116              
117             =head1 LICENSE
118              
119             Copyright (C) Thomas Dorner.
120              
121             This library is free software; you can redistribute it and/or modify it
122             under the same terms as Perl itself. See LICENSE file for more details.
123              
124             =head1 AUTHOR
125              
126             Thomas Dorner Edorner (at) cpan (dot) orgE
127              
128             =cut