line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Color::Output; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6634
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
223
|
|
4
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
92
|
|
5
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
62
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 1.05; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
1
|
|
|
1
|
|
6
|
use Exporter (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
11
|
1
|
|
|
1
|
|
2
|
our (@ISA, @EXPORT); |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
15
|
@ISA = qw(Exporter); |
14
|
1
|
|
|
|
|
1567
|
@EXPORT = qw(&cprint &cprintf &clear); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my ($_Mode, $_Console); |
19
|
|
|
|
|
|
|
my ($_Symbol) = "\x03"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our ($Mode, $Symbol); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub Init { |
25
|
0
|
0
|
|
0
|
1
|
|
if (defined $_Mode) { |
26
|
0
|
|
|
|
|
|
carp "You already ran Init!"; |
27
|
0
|
|
|
|
|
|
return; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
0
|
|
|
|
|
$_Symbol = $Symbol, if (defined $Symbol); |
30
|
0
|
|
|
|
|
|
$_Mode = 0; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
0
|
|
|
|
if (defined $Mode && $Mode =~ /^\d+$/) { |
33
|
0
|
0
|
0
|
|
|
|
if ($Mode == 1 || $Mode == 2) { $_Mode = $Mode; } |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ($^O =~ /Win32/) { |
37
|
0
|
0
|
0
|
|
|
|
$_Mode = 2, unless (defined $_Mode and $_Mode == 1); |
38
|
0
|
0
|
|
|
|
|
if ($_Mode == 1) { |
|
|
0
|
|
|
|
|
|
39
|
0
|
|
|
0
|
|
|
*clear = sub { system("cls"); }; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
elsif ($_Mode == 2) { |
42
|
|
|
|
|
|
|
*clear = sub { |
43
|
0
|
|
|
0
|
|
|
$_Console->Cls(); |
44
|
0
|
|
|
|
|
|
$_Console->Display(); |
45
|
0
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
0
|
0
|
0
|
|
|
|
$_Mode = 1, unless (defined $_Mode and $_Mode == 2); |
50
|
|
|
|
|
|
|
*clear = sub { |
51
|
0
|
|
|
0
|
|
|
system("clear"); |
52
|
0
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
if ($_Mode == 1) { &Init_ANSI(); } |
|
0
|
0
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
elsif ($_Mode == 2) { &Init_Console(); } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
################################################################################ |
62
|
|
|
|
|
|
|
# ANSI-PART # |
63
|
|
|
|
|
|
|
################################################################################ |
64
|
|
|
|
|
|
|
sub Init_ANSI { |
65
|
0
|
|
|
0
|
0
|
|
my @List = qw(0m 30m 34m 34;1m 31m 31;1m 32m 32;1m 35m 35;1m 36m 36;1m 33m 33;1m 37m 37;1m); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
*cprint = sub { |
68
|
0
|
|
|
0
|
|
|
my ($String); |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
0
|
|
|
|
if (defined $_[0] and ref $_[0]) { |
71
|
0
|
0
|
0
|
|
|
|
shift, unless (ref $_[0] eq 'ARRAY' || ref $_[0] eq 'HASH' || ref $_[0] eq 'SCALAR' || ref $_[0] eq 'CODE' || ref $_[0] eq 'GLOB'); |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ($#_ >= 0) { $String = join ("", @_); } |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
else { $String = $_; } |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$String =~ s/$_Symbol(\s|\D|$)/${_Symbol}0$1/g; |
78
|
0
|
|
|
|
|
|
$String =~ s/$_Symbol(\d\d?)/\033[$List[$1]/g; |
79
|
0
|
|
|
|
|
|
print $String; |
80
|
0
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
*cprintf = sub { |
83
|
0
|
|
|
0
|
|
|
my ($String); |
84
|
0
|
0
|
|
|
|
|
if ($#_ >= 0) { $String = shift; $String = sprintf ($String, @_); } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
else { $String = $_; } |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$String =~ s/$_Symbol(\s|\D|$)/${_Symbol}0$1/g; |
88
|
0
|
|
|
|
|
|
$String =~ s/$_Symbol(\d\d?)/\033[$List[$1]/g; |
89
|
0
|
|
|
|
|
|
printf $String; |
90
|
0
|
|
|
|
|
|
}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
END { |
95
|
|
|
|
|
|
|
# Reset text-color. |
96
|
|
|
|
|
|
|
|
97
|
1
|
50
|
33
|
1
|
|
225
|
if (defined $_Mode && $_Mode == 1) { |
98
|
0
|
|
|
|
|
|
printf "\033[0m"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
################################################################################ |
103
|
|
|
|
|
|
|
# W32::Console-PART # |
104
|
|
|
|
|
|
|
################################################################################ |
105
|
|
|
|
|
|
|
sub Init_Console { |
106
|
0
|
0
|
|
0
|
0
|
|
eval { |
107
|
0
|
|
|
|
|
|
require Win32::Console; |
108
|
|
|
|
|
|
|
} or croak $@; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
import Win32::Console qw(STD_OUTPUT_HANDLE); |
111
|
0
|
|
|
|
|
|
$_Console = new Win32::Console(&STD_OUTPUT_HANDLE()); |
112
|
|
|
|
|
|
|
# $_Console = new Win32::Console(); |
113
|
0
|
|
|
|
|
|
my @List = qw(7 0 1 9 4 12 2 10 5 13 3 11 6 14 7 15); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
*cprint = sub { |
116
|
0
|
|
|
0
|
|
|
my ($String); |
117
|
|
|
|
|
|
|
|
118
|
0
|
0
|
0
|
|
|
|
if (defined $_[0] and ref $_[0]) { |
119
|
0
|
0
|
0
|
|
|
|
shift, unless (ref $_[0] eq 'ARRAY' || ref $_[0] eq 'HASH' || ref $_[0] eq 'SCALAR' || ref $_[0] eq 'CODE' || ref $_[0] eq 'GLOB'); |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if ($#_ >= 0) { $String = join ("", @_); } |
|
0
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
else { $String = $_; } |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
ccprint($String, 1); |
126
|
0
|
|
|
|
|
|
}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
*cprintf = sub { |
129
|
0
|
|
|
0
|
|
|
my ($String); |
130
|
0
|
0
|
|
|
|
|
if ($#_ >= 0) { $String = shift; $String = sprintf ($String, @_); } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
else { $String = $_; } |
132
|
0
|
|
|
|
|
|
ccprint($String, 0); |
133
|
0
|
|
|
|
|
|
}; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
*ccprint = sub { |
136
|
0
|
|
|
0
|
|
|
my ($String) = shift; |
137
|
0
|
|
|
|
|
|
my ($Option) = shift; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$String =~ s/$_Symbol(\s|\D|$)/${_Symbol}0$1/g; |
140
|
0
|
|
|
|
|
|
my ($First, $Last) = $String =~ /^(.*?)(?:$_Symbol|$)/s; |
141
|
0
|
0
|
|
|
|
|
$_Console->Write($First), if (defined $First); |
142
|
0
|
0
|
0
|
|
|
|
$_Console->Write("\n"), if (defined $First and defined $Last); |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
while ($String =~ /$_Symbol(\d\d?)([^$_Symbol]*)/g) { |
145
|
0
|
|
|
|
|
|
$_Console->Attr($List[$1]); |
146
|
0
|
|
|
|
|
|
$_Console->Write($2); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
0
|
0
|
0
|
|
|
|
if ($Option && defined $\) { $_Console->Write($\ . ""); } |
|
0
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
$_Console->Display(); |
151
|
0
|
|
|
|
|
|
}; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
157
|
|
|
|
|
|
|
__END__ |