line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::ANSI::Printf; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "2.01"; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
10571
|
use v5.14; |
|
5
|
|
|
|
|
35
|
|
6
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
104
|
|
7
|
5
|
|
|
5
|
|
19
|
use Carp; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
400
|
|
8
|
|
|
|
|
|
|
|
9
|
5
|
|
|
5
|
|
28
|
use Exporter 'import'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
497
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(&ansi_printf &ansi_sprintf); |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
1
|
0
|
sub ansi_printf { &printf (@_) } |
13
|
18
|
|
|
18
|
1
|
7493
|
sub ansi_sprintf { &sprintf(@_) } |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
|
2132
|
use Text::Conceal; |
|
5
|
|
|
|
|
181757
|
|
|
5
|
|
|
|
|
193
|
|
16
|
5
|
|
|
5
|
|
1877
|
use Text::ANSI::Fold::Util qw(ansi_width); |
|
5
|
|
|
|
|
3456
|
|
|
5
|
|
|
|
|
410
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub sprintf { |
19
|
78
|
|
|
78
|
1
|
27621
|
my($format, @args) = @_; |
20
|
78
|
|
|
|
|
456
|
my $conceal = Text::Conceal->new( |
21
|
|
|
|
|
|
|
except => $format, |
22
|
|
|
|
|
|
|
test => qr/[\e\b\P{ASCII}]/, |
23
|
|
|
|
|
|
|
length => \&ansi_width, |
24
|
|
|
|
|
|
|
max => int @args, |
25
|
|
|
|
|
|
|
); |
26
|
78
|
50
|
|
|
|
3395
|
$conceal->encode(@args) if $conceal; |
27
|
78
|
|
|
|
|
79701
|
my $s = CORE::sprintf $format, @args; |
28
|
78
|
50
|
|
|
|
334
|
$conceal->decode($s) if $conceal; |
29
|
78
|
|
|
|
|
6902
|
$s; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub printf { |
33
|
0
|
0
|
|
0
|
1
|
|
my $fh = ref($_[0]) =~ /^(?:GLOB|IO::)/ ? shift : select; |
34
|
0
|
|
|
|
|
|
$fh->print(&sprintf(@_)); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |