Method: TTY::Pager::BasicPager#initialize

Defined in:
lib/tty/pager/basic.rb

#initialize(height: TTY::Screen.height, width: TTY::Screen.width, prompt: DEFAULT_PROMPT, **options) ⇒ BasicPager

Create a basic pager

Parameters:

  • :height (Integer)

    the terminal height

  • :width (Integer)

    the terminal width

  • :prompt (Proc)

    a proc object that accepts page number



36
37
38
39
40
41
42
43
44
45
# File 'lib/tty/pager/basic.rb', line 36

def initialize(height: TTY::Screen.height, width: TTY::Screen.width,
               prompt: DEFAULT_PROMPT, **options)
  super(**options)
  @width   = width
  @prompt  = prompt
  prompt_height = Strings.wrap(prompt.call(100).to_s, width).lines.count
  @page_cursor = PageCursor.new(height - prompt_height)

  reset
end