()
| 53 | |
| 54 | |
| 55 | def _tty_width(): |
| 56 | s = struct.pack("HHHH", 0, 0, 0, 0) |
| 57 | try: |
| 58 | import fcntl, termios |
| 59 | s = fcntl.ioctl(sys.stderr.fileno(), termios.TIOCGWINSZ, s) |
| 60 | except (IOError, ImportError): |
| 61 | return _atoi(os.environ.get('WIDTH')) or 70 |
| 62 | (ysize,xsize,ypix,xpix) = struct.unpack('HHHH', s) |
| 63 | return xsize or 70 |
| 64 | |
| 65 | |
| 66 | class Options: |