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
|
# File 'lib/console.rb', line 13
def col color = "white", background = "black", keep_style = false
backgrounds = {
"grey"=>40,
"red"=>41,
"darkgreen"=>42,
"yellow"=>43,
"blue"=>44,
"purple"=>45,
"cyan"=> 46,
"white"=>47,
"black"=>49,
"white"=>47
}
colors = {
"black" => 30,
"bold" => 1,
"uscore" => 4,
"green" => 32,
"grey" => 30,
"red" => 31,
"darkgreen" => 32,
"yellow" => 33,
"blue" => 34,
"purple" => 35,
"cyan" => 36
}
if color and background
"\033[1;" + colors[color].to_s + ";" +
backgrounds[background].to_s + "m" +
self + ("\033[m" if not keep_style).to_s
else
self
end
end
|