This code returns the size of the terminal window.
def gettermsize():
s = struct.pack("HHHH", 0, 0, 0, 0)
a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ , s))
return (a[0], a[1])
What is it actually doing?