| 1 | package TUI::StdDlg::FileInfoPane; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: A view that displays the currently focused file in a file dialog | ||||||||||||||||||||||||||||
| 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 | TFileInfoPane | ||||||||||||||||||||||||||||
| 15 | new_TFileInfoPane | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use TUI::toolkit; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 5 | ▶ | use TUI::toolkit::Types qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | is_Object | ||||||||||||||||||||||||||||
| 21 | :types | ||||||||||||||||||||||||||||
| 22 | 5 | ); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 5 | ▶ | use TUI::Drivers::Const qw( evBroadcast ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use TUI::StdDlg::Const qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | cmFileFocused | ||||||||||||||||||||||||||||
| 27 | cpInfoPane | ||||||||||||||||||||||||||||
| 28 | 5 | ); | |||||||||||||||||||||||||||
| 29 | 5 | ▶ | use TUI::StdDlg::FileCollection; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 5 | ▶ | use TUI::StdDlg::Util qw( fexpand ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 5 | ▶ | use TUI::Views::DrawBuffer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 5 | ▶ | use TUI::Views::Palette; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 5 | ▶ | use TUI::Views::View; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub TFileInfoPane() { __PACKAGE__ } | ||||||||||||||||||||||||||||
| 36 | sub name() { 'TFileInfoPane' } | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub new_TFileInfoPane { __PACKAGE__->from(@_) } | ||||||||||||||||||||||||||
|
Subroutine
new_TFileInfoPane: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 5 | extends TView; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # declare global variables | ||||||||||||||||||||||||||||
| 42 | 5 | our $pmText = "p"; | |||||||||||||||||||||||||||
| 43 | 5 | our $amText = "a"; | |||||||||||||||||||||||||||
| 44 | 5 | our $months = [ '', qw( | |||||||||||||||||||||||||||
| 45 | Jan Feb Mar Apr May Jun | ||||||||||||||||||||||||||||
| 46 | Jul Aug Sep Oct Nov Dec | ||||||||||||||||||||||||||||
| 47 | )]; | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # private attributes | ||||||||||||||||||||||||||||
| 50 | has file_block => ( | ||||||||||||||||||||||||||||
| 51 | is => 'bare', | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | default => sub { TSearchRec->new( | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 53 | attr => 0, | ||||||||||||||||||||||||||||
| 54 | time => 0, | ||||||||||||||||||||||||||||
| 55 | size => 0, | ||||||||||||||||||||||||||||
| 56 | name => '', | ||||||||||||||||||||||||||||
| 57 | )} | ||||||||||||||||||||||||||||
| 58 | 5 | ); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 61 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | $self->{eventMask} |= evBroadcast; | |||||||||||||||||||||||||||
| 65 | 0 | return; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub draw { # void () | ||||||||||||||||||||||||||
|
Subroutine
draw: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 70 | method => Object, | ||||||||||||||||||||||||||||
| 71 | pos => [], | ||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||
| 73 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my $b = TDrawBuffer->new(); | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # Prevents incorrect directory name display in info pane if wildCard | ||||||||||||||||||||||||||||
| 78 | # has already been expanded. | ||||||||||||||||||||||||||||
| 79 | 0 | my $path = $self->{owner}{wildCard}; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( $path !~ /[:\\]/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | $path = $self->{owner}{directory} . $self->{owner}{wildCard}; | |||||||||||||||||||||||||||
| 82 | 0 | fexpand( $path ); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | my $color = $self->getColor( 0x01 ); | |||||||||||||||||||||||||||
| 86 | 0 | $b->moveChar( 0, ' ', $color, $self->{size}{x} ); | |||||||||||||||||||||||||||
| 87 | 0 | $b->moveStr( 1, $path, $color ); | |||||||||||||||||||||||||||
| 88 | 0 | $self->writeLine( 0, 0, $self->{size}{x}, 1, $b ); | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | $b->moveChar( 0, ' ', $color, $self->{size}{x} ); | |||||||||||||||||||||||||||
| 91 | 0 | $b->moveStr( 1, $self->{file_block}->name, $color ); | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ( length $self->{file_block}->name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 0 | $b->moveStr( 14, $self->{file_block}->size, $color ); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | my $time = $self->{file_block}->time; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | my $date16 = ( $time >> 16 ) & 0xFFFF; | |||||||||||||||||||||||||||
| 99 | 0 | my $day = $date16 & 0x1F; | |||||||||||||||||||||||||||
| 100 | 0 | my $month = ( $date16 >> 5 ) & 0x0F; | |||||||||||||||||||||||||||
| 101 | 0 | my $year = ( $date16 >> 9 ) & 0x7F; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | $b->moveStr( 25, $months->[ $month ], $color ); | |||||||||||||||||||||||||||
| 104 | 0 | $b->moveStr( 29, sprintf( "%02d", $day ), $color ); | |||||||||||||||||||||||||||
| 105 | 0 | $b->putChar( 31, ',' ); | |||||||||||||||||||||||||||
| 106 | 0 | $b->moveStr( 32, $year + 1980, $color ); | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | my $time16 = $time & 0xFFFF; | |||||||||||||||||||||||||||
| 109 | 0 | my $min = ( $time16 >> 5 ) & 0x3F; | |||||||||||||||||||||||||||
| 110 | 0 | my $hour = ( $time16 >> 11 ) & 0x1F; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | my $PM = $hour >= 12; | |||||||||||||||||||||||||||
| 113 | 0 | my $hour12 = $hour % 12; | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | $hour12 = 12 if $hour12 == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | $b->moveStr( 38, sprintf( "%02d", $hour12 ), $color ); | |||||||||||||||||||||||||||
| 117 | 0 | $b->putChar( 40, ':' ); | |||||||||||||||||||||||||||
| 118 | 0 | $b->moveStr( 41, sprintf( "%02d", $min ), $color ); | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | $b->moveStr( 43, $PM ? $pmText : $amText, $color ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | } #/ if ( defined( $self->{file_block}...)) | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | $self->writeLine( 0, 1, $self->{size}{x}, 1, $b ); | |||||||||||||||||||||||||||
| 123 | 0 | $b->moveChar( 0, ' ', $color, $self->{size}{x} ); | |||||||||||||||||||||||||||
| 124 | 0 | $self->writeLine( 0, 2, $self->{size}{x}, $self->{size}{y} - 2, $b ); | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | return; | |||||||||||||||||||||||||||
| 127 | } #/ sub draw | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | sub getPalette { # $palette () | ||||||||||||||||||||||||||
|
Subroutine
getPalette: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 130 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 131 | method => Object, | ||||||||||||||||||||||||||||
| 132 | pos => [], | ||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||
| 134 | 0 | my ( $self ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 135 | 0 | state $palette = TPalette->new( | |||||||||||||||||||||||||||
| 136 | data => cpInfoPane, | ||||||||||||||||||||||||||||
| 137 | size => length( cpInfoPane ), | ||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||
| 139 | 0 | return $palette->clone(); | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub handleEvent { # void ($event) | ||||||||||||||||||||||||||
|
Subroutine
handleEvent: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 0 | state $sig = signature( | |||||||||||||||||||||||||||
| 144 | method => Object, | ||||||||||||||||||||||||||||
| 145 | pos => [Object], | ||||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||
| 147 | 0 | my ( $self, $event ) = $sig->( @_ ); | |||||||||||||||||||||||||||
| 148 | 0 | ▶ | if ( $event->{what} == evBroadcast | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$event->{"what"} == 512 and $event->{"message"}{"command"} == 102
MC/DC0%0/2
$event->{"what"} == 512 and $event->{"message"}{"command"} == 102
$event->{"what"} == 512
$event->{"message"}{"command"} == 102
Truth table0%0/3
A and B
A= $event->{"what"} == 512B= $event->{"message"}{"command"} == 102
| |||||||||||||||||||||||||||||
| 149 | && $event->{message}{command} == cmFileFocused | ||||||||||||||||||||||||||||
| 150 | ) { | ||||||||||||||||||||||||||||
| 151 | 0 | $self->{file_block} = $event->{message}{infoPtr}; | |||||||||||||||||||||||||||
| 152 | 0 | $self->drawView(); | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | 0 | return; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 5 | 1 | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | __END__ | ||||||||||||||||||||||||||||