Add forgotten file from previous commit.

This commit is contained in:
Todd Gamblin 2015-10-13 10:35:19 -07:00
parent 2c81875019
commit d16095c856

View File

@ -158,6 +158,11 @@ def clen(string):
return len(re.sub(r'\033[^m]*m', '', string)) return len(re.sub(r'\033[^m]*m', '', string))
def cextra(string):
""""Length of extra color characters in a string"""
return len(''.join(re.findall(r'\033[^m]*m', string)))
def cwrite(string, stream=sys.stdout, color=None): def cwrite(string, stream=sys.stdout, color=None):
"""Replace all color expressions in string with ANSI control """Replace all color expressions in string with ANSI control
codes and write the result to the stream. If color is codes and write the result to the stream. If color is