# File lib/rbreadline.rb, line 1858
  def _rl_get_screen_size(tty, ignore_env)

    if @hConsoleHandle
      csbi = 0.chr * 24
      @GetConsoleScreenBufferInfo.Call(@hConsoleHandle,csbi)
      wc,wr = csbi[0,4].unpack('SS')
      # wr,wc, = `mode con`.scan(/\d+\n/).map{|x| x.to_i}
      @_rl_screenwidth = wc
      @_rl_screenheight = wr
    else
      wr, wc = 0
      retry_if_interrupted do
        wr, wc = `stty size`.split(' ').map { |x| x.to_i }
      end
      @_rl_screenwidth = wc
      @_rl_screenheight = wr
      if ignore_env==0 && ENV['LINES']
        @_rl_screenheight = ENV['LINES'].to_i
      end
      if ignore_env==0 && ENV['COLUMNS']
        @_rl_screenwidth = ENV['COLUMNS'].to_i
      end
    end

    # If all else fails, default to 80x24 terminal.
    if @_rl_screenwidth.nil? || @_rl_screenwidth <= 1
      @_rl_screenwidth = 80
    end
    if @_rl_screenheight.nil? || @_rl_screenheight <= 0
      @_rl_screenheight = 24
    end
    # If we're being compiled as part of bash, set the environment
    #   variables $LINES and $COLUMNS to new values.  Otherwise, just
    #   do a pair of putenv () or setenv () calls.
    sh_set_lines_and_columns(@_rl_screenheight, @_rl_screenwidth)

    if !@_rl_term_autowrap
      @_rl_screenwidth-=1
    end
    @_rl_screenchars = @_rl_screenwidth * @_rl_screenheight
  end