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.



102
103
104
105
# File 'lib/pry/pager.rb', line 102

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

Instance Method Details

#write(str) ⇒ Object



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/pry/pager.rb', line 107

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

    next unless @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