def _get_terminal_size_linux():
 def ioctl_GWINSZ(fd):
  ' ioctl_GWINSZ. '
  try:
   import fcntl
   import termios
   cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
   return cr
  except:
   pass
 cr = (ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2))
 if ((not cr) or (cr == (0, 0))):
  try:
   fd = os.open(os.ctermid(), os.O_RDONLY)
   cr = ioctl_GWINSZ(fd)
   os.close(fd)
  except:
   pass
 if ((not cr) or (cr == (0, 0))):
  try:
   cr = (os.environ['LINES'], os.environ['COLUMNS'])
  except:
   return
 return (int(cr[1]), int(cr[0]))

def _get_terminal_size_linux ( ) : def ioctl_GWINSZ ( fd ) : try : import fcntl import termios cr = struct . unpack ( 'hh' , fcntl . ioctl ( fd , termios . TIOCGWINSZ , '1234' ) ) return cr except : pass cr = ( ioctl_GWINSZ ( 0 ) or ioctl_GWINSZ ( 1 ) or ioctl_GWINSZ ( 2 ) ) if ( ( not cr ) or ( cr == ( 0 , 0 ) ) ) : try : fd = os . open ( os . ctermid ( ) , os . O_RDONLY ) cr = ioctl_GWINSZ ( fd ) os . close ( fd ) except : pass if ( ( not cr ) or ( cr == ( 0 , 0 ) ) ) : try : cr = ( os . environ [ 'LINES' ] , os . environ [ 'COLUMNS' ] ) except : return return ( int ( cr [ 1 ] ) , int ( cr [ 0 ] ) )
get terminal size linux .