line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
377
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
23
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
103
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package OptArgs2::StatusLine { |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @CARP_NOT; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub _croak { |
9
|
0
|
|
|
0
|
|
0
|
@CARP_NOT = (__PACKAGE__); |
10
|
0
|
|
|
|
|
0
|
require Carp; |
11
|
0
|
|
|
|
|
0
|
Carp::croak(@_); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub import { |
15
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
302
|
|
16
|
3
|
|
|
3
|
|
17
|
my $class = shift; |
17
|
3
|
|
|
|
|
5
|
my $caller = scalar caller; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
26
|
while (@_) { |
20
|
3
|
|
|
|
|
6
|
my ( $l, $p ) = ( shift, shift ); |
21
|
|
|
|
|
|
|
|
22
|
3
|
50
|
|
|
|
15
|
if ( $l =~ s/^\$(.*)// ) { |
23
|
3
|
|
|
|
|
8
|
$l = $caller . '::' . $1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
0
|
|
|
|
|
0
|
die 'first argument must be like "$scalar"'; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
4
|
my $x; |
30
|
3
|
100
|
100
|
|
|
13
|
if ( defined $p && $p =~ s/^\$(.*)// ) { |
31
|
1
|
|
|
|
|
3
|
my $o = make_line_prefix( $x, my $y ); |
32
|
1
|
|
|
|
|
2
|
$p = $caller . '::' . $1; |
33
|
1
|
|
|
|
|
1
|
*{$p} = \$y; |
|
1
|
|
|
|
|
3
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
2
|
|
|
|
|
5
|
make_line( $x, $p ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
4
|
*{$l} = \$x; |
|
3
|
|
|
|
|
47
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub make_line { |
44
|
2
|
|
|
2
|
0
|
5
|
my $o = tie $_[0], 'OptArgs2::StatusLine::Line'; |
45
|
2
|
|
100
|
|
|
10
|
$o->{prefix} = $_[1] // ''; |
46
|
2
|
|
|
|
|
3
|
$o; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub make_line_prefix { |
50
|
1
|
|
|
1
|
0
|
3
|
my $o = tie $_[0], 'OptArgs2::StatusLine::Line'; |
51
|
1
|
|
|
|
|
3
|
tie $_[1], 'OptArgs2::StatusLine::Prefix', $o; |
52
|
1
|
|
|
|
|
2
|
$o; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
package OptArgs2::StatusLine::Line { |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub TIESCALAR { |
59
|
3
|
|
|
3
|
|
3
|
my $class = shift; |
60
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
340
|
|
61
|
3
|
|
|
|
|
10
|
bless { |
62
|
|
|
|
|
|
|
prefix => '', |
63
|
|
|
|
|
|
|
val => undef, |
64
|
|
|
|
|
|
|
}, $class; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub FETCH { |
68
|
21
|
|
|
21
|
|
3809
|
my $self = shift; |
69
|
21
|
|
|
|
|
83
|
$self->{val}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub STORE { |
73
|
10
|
|
|
10
|
|
5792
|
my $self = shift; |
74
|
10
|
|
50
|
|
|
29
|
$self->{val} = shift // return; |
75
|
10
|
50
|
|
|
|
20
|
return if not defined $self->{val}; |
76
|
|
|
|
|
|
|
|
77
|
10
|
50
|
|
|
|
26
|
my $NL = $self->{val} =~ s/\n\z// ? 1 : 0; |
78
|
10
|
|
|
|
|
21
|
my $fh = select; |
79
|
|
|
|
|
|
|
|
80
|
10
|
50
|
|
|
|
57
|
if ( -t $fh ) { |
81
|
|
|
|
|
|
|
$fh->printflush( $self->{prefix} |
82
|
0
|
0
|
|
|
|
0
|
. $self->{val} . "\e[K" |
83
|
|
|
|
|
|
|
. ( $NL ? "\n" : "\r" ) ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else { |
86
|
10
|
|
|
|
|
63
|
$fh->print( $self->{prefix} . $self->{val} . "\n" ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
10
|
50
|
|
|
|
374
|
$self->{val} = '' if $NL; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
package OptArgs2::StatusLine::Prefix { |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub TIESCALAR { |
96
|
1
|
|
|
1
|
|
3
|
my ( $class, $line ) = @_; |
97
|
1
|
|
|
|
|
2
|
bless \$line, $class; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub FETCH { |
101
|
3
|
|
|
3
|
|
21
|
my $self = shift; |
102
|
3
|
|
|
|
|
12
|
$$self->{prefix}; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub STORE { |
106
|
1
|
|
|
1
|
|
604
|
my $self = shift; |
107
|
1
|
|
|
|
|
7
|
my $o = $$self; |
108
|
1
|
|
|
|
|
3
|
my $was_defined = defined $o->{prefix}; |
109
|
1
|
|
|
|
|
3
|
$o->{prefix} = shift; |
110
|
1
|
50
|
33
|
|
|
10
|
$o->STORE( $o->{val} ) if defined $o->{prefix} and $was_defined; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
__END__ |