def terminal_width(): """Return the terminal's width (number of character columns).""" try: if os.name == 'nt': _WindowsCSBI.initialize() return _WindowsCSBI.get_info(_WindowsCSBI.HANDLE_STDOUT)['terminal_width'] return struct.unpack('hhhh', fcntl.ioctl(0, termios.TIOCGWINSZ, '\000' * 8))[1] except IOError: return 80
def terminal_height(): """Return the terminal's height (number of lines).""" try: if os.name == 'nt': _WindowsCSBI.initialize() return _WindowsCSBI.get_info(_WindowsCSBI.HANDLE_STDOUT)['terminal_height'] return struct.unpack('hhhh', fcntl.ioctl(0, termios.TIOCGWINSZ, '\000' * 8))[0] except IOError: return 24
def terminal_width(): """Return the terminal's width (number of character columns).""" try: if os.name == 'nt': _WindowsCSBI.initialize() return _WindowsCSBI.get_info( _WindowsCSBI.HANDLE_STDOUT)['terminal_width'] return struct.unpack('hhhh', fcntl.ioctl(0, termios.TIOCGWINSZ, '\000' * 8))[1] except IOError: return 80
def terminal_height(): """Return the terminal's height (number of lines).""" try: if os.name == 'nt': _WindowsCSBI.initialize() return _WindowsCSBI.get_info( _WindowsCSBI.HANDLE_STDOUT)['terminal_height'] return struct.unpack('hhhh', fcntl.ioctl(0, termios.TIOCGWINSZ, '\000' * 8))[0] except IOError: return 24