File Coverage

blib/lib/Curses/UI/TextEntry.pm
Criterion Covered Total %
statement 15 25 60.0
branch 0 2 0.0
condition 0 3 0.0
subroutine 5 6 83.3
pod 1 1 100.0
total 21 37 56.7


line stmt bran cond sub pod time code
1             # ----------------------------------------------------------------------
2             # Curses::UI::TextEntry
3             #
4             # (c) 2001-2002 by Maurice Makaay. All rights reserved.
5             # This file is part of Curses::UI. Curses::UI is free software.
6             # You can redistribute it and/or modify it under the same terms
7             # as perl itself.
8             #
9             # Currently maintained by Marcus Thiesen
10             # e-mail: marcus@cpan.thiesenweb.de
11             # ----------------------------------------------------------------------
12              
13             # TODO: fix dox
14              
15             package Curses::UI::TextEntry;
16              
17 1     1   5 use strict;
  1         2  
  1         38  
18 1     1   4 use Curses;
  1         1  
  1         2678  
19 1     1   7 use Curses::UI::Common;
  1         2  
  1         94  
20 1     1   975 use Curses::UI::TextEditor;
  1         8  
  1         86  
21              
22 1         311 use vars qw(
23             $VERSION
24             @ISA
25 1     1   13 );
  1         2  
26              
27             $VERSION = '1.10';
28              
29             @ISA = qw(
30             Curses::UI::TextEditor
31             );
32            
33             sub new ()
34             {
35 0     0 1   my $class = shift;
36              
37 0           my %userargs = @_;
38 0           keys_to_lowercase(\%userargs);
39              
40 0           my %args = (
41             -undolevels => 20, # number of undolevels. 0 = infinite
42             -homeonblur => 1, # cursor to homepos on blur?
43              
44             -bg => -1,
45             -fg => -1,
46              
47             %userargs,
48              
49             -singleline => 1, # single line mode or not?
50             -showhardreturns => 0, # show hard returns with diamond char?
51             );
52              
53             # Create the entry.
54 0           my $this = $class->SUPER::new( %args );
55              
56             # There is no reason to show overflow symbols if no
57             # more characters than the available width can be
58             # added (the screen would wrap and after that
59             # typing would be impossible).
60 0 0 0       if ($this->{-maxlength} and
61             $this->canvaswidth > $this->{-maxlength}) {
62 0           $this->{-showoverflow} = 0;
63             }
64              
65             # Setup bindings.
66 0           $this->clear_binding('loose-focus');
67 0           $this->set_binding('loose-focus', KEY_ENTER(), CUI_TAB(), KEY_BTAB() );
68              
69 0           return $this;
70             }
71              
72             1;
73              
74              
75             =pod
76              
77             =head1 NAME
78              
79             Curses::UI::TextEntry - Create and manipulate textentry widgets
80              
81             =head1 CLASS HIERARCHY
82              
83             Curses::UI::Widget
84             Curses::UI::Searchable
85             |
86             +----Curses::UI::TextEditor
87             |
88             +----Curses::UI::TextEntry
89              
90              
91             =head1 SYNOPSIS
92              
93             use Curses::UI;
94             my $cui = new Curses::UI;
95             my $win = $cui->add('window_id', 'Window');
96              
97             my $textentry = $win->add(
98             'mytextentry', 'TextEntry'
99             );
100              
101             $textentry->focus();
102             my $text = $textentry->get();
103              
104              
105             =head1 DESCRIPTION
106              
107             Curses::UI::TextEntry is a widget that can be used
108             to create a textentry widget. This class is
109             derived from Curses::UI::TextEditor. The
110             only special thing about this class is that the
111             B<-singleline> option is forced to a true value.
112             So for the usage of Curses::UI::TextEntry see
113             L.
114              
115              
116              
117              
118             =head1 SEE ALSO
119              
120             L,
121             L,
122              
123              
124              
125              
126             =head1 AUTHOR
127              
128             Copyright (c) 2001-2002 Maurice Makaay. All rights reserved.
129              
130             Maintained by Marcus Thiesen (marcus@cpan.thiesenweb.de)
131              
132              
133             This package is free software and is provided "as is" without express
134             or implied warranty. It may be used, redistributed and/or modified
135             under the same terms as perl itself.
136