| 1 | package TUI::Dialogs::HistoryWindow; | ||||||||||
| 2 | # ABSTRACT: Window component showing and managing history list items | ||||||||||
| 3 | |||||||||||
| 4 | 9 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 9 | our $VERSION = '2.000002'; | |||||||||
| 9 | 9 | $VERSION =~ tr/_//d; | |||||||||
| 10 | 9 | our $AUTHORITY = 'cpan:BRICKPOOL'; | |||||||||
| 11 | |||||||||||
| 12 | 9 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 9 | our @EXPORT = qw( | |||||||||
| 14 | THistoryWindow | ||||||||||
| 15 | new_THistoryWindow | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | 9 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 9 | ▶ | use TUI::toolkit; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 9 | ▶ | use TUI::toolkit::Types qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | :is | ||||||||||
| 22 | :types | ||||||||||
| 23 | 9 | ); | |||||||||
| 24 | |||||||||||
| 25 | 9 | ▶ | use TUI::Dialogs::Const qw( cpHistoryWindow ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 9 | ▶ | use TUI::Dialogs::HistInit; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 9 | ▶ | use TUI::Dialogs::HistoryViewer; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 9 | ▶ | use TUI::Views::Const qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | sbHandleKeyboard | ||||||||||
| 30 | sbHorizontal | ||||||||||
| 31 | sbVertical | ||||||||||
| 32 | wfClose | ||||||||||
| 33 | wnNoNumber | ||||||||||
| 34 | 9 | ); | |||||||||
| 35 | 9 | ▶ | use TUI::Views::Palette; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | 9 | ▶ | use TUI::Views::Window; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 37 | |||||||||||
| 38 | sub THistoryWindow() { __PACKAGE__ } | ||||||||||
| 39 | 0 | ▶ | sub new_THistoryWindow { __PACKAGE__->from(@_) } | ||||||||
|
Subroutine
new_THistoryWindow: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | |||||||||||
| 41 | 9 | extends ( TWindow, THistInit ); | |||||||||
| 42 | |||||||||||
| 43 | # Moo does not inherit attributes from secondary extends() classes. | ||||||||||
| 44 | # Redeclare attribute provided by THistInit. | ||||||||||
| 45 | 9 | ▶ | if ( TUI::toolkit::is_Moo ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | ▶ | has createListViewer => ( is => 'bare', default => sub { die 'required' } ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | # protected attributes | ||||||||||
| 50 | 9 | has viewer => ( is => 'ro' ); | |||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | sub BUILDARGS { # \%args (%args) | ||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 53 | 0 | state $sig = signature( | |||||||||
| 54 | method => 1, | ||||||||||
| 55 | named => [ | ||||||||||
| 56 | bounds => Object, | ||||||||||
| 57 | historyId => PositiveOrZeroInt, | ||||||||||
| 58 | ], | ||||||||||
| 59 | caller_level => +1, | ||||||||||
| 60 | ); | ||||||||||
| 61 | 0 | my ( $class, $args1 ) = $sig->( @_ ); | |||||||||
| 62 | 0 | local $Carp::CarpLevel = $Carp::CarpLevel + 1; | |||||||||
| 63 | my $args2 = TWindow->BUILDARGS( | ||||||||||
| 64 | bounds => $args1->{bounds}, | ||||||||||
| 65 | 0 | title => '', | |||||||||
| 66 | number => wnNoNumber, | ||||||||||
| 67 | ); | ||||||||||
| 68 | 0 | my $args3 = THistInit->BUILDARGS( | |||||||||
| 69 | cListViewer => $class->can( 'initViewer' ) | ||||||||||
| 70 | ); | ||||||||||
| 71 | 0 | return { %$args1, %$args2, %$args3 }; | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||
|
Subroutine
BUILD: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||
| 75 | 0 | my ( $self, $args ) = @_; | |||||||||
| 76 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | 0 | ▶ | assert ( is_Object $self ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 0 | ▶ | assert ( is_HashRef $args ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | 0 | $self->{flags} = wfClose; | |||||||||
| 80 | 0 | ▶ | if ( $self->{createListViewer} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | $self->{viewer} = $self->createListViewer( $self->getExtent(), $self, | ||||||||||
| 82 | 0 | $args->{historyId} ); | |||||||||
| 83 | 0 | ▶ | $self->insert( $self->{viewer} ) if $self->{viewer}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | } | ||||||||||
| 85 | 0 | return; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 0 | ▶ | sub from { # $obj ($bounds, $historyId) | ||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 89 | 0 | state $sig = signature( | |||||||||
| 90 | method => 1, | ||||||||||
| 91 | pos => [Object, PositiveOrZeroInt], | ||||||||||
| 92 | ); | ||||||||||
| 93 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||
| 94 | 0 | return $class->new( bounds => $args[0], historyId => $args[1] ); | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 0 | ▶ | sub getPalette { # $palette () | ||||||||
|
Subroutine
getPalette: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 98 | 0 | state $sig = signature( | |||||||||
| 99 | method => Object, | ||||||||||
| 100 | pos => [], | ||||||||||
| 101 | ); | ||||||||||
| 102 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||
| 103 | 0 | state $palette = TPalette->new( | |||||||||
| 104 | data => cpHistoryWindow, | ||||||||||
| 105 | size => length( cpHistoryWindow ), | ||||||||||
| 106 | ); | ||||||||||
| 107 | 0 | return $palette->clone(); | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | 0 | ▶ | sub getSelection { # void (\$dest) | ||||||||
|
Subroutine
getSelection: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 111 | 0 | state $sig = signature( | |||||||||
| 112 | method => Object, | ||||||||||
| 113 | pos => [ScalarRef], | ||||||||||
| 114 | ); | ||||||||||
| 115 | 0 | my ( $self, $dest ) = @_; | |||||||||
| 116 | 0 | $self->{viewer}->getText( $dest, $self->{viewer}{focused}, 255 ); | |||||||||
| 117 | 0 | return; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub initViewer { # $listViewer ($r, $win, $historyId) | ||||||||
|
Subroutine
initViewer: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 121 | 0 | state $sig = signature( | |||||||||
| 122 | method => 1, | ||||||||||
| 123 | pos => [Object, Object, PositiveOrZeroInt], | ||||||||||
| 124 | ); | ||||||||||
| 125 | 0 | my ( $class, $r, $win, $historyId ) = $sig->( @_ ); | |||||||||
| 126 | 0 | $r->grow( -1, -1 ); | |||||||||
| 127 | 0 | return THistoryViewer->new( | |||||||||
| 128 | bounds => $r, | ||||||||||
| 129 | hScrollBar => $win->standardScrollBar( sbHorizontal | sbHandleKeyboard ), | ||||||||||
| 130 | vScrollBar => $win->standardScrollBar( sbVertical | sbHandleKeyboard ), | ||||||||||
| 131 | historyId => $historyId, | ||||||||||
| 132 | ); | ||||||||||
| 133 | } #/ sub initViewer | ||||||||||
| 134 | |||||||||||
| 135 | 9 | 1 | |||||||||
| 136 | |||||||||||
| 137 | __END__ | ||||||||||