| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PerlIO::via::ANSIColor; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19170
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
32
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
427
|
|
|
5
|
|
|
|
|
|
|
require Term::ANSIColor; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
8
|
|
|
|
|
|
|
my $color = 'red'; |
|
9
|
|
|
|
|
|
|
my $reset = Term::ANSIColor::color('reset'); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub import { |
|
12
|
1
|
|
|
1
|
|
14
|
my( $class, %param ) = @_; |
|
13
|
1
|
|
|
|
|
17
|
$class->$_( $param{$_} ) foreach keys %param; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub color { |
|
17
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
18
|
0
|
|
|
|
|
|
my $new_color = shift; |
|
19
|
0
|
0
|
|
|
|
|
if ( defined $new_color ) { |
|
20
|
0
|
|
|
|
|
|
eval { Term::ANSIColor::color($new_color) }; |
|
|
0
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
$color = $new_color unless $@; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
0
|
|
|
|
|
|
return $color; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub paint { |
|
27
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
28
|
0
|
|
|
|
|
|
my $fh = shift; |
|
29
|
0
|
|
|
|
|
|
my $new_color = shift; |
|
30
|
0
|
0
|
|
|
|
|
return unless $fh; |
|
31
|
0
|
0
|
|
|
|
|
$self->color($new_color) if $new_color; |
|
32
|
0
|
|
|
|
|
|
binmode $fh, ':via(ANSIColor)'; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub PUSHED { |
|
36
|
0
|
|
|
0
|
1
|
|
bless { color => Term::ANSIColor::color($color) }, $_[0]; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub FILL { |
|
40
|
0
|
|
|
0
|
1
|
|
my $color = $_[0]->{color}; |
|
41
|
0
|
0
|
|
|
|
|
if ( defined( my $line = readline( $_[1] ) ) ) { |
|
42
|
0
|
|
|
|
|
|
return $color . $line . $reset; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
0
|
|
|
|
|
|
undef; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub WRITE { |
|
48
|
0
|
|
|
0
|
|
|
my $color = $_[0]->{color}; |
|
49
|
0
|
|
|
|
|
|
my $str = $_[1]; |
|
50
|
0
|
0
|
|
|
|
|
if ($str =~ /\n$/ ) { |
|
51
|
0
|
|
|
|
|
|
chomp $str; |
|
52
|
0
|
0
|
|
|
|
|
print { $_[2] } $color . $str . $reset . "\n" or return -1; |
|
|
0
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
else { |
|
55
|
0
|
0
|
|
|
|
|
print { $_[2] } $color . $_[1] . $reset or return -1; |
|
|
0
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
|
57
|
0
|
|
|
|
|
|
length $_[1]; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |