Use the Windows Console Handles API to get the console width,
        where ``std_handle`` is the WINAPI ``GetStdHandle`` input
        (e.g. STD_INPUT_HANDLE).

        https://msdn.microsoft.com/library/windows/desktop/ms682075

def from_windows_handle(std_handle):
        """
        Use the Windows Console Handles API to get the console width,
        where ``std_handle`` is the WINAPI ``GetStdHandle`` input
        (e.g. STD_INPUT_HANDLE).

        https://msdn.microsoft.com/library/windows/desktop/ms682075
        """
        from ctypes import windll, c_ushort
        # https://msdn.microsoft.com/library/windows/desktop/ms683231
        handle = windll.kernel32.GetStdHandle(std_handle)
        # https://msdn.microsoft.com/library/windows/desktop/ms682093
        info = (c_ushort * 11)() # It's a CONSOLE_SCREEN_BUFFER_INFO:
            # xsize, ysize,             | COORD      dwSize
            # xcursor, ycursor,         | COORD      dwCursorPosition
            # attributes,               | WORD       wAttributes
            # left, top, right, bottom, | SMALL_RECT srWindow
            # xmax, ymax                | COORD      dwMaximumWindowSize
        # https://msdn.microsoft.com/library/windows/desktop/ms683171
        if windll.kernel32.GetConsoleScreenBufferInfo(handle, info):
            return info[7] - info[5] + 1