code: def _terminal_size(file=None):
      
  
      if file is None:
          file = _get_stdout()
  
      try:
          s = struct.pack(str("HHHH"), 0, 0, 0, 0)
          x = fcntl.ioctl(file, termios.TIOCGWINSZ, s)
          (lines, width, xpixels, ypixels) = struct.unpack(str("HHHH"), x)
          if lines > 12:
              lines -= 6
          if width > 10:
              width -= 1
          return (lines, width)
      except:
          try:
              # see if POSIX standard variables will work
              return (int(os.environ.get('LINES')),
                      int(os.environ.get('COLUMNS')))
          except TypeError:
              # fall back on configuration variables, or if not
              # set, (25, 80)
              lines = options.console.max_lines
              width = options.console.max_width
              if lines is None:
                  lines = 25
              if width is None:
                  width = 80
              return lines, width
docs: Returns a tuple (height, width) containing the height and width of
      the terminal.
  
      This function will look for the width in height in multiple areas
      before falling back on the width and height in astropy's
      configuration.