line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::GentooFunctions; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.006001; |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
43904
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
218
|
|
6
|
6
|
|
|
6
|
|
15904
|
use utf8; |
|
6
|
|
|
|
|
156
|
|
|
6
|
|
|
|
|
36
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
6
|
|
|
6
|
|
844
|
eval "use Term::Size;"; my $old = $@; |
|
6
|
|
|
6
|
|
20
|
|
|
6
|
|
|
|
|
5003
|
|
|
6
|
|
|
|
|
456515
|
|
|
6
|
|
|
|
|
254
|
|
10
|
6
|
50
|
|
|
|
32
|
eval "use Term::Size::Win32" if $old; my $new = $@; |
|
6
|
|
|
|
|
12
|
|
11
|
6
|
50
|
33
|
|
|
45
|
die $old if $old and $new; |
12
|
6
|
50
|
|
|
|
158
|
die $new if $new; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
42
|
use Exporter; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
1081
|
|
16
|
6
|
|
|
6
|
|
8208
|
use Term::ANSIColor qw(:constants); |
|
6
|
|
|
|
|
77514
|
|
|
6
|
|
|
|
|
6421
|
|
17
|
6
|
|
|
6
|
|
6910
|
use Term::ANSIScreen qw(:cursor); |
|
6
|
|
|
|
|
15750
|
|
|
6
|
|
|
|
|
2382
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.3607'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw(einfo eerror ewarn ebegin eend eindent eoutdent einfon edie edo start_spinner step_spinner end_spinner equiet); |
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all=>[@EXPORT_OK]); |
23
|
|
|
|
|
|
|
|
24
|
6
|
|
|
6
|
|
47
|
use base qw(Exporter); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
847
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
BEGIN { |
27
|
|
|
|
|
|
|
# use Data::Dumper; |
28
|
|
|
|
|
|
|
# die Dumper(\%ENV) unless defined $ENV{RC_INDENTATION}; |
29
|
6
|
50
|
|
6
|
|
125
|
$ENV{RC_DEFAULT_INDENT} = 2 unless defined $ENV{RC_DEFAULT_INDENT}; |
30
|
6
|
50
|
|
|
|
7636
|
$ENV{RC_INDENTATION} = "" unless defined $ENV{RC_INDENTATION}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $quiet; |
34
|
|
|
|
|
|
|
sub equiet { |
35
|
1
|
50
|
|
1
|
0
|
753
|
$quiet = $_[0] if @_; |
36
|
1
|
|
|
|
|
2
|
return $quiet; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub edie(@) { |
40
|
0
|
0
|
|
0
|
0
|
0
|
my $msg = (@_>0 ? shift : $_); |
41
|
0
|
|
|
|
|
0
|
eerror($msg); |
42
|
0
|
|
|
|
|
0
|
eend(0); |
43
|
0
|
|
|
|
|
0
|
exit 0x65; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub einfon($) { |
47
|
0
|
|
|
0
|
0
|
0
|
my $msg = wash(shift); |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
0
|
return if $quiet; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
0
|
local $| = 1; |
52
|
0
|
|
|
|
|
0
|
print " ", BOLD, GREEN, "*", RESET, $msg; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub eindent() { |
56
|
6
|
|
33
|
6
|
0
|
1071
|
my $i = shift || $ENV{RC_DEFAULT_INDENT}; |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
|
|
40
|
$ENV{RC_INDENTATION} .= " " x $i; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub eoutdent() { |
62
|
34
|
|
33
|
34
|
0
|
439
|
my $i = shift || $ENV{RC_DEFAULT_INDENT}; |
63
|
|
|
|
|
|
|
|
64
|
34
|
|
|
|
|
193
|
$ENV{RC_INDENTATION} =~ s/ // for 1 .. $i; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub wash($) { |
68
|
18
|
|
|
18
|
0
|
31
|
my $msg = shift; |
69
|
18
|
|
|
|
|
54
|
$msg =~ s/^\s+//s; |
70
|
|
|
|
|
|
|
|
71
|
18
|
|
|
|
|
32
|
chomp $msg; |
72
|
18
|
|
|
|
|
63
|
return "$ENV{RC_INDENTATION} $msg"; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub einfo($) { |
76
|
15
|
|
|
15
|
0
|
569
|
my $msg = wash(shift); |
77
|
|
|
|
|
|
|
|
78
|
15
|
100
|
|
|
|
49
|
return if $quiet; |
79
|
14
|
|
|
|
|
299
|
print " ", BOLD, GREEN, "*", RESET, "$msg\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub ebegin($) { |
83
|
6
|
|
|
6
|
0
|
903
|
goto &einfo; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub eerror($) { |
87
|
1
|
|
|
1
|
0
|
794
|
my $msg = wash(shift); |
88
|
|
|
|
|
|
|
|
89
|
1
|
50
|
|
|
|
5
|
return if $quiet; |
90
|
1
|
|
|
|
|
22
|
print " ", BOLD, RED, "*", RESET, "$msg\n"; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub ewarn($) { |
94
|
2
|
|
|
2
|
0
|
354
|
my $msg = wash(shift); |
95
|
|
|
|
|
|
|
|
96
|
2
|
50
|
|
|
|
13
|
return if $quiet; |
97
|
2
|
|
|
|
|
49
|
print " ", BOLD, YELLOW, "*", RESET, "$msg\n"; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub eend(@) { |
101
|
6
|
100
|
|
6
|
0
|
499
|
my $res = (@_>0 ? shift : $_); |
102
|
|
|
|
|
|
|
|
103
|
6
|
100
|
|
|
|
23
|
return if $quiet; |
104
|
|
|
|
|
|
|
|
105
|
5
|
|
|
|
|
344
|
my ($columns, $rows) = eval 'Term::Size::chars *STDOUT{IO}'; |
106
|
5
|
50
|
|
|
|
23
|
($columns, $rows) = eval 'Term::Size::Win32::chars *STDOUT{IO}' if $@; |
107
|
|
|
|
|
|
|
|
108
|
5
|
50
|
|
|
|
18
|
die "couldn't find a term size function to use" if $@; |
109
|
|
|
|
|
|
|
|
110
|
5
|
100
|
|
|
|
52
|
print up(1), right($columns - 6), BOLD, BLUE, "[ ", |
111
|
|
|
|
|
|
|
($res ? GREEN."ok" : RED."!!"), |
112
|
|
|
|
|
|
|
BLUE, " ]", RESET, "\n"; |
113
|
|
|
|
|
|
|
|
114
|
5
|
|
|
|
|
1420
|
$res; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub edo($&) { |
118
|
1
|
|
|
1
|
0
|
11
|
my ($begin_msg, $code) = @_; |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
5
|
ebegin $begin_msg; |
121
|
1
|
|
|
|
|
5
|
eindent; |
122
|
1
|
|
|
|
|
2
|
my ($cr, @cr); |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
2
|
my $wa = wantarray; |
125
|
1
|
50
|
|
|
|
2
|
my $r = eval { if( $wa ) { @cr = $code->() } else { $cr = $code->() } 1 }; |
|
1
|
|
|
|
|
5
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
126
|
1
|
50
|
|
|
|
28
|
edie $@ unless $r; |
127
|
|
|
|
|
|
|
|
128
|
1
|
|
|
|
|
3
|
eoutdent; |
129
|
1
|
|
|
|
|
4
|
eend 1; |
130
|
|
|
|
|
|
|
|
131
|
1
|
50
|
|
|
|
3
|
return @cr if $wa; |
132
|
1
|
|
|
|
|
5
|
return $cr; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
{ |
136
|
|
|
|
|
|
|
my $spinner_state; |
137
|
|
|
|
|
|
|
my $spinner_msg; |
138
|
|
|
|
|
|
|
sub start_spinner($) { |
139
|
0
|
|
|
0
|
0
|
|
my $msg = wash(shift); |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
$spinner_state = "-"; |
142
|
0
|
|
|
|
|
|
$spinner_msg = $msg; |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
einfon $spinner_msg; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $spinext = {"-"=>'\\', '\\'=>'|', "|"=>"/", "/"=>"-"}; |
148
|
|
|
|
|
|
|
sub step_spinner(;$) { |
149
|
|
|
|
|
|
|
# NOTE: really I should use savepost and clline from ANSIScreen, but he doesn't have [0G at all. Meh |
150
|
|
|
|
|
|
|
|
151
|
0
|
0
|
|
0
|
0
|
|
return if $quiet; |
152
|
0
|
|
|
|
|
|
print "\e[0G\e[K"; |
153
|
|
|
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
if( $_[0] ) { |
155
|
0
|
|
|
|
|
|
einfon("$spinner_msg $spinner_state ... $_[0]"); |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} else { |
158
|
0
|
|
|
|
|
|
einfon("$spinner_msg $spinner_state "); |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$spinner_state = $spinext->{$spinner_state}; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub end_spinner($) { |
165
|
0
|
0
|
|
0
|
0
|
|
return if $quiet; |
166
|
0
|
|
|
|
|
|
print "\e[0G\e[K"; |
167
|
0
|
|
|
|
|
|
einfo $spinner_msg; |
168
|
0
|
|
|
|
|
|
goto &eend; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
"this file is true"; |