Check tweet length
[rainbowstream.git] / rainbowstream / colors.py
CommitLineData
6fa09c14
VNM
1def basic_color(code):
2 """
3 16 colors supported
4 """
be4dba0e 5 def inner(text, rl=False):
9ee4a3cc
O
6 """
7 Every raw_input with color sequences should be called with
8 rl=True to avoid readline messed up the length calculation
9 """
533edcdb 10 c = code
be4dba0e 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)
533edcdb 15 return inner
8c840a83 16
6fa09c14 17
37ae740e 18def term_color(code):
6fa09c14
VNM
19 """
20 256 colors supported
21 """
be4dba0e 22 def inner(text, rl=False):
9ee4a3cc
O
23 """
24 Every raw_input with color sequences should be called with
25 rl=True to avoid readline messed up the length calculation
26 """
6fa09c14 27 c = code
be4dba0e 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)
6fa09c14
VNM
32 return inner
33
34
531f5682
O
35"""
3616 basic colors
37"""
c075e6dc
O
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')
6fa09c14 54
531f5682
O
55"""
5616 basic colors on background
57"""
c075e6dc
O
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')
6fa09c14 71on_light_magenta = basic_color('105')
c075e6dc
O
72on_light_cyan = basic_color('106')
73on_white = basic_color('107')