Use entities/urls in open command
[rainbowstream.git] / rainbowstream / colors.py
... / ...
CommitLineData
1def basic_color(code):
2 """
3 16 colors supported
4 """
5 def inner(text, rl=False):
6 """
7 Every raw_input with color sequences should be called with
8 rl=True to avoid readline messed up the length calculation
9 """
10 c = code
11 if rl:
12 return "\001\033[%sm\002%s\001\033[0m\002" % (c, text)
13 else:
14 return "\033[%sm%s\033[0m" % (c, text)
15 return inner
16
17
18def term_color(code):
19 """
20 256 colors supported
21 """
22 def inner(text, rl=False):
23 """
24 Every raw_input with color sequences should be called with
25 rl=True to avoid readline messed up the length calculation
26 """
27 c = code
28 if rl:
29 return "\001\033[38;5;%sm\002%s\001\033[0m\002" % (c, text)
30 else:
31 return "\033[38;5;%sm%s\033[0m" % (c, text)
32 return inner
33
34
35"""
3616 basic colors
37"""
38default = basic_color('39')
39black = basic_color('30')
40red = basic_color('31')
41green = basic_color('32')
42yellow = basic_color('33')
43blue = basic_color('34')
44magenta = basic_color('35')
45cyan = basic_color('36')
46grey = basic_color('90')
47light_red = basic_color('91')
48light_green = basic_color('92')
49light_yellow = basic_color('93')
50light_blue = basic_color('94')
51light_magenta = basic_color('95')
52light_cyan = basic_color('96')
53white = basic_color('97')
54
55"""
5616 basic colors on background
57"""
58on_default = basic_color('49')
59on_black = basic_color('40')
60on_red = basic_color('41')
61on_green = basic_color('42')
62on_yellow = basic_color('43')
63on_blue = basic_color('44')
64on_magenta = basic_color('45')
65on_cyan = basic_color('46')
66on_grey = basic_color('100')
67on_light_red = basic_color('101')
68on_light_green = basic_color('102')
69on_light_yellow = basic_color('103')
70on_light_blue = basic_color('104')
71on_light_magenta = basic_color('105')
72on_light_cyan = basic_color('106')
73on_white = basic_color('107')