blib/lib/Term/ReadLine/Perl5/OO/State.pm untested

filter: Statementstmt 0.0% 0 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 27 SCAR 6.9
CC
1
Cov
0%
new
2.0
len
2.0
plen
2.0
CRAP 2.0
1 package Term::ReadLine::Perl5::OO::State;
2 =pod
3  
4 =head1 NAME
5  
6 Term::ReadLine::Perl5::OO:State
7  
8 =head1 DESCRIPTION
9  
10 Object to old the internal state of an editable line. Thas things like
11 the text of the line and cursor position,
12  
13 =cut
14  
15  
16 use Class::Accessor::Lite 0.05 (
17 rw => [qw(buf pos cols prompt oldpos maxrows query)],
18 );
19  
20 sub new {
21 my $class = shift;
22 bless {
23 buf => '',
24 pos => 0,
25 oldpos => 0,
26 maxrows => 0,
27 }, $class;
28 }
29 use Text::VisualWidth::PP 0.03 qw(vwidth);
30  
31 sub len { length(shift->buf) }
32 sub plen { length(shift->prompt) }
33  
34 sub vpos {
35 my $self = shift;
36 vwidth(substr($self->buf, 0, $self->pos));
37 }
38  
39 sub width {
40 my $self = shift;
41 vwidth($self->prompt . $self->buf);
42 }
43  
44 1;