Call TIOCGWINSZ (Terminal I/O Control to Get the WINdow SiZe)
        where ``fobj`` is a file object (e.g. ``sys.stdout``),
        returning the terminal width assigned to that file.

        See the ``ioctl``, ``ioctl_list`` and tty_ioctl`` man pages
        for more information.

def from_io_control(fobj):
        """
        Call TIOCGWINSZ (Terminal I/O Control to Get the WINdow SiZe)
        where ``fobj`` is a file object (e.g. ``sys.stdout``),
        returning the terminal width assigned to that file.

        See the ``ioctl``, ``ioctl_list`` and tty_ioctl`` man pages
        for more information.
        """
        import fcntl, termios, array
        winsize = array.array("H", [0] * 4) # row, col, xpixel, ypixel
        if not fcntl.ioctl(fobj.fileno(), termios.TIOCGWINSZ, winsize, True):
            return winsize[1]