Class: Pry::Pager::SimplePager

Inherits:
NullPager show all
Defined in:
lib/pry/pager.rb

Overview

‘SimplePager` is a straightforward pure-Ruby pager. We use it on JRuby and when we can’t find a usable external pager.

Instance Method Summary collapse

Methods inherited from NullPager

#close, #print, #puts

Constructor Details

#initializeSimplePager

Returns a new instance of SimplePager.



99
100
101
102
# File 'lib/pry/pager.rb', line 99

def initialize(*)
  super
  @tracker = PageTracker.new(height - 3, width)
end

Instance Method Details

#write(str) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/pry/pager.rb', line 104

def write(str)
  str.lines.each do |line|
    @out.print line
    @tracker.record line

    if @tracker.page?
      @out.print "\n"
      @out.print "\e[0m"
      @out.print "<page break> --- Press enter to continue " \
                 "( q<enter> to break ) --- <page break>\n"
      raise StopPaging if Readline.readline("").chomp == "q"
      @tracker.reset
    end
  end
end