| 1 | package TUI::Dialogs::InputLine; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Editable single-line text input control for dialogs. | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 24 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 24 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 24 | our $VERSION = '2.000002'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 24 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 24 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 24 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 24 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 14 | TInputLine | ||||||||||||||||||||||||||||||||||||||||||
| 15 | new_TInputLine | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 24 | ▶ | use List::Util qw( min max ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 24 | ▶ | use TUI::toolkit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 24 | ▶ | use TUI::toolkit::Types qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | Maybe | ||||||||||||||||||||||||||||||||||||||||||
| 22 | :is | ||||||||||||||||||||||||||||||||||||||||||
| 23 | :types | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 24 | ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 24 | ▶ | use TUI::Const qw( EOS ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 24 | ▶ | use TUI::Dialogs::Const qw( cpInputLine ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 24 | ▶ | use TUI::Drivers::Const qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | :evXXXX | ||||||||||||||||||||||||||||||||||||||||||
| 30 | kbShift | ||||||||||||||||||||||||||||||||||||||||||
| 31 | kbLeft | ||||||||||||||||||||||||||||||||||||||||||
| 32 | kbRight | ||||||||||||||||||||||||||||||||||||||||||
| 33 | kbHome | ||||||||||||||||||||||||||||||||||||||||||
| 34 | kbEnd | ||||||||||||||||||||||||||||||||||||||||||
| 35 | kbBack | ||||||||||||||||||||||||||||||||||||||||||
| 36 | kbDel | ||||||||||||||||||||||||||||||||||||||||||
| 37 | kbIns | ||||||||||||||||||||||||||||||||||||||||||
| 38 | meDoubleClick | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 24 | ); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 24 | ▶ | use TUI::Drivers::Util qw( ctrlToArrow ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 24 | ▶ | use TUI::Validate::Const qw( :TVTransfer ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 24 | ▶ | use TUI::Views::Const qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | cmCancel | ||||||||||||||||||||||||||||||||||||||||||
| 44 | cmValid | ||||||||||||||||||||||||||||||||||||||||||
| 45 | ofSelectable | ||||||||||||||||||||||||||||||||||||||||||
| 46 | ofFirstClick | ||||||||||||||||||||||||||||||||||||||||||
| 47 | :sfXXXX | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 24 | ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 24 | ▶ | use TUI::Views::DrawBuffer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 24 | ▶ | use TUI::Views::Palette; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 24 | ▶ | use TUI::Views::View; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | sub TInputLine() { __PACKAGE__ } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | sub name() { 'TInputLine' } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub new_TInputLine { __PACKAGE__->from(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_TInputLine: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 24 | extends TView; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 24 | ▶ | use constant CONTROL_Y => 25; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # declare global variables | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 24 | our $rightArrow = "\x10"; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 24 | our $leftArrow = "\x11"; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | # public attributes | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 24 | has data => ( is => 'rw', default => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | has maxLen => ( is => 'ro', default => sub { die 'required' } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 24 | has curPos => ( is => 'rw', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 24 | has firstPos => ( is => 'rw', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 24 | has selStart => ( is => 'ro', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 24 | has selEnd => ( is => 'ro', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # private attributes | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 24 | has validator => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 24 | has anchor => ( is => 'bare', default => -1 ); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 24 | has oldAnchor => ( is => 'bare', default => -1 ); # New to save state info | |||||||||||||||||||||||||||||||||||||||||
| 77 | 24 | has oldData => ( is => 'bare', default => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 78 | 24 | has oldCurPos => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 24 | has oldFirstPos => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 24 | has oldSelStart => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | 24 | has oldSelEnd => ( is => 'bare' ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | # predeclare private methods | ||||||||||||||||||||||||||||||||||||||||||
| 84 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 24 | $canScroll, | |||||||||||||||||||||||||||||||||||||||||
| 86 | $mouseDelta, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | $mousePos, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | $deleteSelect, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | $adjustSelectBlock, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | $saveState, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | $restoreState, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | $checkValid, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub BUILDARGS { # \%args (%args) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 97 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | named => [ | ||||||||||||||||||||||||||||||||||||||||||
| 99 | bounds => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | maxLen => Int, { alias => 'aMaxLen' }, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | validator => Object, { alias => 'aValid', optional => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 103 | caller_level => +1, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my ( $class, $args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return { %$args }; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->{state} |= sfCursorVis; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->{options} |= ofSelectable | ofFirstClick; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | sub from { # $obj ($bounds, $aMaxLen, |$aValid) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 120 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | pos => [ | ||||||||||||||||||||||||||||||||||||||||||
| 122 | Object, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | Int, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | Object, { optional => 1 } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | SWITCH: for ( scalar @args ) { | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $_ == 2 and return $class->new( bounds => $args[0], maxLen => $args[1] ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $_ == 3 and return $class->new( bounds => $args[0], maxLen => $args[1], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | validator => $args[2] ); | ||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | sub DEMOLISH { # void ($in_global_destruction) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my ( $self, $in_global_destruction ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $self->{data} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->{oldData} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self->destroy( $self->{validator} ); | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub dataSize { # $dSize () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dataSize: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 147 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $dSize = 0; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ( $self->{validator} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $dSize = $self->{validator}->transfer( $self->{data}, undef, vtDataSize ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if ( $dSize == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $dSize = 1; # In Perl, this must be the number of entries in the list | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return $dSize; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } #/ sub dataSize | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub draw { # void () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
draw: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 164 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ( $l, $r ); | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $b = TDrawBuffer->new(); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | my $color = $self->{state} & sfFocused | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | ? $self->getColor( 2 ) | ||||||||||||||||||||||||||||||||||||||||||
| 173 | : $self->getColor( 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $b->moveChar( 0, ' ', $color, $self->{size}{x} ); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $buf = substr( $self->{data}, $self->{firstPos}, $self->{size}{x} - 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $b->moveStr( 1, $buf, $color ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( $self->$canScroll( 1 ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $b->moveChar( $self->{size}{x} - 1, $rightArrow, $self->getColor( 4 ), 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ( $self->{state} & sfSelected ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | if ( $self->$canScroll( -1 ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $b->moveChar( 0, $leftArrow, $self->getColor( 4 ), 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $l = $self->{selStart} - $self->{firstPos}; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $r = $self->{selEnd} - $self->{firstPos}; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $l = max( 0, $l ); | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $r = min( $self->{size}{x} - 2, $r ); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ( $l < $r ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $b->moveChar( $l + 1, undef, $self->getColor( 3 ), $r - $l ); | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | } #/ if ( ( $self->{state} ...)) | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->writeLine( 0, 0, $self->{size}{x}, $self->{size}{y}, $b ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->setCursor( $self->{curPos} - $self->{firstPos} + 1, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } #/ sub draw | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub getData { # void (\@rec) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getData: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 201 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 202 | pos => [ArrayLike], | ||||||||||||||||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my ( $self, $rec ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if ( !$self->{validator} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"validator"} and $self->{"validator"}->transfer($self->{"data"}, $rec, 2)
MC/DC0%0/2
$self->{"validator"} and $self->{"validator"}->transfer($self->{"data"}, $rec, 2)
$self->{"validator"}
$self->{"validator"}->transfer($self->{"data"}, $rec, 2)
Truth table0%0/3
A and B
A= $self->{"validator"}B= $self->{"validator"}->transfer($self->{"data"}, $rec, 2)
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | || !$self->{validator}->transfer( $self->{data}, $rec, vtGetData ) | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ) { | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | assert ( $self->dataSize() ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $rec->[0] = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } #/ sub getData | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub getPalette { # $palette () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getPalette: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 216 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | pos => [], | ||||||||||||||||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | state $palette = TPalette->new( | |||||||||||||||||||||||||||||||||||||||||
| 221 | data => cpInputLine, | ||||||||||||||||||||||||||||||||||||||||||
| 222 | size => length( cpInputLine ), | ||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return $palette->clone(); | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub handleEvent { # void ($event) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handleEvent: not called CC=41 SCAR=74.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 229 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | pos => [Object], | ||||||||||||||||||||||||||||||||||||||||||
| 231 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my ( $self, $event ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 233 | # Home, Left Arrow, Right Arrow, End, Ctrl-Left Arrow, Ctrl-Right Arrow | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my @padKeys = ( 0x47, 0x4b, 0x4d, 0x4f, 0x73, 0x74 ); | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $self->SUPER::handleEvent( $event ); | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my ( $delta, $i ); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return unless ( $self->{state} & sfSelected ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | SWITCH: for ( $event->{what} ) { | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | evMouseDown == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ( $self->$canScroll( $delta = $self->$mouseDelta( $event ) ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ( $self->$canScroll( $delta ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $self->{firstPos} += $delta; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } while $self->mouseEvent( $event, evMouseAuto ); | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } #/ if ( $self->$canScroll(...)) | ||||||||||||||||||||||||||||||||||||||||||
| 249 | elsif ( $event->{mouse}{eventFlags} & meDoubleClick ) { | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $self->selectAll( 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $self->{anchor} = $self->$mousePos( $event ); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if ( $event->{what} == evMouseAuto ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $delta = $self->$mouseDelta( $event ); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ( $self->$canScroll( $delta ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->{firstPos} += $delta; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->{curPos} = $self->$mousePos( $event ); | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->$adjustSelectBlock(); | |||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||||||||||||
| 264 | } while $self->mouseEvent( $event, evMouseMove | evMouseAuto ); | ||||||||||||||||||||||||||||||||||||||||||
| 265 | } #/ else [ if ( $self->$canScroll(...))] | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $self->clearEvent( $event ); | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 268 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | evKeyDown == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->$saveState(); | |||||||||||||||||||||||||||||||||||||||||
| 272 | $event->{keyDown}{keyCode} = | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ctrlToArrow( $event->{keyDown}{keyCode} ); | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my $scanCode = $event->{keyDown}{charScan}{scanCode}; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $isPad = grep { $_ == $scanCode } @padKeys; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $hasShift = $event->{keyDown}{controlKeyState} & kbShift; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ( $isPad && $hasShift ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$isPad and $hasShift
MC/DC0%0/2
$isPad and $hasShift
$isPad
$hasShift
Truth table0%0/3
A and B
A= $isPadB= $hasShift
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $event->{keyDown}{charScan}{charCode} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ( $self->{anchor} < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $self->{anchor} = $self->{curPos}; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $self->{anchor} = -1; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | SWITCH: for ( $event->{keyDown}{keyCode} ) { | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | kbLeft == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if ( $self->{curPos} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->{curPos}--; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 292 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | kbRight == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ( $self->{curPos} < length( $self->{data} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->{curPos}++; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 298 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | kbHome == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->{curPos} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 302 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | kbEnd == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $self->{curPos} = length( $self->{data} ); | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 306 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | kbBack == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if ( $self->{curPos} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | substr( $self->{data}, $self->{curPos} - 1, 1, '' ); | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $self->{curPos}--; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if ( $self->{firstPos} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $self->{firstPos}--; | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $self->$checkValid( true ); | |||||||||||||||||||||||||||||||||||||||||
| 315 | } #/ if ( $self->{curPos} >...) | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 317 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | kbDel == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if ( $self->{selStart} == $self->{selEnd} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if ( $self->{curPos} < length( $self->{data} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $self->{selStart} = $self->{curPos}; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $self->{selEnd} = $self->{curPos} + 1; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $self->$deleteSelect(); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $self->$checkValid( true ); | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 328 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | kbIns == $_ and do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $self->setState( sfCursorIns, !( $self->{state} & sfCursorIns ) ); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 332 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 333 | DEFAULT: { | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $ch = $event->{keyDown}{charScan}{charCode}; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ( defined $ch && $ch >= ord( ' ' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $ch and $ch >= 32
MC/DC0%0/2
defined $ch and $ch >= 32
defined $ch
$ch >= 32
Truth table0%0/3
A and B
A= defined $chB= $ch >= 32
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->$deleteSelect(); | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ( $self->{state} & sfCursorIns ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | # The following is always a signed comparison in Perl! | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | if ( $self->{curPos} < length( $self->{data} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | substr( $self->{data}, $self->{curPos}, 1, '' ); | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if ( $self->$checkValid( true ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $strlen = length( $self->{data} ); | |||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if ( $strlen < $self->{maxLen} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | if ( $self->{firstPos} > $self->{curPos} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $self->{firstPos} = $self->{curPos}; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # In Perl, only move the data if the insertion is not at end | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if ( $self->{curPos} < $strlen ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | substr( $self->{data}, $self->{curPos} + 1 ) = | ||||||||||||||||||||||||||||||||||||||||||
| 352 | substr( $self->{data}, $self->{curPos} ) | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | substr( $self->{data}, $self->{curPos}, 1 ) = chr( $ch ); | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $self->{curPos}++; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $self->$checkValid( false ); | |||||||||||||||||||||||||||||||||||||||||
| 358 | } #/ if ( $self->$checkValid...) | ||||||||||||||||||||||||||||||||||||||||||
| 359 | } #/ if ( defined $ch && $ch...) | ||||||||||||||||||||||||||||||||||||||||||
| 360 | ▶ | elsif ( defined $ch && $ch == CONTROL_Y ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $ch and $ch == 25
MC/DC0%0/2
defined $ch and $ch == 25
defined $ch
$ch == 25
Truth table0%0/3
A and B
A= defined $chB= $ch == 25
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | $self->{data} = EOS; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->{curPos} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 368 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 369 | } #/ SWITCH: for ( $event->{keyDown}...) | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $self->$adjustSelectBlock(); | |||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ( $self->{firstPos} > $self->{curPos} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $self->{firstPos} = $self->{curPos}; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $i = $self->{curPos} - $self->{size}{x} + 2; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if ( $self->{firstPos} < $i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $self->{firstPos} = $i; | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $self->clearEvent( $event ); | |||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 382 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } #/ SWITCH: for ( $event->{what} ) | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 385 | } #/ sub handleEvent | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | sub selectAll { # void ($enable) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
selectAll: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 389 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 390 | pos => [Bool], | ||||||||||||||||||||||||||||||||||||||||||
| 391 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my ( $self, $enable ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $self->{selStart} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ( $enable ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my $len = length( $self->{data} ); | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $self->{curPos} = $self->{selEnd} = $len; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $self->{curPos} = $self->{selEnd} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $self->{firstPos} = max( 0, $self->{curPos} - $self->{size}{x} + 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $self->{anchor} = 0; # This sets anchor to avoid deselect on init selection | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } #/ sub selectAll | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub setData { # void (\@rec) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setData: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 409 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 410 | pos => [ArrayLike], | ||||||||||||||||||||||||||||||||||||||||||
| 411 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my ( $self, $rec ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if ( !$self->{validator} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"validator"} and $self->{"validator"}->transfer($self->{"data"}, $rec, 1)
MC/DC0%0/2
$self->{"validator"} and $self->{"validator"}->transfer($self->{"data"}, $rec, 1)
$self->{"validator"}
$self->{"validator"}->transfer($self->{"data"}, $rec, 1)
Truth table0%0/3
A and B
A= $self->{"validator"}B= $self->{"validator"}->transfer($self->{"data"}, $rec, 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | || !$self->{validator}->transfer( $self->{data}, $rec, vtSetData ) | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ) { | |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | assert ( $self->dataSize() ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | assert ( defined $rec->[0] and !ref $rec->[0] ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $rec->[0] and not ref $rec->[0]
MC/DC0%0/2
defined $rec->[0] and not ref $rec->[0]
defined $rec->[0]
not ref $rec->[0]
Truth table0%0/3
A and not(B)
A= defined $rec->[0]B= not ref $rec->[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $self->{data} = substr( $rec->[0], 0, $self->{maxLen} ); | |||||||||||||||||||||||||||||||||||||||||
| 419 | } #/ if ( !$self->{validator...}) | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $self->selectAll( true ); | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 422 | } #/ sub setData | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub setState { # void ($aState, $enable) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setState: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 426 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 427 | pos => [PositiveOrZeroInt, Bool], | ||||||||||||||||||||||||||||||||||||||||||
| 428 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my ( $self, $aState, $enable ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $self->SUPER::setState( $aState, $enable ); | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if ( $aState == sfSelected | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$aState == 32 or $aState == 16 and $self->{"state"} & 32
$aState == 16 and $self->{"state"} & 32
MC/DC0%0/3
$aState == 32 or $aState == 16 and $self->{"state"} & 32
$aState == 32
$aState == 16
$self->{"state"} & 32
Truth table0%0/4
A or B and C
A= $aState == 32B= $aState == 16C= $self->{"state"} & 32
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | || ( $aState == sfActive && ( $self->{state} & sfSelected ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 433 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $self->selectAll( $enable ); | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 437 | } #/ sub setState | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | sub valid { # $bool ($command) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 441 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 442 | pos => [PositiveOrZeroInt], | ||||||||||||||||||||||||||||||||||||||||||
| 443 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my ( $self, $command ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | if ( $self->{validator} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if ( $command == cmValid ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | my $status = $self->{validator}->can( 'status' ) | ||||||||||||||||||||||||||||||||||||||||||
| 449 | ? $self->{validator}->status() | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | return $status == 0; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | elsif ( $command != cmCancel ) { | ||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | unless ( $self->{validator}->validate( $self->{data} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $self->select(); | |||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | return false; | |||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return true; | |||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | sub setValidator { # void ($aValid|undef) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setValidator: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 465 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 466 | pos => [Maybe[Object]], | ||||||||||||||||||||||||||||||||||||||||||
| 467 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my ( $self, $aValid ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | if ( $self->{validator} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->destroy( $self->{validator} ); | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $self->{validator} = $aValid; | |||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 474 | } #/ sub setValidator | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | $canScroll = sub { # bool ($delta) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my ( $self, $delta ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | assert ( is_Int $delta ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | if ( $delta < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | return $self->{firstPos} > 0; | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | elsif ( $delta > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return length( $self->{data} ) - $self->{firstPos} + 2 > $self->{size}{x}; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return false; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | $mouseDelta = sub { # void ($event) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my ( $self, $event ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | assert ( is_Object $event ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $mouse = $self->makeLocal( $event->{mouse}{where} ); | |||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if ( $mouse->{x} <= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | $mouse->{x} >= $self->{size}{x} - 1 ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | $mousePos = sub { # void ($event) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my ( $self, $event ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | assert ( is_Object $event ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my $mouse = $self->makeLocal( $event->{mouse}{where} ); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $mouse->{x} = max( $mouse->{x}, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $pos = $mouse->{x} + $self->{firstPos} - 1; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $pos = max( $pos, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $pos = min( $pos, length( $self->{data} ) ); | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | return $pos; | |||||||||||||||||||||||||||||||||||||||||
| 518 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | $deleteSelect = sub { # void () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | assert ( @_ == 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | if ( $self->{selStart} < $self->{selEnd} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | substr( $self->{data}, $self->{selStart} ) = | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | substr( $self->{data}, $self->{selEnd} ); | |||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | $self->{curPos} = $self->{selStart}; | |||||||||||||||||||||||||||||||||||||||||
| 528 | } #/ if ( $self->{selStart}...) | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | $adjustSelectBlock = sub { # void () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | assert ( @_ == 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if ( $self->{anchor} < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $self->{selStart} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $self->{selEnd} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 540 | elsif ( $self->{anchor} > $self->{curPos} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $self->{selStart} = $self->{curPos}; | |||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $self->{selEnd} = $self->{anchor}; | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | $self->{selStart} = $self->{anchor}; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $self->{selEnd} = $self->{curPos}; | |||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | $saveState = sub { # void () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | assert ( @_ == 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | if ( $self->{validator} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $self->{oldData} = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $self->{oldCurPos} = $self->{curPos}; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $self->{oldFirstPos} = $self->{firstPos}; | |||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $self->{oldSelStart} = $self->{selStart}; | |||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | $self->{oldSelEnd} = $self->{selEnd}; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $self->{oldAnchor} = $self->{anchor}; | |||||||||||||||||||||||||||||||||||||||||
| 562 | } #/ if ( $self->{validator...}) | ||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | $restoreState = sub { # void () | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | assert ( @_ == 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | if ( $self->{validator} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | $self->{data} = $self->{oldData}; | |||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $self->{curPos} = $self->{oldCurPos}; | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $self->{firstPos} = $self->{oldFirstPos}; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $self->{selStart} = $self->{oldSelStart}; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $self->{selEnd} = $self->{oldSelEnd}; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $self->{anchor} = $self->{oldAnchor}; | |||||||||||||||||||||||||||||||||||||||||
| 577 | } #/ if ( $self->{validator...}) | ||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 579 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | $checkValid = sub { # $bool ($noAutoFill) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my ( $self, $noAutoFill ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | assert ( is_Bool $noAutoFill ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | return true unless $self->{validator}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $oldLen = length( $self->{data} ); | |||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my $newData = $self->{data}; | |||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | if ( !$self->{validator}->isValidInput( $newData, $noAutoFill ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | $self->$restoreState(); | |||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | return false; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | if ( length( $newData ) > $self->{maxLen} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | substr( $newData, $self->{maxLen} ) = ''; | |||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $self->{data} = $newData; | |||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | if ( $self->{curPos} >= $oldLen && length( $self->{data} ) > $oldLen ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"curPos"} >= $oldLen and length $self->{"data"} > $oldLen
MC/DC0%0/2
$self->{"curPos"} >= $oldLen and length $self->{"data"} > $oldLen
$self->{"curPos"} >= $oldLen
length $self->{"data"} > $oldLen
Truth table0%0/3
A and B
A= $self->{"curPos"} >= $oldLenB= length $self->{"data"} > $oldLen
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $self->{curPos} = length( $self->{data} ); | |||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | return true; | |||||||||||||||||||||||||||||||||||||||||
| 602 | } #/ else [ if ( !$self->{validator...})] | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 24 | 1 | |||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | __END__ | ||||||||||||||||||||||||||||||||||||||||||