Changeset 601
- Timestamp:
- 17/04/09 23:24:25 (11 months ago)
- Files:
-
- 1 modified
-
cly/trunk/cly/console.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cly/trunk/cly/console.py
r600 r601 35 35 36 36 __all__ = """ 37 cwrite getch cerror cfatal register_codec cinfo cjustify clen cprint c printstrip38 c splice cwarning cwraptext print_table rjustify termheight termwidth wraptoterm37 cwrite getch cerror cfatal register_codec cinfo cjustify clen cprint csplice 38 cwarning cwraptext print_table rjustify termheight termwidth wraptoterm cstrip 39 39 cencode cdecode 40 40 """.split() … … 45 45 _decode_re = re.compile(r'\^([N0-7BU])|[^^]+|\^') 46 46 _encode_re = re.compile(r'\033(?:[^[]|$)|\033\[(.*?)m') 47 _c print_strip= re.compile(r'\^([N0-7BU])')47 _cstrip_re = re.compile(r'\^([N0-7BU])') 48 48 _cwrap_re = re.compile(r'(\n)|(\s+)|((?:\^[N0-7BU]|\S)+\b[^\n^\w]*)|(.)') 49 49 _terminal_type = None … … 57 57 58 58 def mono_cwrite(io, text): 59 io.write(_c print_strip.sub('', text))59 io.write(_cstrip_re.sub('', text)) 60 60 61 61 … … 336 336 337 337 338 def c printstrip(*args):339 """ As with cprint, but strip colour codes."""340 return _c print_strip.sub('', ' '.join(map(str, args)))338 def cstrip(text): 339 """Strip colour codes from text.""" 340 return _cstrip_re.sub('', text) 341 341 342 342 343 343 def clen(arg): 344 344 """Return the length of arg after colour codes are stripped.""" 345 return len(c printstrip(arg))345 return len(cstrip(arg)) 346 346 347 347
