| 1 | package TUI::Outline::OutlineViewer; | ||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: abstract base class for scrollable outline viewers | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 7 | our $VERSION = '2.000003'; | |||||||||||||||||||||||||||||||
| 9 | 7 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||
| 10 | 7 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 7 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||
| 14 | TOutlineViewer | ||||||||||||||||||||||||||||||||
| 15 | new_TOutlineViewer | ||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 7 | ▶ | use Storable; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 7 | ▶ | use TUI::toolkit; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 7 | ▶ | use TUI::toolkit::Types qw( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | Maybe | ||||||||||||||||||||||||||||||||
| 23 | :is | ||||||||||||||||||||||||||||||||
| 24 | :types | ||||||||||||||||||||||||||||||||
| 25 | 7 | ); | |||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 7 | ▶ | use TUI::Drivers::Const qw( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 28 | :evXXXX | ||||||||||||||||||||||||||||||||
| 29 | :kbXXXX | ||||||||||||||||||||||||||||||||
| 30 | meDoubleClick | ||||||||||||||||||||||||||||||||
| 31 | 7 | ); | |||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | use TUI::Drivers::Util qw( ctrlToArrow ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 33 | 7 | ▶ | use TUI::Outline::Const qw( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 34 | :ovXXXX | ||||||||||||||||||||||||||||||||
| 35 | :cpXXXX | ||||||||||||||||||||||||||||||||
| 36 | 7 | ); | |||||||||||||||||||||||||||||||
| 37 | 7 | ▶ | use TUI::Views::Const qw( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 38 | gfGrowHiX | ||||||||||||||||||||||||||||||||
| 39 | gfGrowHiY | ||||||||||||||||||||||||||||||||
| 40 | :sfXXXX | ||||||||||||||||||||||||||||||||
| 41 | 7 | ); | |||||||||||||||||||||||||||||||
| 42 | 7 | ▶ | use TUI::Objects::Rect; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 43 | 7 | ▶ | use TUI::Views::DrawBuffer; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 44 | 7 | ▶ | use TUI::Views::Palette; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 45 | 7 | ▶ | use TUI::Views::Scroller; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | sub TOutlineViewer() { __PACKAGE__ } | ||||||||||||||||||||||||||||||||
| 48 | sub name() { 'TOutlineViewer' } | ||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub new_TOutlineViewer { __PACKAGE__->from(@_) } | ||||||||||||||||||||||||||||||
|
Subroutine
new_TOutlineViewer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | 7 | extends TScroller; | |||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | # public attributes | ||||||||||||||||||||||||||||||||
| 54 | 7 | has foc => ( is => 'rw', default => 0 ); | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | # private methods | ||||||||||||||||||||||||||||||||
| 57 | my ( | ||||||||||||||||||||||||||||||||
| 58 | 7 | $adjustFocus, | |||||||||||||||||||||||||||||||
| 59 | $iterate, | ||||||||||||||||||||||||||||||||
| 60 | $traverseTree | ||||||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | # declare local variables | ||||||||||||||||||||||||||||||||
| 64 | 7 | my $dBuf = TDrawBuffer->new(); | |||||||||||||||||||||||||||||||
| 65 | 7 | my $auxPos = 0; | |||||||||||||||||||||||||||||||
| 66 | 7 | my $focLevel = 0; | |||||||||||||||||||||||||||||||
| 67 | 7 | my $focLines = 0; | |||||||||||||||||||||||||||||||
| 68 | 7 | my $focFlags = 0; | |||||||||||||||||||||||||||||||
| 69 | 7 | my $updateCount = 0; | |||||||||||||||||||||||||||||||
| 70 | 7 | my $updateMaxX = 0; | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub BUILDARGS { # \%args (%args) | ||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 73 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 74 | method => 1, | ||||||||||||||||||||||||||||||||
| 75 | named => [ | ||||||||||||||||||||||||||||||||
| 76 | bounds => Object, | ||||||||||||||||||||||||||||||||
| 77 | hScrollBar => Maybe[Object], { alias => 'aHScrollBar' }, | ||||||||||||||||||||||||||||||||
| 78 | vScrollBar => Maybe[Object], { alias => 'aVScrollBar' }, | ||||||||||||||||||||||||||||||||
| 79 | ], | ||||||||||||||||||||||||||||||||
| 80 | caller_level => +1, | ||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||
| 82 | 0 | my ( $class, $args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 83 | 0 | return { %$args }; | |||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 87 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 90 | 0 | $self->{growMode} |= gfGrowHiX | gfGrowHiY; | |||||||||||||||||||||||||||||||
| 91 | 0 | return; | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub from { # $viewer ($bounds, $aHScrollBar|undef, $aVScrollBar|undef) | ||||||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 95 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 96 | method => 1, | ||||||||||||||||||||||||||||||||
| 97 | pos => [Object, Maybe[Object], Maybe[Object]], | ||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||
| 99 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 100 | 0 | return $class->new( bounds => $args[0], hScrollBar => $args[1], | |||||||||||||||||||||||||||||||
| 101 | vScrollBar => $args[2] ); | ||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub adjust { # void ($node, $expand) | ||||||||||||||||||||||||||||||
|
Subroutine
adjust: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 105 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 106 | method => Object, | ||||||||||||||||||||||||||||||||
| 107 | pos => [Object, Bool], | ||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||
| 109 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 110 | ... | ||||||||||||||||||||||||||||||||
| 111 | 0 | } | |||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | # Called to draw the outline | ||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $drawTree = sub { # $bool ($beingDrawn, $cur, $level, $position, $lines, $flags) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=15 SCAR=54.8
| |||||||||||||||||||||||||||||||||
| 115 | 0 | my ( $beingDrawn, $cur, $level, $position, $lines, $flags ) = @_; | |||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | assert ( @_ == 6 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | assert ( is_Object $beingDrawn ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | assert ( is_Object $cur ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | assert ( is_Int $level ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | assert ( is_Int $position ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | assert ( is_Int $lines ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | assert ( is_PositiveOrZeroInt $flags ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return false if $position < $beingDrawn->{delta}{y}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 125 | return true | ||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if $position >= $beingDrawn->{delta}{y} + $beingDrawn->{size}{y}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | 0 | my $color; | |||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( ( $position == $beingDrawn->{foc} ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$position == $beingDrawn->{"foc"} and $beingDrawn->{"state"} & 64
MC/DC0%0/2
$position == $beingDrawn->{"foc"} and $beingDrawn->{"state"} & 64
$position == $beingDrawn->{"foc"}
$beingDrawn->{"state"} & 64
Truth table0%0/3
A and B
A= $position == $beingDrawn->{"foc"}B= $beingDrawn->{"state"} & 64
| |||||||||||||||||||||||||||||||||
| 130 | && ( $beingDrawn->{state} & sfFocused ) | ||||||||||||||||||||||||||||||||
| 131 | ) { | ||||||||||||||||||||||||||||||||
| 132 | 0 | $color = $beingDrawn->getColor( 0x0202 ); | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | elsif ( $beingDrawn->isSelected( $position ) ) { | ||||||||||||||||||||||||||||||||
| 135 | 0 | $color = $beingDrawn->getColor( 0x0303 ); | |||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||
| 137 | else { | ||||||||||||||||||||||||||||||||
| 138 | 0 | $color = $beingDrawn->getColor( 0x0401 ); | |||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | 0 | $dBuf->moveChar( 0, ' ', $color, $beingDrawn->{size}{x} ); | |||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | 0 | my $s = $beingDrawn->getGraph( $level, $lines, $flags ); | |||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if ( ( $flags & ovExpanded ) == 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 144 | 0 | $s .= '~' . $beingDrawn->getText( $cur ) . '~'; | |||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||
| 146 | else { | ||||||||||||||||||||||||||||||||
| 147 | 0 | $s .= $beingDrawn->getText( $cur ); | |||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||
| 149 | 0 | my $offset = $beingDrawn->{delta}{x}; | |||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $dBuf->moveCStr( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | 0, | ||||||||||||||||||||||||||||||||
| 152 | $offset <= length( $s ) ? substr( $s, $offset ) : '', | ||||||||||||||||||||||||||||||||
| 153 | $color, | ||||||||||||||||||||||||||||||||
| 154 | ); | ||||||||||||||||||||||||||||||||
| 155 | $beingDrawn->writeLine( 0, $position - $beingDrawn->{delta}{y}, | ||||||||||||||||||||||||||||||||
| 156 | 0 | $beingDrawn->{size}{x}, 1, $dBuf ); | |||||||||||||||||||||||||||||||
| 157 | 0 | $auxPos = $position; | |||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | 0 | return false; | |||||||||||||||||||||||||||||||
| 160 | 7 | }; | |||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub draw { # void () | ||||||||||||||||||||||||||||||
|
Subroutine
draw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 163 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 164 | method => Object, | ||||||||||||||||||||||||||||||||
| 165 | pos => [], | ||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||
| 167 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | 0 | $self->firstThat( $drawTree ); | |||||||||||||||||||||||||||||||
| 170 | 0 | my $nrmColor = $self->getColor( 0x0401 ); | |||||||||||||||||||||||||||||||
| 171 | 0 | $dBuf->moveChar( 0, ' ', $nrmColor, $self->{size}{x} ); | |||||||||||||||||||||||||||||||
| 172 | $self->writeLine( | ||||||||||||||||||||||||||||||||
| 173 | 0, | ||||||||||||||||||||||||||||||||
| 174 | $auxPos + 1, | ||||||||||||||||||||||||||||||||
| 175 | $self->{size}{x}, | ||||||||||||||||||||||||||||||||
| 176 | 0 | $self->{size}{y} - ( $auxPos - $self->{delta}{y} ), | |||||||||||||||||||||||||||||||
| 177 | $dBuf, | ||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||
| 179 | 0 | return; | |||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||
| 182 | # Called whenever Node is receives focus | ||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | sub focused { # void ($i) | ||||||||||||||||||||||||||||||
|
Subroutine
focused: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 184 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 185 | method => Object, | ||||||||||||||||||||||||||||||||
| 186 | pos => [Int], | ||||||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||||||
| 188 | 0 | my ( $self, $i ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 189 | 0 | $self->{foc} = $i; | |||||||||||||||||||||||||||||||
| 190 | 0 | return; | |||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub getChild { # $node ($node, $i) | ||||||||||||||||||||||||||||||
|
Subroutine
getChild: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 194 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 195 | method => Object, | ||||||||||||||||||||||||||||||||
| 196 | pos => [Object, Int], | ||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||
| 198 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 199 | ... | ||||||||||||||||||||||||||||||||
| 200 | 0 | } | |||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | # | ||||||||||||||||||||||||||||||||
| 203 | # Called to retrieve the characters to display prior to the | ||||||||||||||||||||||||||||||||
| 204 | # text returned by GetText. Can be overridden to return | ||||||||||||||||||||||||||||||||
| 205 | # change the appearance of the outline. My default calls | ||||||||||||||||||||||||||||||||
| 206 | # createGraph with the default. | ||||||||||||||||||||||||||||||||
| 207 | # | ||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub getGraph { # $graph ($level, $lines, $flags) | ||||||||||||||||||||||||||||||
|
Subroutine
getGraph: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 209 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 210 | method => Object, | ||||||||||||||||||||||||||||||||
| 211 | pos => [Int, Int, PositiveOrZeroInt], | ||||||||||||||||||||||||||||||||
| 212 | ); | ||||||||||||||||||||||||||||||||
| 213 | 0 | my ( $self, $level, $lines, $flags ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 214 | 0 | my $levelWidth = 3; | |||||||||||||||||||||||||||||||
| 215 | 0 | my $endWidth = $levelWidth; | |||||||||||||||||||||||||||||||
| 216 | 0 | my $graphChars = "\x20\xB3\xC3\xC0\xC4\xC4+\xC4"; | |||||||||||||||||||||||||||||||
| 217 | 0 | return $self->createGraph( | |||||||||||||||||||||||||||||||
| 218 | $level, $lines, $flags, $levelWidth, $endWidth, $graphChars ); | ||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub getNumChildren { # $count ($node) | ||||||||||||||||||||||||||||||
|
Subroutine
getNumChildren: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 222 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 223 | method => Object, | ||||||||||||||||||||||||||||||||
| 224 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||||||
| 226 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 227 | ... | ||||||||||||||||||||||||||||||||
| 228 | 0 | } | |||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | my $isNode = sub { # $bool ($outLine, $node, $level, $position, $lines, $flags) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||
| 231 | 0 | my ( $outLine, $node, $level, $position, $lines, $flags ) = @_; | |||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | assert ( @_ == 6 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | assert ( is_Object $outLine ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | assert ( is_Object $node ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | assert ( is_Int $level ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | assert ( is_Int $position ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | assert ( is_Int $lines ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | assert ( is_PositiveOrZeroInt $flags ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 239 | 0 | return $auxPos == $position; | |||||||||||||||||||||||||||||||
| 240 | 7 | }; | |||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | # Returns a pointer to the node that is to be shown on line i | ||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub getNode { # $node|undef ($i) | ||||||||||||||||||||||||||||||
|
Subroutine
getNode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 244 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 245 | method => Object, | ||||||||||||||||||||||||||||||||
| 246 | pos => [Int], | ||||||||||||||||||||||||||||||||
| 247 | ); | ||||||||||||||||||||||||||||||||
| 248 | 0 | my ( $self, $i ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 249 | 0 | $auxPos = $i; | |||||||||||||||||||||||||||||||
| 250 | 0 | return $self->firstThat( $isNode ); | |||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||
| 253 | # | ||||||||||||||||||||||||||||||||
| 254 | # Returns the outline palette | ||||||||||||||||||||||||||||||||
| 255 | # | ||||||||||||||||||||||||||||||||
| 256 | # Palette layout | ||||||||||||||||||||||||||||||||
| 257 | # 1 = Normal color | ||||||||||||||||||||||||||||||||
| 258 | # 2 = Focus color | ||||||||||||||||||||||||||||||||
| 259 | # 3 = Select color | ||||||||||||||||||||||||||||||||
| 260 | # 4 = Not expanded color | ||||||||||||||||||||||||||||||||
| 261 | # | ||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub getPalette { # $palette () | ||||||||||||||||||||||||||||||
|
Subroutine
getPalette: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 263 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 264 | method => Object, | ||||||||||||||||||||||||||||||||
| 265 | pos => [], | ||||||||||||||||||||||||||||||||
| 266 | ); | ||||||||||||||||||||||||||||||||
| 267 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 268 | 0 | state $palette = TPalette->new( | |||||||||||||||||||||||||||||||
| 269 | data => cpOutlineViewer, | ||||||||||||||||||||||||||||||||
| 270 | size => length( cpOutlineViewer ), | ||||||||||||||||||||||||||||||||
| 271 | ); | ||||||||||||||||||||||||||||||||
| 272 | 0 | return $palette->clone(); | |||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub getRoot { # $node () | ||||||||||||||||||||||||||||||
|
Subroutine
getRoot: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 276 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 277 | method => Object, | ||||||||||||||||||||||||||||||||
| 278 | pos => [], | ||||||||||||||||||||||||||||||||
| 279 | ); | ||||||||||||||||||||||||||||||||
| 280 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 281 | ... | ||||||||||||||||||||||||||||||||
| 282 | 0 | } | |||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub getText { # $text ($node) | ||||||||||||||||||||||||||||||
|
Subroutine
getText: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 285 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 286 | method => Object, | ||||||||||||||||||||||||||||||||
| 287 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 288 | ); | ||||||||||||||||||||||||||||||||
| 289 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 290 | ... | ||||||||||||||||||||||||||||||||
| 291 | 0 | } | |||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $isFocused = sub { # $bool ($focusCheck, $cur, $level, $position, $lines, $flags) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||
| 294 | 0 | my ( $focusCheck, $cur, $level, $position, $lines, $flags ) = @_; | |||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | assert ( @_ == 6 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | assert ( is_Object $focusCheck ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | assert ( is_Object $cur ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | assert ( is_Int $level ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | assert ( is_Int $position ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | assert ( is_Int $lines ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | assert ( is_PositiveOrZeroInt $flags ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 302 | return false | ||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if $position != $focusCheck->{foc}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | 0 | $focLevel = $level; | |||||||||||||||||||||||||||||||
| 305 | 0 | $focLines = $lines; | |||||||||||||||||||||||||||||||
| 306 | 0 | $focFlags = $flags; | |||||||||||||||||||||||||||||||
| 307 | 0 | return true; | |||||||||||||||||||||||||||||||
| 308 | 7 | }; | |||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||
| 310 | # Called to handle an event | ||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub handleEvent { # void ($event) | ||||||||||||||||||||||||||||||
|
Subroutine
handleEvent: not called CC=36 SCAR=71.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 312 | 7 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 313 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 314 | method => Object, | ||||||||||||||||||||||||||||||||
| 315 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||
| 317 | 0 | my ( $self, $event ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||
| 319 | 0 | my $mouseAutoToSkip = 3; | |||||||||||||||||||||||||||||||
| 320 | 0 | my ( $mouse, $newFocus, $count, $dragged, $cur, $graph ); | |||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||
| 322 | 0 | $self->SUPER::handleEvent( $event ); | |||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||
| 324 | 0 | SWITCH: for ( $event->{what} ) { | |||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | evMouseDown == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 326 | 0 | $count = 0; | |||||||||||||||||||||||||||||||
| 327 | 0 | $dragged = 0; | |||||||||||||||||||||||||||||||
| 328 | # C++ leaves newFocus unset for a click outside the view; keep the | ||||||||||||||||||||||||||||||||
| 329 | # current focus instead of letting undef jump to line 0. | ||||||||||||||||||||||||||||||||
| 330 | 0 | $newFocus = $self->{foc}; | |||||||||||||||||||||||||||||||
| 331 | do { | ||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $dragged++ if $dragged < 2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 333 | 0 | $mouse = $self->makeLocal( $event->{mouse}{where} ); | |||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if ( $self->mouseInView( $event->{mouse}{where} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 335 | 0 | $newFocus = $self->{delta}{y} + $mouse->{y}; | |||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||
| 337 | else { | ||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $count++ if $event->{what} == evMouseAuto; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | if ( $count == $mouseAutoToSkip ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 340 | 0 | $count = 0; | |||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | $newFocus-- if $mouse->{y} < 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $newFocus++ if $mouse->{y} >= $self->{size}{y}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if ( $self->{foc} != $newFocus ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 346 | 0 | $self->$adjustFocus( $newFocus ); | |||||||||||||||||||||||||||||||
| 347 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | } while ( !( $event->{mouse}{eventFlags} & meDoubleClick ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $event->{"mouse"}{"eventFlags"} & 2 and $self->mouseEvent($event, 12)
MC/DC0%0/2
not $event->{"mouse"}{"eventFlags"} & 2 and $self->mouseEvent($event, 12)
not $event->{"mouse"}{"eventFlags"} & 2
$self->mouseEvent($event, 12)
Truth table0%0/3
not(A) and B
A= not $event->{"mouse"}{"eventFlags"} & 2B= $self->mouseEvent($event, 12)
| |||||||||||||||||||||||||||||||||
| 350 | && $self->mouseEvent( $event, evMouseMove | evMouseAuto ) ); | ||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if ( $event->{mouse}{eventFlags} & meDoubleClick ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 353 | 0 | $self->selected( $self->{foc} ); | |||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||
| 355 | elsif ( $dragged < 2 ) { | ||||||||||||||||||||||||||||||||
| 356 | 0 | $cur = $self->firstThat( $isFocused ); | |||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if ( defined $cur ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | # C++ calls adjust() even when no node is focused (empty outline), | ||||||||||||||||||||||||||||||||
| 359 | # which dereferences NULL; skip expand/collapse in that case. | ||||||||||||||||||||||||||||||||
| 360 | 0 | $graph = $self->getGraph( $focLevel, $focLines, $focFlags ); | |||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ( $mouse->{x} < length( $graph ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 362 | 0 | $self->adjust( $cur, !$self->isExpanded( $cur ) ); | |||||||||||||||||||||||||||||||
| 363 | 0 | $self->update(); | |||||||||||||||||||||||||||||||
| 364 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||
| 368 | 0 | last; | |||||||||||||||||||||||||||||||
| 369 | }; | ||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | evKeyboard == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 372 | 0 | $newFocus = $self->{foc}; | |||||||||||||||||||||||||||||||
| 373 | 0 | SWITCH: for ( ctrlToArrow( $event->{keyDown}{keyCode} ) ) { | |||||||||||||||||||||||||||||||
| 374 | kbUp == $_ || | ||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | kbLeft == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
18432 == $_ or 19200 == $_
MC/DC0%0/2
18432 == $_ or 19200 == $_
18432 == $_
19200 == $_
Truth table0%0/3
A or B
A= 18432 == $_B= 19200 == $_
| |||||||||||||||||||||||||||||||||
| 376 | 0 | $newFocus--; | |||||||||||||||||||||||||||||||
| 377 | 0 | last; | |||||||||||||||||||||||||||||||
| 378 | }; | ||||||||||||||||||||||||||||||||
| 379 | kbDown == $_ || | ||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | kbRight == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
20480 == $_ or 19712 == $_
MC/DC0%0/2
20480 == $_ or 19712 == $_
20480 == $_
19712 == $_
Truth table0%0/3
A or B
A= 20480 == $_B= 19712 == $_
| |||||||||||||||||||||||||||||||||
| 381 | 0 | $newFocus++; | |||||||||||||||||||||||||||||||
| 382 | 0 | last; | |||||||||||||||||||||||||||||||
| 383 | }; | ||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | kbPgDn == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 385 | 0 | $newFocus += $self->{size}{y} - 1; | |||||||||||||||||||||||||||||||
| 386 | 0 | last; | |||||||||||||||||||||||||||||||
| 387 | }; | ||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | kbPgUp == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 389 | 0 | $newFocus -= $self->{size}{y} - 1; | |||||||||||||||||||||||||||||||
| 390 | 0 | last; | |||||||||||||||||||||||||||||||
| 391 | }; | ||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | kbHome == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 393 | 0 | $newFocus = $self->{delta}{y}; | |||||||||||||||||||||||||||||||
| 394 | 0 | last; | |||||||||||||||||||||||||||||||
| 395 | }; | ||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | kbEnd == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 397 | 0 | $newFocus = $self->{delta}{y} + $self->{size}{y} - 1; | |||||||||||||||||||||||||||||||
| 398 | 0 | last; | |||||||||||||||||||||||||||||||
| 399 | }; | ||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | kbCtrlPgUp == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 401 | 0 | $newFocus = 0; | |||||||||||||||||||||||||||||||
| 402 | 0 | last; | |||||||||||||||||||||||||||||||
| 403 | }; | ||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | kbCtrlPgDn == $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 405 | 0 | $newFocus = $self->{limit}{y} - 1; | |||||||||||||||||||||||||||||||
| 406 | 0 | last; | |||||||||||||||||||||||||||||||
| 407 | }; | ||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | ( kbCtrlEnter == $_ || kbEnter == $_ ) and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
7178 == $_ or 7181 == $_
MC/DC0%0/2
7178 == $_ or 7181 == $_
7178 == $_
7181 == $_
Truth table0%0/3
A or B
A= 7178 == $_B= 7181 == $_
| |||||||||||||||||||||||||||||||||
| 409 | 0 | $self->selected( $newFocus ); | |||||||||||||||||||||||||||||||
| 410 | 0 | last; | |||||||||||||||||||||||||||||||
| 411 | }; | ||||||||||||||||||||||||||||||||
| 412 | DEFAULT: { | ||||||||||||||||||||||||||||||||
| 413 | 0 | my $code = chr $event->{keyDown}{charScan}{charCode}; | |||||||||||||||||||||||||||||||
| 414 | 0 | SWITCH: for ( $code ) { | |||||||||||||||||||||||||||||||
| 415 | '-' eq $_ || | ||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | '+' eq $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
"-" eq $_ or "+" eq $_
MC/DC0%0/2
"-" eq $_ or "+" eq $_
"-" eq $_
"+" eq $_
Truth table0%0/3
A or B
A= "-" eq $_B= "+" eq $_
| |||||||||||||||||||||||||||||||||
| 417 | 0 | my $node = $self->getNode( $newFocus ); | |||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | $self->adjust( $node, '+' eq $_ ) if $node; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 419 | 0 | last; | |||||||||||||||||||||||||||||||
| 420 | }; | ||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | '*' eq $_ and do { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 422 | 0 | my $node = $self->getNode( $newFocus ); | |||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | $self->expandAll( $node ) if $node; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 424 | 0 | last; | |||||||||||||||||||||||||||||||
| 425 | }; | ||||||||||||||||||||||||||||||||
| 426 | DEFAULT: { | ||||||||||||||||||||||||||||||||
| 427 | 0 | return; | |||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||
| 429 | } #/ SWITCH: for ( $code ) | ||||||||||||||||||||||||||||||||
| 430 | 0 | $self->update(); | |||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||
| 432 | } #/ SWITCH: for ( ctrlToArrow( $event...)) | ||||||||||||||||||||||||||||||||
| 433 | 0 | $self->clearEvent( $event ); | |||||||||||||||||||||||||||||||
| 434 | 0 | $self->$adjustFocus( $newFocus ); | |||||||||||||||||||||||||||||||
| 435 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||
| 436 | 0 | last; | |||||||||||||||||||||||||||||||
| 437 | }; | ||||||||||||||||||||||||||||||||
| 438 | } #/ SWITCH: for ( $event->{what} ) | ||||||||||||||||||||||||||||||||
| 439 | 0 | return; | |||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub hasChildren { # $bool ($node) | ||||||||||||||||||||||||||||||
|
Subroutine
hasChildren: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 443 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 444 | method => Object, | ||||||||||||||||||||||||||||||||
| 445 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 446 | ); | ||||||||||||||||||||||||||||||||
| 447 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 448 | ... | ||||||||||||||||||||||||||||||||
| 449 | 0 | } | |||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | sub isExpanded { # $bool ($node) | ||||||||||||||||||||||||||||||
|
Subroutine
isExpanded: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 452 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 453 | method => Object, | ||||||||||||||||||||||||||||||||
| 454 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 455 | ); | ||||||||||||||||||||||||||||||||
| 456 | 0 | $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 457 | ... | ||||||||||||||||||||||||||||||||
| 458 | 0 | } | |||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||
| 460 | # | ||||||||||||||||||||||||||||||||
| 461 | # Returns if Node is selected. By default, returns true if Node is | ||||||||||||||||||||||||||||||||
| 462 | # Focused (i.e. single selection). Can be overridden to handle | ||||||||||||||||||||||||||||||||
| 463 | # multiple selections. | ||||||||||||||||||||||||||||||||
| 464 | # | ||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | sub isSelected { # $bool ($i) | ||||||||||||||||||||||||||||||
|
Subroutine
isSelected: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 466 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 467 | method => Object, | ||||||||||||||||||||||||||||||||
| 468 | pos => [Int], | ||||||||||||||||||||||||||||||||
| 469 | ); | ||||||||||||||||||||||||||||||||
| 470 | 0 | my ( $self, $i ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 471 | 0 | return $self->{foc} == $i; | |||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||
| 474 | # Called whenever Node is selected by the user either via keyboard | ||||||||||||||||||||||||||||||||
| 475 | # control or by the mouse. | ||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub selected { # void ($i) | ||||||||||||||||||||||||||||||
|
Subroutine
selected: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 477 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 478 | method => Object, | ||||||||||||||||||||||||||||||||
| 479 | pos => [Int], | ||||||||||||||||||||||||||||||||
| 480 | ); | ||||||||||||||||||||||||||||||||
| 481 | 0 | my ( $self, $i ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 482 | 0 | return; | |||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||
| 485 | # Redraws the outline if the outliner sfFocus state changes | ||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | sub setState { # void ($aState, $enable) | ||||||||||||||||||||||||||||||
|
Subroutine
setState: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 487 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 488 | method => Object, | ||||||||||||||||||||||||||||||||
| 489 | pos => [PositiveOrZeroInt, Bool], | ||||||||||||||||||||||||||||||||
| 490 | ); | ||||||||||||||||||||||||||||||||
| 491 | 0 | my ( $self, $aState, $enable ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 492 | 0 | $self->SUPER::setState( $aState, $enable ); | |||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | $self->drawView() | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 494 | if $aState & sfFocused; | ||||||||||||||||||||||||||||||||
| 495 | 0 | return; | |||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | my $countNode = sub { # $bool ($beingCounted, $p, $level, $position, $lines, $flags) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||
| 499 | 0 | my ( $beingCounted, $p, $level, $position, $lines, $flags ) = @_; | |||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | assert ( @_ == 6 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | assert ( is_Object $beingCounted ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | assert ( is_Object $p ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | assert ( is_Int $level ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | assert ( is_Int $position ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | assert ( is_Int $lines ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | assert ( is_PositiveOrZeroInt $flags ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 507 | 0 | $updateCount++; | |||||||||||||||||||||||||||||||
| 508 | 0 | my $graph = $beingCounted->getGraph( $level, $lines, $flags ); | |||||||||||||||||||||||||||||||
| 509 | 0 | my $len = length( $beingCounted->getText( $p ) ) + length( $graph ); | |||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | $updateMaxX = $len | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 511 | if $updateMaxX < $len; | ||||||||||||||||||||||||||||||||
| 512 | 0 | return false; | |||||||||||||||||||||||||||||||
| 513 | 7 | }; | |||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||
| 515 | # | ||||||||||||||||||||||||||||||||
| 516 | # Updates the limits of the outline viewer. Should be called whenever | ||||||||||||||||||||||||||||||||
| 517 | # the data of the outline viewer changes. This includes during | ||||||||||||||||||||||||||||||||
| 518 | # the initialization of base classes. TOutlineViewer assumes that the | ||||||||||||||||||||||||||||||||
| 519 | # outline is empty. If the outline becomes non-empty during the | ||||||||||||||||||||||||||||||||
| 520 | # initialization, Update must be called. Also, if during the operation | ||||||||||||||||||||||||||||||||
| 521 | # of the TOutlineViewer the data being displayed changes, Update and | ||||||||||||||||||||||||||||||||
| 522 | # DrawView must be called. | ||||||||||||||||||||||||||||||||
| 523 | # | ||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | sub update { # void () | ||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 525 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 526 | method => Object, | ||||||||||||||||||||||||||||||||
| 527 | pos => [], | ||||||||||||||||||||||||||||||||
| 528 | ); | ||||||||||||||||||||||||||||||||
| 529 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 530 | 0 | $updateCount = 0; | |||||||||||||||||||||||||||||||
| 531 | 0 | $updateMaxX = 0; | |||||||||||||||||||||||||||||||
| 532 | 0 | $self->firstThat( $countNode ); | |||||||||||||||||||||||||||||||
| 533 | 0 | $self->setLimit( $updateMaxX, $updateCount ); | |||||||||||||||||||||||||||||||
| 534 | 0 | $self->$adjustFocus( $self->{foc} ); | |||||||||||||||||||||||||||||||
| 535 | 0 | return; | |||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||
| 538 | # ExpandAll expands the current node and all child nodes | ||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | sub expandAll { # void ($node) | ||||||||||||||||||||||||||||||
|
Subroutine
expandAll: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 540 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 541 | method => Object, | ||||||||||||||||||||||||||||||||
| 542 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 543 | ); | ||||||||||||||||||||||||||||||||
| 544 | 0 | my ( $self, $node ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if ( $self->hasChildren( $node ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 546 | 0 | $self->adjust( $node, true ); | |||||||||||||||||||||||||||||||
| 547 | 0 | my $n = $self->getNumChildren( $node ) - 1; | |||||||||||||||||||||||||||||||
| 548 | 0 | for my $i ( 0 .. $n ) { | |||||||||||||||||||||||||||||||
| 549 | 0 | $self->expandAll( $self->getChild( $node, $i ) ); | |||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||
| 552 | 0 | return; | |||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||
| 555 | # | ||||||||||||||||||||||||||||||||
| 556 | # FirstThat iterates over the nodes of the outline until the given | ||||||||||||||||||||||||||||||||
| 557 | # local function returns true. The declaration for the local function | ||||||||||||||||||||||||||||||||
| 558 | # must look like (save for the names, of course): | ||||||||||||||||||||||||||||||||
| 559 | # | ||||||||||||||||||||||||||||||||
| 560 | # sub myIter ($cur, $level, $position, $lines, $flags) { ... } | ||||||||||||||||||||||||||||||||
| 561 | # | ||||||||||||||||||||||||||||||||
| 562 | # The parameters are as follows: | ||||||||||||||||||||||||||||||||
| 563 | # | ||||||||||||||||||||||||||||||||
| 564 | # $cur: A object to the node being checked. | ||||||||||||||||||||||||||||||||
| 565 | # $level: The level of the node (how many node above it it has) | ||||||||||||||||||||||||||||||||
| 566 | # $level is 0 based. This can be used to a call to | ||||||||||||||||||||||||||||||||
| 567 | # either getGraph() or createGraph(). | ||||||||||||||||||||||||||||||||
| 568 | # $position: The display order position of the node in the list. | ||||||||||||||||||||||||||||||||
| 569 | # This can be used in a call to focused() or selected(). | ||||||||||||||||||||||||||||||||
| 570 | # If in range, $position - $delta->{y} is the location the node | ||||||||||||||||||||||||||||||||
| 571 | # is displayed on the view. | ||||||||||||||||||||||||||||||||
| 572 | # $lines: Bits indicating the active levels. This can be used in a | ||||||||||||||||||||||||||||||||
| 573 | # call to getGraph() or createGraph(). It dictates which | ||||||||||||||||||||||||||||||||
| 574 | # horizontal lines need to be drawn. | ||||||||||||||||||||||||||||||||
| 575 | # $flags: Various flags for drawing (see :ovXXXX flags). Can be used | ||||||||||||||||||||||||||||||||
| 576 | # in a call to getGraph() or createGraph(). | ||||||||||||||||||||||||||||||||
| 577 | # | ||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | sub firstThat { # $node|undef (\&test) | ||||||||||||||||||||||||||||||
|
Subroutine
firstThat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 579 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 580 | method => Object, | ||||||||||||||||||||||||||||||||
| 581 | pos => [CodeRef], | ||||||||||||||||||||||||||||||||
| 582 | ); | ||||||||||||||||||||||||||||||||
| 583 | 0 | my ( $self, $test ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 584 | 0 | return $self->$iterate( $test, true ); | |||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | sub forEach { # $node|undef (\&action) | ||||||||||||||||||||||||||||||
|
Subroutine
forEach: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 588 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 589 | method => Object, | ||||||||||||||||||||||||||||||||
| 590 | pos => [CodeRef], | ||||||||||||||||||||||||||||||||
| 591 | ); | ||||||||||||||||||||||||||||||||
| 592 | 0 | my ( $self, $action ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 593 | 0 | return $self->$iterate( $action, false ); | |||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||
| 596 | # | ||||||||||||||||||||||||||||||||
| 597 | # Draws a graph string suitable for returning from getGraph. Level | ||||||||||||||||||||||||||||||||
| 598 | # indicates the outline level. Lines is the set of bits describing | ||||||||||||||||||||||||||||||||
| 599 | # the which levels have a "continuation" mark (usually a vertical | ||||||||||||||||||||||||||||||||
| 600 | # lines). If bit 3 is set, level 3 is continued beyond this level. | ||||||||||||||||||||||||||||||||
| 601 | # Flags gives extra information about how to draw the end of the | ||||||||||||||||||||||||||||||||
| 602 | # graph (see the ovXXX constants). LevWidth is how many characters | ||||||||||||||||||||||||||||||||
| 603 | # to indent for each level. endWidth is the length the end characters. | ||||||||||||||||||||||||||||||||
| 604 | # | ||||||||||||||||||||||||||||||||
| 605 | # The graphics is divided into two parts: the level marks, and the end | ||||||||||||||||||||||||||||||||
| 606 | # or node graphic. The level marks consist of the Level Mark character | ||||||||||||||||||||||||||||||||
| 607 | # separated by Level Filler. What marks are present is determined by | ||||||||||||||||||||||||||||||||
| 608 | # Lines. The end graphic is constructed by placing on of the End First | ||||||||||||||||||||||||||||||||
| 609 | # characters followed by endWidth-4 End Filler characters, followed by the | ||||||||||||||||||||||||||||||||
| 610 | # End Child character, followed by the Retract/Expand character. If | ||||||||||||||||||||||||||||||||
| 611 | # endWidth equals 2, End First and Retract/Expand are used. If endWidth | ||||||||||||||||||||||||||||||||
| 612 | # equals 1, only the Retract/Expand character is used. Which characters | ||||||||||||||||||||||||||||||||
| 613 | # are selected is determined by Flags. | ||||||||||||||||||||||||||||||||
| 614 | # | ||||||||||||||||||||||||||||||||
| 615 | # The layout for the characters in the Chars is: | ||||||||||||||||||||||||||||||||
| 616 | # | ||||||||||||||||||||||||||||||||
| 617 | # 1: Level Filler | ||||||||||||||||||||||||||||||||
| 618 | # Typically a space. Used between level markers. | ||||||||||||||||||||||||||||||||
| 619 | # 2: Level Mark | ||||||||||||||||||||||||||||||||
| 620 | # Typically a vertical bar. Used to mark the levels currently active. | ||||||||||||||||||||||||||||||||
| 621 | # 3: End First (not last child) | ||||||||||||||||||||||||||||||||
| 622 | # Typically a sideways T. Used as the first character of the end part | ||||||||||||||||||||||||||||||||
| 623 | # of a node graphic if the node is not the last child of the parent. | ||||||||||||||||||||||||||||||||
| 624 | # 4: End First (last child) | ||||||||||||||||||||||||||||||||
| 625 | # Typically a L shape. Used as the first character of the end part | ||||||||||||||||||||||||||||||||
| 626 | # of a node graphic if the node is the last child of the parent. | ||||||||||||||||||||||||||||||||
| 627 | # 5: End Filler | ||||||||||||||||||||||||||||||||
| 628 | # Typically a horizontal line. Used as filler for the end part of a | ||||||||||||||||||||||||||||||||
| 629 | # node graphic. | ||||||||||||||||||||||||||||||||
| 630 | # 6: End Child position | ||||||||||||||||||||||||||||||||
| 631 | # Typically not used. If endWidth > LevWidth this character will | ||||||||||||||||||||||||||||||||
| 632 | # be placed on top of the markers for next level. If used it is | ||||||||||||||||||||||||||||||||
| 633 | # typically a T. | ||||||||||||||||||||||||||||||||
| 634 | # 7: Retracted character | ||||||||||||||||||||||||||||||||
| 635 | # Typically a '+'. Displayed as the last character of the end | ||||||||||||||||||||||||||||||||
| 636 | # node if the level has children and they are not expanded. | ||||||||||||||||||||||||||||||||
| 637 | # 8: Expanded character | ||||||||||||||||||||||||||||||||
| 638 | # Typically as straight line. Displayed as the last character of | ||||||||||||||||||||||||||||||||
| 639 | # the end node if the level has children and they are expanded. | ||||||||||||||||||||||||||||||||
| 640 | # | ||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | sub createGraph { # $graph ($level, $lines, $flags, $levW, $endW, $chars) | ||||||||||||||||||||||||||||||
|
Subroutine
createGraph: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 642 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 643 | method => Object, | ||||||||||||||||||||||||||||||||
| 644 | pos => [Int, Int, PositiveOrZeroInt, Int, Int, Str], | ||||||||||||||||||||||||||||||||
| 645 | ); | ||||||||||||||||||||||||||||||||
| 646 | 0 | my ( $self, $level, $lines, $flags, $levWidth, $endWidth, $chars ) | |||||||||||||||||||||||||||||||
| 647 | = $sig->( @_ ); | ||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||
| 649 | 0 | my $fillerOrBar = 0; | |||||||||||||||||||||||||||||||
| 650 | 0 | my $yOrL = 2; | |||||||||||||||||||||||||||||||
| 651 | 0 | my $straightOrTee = 4; | |||||||||||||||||||||||||||||||
| 652 | 0 | my $retracted = 6; | |||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||
| 654 | 0 | my $expanded = ( $flags & ovExpanded ) != 0; | |||||||||||||||||||||||||||||||
| 655 | 0 | my $children = ( $flags & ovChildren ) != 0; | |||||||||||||||||||||||||||||||
| 656 | 0 | my $last = ( $flags & ovLast ) != 0; | |||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||
| 658 | 0 | my $graph = ''; | |||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | for ( ; $level > 0 ; $level--, $lines >>= 1 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | $graph .= substr( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 661 | $chars, | ||||||||||||||||||||||||||||||||
| 662 | ( $lines & 1 ) ? $fillerOrBar + 1 : $fillerOrBar, 1 | ||||||||||||||||||||||||||||||||
| 663 | ); | ||||||||||||||||||||||||||||||||
| 664 | 0 | $graph .= substr( $chars, $fillerOrBar, 1 ) x ( $levWidth - 1 ); | |||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | if ( --$endWidth > 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | $graph .= substr( $chars, $last ? $yOrL + 1 : $yOrL, 1 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | if ( --$endWidth > 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if ( --$endWidth > 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 671 | 0 | $graph .= substr( $chars, $straightOrTee, 1 ) x $endWidth; | |||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | $graph .= substr( $chars, | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 674 | $children ? $straightOrTee + 1 : $straightOrTee, 1 ); | ||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | $graph .= substr( $chars, | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 677 | $expanded ? $retracted + 1 : $retracted, 1 ); | ||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||
| 679 | 0 | return $graph; | |||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||
| 682 | # Called internally to ensure the focus is within range and displayed | ||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | $adjustFocus = sub { # void ($self, $newFocus) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||
| 684 | 0 | my ( $self, $newFocus ) = @_; | |||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | assert ( is_Int $newFocus ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | if ( $newFocus < 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 689 | 0 | $newFocus = 0; | |||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||
| 691 | elsif ( $newFocus >= $self->{limit}{y} ) { | ||||||||||||||||||||||||||||||||
| 692 | 0 | $newFocus = $self->{limit}{y} - 1; | |||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | if ( $self->{foc} != $newFocus ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 695 | 0 | $self->focused( $newFocus ); | |||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | if ( $newFocus < $self->{delta}{y} ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 698 | 0 | $self->scrollTo( $self->{delta}{x}, $newFocus ); | |||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||
| 700 | elsif ( ( $newFocus - $self->{size}{y} ) >= $self->{delta}{y} ) { | ||||||||||||||||||||||||||||||||
| 701 | 0 | $self->scrollTo( $self->{delta}{x}, $newFocus - $self->{size}{y} + 1 ); | |||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||
| 703 | 0 | return; | |||||||||||||||||||||||||||||||
| 704 | 7 | }; | |||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||
| 706 | # Internal function used by both FirstThat and ForEach to do the | ||||||||||||||||||||||||||||||||
| 707 | # actual iteration over the data. See FirstThat for more details | ||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | $traverseTree = sub { # $node|undef ($outLine, \&action, \$position, $checkResult, $cur, $level, $lines, $lastChild) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=24 SCAR=64.0
| |||||||||||||||||||||||||||||||||
| 709 | 0 | my ( $outLine, $action, $position, $checkResult, $cur, $level, $lines, | |||||||||||||||||||||||||||||||
| 710 | 0 | $lastChild ) = @_; | |||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | assert ( @_ == 8 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | assert ( is_Object $outLine ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | assert ( is_CodeRef $action ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | assert ( is_ScalarRef $position ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | assert ( is_Bool $checkResult ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | assert ( is_Undef( $cur ) || is_Object( $cur ) ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&is_Undef($cur) or &is_Object($cur)
MC/DC0%0/2
&is_Undef($cur) or &is_Object($cur)
&is_Undef($cur)
&is_Object($cur)
Truth table0%0/3
A or B
A= &is_Undef($cur)B= &is_Object($cur)
| |||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | assert ( is_Int $level ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | assert ( is_Int $lines ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | assert ( is_Bool $lastChild ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | return unless $cur; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||
| 722 | 0 | my $children = $outLine->hasChildren( $cur ); | |||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||
| 724 | 0 | my $flags = 0; | |||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | $flags |= ovLast if $lastChild; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | $flags |= ovChildren if $children && $outLine->isExpanded( $cur ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$children and $outLine->isExpanded($cur)
MC/DC0%0/2
$children and $outLine->isExpanded($cur)
$children
$outLine->isExpanded($cur)
Truth table0%0/3
A and B
A= $childrenB= $outLine->isExpanded($cur)
| |||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | $flags |= ovExpanded if !$children || $outLine->isExpanded( $cur ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $children or $outLine->isExpanded($cur)
MC/DC0%0/2
not $children or $outLine->isExpanded($cur)
not $children
$outLine->isExpanded($cur)
Truth table0%0/3
not(A) or B
A= not $childrenB= $outLine->isExpanded($cur)
| |||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||
| 729 | 0 | $$position++; | |||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||
| 731 | 0 | my $result = $action->( | |||||||||||||||||||||||||||||||
| 732 | $outLine, $cur, $level, $$position, $lines, $flags ); | ||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | return $cur if $checkResult && $result; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$checkResult and $result
MC/DC0%0/2
$checkResult and $result
$checkResult
$result
Truth table0%0/3
A and B
A= $checkResultB= $result
| |||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | if ( $children && $outLine->isExpanded( $cur ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$children and $outLine->isExpanded($cur)
MC/DC0%0/2
$children and $outLine->isExpanded($cur)
$children
$outLine->isExpanded($cur)
Truth table0%0/3
A and B
A= $childrenB= $outLine->isExpanded($cur)
| |||||||||||||||||||||||||||||||||
| 736 | 0 | my $childCount = $outLine->getNumChildren( $cur ); | |||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | $lines |= 1 << $level unless $lastChild; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||
| 740 | 0 | for my $j ( 0 .. $childCount - 1 ) { | |||||||||||||||||||||||||||||||
| 741 | 0 | my $ret = $traverseTree->( | |||||||||||||||||||||||||||||||
| 742 | $outLine, | ||||||||||||||||||||||||||||||||
| 743 | $action, | ||||||||||||||||||||||||||||||||
| 744 | $position, | ||||||||||||||||||||||||||||||||
| 745 | $checkResult, | ||||||||||||||||||||||||||||||||
| 746 | $outLine->getChild( $cur, $j ), | ||||||||||||||||||||||||||||||||
| 747 | $level + 1, | ||||||||||||||||||||||||||||||||
| 748 | $lines, | ||||||||||||||||||||||||||||||||
| 749 | $j == $childCount - 1, | ||||||||||||||||||||||||||||||||
| 750 | ); | ||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | return $ret if $ret; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||
| 754 | 0 | return; | |||||||||||||||||||||||||||||||
| 755 | 7 | }; | |||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | $iterate = sub { # $node|undef ($outLine, \&action, $checkResult) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||
| 758 | 0 | my ( $outLine, $action, $checkResult ) = @_; | |||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | assert ( @_ == 3 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | assert ( is_Object $outLine ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | assert ( is_CodeRef $action ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | assert ( is_Bool $checkResult ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 763 | 0 | my $position = -1; | |||||||||||||||||||||||||||||||
| 764 | 0 | return $traverseTree->( | |||||||||||||||||||||||||||||||
| 765 | $outLine, | ||||||||||||||||||||||||||||||||
| 766 | $action, | ||||||||||||||||||||||||||||||||
| 767 | \$position, | ||||||||||||||||||||||||||||||||
| 768 | $checkResult, | ||||||||||||||||||||||||||||||||
| 769 | $outLine->getRoot(), | ||||||||||||||||||||||||||||||||
| 770 | 0, | ||||||||||||||||||||||||||||||||
| 771 | 0, | ||||||||||||||||||||||||||||||||
| 772 | true, | ||||||||||||||||||||||||||||||||
| 773 | ); | ||||||||||||||||||||||||||||||||
| 774 | 7 | }; | |||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | sub read :method { # $self ($is) | ||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 777 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 778 | method => Object, | ||||||||||||||||||||||||||||||||
| 779 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 780 | ); | ||||||||||||||||||||||||||||||||
| 781 | 0 | my ( $self, $is ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 782 | 0 | $self->SUPER::read( $is ); | |||||||||||||||||||||||||||||||
| 783 | 0 | $self->{foc} = $is->get(); | |||||||||||||||||||||||||||||||
| 784 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | sub write :method { # void ($os) | ||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 788 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||
| 789 | method => Object, | ||||||||||||||||||||||||||||||||
| 790 | pos => [Object], | ||||||||||||||||||||||||||||||||
| 791 | ); | ||||||||||||||||||||||||||||||||
| 792 | 0 | my ( $self, $os ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||
| 793 | 0 | $self->SUPER::write( $os ); | |||||||||||||||||||||||||||||||
| 794 | 0 | $os->put( $self->{foc} ); | |||||||||||||||||||||||||||||||
| 795 | 0 | return; | |||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | sub build { # $obj () | ||||||||||||||||||||||||||||||
|
Subroutine
build: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 799 | 0 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | assert ( @_ == 1 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | assert ( is_Str $class ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | assert ( Storable::is_retrieving ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 803 | 0 | return $class->new( | |||||||||||||||||||||||||||||||
| 804 | bounds => TRect->new(), | ||||||||||||||||||||||||||||||||
| 805 | hScrollBar => undef, | ||||||||||||||||||||||||||||||||
| 806 | vScrollBar => undef, | ||||||||||||||||||||||||||||||||
| 807 | ); | ||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||
| 810 | 7 | 1; | |||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||
| 812 | __END__ | ||||||||||||||||||||||||||||||||