Commit 877a6a7a authored by Jacek Sowiński's avatar Jacek Sowiński

Safer way to display base 16 colors

parent 2a03b582
......@@ -45,6 +45,11 @@ class Colors(object):
decoration = decoration_dict[p_decorator]
try:
if 8 > int(p_int) >=0:
return '\033[{};3{}m'.format(decoration, str(p_int))
elif 16 > int(p_int):
p_int = int(p_int) - 8
return '\033[{};9{}m'.format(decoration, str(p_int))
if 256 > int(p_int) >=0:
return '\033[{};38;5;{}m'.format(decoration, str(p_int))
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment