OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 import termios, fcntl, struct, os, sys |
| 4 |
| 5 def getwinsize(): |
| 6 s = struct.pack("HHHH", 0, 0, 0, 0) |
| 7 x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, s) |
| 8 rows, cols = struct.unpack("HHHH", x)[:2] |
| 9 return rows, cols |
| 10 |
| 11 def setwinsize(r,c): |
| 12 # Assume ws_xpixel and ws_ypixel are zero. |
| 13 s = struct.pack("HHHH", r,c,0,0) |
| 14 x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCSWINSZ, s) |
| 15 print 'stdin tty:', os.ttyname(0) |
| 16 print 'stdout tty:', os.ttyname(1) |
| 17 print 'controlling terminal:', os.ctermid() |
| 18 print 'winsize %d,%d' % getwinsize() |
| 19 print 'ENDTEST' |
OLD | NEW |