"""
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
- if bold:
- c = "1;%s" % c
- return "\001\033[%sm\002%s\001\033[0m\002" % (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
"""
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
- return "\001\033[38;5;%sm\002%s\001\033[0m\002" % (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