class IRB::Pager

def content_exceeds_screen_height?(content)

def content_exceeds_screen_height?(content)
  screen_height, screen_width = begin
    Reline.get_screen_size
  rescue Errno::EINVAL
    [24, 80]
  end
  pageable_height = screen_height - 3 # leave some space for previous and the current prompt
  # If the content has more lines than the pageable height
  content.lines.count > pageable_height ||
    # Or if the content is a few long lines
    pageable_height * screen_width < Reline::Unicode.calculate_width(content, true)
end