lib/TUI/Dialogs/History.pm

filter: Statementstmt 47.5% 68 / 143 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 62.5% 20 / 32 Podpod 90.0% 9 / 10 totaltotal 43.5% 97 / 223 CC 14 SCAR 36.4
CC
14
Cov
39%
handleEvent
136.7
BUILD
12.0
new_THistory
2.0
CRAP 38.1
« lib/TUI/Menus/SubMenu.pm ↑ Summary lib/TUI/StdDlg/FileInputLine.pm »
1 package TUI::Dialogs::History;
2 # ABSTRACT: A TWindow-based history browser for input controls
3
4 8 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 8 our $VERSION = '2.000002';
10 8 $VERSION =~ tr/_//d;
11 8 our $AUTHORITY = 'cpan:BRICKPOOL';
12
13 8 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 8 our @EXPORT = qw(
15 THistory
16 new_THistory
17 );
18
19 8 ▶use Encode qw( encode );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 8 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 8 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 is_Object
23 :types
24 8 );
25
26 8 ▶use TUI::Dialogs::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 cmRecordHistory
28 cpHistory
29 8 );
30 8 ▶use TUI::Dialogs::HistoryViewer::HistList qw( historyAdd );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 8 ▶use TUI::Dialogs::HistoryWindow;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 8 ▶use TUI::Dialogs::InputLine;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 8 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
34 :evXXXX
35 kbDown
36 8 );
37 8 ▶use TUI::Drivers::Util qw( ctrlToArrow );
Subroutine BEGIN: called CC=1 SCAR=0.0
38 8 ▶use TUI::Objects::Rect;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 8 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
40 cmOK
41 cmReleasedFocus
42 ofPostProcess
43 sfFocused
44 8 );
45 8 ▶use TUI::Views::DrawBuffer;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 8 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 8 ▶use TUI::Views::View;
Subroutine BEGIN: called CC=1 SCAR=0.0
48
49 sub THistory() { __PACKAGE__ }
50 sub name() { 'THistory' }
51 0 ▶sub new_THistory { __PACKAGE__->from(@_) }
Subroutine new_THistory: not called CC=1 SCAR=6.9
Pod documented
52
53 8 extends TView;
54
55 # declare global variables
56 8 our $icon = "\xDE~\x19~\xDD"; # cp437: "▐~↓~▌"
57 # our $icon = encode( cp437 => "▐~↓~▌" );
58
59 # protected attributes
60 0 ▶has link => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
61 0 ▶has historyId => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
62
63 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
64 0 state $sig = signature(
65 method => 1,
66 named => [
67 bounds => Object,
68 link => Object, { alias => 'aLink' },
69 historyId => PositiveOrZeroInt, { alias => 'aHistoryId' },
70 ],
71 caller_level => +1,
72 );
73 0 my ( $class, $args ) = $sig->( @_ );
74 0 return { %$args };
75 }
76
77 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=3 SCAR=24.8
Pod documented
78 0 my ( $self, $args ) = @_;
79 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
80 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
81 0 $self->{options} |= ofPostProcess;
82 0 $self->{eventMask} |= evBroadcast;
83 0 return;
84 }
85
86 0 ▶sub from { # $obj ($bounds, $aLink, $aHistoryId)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
87 0 state $sig = signature(
88 method => 1,
89 pos => [Object, Object, PositiveOrZeroInt],
90 );
91 0 my ( $class, @args ) = $sig->( @_ );
92 0 return $class->new( bounds => $args[0], link => $args[1],
93 historyId => $args[2] );
94 }
95
96 0 ▶sub draw { # void ()
Subroutine draw: not called CC=1 SCAR=6.9
Pod documented
97 0 state $sig = signature(
98 method => Object,
99 pos => [],
100 );
101 0 my ( $self ) = $sig->( @_ );
102 0 my $b = TDrawBuffer->new();
103 0 $b->moveCStr( 0, $icon, $self->getColor( 0x0102 ) );
104 0 $self->writeLine( 0, 0, $self->{size}{x}, $self->{size}{y}, $b );
105 0 return;
106 }
107
108 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=1 SCAR=6.9
Pod documented
109 0 state $sig = signature(
110 method => Object,
111 pos => [],
112 );
113 0 my ( $self ) = $sig->( @_ );
114 0 state $palette = TPalette->new(
115 data => cpHistory,
116 size => length( cpHistory ),
117 );
118 0 return $palette->clone();
119 }
120
121 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=12 SCAR=49.2
Pod documented
122 0 state $sig = signature(
123 method => Object,
124 pos => [Object],
125 );
126 0 my ( $self, $event ) = $sig->( @_ );
127
128 0 my $historyWindow;
129 0 my ( $r, $p );
130 0 my $c;
131
132 0 $self->SUPER::handleEvent( $event );
133 0 ▶ if ( $event->{what} == evMouseDown
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{'what'} == 1 or $event->{'what'} == 16 and &ctrlToArrow($event->{'keyDown'}{'keyCode'}) == 20480 and $self->{'link'}{'state'} & 64) { } 0 0 0
Condition0%0/9
$event->{"what"} == 1 or $event->{"what"} == 16 and &ctrlToArrow($event->{"keyDown"}{"keyCode"}) == 20480 and $self->{"link"}{"state"} & 64
l!l&&r!l&&!r
000
$event->{"what"} == 16 and &ctrlToArrow($event->{"keyDown"}{"keyCode"}) == 20480 and $self->{"link"}{"state"} & 64
!ll&&!rl&&r
000
$event->{"what"} == 16 and &ctrlToArrow($event->{"keyDown"}{"keyCode"}) == 20480
!ll&&!rl&&r
000
MC/DC0%0/4
$event->{"what"} == 1 or $event->{"what"} == 16 and &ctrlToArrow($event->{"keyDown"}{"keyCode"}) == 20480 and $self->{"link"}{"state"} & 64
$event->{"what"} == 1 $event->{"what"} == 16 &ctrlToArrow($event->{"keyDown"}{"keyCode"}) == 20480 $self->{"link"}{"state"} & 64
Truth table0%0/5
A or B and C and D
A= $event->{"what"} == 1B= $event->{"what"} == 16C= &ctrlToArrow($event->{"keyDown"}{"keyCode"}) == 20480D= $self->{"link"}{"state"} & 64
ABCDresult
1XXX1
01111
00XX0
010X0
01100
134 || ( $event->{what} == evKeyDown
135 && ctrlToArrow( $event->{keyDown}{keyCode} ) == kbDown
136 && ( $self->{link}{state} & sfFocused ) )
137 ) {
138 0 ▶ if ( !$self->{link}->focus() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"link"}->focus) 0 0 0
139 0 $self->clearEvent( $event );
140 0 return;
141 }
142 0 $self->recordHistory( $self->{link}{data} );
143 0 $r = $self->{link}->getBounds();
144 0 $r->{a}{x}--;
145 0 $r->{b}{x}++;
146 0 $r->{b}{y} += 7;
147 0 $r->{a}{y}--;
148 0 $p = $self->{owner}->getExtent();
149 0 $r->intersect( $p );
150 0 $r->{b}{y}--;
151 0 $historyWindow = $self->initHistoryWindow( $r );
152
153 0 ▶ if ( $historyWindow != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($historyWindow != 0) 0 0 0
154 0 $c = $self->{owner}->execView( $historyWindow );
155 0 ▶ if ( $c == cmOK ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c == 10) 0 0 0
156 0 my $rslt;
157 0 $historyWindow->getSelection( \$rslt );
158 0 $self->{link}{data} = substr( $rslt, 0, $self->{link}{maxLen} );
159 0 $self->{link}->selectAll( true );
160 0 $self->{link}->drawView();
161 }
162 0 $self->destroy( $historyWindow );
163 } #/ if ( $historyWindow !=...)
164 0 $self->clearEvent( $event );
165 }
166 else {
167 0 ▶ if ( $event->{what} == evBroadcast ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"what"} == 512) 0 0 0
168 8 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
169 0 ▶ if ( ( $event->{message}{command} == cmReleasedFocus
Branch: 1 branch
BranchTrueFalseTotal
if ($event->{"message"}{"command"} == 51 and $event->{"message"}{"infoPtr"} == $self->{"link"} or $event->{"message"}{"command"} == 60) 0 0 0
Condition0%0/6
$event->{"message"}{"command"} == 51 and $event->{"message"}{"infoPtr"} == $self->{"link"} or $event->{"message"}{"command"} == 60
l!l&&r!l&&!r
000
$event->{"message"}{"command"} == 51 and $event->{"message"}{"infoPtr"} == $self->{"link"}
!ll&&!rl&&r
000
MC/DC0%0/3
$event->{"message"}{"command"} == 51 and $event->{"message"}{"infoPtr"} == $self->{"link"} or $event->{"message"}{"command"} == 60
$event->{"message"}{"command"} == 51 $event->{"message"}{"infoPtr"} == $self->{"link"} $event->{"message"}{"command"} == 60
Truth table0%0/5
A and B or C
A= $event->{"message"}{"command"} == 51B= $event->{"message"}{"infoPtr"} == $self->{"link"}C= $event->{"message"}{"command"} == 60
ABCresult
11X1
0X11
1011
0X00
1000
170 && $event->{message}{infoPtr} == $self->{link} )
171 || $event->{message}{command} == cmRecordHistory
172 ) {
173 0 $self->recordHistory( $self->{link}{data} );
174 } #/ if ( ( $event->{message...}))
175 } #/ if ( $event->{what} ==...)
176 }
177 0 return;
178 }
179
180 0 ▶sub initHistoryWindow { # $historyWindow ($bounds)
Subroutine initHistoryWindow: not called CC=1 SCAR=6.9
Pod documented
181 0 state $sig = signature(
182 method => Object,
183 pos => [Object],
184 );
185 0 my ( $self, $bounds ) = $sig->( @_ );
186 my $p = THistoryWindow->new(
187 bounds => $bounds,
188 historyId => $self->{historyId},
189 0 );
190 0 $p->{helpCtx} = $self->{link}{helpCtx};
191 0 return $p;
192 }
193
194 0 ▶sub recordHistory { # void ($s)
Subroutine recordHistory: not called CC=1 SCAR=6.9
Pod documented
195 0 state $sig = signature(
196 method => Object,
197 pos => [Str],
198 );
199 0 my ( $self, $s ) = $sig->( @_ );
200 0 historyAdd( $self->{historyId}, $s );
201 0 return;
202 }
203
204 0 ▶sub shutDown { # void ()
Subroutine shutDown: not called CC=1 SCAR=6.9
Pod documented
205 0 state $sig = signature(
206 method => Object,
207 pos => [],
208 );
209 0 my ( $self ) = $sig->( @_ );
210 0 $self->{link} = undef;
211 0 $self->SUPER::shutDown();
212 0 return;
213 }
214
215 8 1
216
217 __END__
« lib/TUI/Menus/SubMenu.pm ↑ Summary lib/TUI/StdDlg/FileInputLine.pm »