lib/TUI/Dialogs/Label.pm

filter: Statementstmt 47.1% 74 / 157 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 60.6% 20 / 33 Podpod 63.6% 7 / 11 totaltotal 38.2% 101 / 264 CC 24 SCAR 33.9
CC
24
Cov
35%
handleEvent
106.8
__ANON__
42.0
draw
20.0
CRAP 29.6
« lib/TUI/StdDlg/FileInputLine.pm ↑ Summary lib/TUI/App/Program.pm »
1 package TUI::Dialogs::Label;
2 # ABSTRACT: Provides a descriptive label linked to another dialog control.
3
4 37 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 37 our $VERSION = '2.000003';
9 37 $VERSION =~ tr/_//d;
10 37 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 37 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 37 our @EXPORT = qw(
14 TLabel
15 new_TLabel
16 );
17
18 37 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 37 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 37 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 Maybe
22 is_Object
23 :types
24 37 );
25
26 37 ▶use TUI::Dialogs::Const qw( cpLabel );
Subroutine BEGIN: called CC=1 SCAR=0.0
27 37 ▶use TUI::Dialogs::StaticText;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 37 ▶use TUI::Dialogs::Util qw( hotKey );
Subroutine BEGIN: called CC=1 SCAR=0.0
29 37 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
30 :evXXXX
31 37 );
32 37 ▶use TUI::Drivers::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
33 cstrlen
34 getAltCode
35 37 );
36 37 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 37 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
38 cmReceivedFocus
39 cmReleasedFocus
40 :ofXXXX
41 phPostProcess
42 sfFocused
43 37 );
44 37 ▶use TUI::Views::DrawBuffer;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 37 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 37 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
47
48 sub TLabel() { __PACKAGE__ }
49 sub name() { 'TLabel' }
50 0 ▶sub new_TLabel { __PACKAGE__->from(@_) }
Subroutine new_TLabel: not called CC=1 SCAR=6.9
Pod documented
51
52 37 extends TStaticText;
53
54 # import global variables
55 37 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
56 $showMarkers
57 $specialChars
58 37 );
59 {
60 37 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
61 37 *showMarkers = \${ TView . '::showMarkers' };
62 37 *specialChars = \${ TView . '::specialChars' };
63 }
64
65 # protected attributes
66 0 ▶has link => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
67 37 has light => ( is => 'ro', default => false );
68
69 # predeclare private methods
70 my (
71 37 $focusLink,
72 );
73
74 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
75 0 state $sig = signature(
76 method => 1,
77 named => [
78 bounds => Object,
79 text => Str, { alias => 'aText' },
80 link => Maybe[Object], { alias => 'aLink' },
81 ],
82 caller_level => +1,
83 );
84 0 my ( $class, $args ) = $sig->( @_ );
85 0 return { %$args };
86 }
87
88 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod documented
89 0 my ( $self, $args ) = @_;
90 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
91 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
92 0 $self->{options} |= ofPreProcess | ofPostProcess;
93 0 $self->{eventMask} |= evBroadcast;
94 0 return;
95 }
96
97 0 ▶sub from { # $obj ($bounds, $aText, $aLink|undef)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
98 0 state $sig = signature(
99 method => 1,
100 pos => [Object, Str, Maybe[Object]],
101 );
102 0 my ( $class, @args ) = $sig->( @_ );
103 0 return $class->new( bounds => $args[0], text => $args[1], link => $args[2] );
104 }
105
106 0 ▶sub shutDown { # void ()
Subroutine shutDown: not called CC=1 SCAR=6.9
Pod documented
107 0 state $sig = signature(
108 method => Object,
109 pos => [],
110 );
111 0 my ( $self ) = $sig->( @_ );
112 0 $self->{link} = undef;
113 0 $self->SUPER::shutDown();
114 0 return;
115 }
116
117 0 ▶sub draw { # void ()
Subroutine draw: not called CC=4 SCAR=30.0
Pod documented
118 0 state $sig = signature(
119 method => Object,
120 pos => [],
121 );
122 0 my ( $self ) = $sig->( @_ );
123 0 my $color;
124 0 my $b = TDrawBuffer->new();
125 0 my $scOff;
126
127 0 ▶ if ( $self->{light} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'light'}) { } 0 0 0
128 0 $color = $self->getColor( 0x0402 );
129 0 $scOff = 0;
130 }
131 else {
132 0 $color = $self->getColor( 0x0301 );
133 0 $scOff = 4;
134 }
135
136 0 $b->moveChar( 0, ' ', $color, $self->{size}{x} );
137 0 ▶ if ( $self->{text} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"text"}) 0 0 0
138 0 $b->moveCStr( 1, $self->{text}, $color );
139 }
140 0 ▶ if ( $showMarkers ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($TUI::Dialogs::Label::showMarkers) 0 0 0
141 0 $b->putChar( 0, $specialChars->[$scOff] );
142 }
143 0 $self->writeLine( 0, 0, $self->{size}{x}, 1, $b );
144 0 return;
145 }
146
147 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=1 SCAR=6.9
Pod documented
148 0 state $sig = signature(
149 method => Object,
150 pos => [],
151 );
152 0 my ( $self ) = $sig->( @_ );
153 0 state $palette = TPalette->new( data => cpLabel, size => length( cpLabel ) );
154 0 return $palette->clone();
155 }
156
157 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=11 SCAR=46.7
Pod documented
158 37 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
159 0 state $sig = signature(
160 method => Object,
161 pos => [Object],
162 );
163 0 my ( $self, $event ) = $sig->( @_ );
164
165 0 $self->SUPER::handleEvent( $event );
166 0 ▶ if ( $event->{what} == evMouseDown ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($event->{'what'} == 1) { } 0 0 0
elsif ($event->{'what'} == 16) { } 0 0 0
elsif ($event->{'what'} == 512 and $self->{'link'} and $event->{'message'}{'command'} == 50 || $event->{'message'}{'command'} == 51) { } 0 0 0
167 0 $self->$focusLink( $event );
168 }
169 elsif ( $event->{what} == evKeyDown ) {
170 0 my $c = hotKey( $self->{text} );
171 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (&getAltCode($c) == $event->{"keyDown"}{"keyCode"} or $c and $self->{"owner"}{"phase"} == 2 and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c) 0 0 0
Condition0%0/9
&getAltCode($c) == $event->{"keyDown"}{"keyCode"} or $c and $self->{"owner"}{"phase"} == 2 and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c
l!l&&r!l&&!r
000
$c and $self->{"owner"}{"phase"} == 2 and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c
!ll&&!rl&&r
000
$c and $self->{"owner"}{"phase"} == 2
!ll&&!rl&&r
000
MC/DC0%0/4
&getAltCode($c) == $event->{"keyDown"}{"keyCode"} or $c and $self->{"owner"}{"phase"} == 2 and uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c
&getAltCode($c) == $event->{"keyDown"}{"keyCode"} $c $self->{"owner"}{"phase"} == 2 uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c
Truth table0%0/5
A or B and C and D
A= &getAltCode($c) == $event->{"keyDown"}{"keyCode"}B= $cC= $self->{"owner"}{"phase"} == 2D= uc $event->{"keyDown"}{"charScan"}{"charCode"} eq $c
ABCDresult
1XXX1
01111
00XX0
010X0
01100
172 getAltCode( $c ) == $event->{keyDown}{keyCode}
173 || ( $c
174 && $self->{owner}{phase} == phPostProcess
175 && uc( $event->{keyDown}{charScan}{charCode} ) eq $c )
176 ) {
177 0 $self->$focusLink( $event );
178 }
179 } #/ elsif ( $event->{what} ==...)
180 ▶ elsif (
Condition0%0/9
$event->{"what"} == 512 and $self->{"link"} and $event->{"message"}{"command"} == 50 || $event->{"message"}{"command"} == 51
!ll&&!rl&&r
000
$event->{"what"} == 512 and $self->{"link"}
!ll&&!rl&&r
000
$event->{"message"}{"command"} == 50 or $event->{"message"}{"command"} == 51
l!l&&r!l&&!r
000
MC/DC0%0/4
$event->{"what"} == 512 and $self->{"link"} and $event->{"message"}{"command"} == 50 || $event->{"message"}{"command"} == 51
$event->{"what"} == 512 $self->{"link"} $event->{"message"}{"command"} == 50 $event->{"message"}{"command"} == 51
Truth table0%0/5
A and B and C or D
A= $event->{"what"} == 512B= $self->{"link"}C= $event->{"message"}{"command"} == 50D= $event->{"message"}{"command"} == 51
ABCDresult
0XXX0
10XX0
11000
111X1
11011
181 $event->{what} == evBroadcast && $self->{link}
182 && ( $event->{message}{command} == cmReceivedFocus
183 || $event->{message}{command} == cmReleasedFocus )
184 ) {
185 0 $self->{light} = ( $self->{link}{state} & sfFocused ) != 0;
186 0 $self->drawView();
187 } #/ elsif ( $event->{what} ==...)
188 0 return;
189 } #/ sub handleEvent
190
191 0 ▶$focusLink = sub { # void ($event)
Subroutine __ANON__: not called CC=6 SCAR=37.4
192 0 my ( $self, $event ) = @_;
193 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
194 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
195 0 ▶ assert ( is_Object $event );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($event) 0 0 0
196 0 ▶ if ( $self->{link} && ( $self->{link}{options} & ofSelectable ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"link"} and $self->{"link"}{"options"} & 1) 0 0 0
Condition0%0/3
$self->{"link"} and $self->{"link"}{"options"} & 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"link"} and $self->{"link"}{"options"} & 1
$self->{"link"} $self->{"link"}{"options"} & 1
Truth table0%0/3
A and B
A= $self->{"link"}B= $self->{"link"}{"options"} & 1
ABresult
0X0
100
111
197 0 $self->{link}->focus();
198 }
199 0 $self->clearEvent( $event );
200 0 return;
201 37 };
202
203 0 ▶sub write :method { # void ($os)
Subroutine write: not called CC=1 SCAR=6.9
Pod undocumented
204 0 state $sig = signature(
205 method => Object,
206 pos => [Object],
207 );
208 0 my ( $self, $os ) = $sig->( @_ );
209 0 $self->SUPER::write( $os );
210 0 $os->put( $self->{link} );
211 0 return;
212 }
213
214 0 ▶sub read :method { # $self ($is)
Subroutine read: not called CC=1 SCAR=6.9
Pod undocumented
215 0 state $sig = signature(
216 method => Object,
217 pos => [Object],
218 );
219 0 my ( $self, $is ) = $sig->( @_ );
220 0 $self->SUPER::read( $is );
221 0 $self->{link} = $is->get();
222 0 $self->{light} = false;
223 0 return $self;
224 }
225
226 0 ▶sub build { # $obj ()
Subroutine build: not called CC=4 SCAR=30.0
Pod undocumented
227 0 my ( $class ) = @_;
228 0 ▶ assert ( @_ == 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
229 0 ▶ assert ( is_Str $class );
Branch: 1 branch
BranchTrueFalseTotal
unless $class->is_Str 0 0 0
230 0 ▶ assert ( Storable::is_retrieving );
Branch: 1 branch
BranchTrueFalseTotal
unless &Storable::is_retrieving() 0 0 0
231 0 return $class->new(
232 bounds => TRect->new(),
233 text => '',
234 link => undef,
235 );
236 }
237
238 37 1
239
240 __END__
« lib/TUI/StdDlg/FileInputLine.pm ↑ Summary lib/TUI/App/Program.pm »