Class: Pry::Pager::SimplePager
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
-
#initialize ⇒ SimplePager
constructor
A new instance of SimplePager.
- #write(str) ⇒ Object
Methods inherited from NullPager
Constructor Details
#initialize ⇒ SimplePager
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 |