-
Notifications
You must be signed in to change notification settings - Fork 9
/
colormake-vvtk.pl
executable file
·167 lines (157 loc) · 4.63 KB
/
colormake-vvtk.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/perl
#
# colormake.pl 0.3
#
# Copyright: (C) 1999, Bjarni R. Einarsson <bre@netverjar.is>
# http://bre.klaki.net/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Some useful color codes, see end of file for more.
#
$col_ltgray = "\033[37m";
$col_purple = "\033[35m";
$col_green = "\033[32m";
$col_cyan = "\033[36m";
$col_enter= "\e[0;36m";
$col_leave = "\e[1;36m";
$col_brown = "\033[33m";
$col_red = "\033[31m";
$col_norm = "\033[00m";
$col_background = "\033[07m";
$col_brighten = "\033[01m";
$col_underline = "\033[04m";
$col_blink = "\033[05m";
# Customize colors here...
#
$col_default = $col_ltgray;
#$col_gcc = $col_purple . $col_brighten;
$col_make_enter = $col_enter;
$col_make_leave = $col_leave;
#$col_filename = $col_brown;
#$col_linenum = $col_cyan;
$col_trace = $col_brown;
$col_warning = $col_green;
#$tag_error = "Error: ";
$col_error = $tag_error . $col_red . $col_brighten;
#$error_highlight = $col_brighten;
# Get size of terminal
#
$lines = shift @ARGV || 0;
$cols = shift @ARGV || 0;
$cols -= 19;
$in = 'unknown';
while (<>)
{
$orgline = $thisline = $_;
# Truncate lines.
# I suppose this is bad, but it's better than what less does!
if ($cols >= 0)
{
$thisline =~ s/^(.{$cols}).....*(.{15})$/$1 .. $2/;
}
# make[1]: Entering directory `/blah/blah/blah'
#if ($thisline =~ s/^((p|g)?make\[)/$col_make$1/x)
#{
# $in = 'make';
# }
elsif ($thisline =~ s/^((g?cc|(g|c)\+\+).*)$/$col_gcc$1$col_norm/)
{
$in = 'gcc';
}
elsif ($thisline =~ /^(\(|\[|a(r|wk)|c(p|d|h(mod|own))|do(ne)?|e(cho|lse)|f(ind|or)|i(f|nstall)|mv|perl|r(anlib|m(dir)?)|s(e(d|t)|trip)|tar|Compile)\s+/)
{
$in = $1;
}
elsif ($thisline =~ /^((p|g)?make\[.*Entering directory)/)
{
$thisline =~ s/^((p|g)?make\[)/$col_make_enter$1/x;
}
elsif ($thisline =~ /^((p|g)?make\[.*Leaving directory)/)
{
$thisline =~ s/^((p|g)?make\[)/$col_make_leave$1/x;
}
elsif ($thisline =~ /warning:/)
{
#$thisline =~ s|(warning:\s+)(.*)$|$1$col_warning$2|;
$thisline =~ s|(\s+)(.*)$|$1$col_warning$2|;
}
elsif ($thisline =~ /WARNING:/)
{
$thisline =~ s|(\s+)(.*)$|$1$col_brown$2|;
}
elsif ($thisline =~ /error:/)
{
$thisline =~ s/(\d+:\s+)/$1$col_default$col_error/;
$thisline = $error_highlight . $thisline . $col_norm;
}
elsif ($thisline =~ /undefined /)
{
$thisline =~ s/(\d+:\s+)/$1$col_default$col_error/;
$thisline = $error_highlight . $thisline . $col_norm;
}
# elsif ($in eq 'gcc' or $in eq 'Compile')
# {
# # Do interesting things if make is compiling something.
#
# #if (($thisline !~ /[,:]$/) && ($thisline !~ /warning/))
#
# if ($thisline =~ /error/)
# {
# # error?
# if ($cols >= 0)
# {
# # Retruncate line, because we are about to insert "Error:".
# my $c = $cols - length($tag_error);
# $thisline = $orgline;
# $thisline =~ s/^(.{$c}).....*(.{15})$/$1 .. $2/;
# }
# $thisline =~ s/(\d+:\s+)/$1$col_default$col_error/;
# $thisline = $error_highlight . $thisline . $col_norm;
# }
# elsif ($thisline =~ /warning/)
# {
# # warning
# $thisline =~ s|(warning:\s+)(.*)$|$1$col_warning$2|;
# }
#
# # In file included from main.cpp:38:
# # main.cpp: In function int main(...)':
# $thisline =~ s/(In f(unction|ile))/$col_trace$1/x;
#
# # /blah/blah/blah.cpp:123:
# $thisline =~ s|^([^:]+)|$col_filename$1$col_default|;
# $thisline =~ s|:(\d+)([:,])|:$col_linenum$1$col_default$2|;
# }
if ($thisline !~ /^\s+/)
{
print $col_norm, $col_default;
}
print $thisline;
}
print $col_norm;
# UNUSED:
#
#%colors = (
# 'black' => "\033[30m",
# 'red' => "\033[31m",
# 'green' => "\033[32m",
# 'yellow' => "\033[33m",
# 'blue' => "\033[34m",
# 'magenta' => "\033[35m",
# 'purple' => "\033[35m",
# 'cyan' => "\033[36m",
# 'white' => "\033[37m",
# 'darkgray' => "\033[30m");