clint icon indicating copy to clipboard operation
clint copied to clipboard

examples/text_width.py only works with terminals wider than 135 chars

Open redtoad opened this issue 13 years ago • 2 comments

When running examples/text_width.py inside terminals with 135 or less characters in width, the following error pops up:

Traceback (most recent call last):
  File "text_width.py", line 22, in <module>
    puts(columns([(colored.red('Column 1')), col], [(colored.green('Column Two')), None], [(colored.magenta('Column III')), col]))
  File "/tmp/clint/clint/textui/cols.py", line 95, in columns
    cols[_big_col][0] = max_width(cols[_big_col][0], cols[_big_col][1]).split('\n')
  File "/tmp/clint/clint/textui/formatters.py", line 70, in max_width
    chunks = schunk(word, (cols + offset))
  File "/tmp/clint/clint/utils.py", line 61, in schunk
    for char in string:
TypeError: 'ColoredString' object is not iterable

redtoad avatar Apr 04 '11 12:04 redtoad

Thanks for this. Sorry I didn't see it before.

kennethreitz avatar Apr 20 '11 00:04 kennethreitz

It actually appears that for this example, when you a terminal <120 it runs, but omits column II, so 120=>w<135 is the error zone. It's because that the example uses a column width of 60. Not sure the best way to handle it when columns is given column widths which in total are wider than the terminal.

jpiper avatar Jan 10 '14 17:01 jpiper