lib/TUI/Dialogs/HistoryViewer.pm

filter: Statementstmt 54.5% 54 / 99 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 64.0% 16 / 25 Podpod 87.5% 7 / 8 totaltotal 44.7% 77 / 172 CC 14 SCAR 30.0
CC
14
Cov
41%
handleEvent
70.4
BUILD
20.0
getText
6.0
CRAP 20.1
« lib/TUI/Menus/MenuBar.pm ↑ Summary lib/TUI/Views/View/Exposed.pm »
1 package TUI::Dialogs::HistoryViewer;
2 # ABSTRACT: THistoryViewer displays and manages input history in dialog boxes
3
4 10 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 10 our $VERSION = '2.000002';
9 10 $VERSION =~ tr/_//d;
10 10 our $AUTHORITY = 'cpan:BRICKPOOL';
11
12 10 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 our @EXPORT = qw(
14 THistoryViewer
15 new_THistoryViewer
16 );
17
18 10 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
19 10 ▶use List::Util qw( max );
Subroutine BEGIN: called CC=1 SCAR=0.0
20 10 ▶use TUI::toolkit;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 10 ▶use TUI::toolkit::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
22 is_Object
23 :types
24 10 );
25
26 10 ▶use TUI::Const qw( EOS );
Subroutine BEGIN: called CC=1 SCAR=0.0
27 10 ▶use TUI::Dialogs::Const qw( cpHistoryViewer );
Subroutine BEGIN: called CC=1 SCAR=0.0
28 10 ▶use TUI::Dialogs::HistoryViewer::HistList qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
29 historyCount
30 historyStr
31 10 );
32 10 ▶use TUI::Drivers::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
33 :evXXXX
34 kbEnter
35 kbEsc
36 meDoubleClick
37 10 );
38 10 ▶use TUI::Views::Const qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
39 cmCancel
40 cmOK
41 10 );
42 10 ▶use TUI::Views::ListViewer;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 10 ▶use TUI::Views::Palette;
Subroutine BEGIN: called CC=1 SCAR=0.0
44
45 sub THistoryViewer() { __PACKAGE__ }
46 0 ▶sub new_THistoryViewer { __PACKAGE__->from( @_ ) }
Subroutine new_THistoryViewer: not called CC=1 SCAR=6.9
Pod documented
47
48 10 extends TListViewer;
49
50 # protected attributes
51 0 ▶has historyId => ( is => 'ro', default => sub { die 'required' } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
52
53 0 ▶sub BUILDARGS { # \%args (%args)
Subroutine BUILDARGS: not called CC=1 SCAR=6.9
Pod documented
54 0 state $sig = signature(
55 method => 1,
56 named => [
57 bounds => Object,
58 hScrollBar => Object, { alias => 'aHScrollBar' },
59 vScrollBar => Object, { alias => 'aVScrollBar' },
60 historyId => PositiveOrZeroInt, { alias => 'aHistoryId' },
61 ],
62 caller_level => +1,
63 );
64 0 my ( $class, $args1 ) = $sig->( @_ );
65 0 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
66 my $args2 = $class->SUPER::BUILDARGS(
67 bounds => $args1->{bounds},
68 numCols => 1,
69 hScrollBar => $args1->{hScrollBar},
70 vScrollBar => $args1->{vScrollBar},
71 0 );
72 0 return { %$args1, %$args2 };
73 }
74
75 0 ▶sub BUILD { # void (\%args)
Subroutine BUILD: not called CC=4 SCAR=30.0
Pod documented
76 0 my ( $self, $args ) = @_;
77 0 ▶ assert ( @_ == 2 );
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 0 0
78 0 ▶ assert ( is_Object $self );
Branch: 1 branch
BranchTrueFalseTotal
unless &is_Object($self) 0 0 0
79 0 $self->setRange( historyCount( $self->{historyId} ) );
80 $self->focusItem( 1 )
81 0 ▶ if $self->{range} > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"range"} > 1 0 0 0
82 $self->{hScrollBar}->setRange(
83 0,
84 0 $self->historyWidth() - $self->{size}{x} + 3
85 );
86 0 return;
87 }
88
89 0 ▶sub from { # $obj ($bounds, $aHScrollBar, $aVScrollBar, $aHistoryId)
Subroutine from: not called CC=1 SCAR=6.9
Pod undocumented
90 0 state $sig = signature(
91 method => 1,
92 pos => [ Object, Object, Object, PositiveOrZeroInt ],
93 );
94 0 my ( $class, @args ) = $sig->( @_ );
95 0 return $class->new( bounds => $args[0], hScrollBar => $args[1],
96 vScrollBar => $args[2], historyId => $args[3] );
97 }
98
99 0 ▶sub getPalette { # $palette ()
Subroutine getPalette: not called CC=1 SCAR=6.9
Pod documented
100 0 state $sig = signature(
101 method => Object,
102 pos => [],
103 );
104 0 my ( $self ) = $sig->( @_ );
105 0 state $palette = TPalette->new(
106 data => cpHistoryViewer,
107 size => length( cpHistoryViewer ),
108 );
109 0 return $palette->clone();
110 }
111
112 0 ▶sub getText { # void (\$dest, $item, $maxChars)
Subroutine getText: not called CC=2 SCAR=17.9
Pod documented
113 0 state $sig = signature(
114 method => Object,
115 pos => [ ScalarRef, Int, Int ],
116 );
117 0 my ( $self, $dest, $item, $maxChars ) = $sig->( @_ );
118 0 my $str = historyStr( $self->{historyId}, $item );
119 0 ▶ $$dest = length( $str ) ? substr( $str, 0, $maxChars ) : EOS;
Branch: 1 branch
BranchTrueFalseTotal
length $str ? : 0 0 0
120 0 return;
121 }
122
123 0 ▶sub handleEvent { # void ($event)
Subroutine handleEvent: not called CC=9 SCAR=42.5
Pod documented
124 10 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
125 0 state $sig = signature(
126 method => Object,
127 pos => [Object],
128 );
129 0 my ( $self, $event ) = $sig->( @_ );
130 0 ▶ if ( ( $event->{what} == evMouseDown
Branch: 2 branches
BranchTrueFalseTotal
if ($event->{'what'} == 1 and $event->{'mouse'}{'eventFlags'} & 2 or $event->{'what'} == 16 and $event->{'keyDown'}{'keyCode'} == 7181) { } 0 0 0
elsif ($event->{'what'} == 16 and $event->{'keyDown'}{'keyCode'} == 283 or $event->{'what'} == 256 and $event->{'message'}{'command'} == 11) { } 0 0 0
Condition0%0/9
$event->{"what"} == 1 and $event->{"mouse"}{"eventFlags"} & 2 or $event->{"what"} == 16 and $event->{"keyDown"}{"keyCode"} == 7181
l!l&&r!l&&!r
000
$event->{"what"} == 1 and $event->{"mouse"}{"eventFlags"} & 2
!ll&&!rl&&r
000
$event->{"what"} == 16 and $event->{"keyDown"}{"keyCode"} == 7181
!ll&&!rl&&r
000
MC/DC0%0/4
$event->{"what"} == 1 and $event->{"mouse"}{"eventFlags"} & 2 or $event->{"what"} == 16 and $event->{"keyDown"}{"keyCode"} == 7181
$event->{"what"} == 1 $event->{"mouse"}{"eventFlags"} & 2 $event->{"what"} == 16 $event->{"keyDown"}{"keyCode"} == 7181
Truth table0%0/7
A and B or C and D
A= $event->{"what"} == 1B= $event->{"mouse"}{"eventFlags"} & 2C= $event->{"what"} == 16D= $event->{"keyDown"}{"keyCode"} == 7181
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
131 && ( $event->{mouse}{eventFlags} & meDoubleClick ) )
132 || ( $event->{what} == evKeyDown
133 && $event->{keyDown}{keyCode} == kbEnter )
134 ) {
135 0 $self->endModal( cmOK );
136 0 $self->clearEvent( $event );
137 }
138 ▶ elsif (
Condition0%0/9
$event->{"what"} == 16 and $event->{"keyDown"}{"keyCode"} == 283 or $event->{"what"} == 256 and $event->{"message"}{"command"} == 11
l!l&&r!l&&!r
000
$event->{"what"} == 16 and $event->{"keyDown"}{"keyCode"} == 283
!ll&&!rl&&r
000
$event->{"what"} == 256 and $event->{"message"}{"command"} == 11
!ll&&!rl&&r
000
MC/DC0%0/4
$event->{"what"} == 16 and $event->{"keyDown"}{"keyCode"} == 283 or $event->{"what"} == 256 and $event->{"message"}{"command"} == 11
$event->{"what"} == 16 $event->{"keyDown"}{"keyCode"} == 283 $event->{"what"} == 256 $event->{"message"}{"command"} == 11
Truth table0%0/7
A and B or C and D
A= $event->{"what"} == 16B= $event->{"keyDown"}{"keyCode"} == 283C= $event->{"what"} == 256D= $event->{"message"}{"command"} == 11
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
139 ( $event->{what} == evKeyDown && $event->{keyDown}{keyCode} == kbEsc )
140 || ( $event->{what} == evCommand && $event->{message}{command} == cmCancel )
141 ) {
142 0 $self->endModal( cmCancel );
143 0 $self->clearEvent( $event );
144 }
145 else {
146 0 $self->SUPER::handleEvent( $event );
147 }
148 0 return;
149 } #/ sub handleEvent
150
151 0 ▶sub historyWidth { # $width ()
Subroutine historyWidth: not called CC=2 SCAR=17.9
Pod documented
152 0 state $sig = signature(
153 method => Object,
154 pos => [],
155 );
156 0 my ( $self ) = $sig->( @_ );
157 0 my $width = 0;
158 0 my $count = historyCount( $self->{historyId} );
159 0 ▶ for ( my $i = 0 ; $i < $count ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $count) 0 0 0
160 0 my $T = length( historyStr( $self->{historyId}, $i ) );
161 0 $width = max( $width, $T );
162 }
163 0 return $width;
164 }
165
166 10 1
167
168 __END__
« lib/TUI/Menus/MenuBar.pm ↑ Summary lib/TUI/Views/View/Exposed.pm »