Changeset 405
- Timestamp:
- 05/01/07 22:43:40 (2 years ago)
- Files:
-
- pycrash/trunk/crash/console.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
pycrash/trunk/crash/console.py
r404 r405 5 5 __cprint_re = re.compile(r'''[^^]+|\^([N0-7BU])''') 6 6 __cprint_strip = re.compile(r'''\^([N0-7BU])''') 7 __cwrap_re = re.compile(r'''(\n)|(\s+)|((?:\^[N0-7BU]|\S)+\b[^\n^\w]*)''') 7 8 __colour_terminal = 0 8 9 … … 95 96 return curses.tigetnum('cols') 96 97 except: 97 return 'COLUMNS' in os.environ and int(os.environ['COLUMNS']) or 8098 return int(os.environ.get('COLUMNS', 80)) 98 99 99 100 def termheight(): … … 102 103 return curses.tigetnum('lines') 103 104 except: 104 return 'LINES' in os.environ and int(os.environ['LINES']) or 25105 return int(os.environ.get('LINES', 25)) 105 106 106 107 def csplice(text, start = 0, end = -1): … … 133 134 return out 134 135 135 __cwrap_re = re.compile(r'''(\n)|(\s+)|((?:\^[N0-7BU]|\S)+\b[^\n^\w]*)''')136 136 def cwraptext(rtext, width = termwidth(), subsequent_indent = ''): 137 137 """ Wrap multi-line text to width (defaults to termwidth()) """ … … 189 189 header, if specified, will be printed as the first row. sep is the 190 190 separator between columns. 191 191 192 192 auto_format is a list specifying the formatting colours to use for each 193 193 row. The first element is the header colour, subsequent elements are … … 196 196 expand_to_fit signifies whether print_table should expand the table to the 197 197 width of the terminal. 198 198 199 199 Note: print_table supports the ^R formatting code, in addition to those 200 200 supported by cprint, which corresponds to the colour formatting of the … … 221 221 if col == mincol: 222 222 colwidths[0] += termwidth() - sum(colwidths) 223 223 224 224 auto_format = auto_format[:] 225 225 … … 238 238 fmt = auto_format[rowalt % len(auto_format)] 239 239 # Perform wrapping 240 xrow = [cwraptext(col.replace('^R', fmt), colwidths[i] - (i < cols - 1 and seplen or 0)) for i, col in enumerate(row)] 240 xrow = [cwraptext(col.replace('^R', fmt), 241 colwidths[i] - (i < cols - 1 and seplen or 0)) 242 for i, col in enumerate(row)] 241 243 # Pad column rows out to the maximum of all columns 242 244 maxrows = max([0] + map(len, xrow))
