| 1 | package TUI::ColorSel::ColorGroupList; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: A list viewer for color groups | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 5 | our $VERSION = '2.000002'; | |||||||||||||||||||||||||||
| 9 | 5 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||
| 10 | 5 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 5 | our @EXPORT = qw( | |||||||||||||||||||||||||||
| 14 | TColorGroupList | ||||||||||||||||||||||||||||
| 15 | new_TColorGroupList | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use TUI::toolkit; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use TUI::toolkit::Types qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | Maybe | ||||||||||||||||||||||||||||
| 22 | is_Object | ||||||||||||||||||||||||||||
| 23 | :types | ||||||||||||||||||||||||||||
| 24 | 5 | ); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 5 | ▶ | use TUI::Drivers::Const qw( evBroadcast ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 5 | ▶ | use TUI::ColorSel::Const qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | cmNewColorItem | ||||||||||||||||||||||||||||
| 29 | cmSaveColorIndex | ||||||||||||||||||||||||||||
| 30 | 5 | ); | |||||||||||||||||||||||||||
| 31 | 5 | ▶ | use TUI::Views::ListViewer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 5 | ▶ | use TUI::Views::Util qw( message ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub TColorGroupList() { __PACKAGE__ } | ||||||||||||||||||||||||||||
| 35 | sub name() { 'TColorGroupList' } | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub new_TColorGroupList { __PACKAGE__->from( @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
new_TColorGroupList: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 5 | extends TListViewer; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | # protected attributes | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | has groups => ( is => 'ro', default => sub { die 'required' } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub BUILDARGS { # \%args (%args) | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 45 | method => 1, | ||||||||||||||||||||||||||||
| 46 | named => [ | ||||||||||||||||||||||||||||
| 47 | bounds => Object, | ||||||||||||||||||||||||||||
| 48 | scrollBar => Maybe[Object], { alias => 'aScrollBar' }, | ||||||||||||||||||||||||||||
| 49 | groups => Maybe[Object], { alias => 'aGroups' }, | ||||||||||||||||||||||||||||
| 50 | ], | ||||||||||||||||||||||||||||
| 51 | caller_level => +1, | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | 0 | my ( $class, $args1 ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 54 | 0 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||||||||||||||||||||
| 55 | my $args2 = $class->SUPER::BUILDARGS( | ||||||||||||||||||||||||||||
| 56 | bounds => $args1->{bounds}, | ||||||||||||||||||||||||||||
| 57 | numCols => 1, | ||||||||||||||||||||||||||||
| 58 | hScrollBar => undef, | ||||||||||||||||||||||||||||
| 59 | vScrollBar => delete $args1->{scrollBar}, | ||||||||||||||||||||||||||||
| 60 | 0 | ); | |||||||||||||||||||||||||||
| 61 | 0 | return { %$args1, %$args2 }; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 65 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 69 | 0 | my $aGroups = $self->{groups}; | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | while ( $aGroups ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | $aGroups = $aGroups->{next}; | |||||||||||||||||||||||||||
| 72 | 0 | $i++; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | 0 | $self->setRange( $i ); | |||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub from { # $obj ($bounds, $aScrollBar|undef, $aGroups|undef) | ||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 80 | method => 1, | ||||||||||||||||||||||||||||
| 81 | pos => [Object, Maybe[Object], Maybe[Object]], | ||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||
| 83 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 84 | 0 | return $class->new( bounds => $args[0], scrollBar => $args[1], | |||||||||||||||||||||||||||
| 85 | groups => $args[2] ); | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | my $freeItems = sub { # void ($curItem|undef) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 89 | 0 | my ( $curItem ) = @_; | |||||||||||||||||||||||||||
| 90 | 0 | ▶ | assert ( !defined $curItem or is_Object $curItem ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $curItem or &is_Object($curItem)
MC/DC0%0/2
not defined $curItem or &is_Object($curItem)
not defined $curItem
&is_Object($curItem)
Truth table0%0/3
not(A) or B
A= not defined $curItemB= &is_Object($curItem)
| |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | while ( $curItem ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | my $p = $curItem; | |||||||||||||||||||||||||||
| 93 | 0 | $curItem = $curItem->{next}; | |||||||||||||||||||||||||||
| 94 | 0 | undef $p; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | 0 | return; | |||||||||||||||||||||||||||
| 97 | 5 | }; | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $freeGroups = sub { # void ($curGroup|undef) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 100 | 0 | my ( $curGroup ) = @_; | |||||||||||||||||||||||||||
| 101 | 0 | ▶ | assert ( !defined $curGroup or is_Object $curGroup ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $curGroup or &is_Object($curGroup)
MC/DC0%0/2
not defined $curGroup or &is_Object($curGroup)
not defined $curGroup
&is_Object($curGroup)
Truth table0%0/3
not(A) or B
A= not defined $curGroupB= &is_Object($curGroup)
| |||||||||||||||||||||||||||||
| 102 | 0 | ▶ | while ( $curGroup ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 0 | my $p = $curGroup; | |||||||||||||||||||||||||||
| 104 | 0 | $freeItems->( $curGroup->{items} ); | |||||||||||||||||||||||||||
| 105 | 0 | $curGroup = $curGroup->{next}; | |||||||||||||||||||||||||||
| 106 | 0 | undef $p; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 0 | return; | |||||||||||||||||||||||||||
| 109 | 5 | }; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub DEMOLISH { # void ($in_global_destruction) | ||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 0 | my ( $self, $in_global_destruction ) = @_; | |||||||||||||||||||||||||||
| 113 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | $freeGroups->( $self->{groups} ); | |||||||||||||||||||||||||||
| 116 | 0 | return; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub focusItem { # void ($item) | ||||||||||||||||||||||||||
|
Subroutine
focusItem: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 121 | method => Object, | ||||||||||||||||||||||||||||
| 122 | pos => [Int], | ||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||
| 124 | 0 | my ( $self, $item ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 125 | 0 | $self->SUPER::focusItem( $item ); | |||||||||||||||||||||||||||
| 126 | 0 | my $curGroup = $self->{groups}; | |||||||||||||||||||||||||||
| 127 | $curGroup = $curGroup->{next} | ||||||||||||||||||||||||||||
| 128 | 0 | ▶ | while $curGroup && $item-- > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$curGroup and $item-- > 0
MC/DC0%0/2
$curGroup and $item-- > 0
$curGroup
$item-- > 0
Truth table0%0/3
A and B
A= $curGroupB= $item-- > 0
| |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | message( $self->{owner}, evBroadcast, cmNewColorItem, $curGroup ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | if $curGroup; | ||||||||||||||||||||||||||||
| 131 | 0 | return; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub getText { # void (\$dest, $item, $maxChars) | ||||||||||||||||||||||||||
|
Subroutine
getText: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 135 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 136 | method => Object, | ||||||||||||||||||||||||||||
| 137 | pos => [ScalarRef, Int, Int], | ||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||
| 139 | 0 | my ( $self, $dest, $item, $maxChars ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 140 | 0 | my $curGroup = $self->{groups}; | |||||||||||||||||||||||||||
| 141 | $curGroup = $curGroup->{next} | ||||||||||||||||||||||||||||
| 142 | 0 | ▶ | while $curGroup && $item-- > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$curGroup and $item-- > 0
MC/DC0%0/2
$curGroup and $item-- > 0
$curGroup
$item-- > 0
Truth table0%0/3
A and B
A= $curGroupB= $item-- > 0
| |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | $$dest = substr( $curGroup->{name}, 0, $maxChars ) if $curGroup; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 0 | return; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub handleEvent { # void ($event) | ||||||||||||||||||||||||||
|
Subroutine
handleEvent: not called CC=3 SCAR=20.0
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 5 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 149 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 150 | method => Object, | ||||||||||||||||||||||||||||
| 151 | pos => [Object], | ||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||
| 153 | 0 | my ( $self, $event ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 154 | 0 | $self->SUPER::handleEvent( $event ); | |||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ( $event->{what} == evBroadcast | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$event->{"what"} == 512 and $event->{"message"}{"command"} == 76
MC/DC0%0/2
$event->{"what"} == 512 and $event->{"message"}{"command"} == 76
$event->{"what"} == 512
$event->{"message"}{"command"} == 76
Truth table0%0/3
A and B
A= $event->{"what"} == 512B= $event->{"message"}{"command"} == 76
| |||||||||||||||||||||||||||||
| 156 | && $event->{message}{command} == cmSaveColorIndex | ||||||||||||||||||||||||||||
| 157 | ) { | ||||||||||||||||||||||||||||
| 158 | 0 | $self->setGroupIndex( $self->{focused}, $event->{message}{infoByte} ); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | 0 | return; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub setGroupIndex { # void ($groupNum, $itemNum) | ||||||||||||||||||||||||||
|
Subroutine
setGroupIndex: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 165 | method => Object, | ||||||||||||||||||||||||||||
| 166 | pos => [PositiveOrZeroInt, PositiveOrZeroInt], | ||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||
| 168 | 0 | my ( $self, $groupNum, $itemNum ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 169 | 0 | my $g = $self->getGroup( $groupNum ); | |||||||||||||||||||||||||||
| 170 | 0 | ▶ | $g->{index} = $itemNum | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | if $g; | ||||||||||||||||||||||||||||
| 172 | 0 | return; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub getGroupIndex { # $index ($groupNum) | ||||||||||||||||||||||||||
|
Subroutine
getGroupIndex: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 177 | method => Object, | ||||||||||||||||||||||||||||
| 178 | pos => [PositiveOrZeroInt], | ||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||
| 180 | 0 | my ( $self, $groupNum ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 181 | 0 | my $g = $self->getGroup( $groupNum ); | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | return $g ? $g->{index} : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | ▶ | sub getGroup { # $colorGroup ($groupNum) | ||||||||||||||||||||||||||
|
Subroutine
getGroup: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 186 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 187 | method => Object, | ||||||||||||||||||||||||||||
| 188 | pos => [PositiveOrZeroInt], | ||||||||||||||||||||||||||||
| 189 | ); | ||||||||||||||||||||||||||||
| 190 | 0 | my ( $self, $groupNum ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 191 | 0 | my $g = $self->{groups}; | |||||||||||||||||||||||||||
| 192 | $g = $g->{next} | ||||||||||||||||||||||||||||
| 193 | 0 | ▶ | while $g && $groupNum--; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$g and $groupNum--
MC/DC0%0/2
$g and $groupNum--
$g
$groupNum--
Truth table0%0/3
A and B
A= $gB= $groupNum--
| |||||||||||||||||||||||||||||
| 194 | 0 | return $g; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub getNumGroups { # $num () | ||||||||||||||||||||||||||
|
Subroutine
getNumGroups: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 198 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 199 | method => Object, | ||||||||||||||||||||||||||||
| 200 | pos => [], | ||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||
| 202 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 203 | 0 | my $n; | |||||||||||||||||||||||||||
| 204 | 0 | my $g = $self->{groups}; | |||||||||||||||||||||||||||
| 205 | 0 | ▶ | for ( $n = 0 ; $g ; $n++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | $g = $g->{next}; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | 0 | return $n; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 5 | 1 | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | __END__ | ||||||||||||||||||||||||||||