[] and id=
[rainbowstream.git] / rainbowstream / colors.py
1 def basic_color(code):
2 """
3 16 colors supported
4 """
5 def inner(text, bold=True):
6 c = code
7 if bold:
8 c = "1;%s" % c
9 return "\033[%sm%s\033[0m" % (c, text)
10 return inner
11
12
13 def term_color(code):
14 """
15 256 colors supported
16 """
17 def inner(text):
18 c = code
19 return "\033[38;5;%sm%s\033[0m" % (c, text)
20 return inner
21
22
23 """
24 16 basic colors
25 """
26 default = basic_color('39')
27 black = basic_color('30')
28 red = basic_color('31')
29 green = basic_color('32')
30 yellow = basic_color('33')
31 blue = basic_color('34')
32 magenta = basic_color('35')
33 cyan = basic_color('36')
34 grey = basic_color('90')
35 light_red = basic_color('91')
36 light_green = basic_color('92')
37 light_yellow = basic_color('93')
38 light_blue = basic_color('94')
39 light_magenta = basic_color('95')
40 light_cyan = basic_color('96')
41 white = basic_color('97')
42
43 """
44 16 basic colors on background
45 """
46 on_default = basic_color('49')
47 on_black = basic_color('40')
48 on_red = basic_color('41')
49 on_green = basic_color('42')
50 on_yellow = basic_color('43')
51 on_blue = basic_color('44')
52 on_magenta = basic_color('45')
53 on_cyan = basic_color('46')
54 on_grey = basic_color('100')
55 on_light_red = basic_color('101')
56 on_light_green = basic_color('102')
57 on_light_yellow = basic_color('103')
58 on_light_blue = basic_color('104')
59 on_light_magenta = basic_color('105')
60 on_light_cyan = basic_color('106')
61 on_white = basic_color('107')