def _get_size_linux():
 def ioctl_GWINSZ(fd):
  '\n        Attempt to discover the dimensions of a terminal window, using IOCTL.\n        '
  try:
   import fcntl, termios
   cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
  except:
   return None
  return cr
 cr = (ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2))
 if (not cr):
  try:
   fd = os.open(os.ctermid(), os.O_RDONLY)
   cr = ioctl_GWINSZ(fd)
   os.close(fd)
  except:
   pass
 if (not cr):
  try:
   cr = (env['LINES'], env['COLUMNS'])
  except:
   return None
 return (int(cr[1]), int(cr[0]))

def _get_size_linux ( ) : def ioctl_GWINSZ ( fd ) : try : import fcntl , termios cr = struct . unpack ( 'hh' , fcntl . ioctl ( fd , termios . TIOCGWINSZ , '1234' ) ) except : return None return cr cr = ( ioctl_GWINSZ ( 0 ) or ioctl_GWINSZ ( 1 ) or ioctl_GWINSZ ( 2 ) ) if ( not cr ) : try : fd = os . open ( os . ctermid ( ) , os . O_RDONLY ) cr = ioctl_GWINSZ ( fd ) os . close ( fd ) except : pass if ( not cr ) : try : cr = ( env [ 'LINES' ] , env [ 'COLUMNS' ] ) except : return None return ( int ( cr [ 1 ] ) , int ( cr [ 0 ] ) )
attempt to discover the dimensions of a terminal window .