| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::ansiexpand; |
|
2
|
|
|
|
|
|
|
our $VERSION = "1.04"; |
|
3
|
|
|
|
|
|
|
|
|
4
|
21
|
|
|
21
|
|
1869371
|
use 5.014; |
|
|
21
|
|
|
|
|
299
|
|
|
5
|
21
|
|
|
21
|
|
111
|
use warnings; |
|
|
21
|
|
|
|
|
26
|
|
|
|
21
|
|
|
|
|
633
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
21
|
|
|
21
|
|
638
|
use open IO => 'utf8', ':std'; |
|
|
21
|
|
|
|
|
1450
|
|
|
|
21
|
|
|
|
|
138
|
|
|
8
|
21
|
|
|
21
|
|
13450
|
use Encode; |
|
|
21
|
|
|
|
|
203299
|
|
|
|
21
|
|
|
|
|
1459
|
|
|
9
|
21
|
|
|
21
|
|
11106
|
use Pod::Usage; |
|
|
21
|
|
|
|
|
857797
|
|
|
|
21
|
|
|
|
|
2738
|
|
|
10
|
21
|
|
|
21
|
|
913
|
use Data::Dumper; |
|
|
21
|
|
|
|
|
6403
|
|
|
|
21
|
|
|
|
|
1197
|
|
|
11
|
21
|
|
|
21
|
|
10418
|
use Text::ANSI::Tabs qw(ansi_expand ansi_unexpand); |
|
|
21
|
|
|
|
|
1300222
|
|
|
|
21
|
|
|
|
|
2152
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $DEFAULT_UNEXPAND; |
|
14
|
|
|
|
|
|
|
|
|
15
|
21
|
|
|
21
|
|
10986
|
use Getopt::EX::Hashed 1.05; { |
|
|
21
|
|
|
|
|
146061
|
|
|
|
21
|
|
|
|
|
125
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Getopt::EX::Hashed->configure(DEFAULT => [ is => 'ro' ]); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has unexpand => ' u ! ' , default => $DEFAULT_UNEXPAND; |
|
20
|
|
|
|
|
|
|
has ambiguous => ' =s ' , any => [ qw(wide narrow) ]; |
|
21
|
|
|
|
|
|
|
has tabstop => ' t =i ' , min => 1; |
|
22
|
|
|
|
|
|
|
has tabhead => ' =s ' ; |
|
23
|
|
|
|
|
|
|
has tabspace => ' =s ' ; |
|
24
|
|
|
|
|
|
|
has tabstyle => ' ts :s ' ; |
|
25
|
|
|
|
|
|
|
has help => ' h ' ; |
|
26
|
|
|
|
|
|
|
has version => ' v ' ; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has '+tabstop' => sub { |
|
29
|
|
|
|
|
|
|
$_->{$_[0]} = $Text::ANSI::Tabs::tabstop = $_[1]; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has [ qw(+tabhead +tabspace +tabstyle) ] => sub { |
|
33
|
|
|
|
|
|
|
if ($_[1] eq '') { |
|
34
|
|
|
|
|
|
|
list_tabstyle(); |
|
35
|
|
|
|
|
|
|
exit; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
Text::ANSI::Tabs->configure("$_[0]" => $_[1]); |
|
38
|
|
|
|
|
|
|
}; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has '+help' => sub { |
|
41
|
|
|
|
|
|
|
pod2usage |
|
42
|
|
|
|
|
|
|
-verbose => 99, |
|
43
|
|
|
|
|
|
|
-sections => [ qw(SYNOPSIS VERSION) ]; |
|
44
|
|
|
|
|
|
|
}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has '+version' => sub { |
|
47
|
|
|
|
|
|
|
print "Version: $VERSION\n"; |
|
48
|
|
|
|
|
|
|
exit; |
|
49
|
|
|
|
|
|
|
}; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has ARGV => default => []; |
|
52
|
|
|
|
|
|
|
has '<>' => sub { |
|
53
|
|
|
|
|
|
|
if ($_[0] =~ /^-([0-9]+)$/x) { |
|
54
|
|
|
|
|
|
|
$_->{tabstop} = $Text::ANSI::Tabs::tabstop = $1 or |
|
55
|
|
|
|
|
|
|
die "$_[0]: invalid tabstop\n"; |
|
56
|
|
|
|
|
|
|
} else { |
|
57
|
|
|
|
|
|
|
if ($_[0] =~ /^-{1,2}+(.+)/) { |
|
58
|
|
|
|
|
|
|
warn "Unknown option: $1\n"; |
|
59
|
|
|
|
|
|
|
pod2usage(); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
push @{$_->ARGV}, $_[0]; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
21
|
|
|
21
|
|
11734
|
} no Getopt::EX::Hashed; |
|
|
21
|
|
|
|
|
63
|
|
|
|
21
|
|
|
|
|
111
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub run { |
|
68
|
17
|
|
|
17
|
0
|
16406094
|
my $app = shift; |
|
69
|
17
|
50
|
|
|
|
251
|
local @ARGV = map { utf8::is_utf8($_) ? $_ : decode('utf8', $_) } @_; |
|
|
32
|
|
|
|
|
2851
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
21
|
|
|
21
|
|
12278
|
use Getopt::EX::Long qw(:DEFAULT ExConfigure Configure); |
|
|
21
|
|
|
|
|
770828
|
|
|
|
21
|
|
|
|
|
6781
|
|
|
72
|
17
|
|
|
|
|
2457
|
ExConfigure BASECLASS => [ __PACKAGE__, 'Getopt::EX' ]; |
|
73
|
17
|
|
|
|
|
1949
|
Configure qw(bundling pass_through); |
|
74
|
17
|
100
|
|
|
|
2672
|
$app->getopt || pod2usage(); |
|
75
|
11
|
|
|
|
|
10271
|
@ARGV = @{$app->ARGV}; |
|
|
11
|
|
|
|
|
108
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
11
|
100
|
|
|
|
197
|
my $action = $app->unexpand ? \&ansi_unexpand : \&ansi_expand; |
|
78
|
|
|
|
|
|
|
|
|
79
|
11
|
|
|
|
|
1369
|
while (<>) { |
|
80
|
13
|
|
|
|
|
23655
|
print $action->($_); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
11
|
|
|
|
|
84660
|
return 0; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub list_tabstyle { |
|
87
|
0
|
|
|
0
|
0
|
|
my %style = %Text::ANSI::Fold::TABSTYLE; |
|
88
|
21
|
|
|
21
|
|
196
|
use List::Util 'max'; |
|
|
21
|
|
|
|
|
47
|
|
|
|
21
|
|
|
|
|
4057
|
|
|
89
|
0
|
|
|
|
|
|
my $max = max map length, keys %style; |
|
90
|
0
|
|
|
|
|
|
for my $name (sort keys %style) { |
|
91
|
0
|
|
|
|
|
|
my($head, $space) = @{$style{$name}}; |
|
|
0
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
printf "%*s %s%s\n", $max, $name, $head, $space x 7; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
__END__ |