projects
/
rainbowstream.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bumped version 1.5.2
[rainbowstream.git]
/
rainbowstream
/
colors.py
diff --git
a/rainbowstream/colors.py
b/rainbowstream/colors.py
index 159244d56f5ce2203a23d41b6dd3c0b8626255b9..a39dcb6b0c41ac9d78e1495c27e92bf4cda17d56 100644
(file)
--- a/
rainbowstream/colors.py
+++ b/
rainbowstream/colors.py
@@
-1,26
+1,40
@@
-
def basic_color(code):
"""
16 colors supported
"""
def basic_color(code):
"""
16 colors supported
"""
- def inner(text, bold=True):
+ def inner(text, rl=False):
+ """
+ Every raw_input with color sequences should be called with
+ rl=True to avoid readline messed up the length calculation
+ """
c = code
c = code
- if bold:
- c = "1;%s" % c
- return "\033[%sm%s\033[0m" % (c, text)
+ if rl:
+ return "\001\033[%sm\002%s\001\033[0m\002" % (c, text)
+ else:
+ return "\033[%sm%s\033[0m" % (c, text)
return inner
return inner
-def
RGB
(code):
+def
term_color
(code):
"""
256 colors supported
"""
"""
256 colors supported
"""
- def inner(text):
+ def inner(text, rl=False):
+ """
+ Every raw_input with color sequences should be called with
+ rl=True to avoid readline messed up the length calculation
+ """
c = code
c = code
- return "\033[38;5;%sm%s\033[0m" % (c, text)
+ if rl:
+ return "\001\033[38;5;%sm\002%s\001\033[0m\002" % (c, text)
+ else:
+ return "\033[38;5;%sm%s\033[0m" % (c, text)
return inner
return inner
+"""
+16 basic colors
+"""
default = basic_color('39')
black = basic_color('30')
red = basic_color('31')
default = basic_color('39')
black = basic_color('30')
red = basic_color('31')
@@
-38,6
+52,9
@@
light_magenta = basic_color('95')
light_cyan = basic_color('96')
white = basic_color('97')
light_cyan = basic_color('96')
white = basic_color('97')
+"""
+16 basic colors on background
+"""
on_default = basic_color('49')
on_black = basic_color('40')
on_red = basic_color('41')
on_default = basic_color('49')
on_black = basic_color('40')
on_red = basic_color('41')