def expand(lines, indent=4, maxwidth=100):
"""Expand all tabstops (\t) in each line intelligently
"Intelligently" means that consecutive lines with the same amount of '\t'
characters are treated like a table, giving each column the same space.
Return `lines` with all tabs expanded
"""
width = min(get_terminal_size()[0], maxwidth)
expanded = []
for section in _split_sections(_explode(lines, indent)):
widths = _col_widths(section)
for line in section:
expanded.append(_join_line(line, widths, width))
return expanded
评论列表
文章目录