line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Padre::Plugin::Vi::TabCompletition; |
2
|
1
|
|
|
1
|
|
34255
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
20
|
use 5.008005; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
710
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(clear_tab handle_tab set_original_cwd); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.23'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my @commands = qw(e w); |
12
|
|
|
|
|
|
|
my @current_options; |
13
|
|
|
|
|
|
|
my $tab_started; |
14
|
|
|
|
|
|
|
my $last_tab; |
15
|
|
|
|
|
|
|
my $original_cwd; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub set_original_cwd { |
18
|
1
|
|
|
1
|
0
|
490
|
$original_cwd = shift; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub clear_tab { |
22
|
0
|
|
|
0
|
0
|
0
|
$tab_started = undef; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub handle_tab { |
26
|
5
|
|
|
5
|
0
|
2478
|
my ( $txt, $shift ) = @_; |
27
|
|
|
|
|
|
|
|
28
|
5
|
100
|
|
|
|
22
|
$txt = '' if not defined $txt; |
29
|
|
|
|
|
|
|
|
30
|
5
|
100
|
|
|
|
13
|
if ( not defined $tab_started ) { |
31
|
1
|
|
|
|
|
3
|
$last_tab = ''; |
32
|
1
|
|
|
|
|
3
|
$tab_started = $txt; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# setup the loop |
35
|
1
|
50
|
|
|
|
7
|
if ( $tab_started eq '' ) { |
|
|
0
|
|
|
|
|
|
36
|
1
|
|
|
|
|
6
|
@current_options = @commands; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#warn "C @current_options"; |
39
|
|
|
|
|
|
|
} elsif ( $tab_started =~ /^e\s+(.*)$/ ) { |
40
|
0
|
|
|
|
|
0
|
my $prefix = $1; |
41
|
0
|
|
|
|
|
0
|
my $path = $original_cwd; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#warn "O: $path"; |
44
|
0
|
0
|
|
|
|
0
|
if ($prefix) { |
45
|
0
|
0
|
|
|
|
0
|
if ( File::Spec->file_name_is_absolute($prefix) ) { |
46
|
0
|
|
|
|
|
0
|
$path = $prefix; |
47
|
|
|
|
|
|
|
} else { |
48
|
0
|
|
|
|
|
0
|
$path = File::Spec->catfile( $path, $prefix ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#warn "O: $path"; |
53
|
0
|
|
|
|
|
0
|
$prefix = ''; |
54
|
0
|
|
|
|
|
0
|
my $dir = $path; |
55
|
0
|
0
|
|
|
|
0
|
if ( -e $path ) { |
56
|
0
|
0
|
|
|
|
0
|
if ( -f $path ) { |
|
|
0
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
return; |
58
|
|
|
|
|
|
|
} elsif ( -d $path ) { |
59
|
0
|
|
|
|
|
0
|
$dir = $path; |
60
|
0
|
|
|
|
|
0
|
$prefix = ''; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# go ahead, opening the directory |
63
|
|
|
|
|
|
|
} else { |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# what shall we do here? |
66
|
0
|
|
|
|
|
0
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} else { # partial file or directory name |
69
|
0
|
|
|
|
|
0
|
$dir = File::Basename::dirname($path); |
70
|
0
|
|
|
|
|
0
|
$prefix = File::Basename::basename($path); |
71
|
|
|
|
|
|
|
} |
72
|
0
|
0
|
|
|
|
0
|
if ( opendir my $dh, $dir ) { |
73
|
0
|
0
|
|
|
|
0
|
@current_options = sort |
74
|
0
|
|
|
|
|
0
|
map { -d File::Spec->catfile( $dir, "$prefix$_" ) ? "$_/" : $_ } |
75
|
0
|
|
|
|
|
0
|
map { $_ =~ s/^$prefix//; $_ } |
|
0
|
|
|
|
|
0
|
|
76
|
0
|
0
|
|
|
|
0
|
grep { $_ =~ /^$prefix/ } |
77
|
0
|
|
|
|
|
0
|
grep { $_ ne '.' and $_ ne '..' } readdir $dh; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} else { |
80
|
0
|
|
|
|
|
0
|
@current_options = (); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
5
|
50
|
|
|
|
18
|
return if not @current_options; # somehow alert the user? |
85
|
|
|
|
|
|
|
|
86
|
5
|
|
|
|
|
7
|
my $option; |
87
|
5
|
100
|
|
|
|
12
|
if ($shift) { |
88
|
1
|
50
|
|
|
|
5
|
if ( $last_tab eq 'for' ) { |
89
|
1
|
|
|
|
|
3
|
unshift @current_options, pop @current_options; |
90
|
|
|
|
|
|
|
} |
91
|
1
|
|
|
|
|
3
|
$option = pop @current_options; |
92
|
1
|
|
|
|
|
2
|
unshift @current_options, $option; |
93
|
1
|
|
|
|
|
3
|
$last_tab = 'back'; |
94
|
|
|
|
|
|
|
} else { |
95
|
4
|
50
|
|
|
|
12
|
if ( $last_tab eq 'back' ) { |
96
|
0
|
|
|
|
|
0
|
push @current_options, shift @current_options; |
97
|
|
|
|
|
|
|
} |
98
|
4
|
|
|
|
|
6
|
$option = shift @current_options; |
99
|
4
|
|
|
|
|
6
|
push @current_options, $option; |
100
|
4
|
|
|
|
|
9
|
$last_tab = 'for'; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
5
|
|
|
|
|
17
|
return $tab_started . $option; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Copyright 2008-2010 Gabor Szabo. |
109
|
|
|
|
|
|
|
# LICENSE |
110
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
111
|
|
|
|
|
|
|
# modify it under the same terms as Perl 5 itself. |