| 1 | package TUI::StdDlg::FileInputLine; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Input line view for file dialog focus handling | ||||||||||||||||||||||||||||||||||||||||||
| 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 | TFileInputLine | ||||||||||||||||||||||||||||||||||||||||||
| 15 | new_TFileInputLine | ||||||||||||||||||||||||||||||||||||||||||
| 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::Dialogs::InputLine; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use TUI::Drivers::Const qw( evBroadcast ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | ▶ | use TUI::StdDlg::Const qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | cmFileFocused | ||||||||||||||||||||||||||||||||||||||||||
| 28 | FA_DIREC | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | ▶ | use TUI::StdDlg::Util qw( fexpand ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | use TUI::Views::Const qw( sfSelected ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | sub TFileInputLine() { __PACKAGE__ } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | sub name() { 'TFileInputLine' }; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub new_TFileInputLine { __PACKAGE__->from(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_TFileInputLine: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 5 | extends TInputLine; | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub BUILDARGS { # \%args (|%args) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 41 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | named => [ | ||||||||||||||||||||||||||||||||||||||||||
| 43 | bounds => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | maxLen => Int, { alias => 'aMaxLen' }, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 46 | caller_level => +1, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my ( $class, $args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return { %$args }; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub BUILD { # void (\%args) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | assert ( @_ == 2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | assert ( is_Object $self ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->{eventMask} = evBroadcast; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub from { # $obj ($aLimit, $aDelta) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 62 | method => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | pos => [Object, Int], | ||||||||||||||||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my ( $class, @args ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | return $class->new( bounds => $args[0], maxLen => $args[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | sub handleEvent { # void ($event) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handleEvent: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | state $sig = signature( | |||||||||||||||||||||||||||||||||||||||||
| 71 | method => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | pos => [Object], | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ( $self, $event ) = $sig->( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $self->SUPER::handleEvent( $event ); | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ( $event->{what} == evBroadcast | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$event->{"what"} == 512 and $event->{"message"}{"command"} == 102 and not $self->{"state"} & 32
$event->{"what"} == 512 and $event->{"message"}{"command"} == 102
MC/DC0%0/3
$event->{"what"} == 512 and $event->{"message"}{"command"} == 102 and not $self->{"state"} & 32
$event->{"what"} == 512
$event->{"message"}{"command"} == 102
not $self->{"state"} & 32
Truth table0%0/4
A and B and not(C)
A= $event->{"what"} == 512B= $event->{"message"}{"command"} == 102C= not $self->{"state"} & 32
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | && $event->{message}{command} == cmFileFocused | ||||||||||||||||||||||||||||||||||||||||||
| 79 | && !( $self->{state} & sfSelected ) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # Prevents incorrect display in the input line if wildCard has | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | # already been expanded. | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | assert ( is_Object $event->{message}{infoPtr} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | assert ( defined $event->{message}{infoPtr}->name ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ( $event->{message}{infoPtr}->attr & FA_DIREC ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $self->{data} = $self->{owner}->wildCard; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ( $self->{data} !~ /[:\\]/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | $self->{data} = $event->{message}{infoPtr}->name | ||||||||||||||||||||||||||||||||||||||||||
| 89 | . "\\" | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | . $self->{owner}->wildCard; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # Insert "<name>\\" between last name/wildcard and last '\' | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | fexpand( $self->{data} ); # Insure complete expansion to begin with | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $pos = rindex( $self->{data}, '\\' ); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $nm = $event->{message}{infoPtr}->name; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ( $pos >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $offset = $pos + 1; # position after last '\' | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | substr( $self->{data}, $offset, 0 ) = $nm . '\\'; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | # No backslash found: prepend "<name>\" | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->{data} = $nm . '\\' . $self->{data}; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | fexpand( $self->{data} ); # Expand again incase it was '..'. | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->{data} = $event->{message}{infoPtr}->name; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $self->drawView(); | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } #/ sub handleEvent | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | 1 | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | __END__ | ||||||||||||||||||||||||||||||||||||||||||