1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

SimplePager: take into account the info bar

Fix issue #786 (SimplePager is a bit neglectful)

The info bar takes exactly 3 lines.
This commit is contained in:
Kyrylo Silin 2013-01-24 02:54:47 +02:00
parent 0cb9a49705
commit 6138218c94

View file

@ -38,11 +38,14 @@ class Pry::Pager
class SimplePager < Pry::Pager
def page
# The pager size minus the number of lines used by the simple pager info bar.
page_size = Pry::Pager.page_size - 3
text_array = @text.lines.to_a
text_array.each_slice(Pry::Pager.page_size) do |chunk|
text_array.each_slice(page_size) do |chunk|
puts chunk.join
break if chunk.size < Pry::Pager.page_size
if text_array.size > Pry::Pager.page_size
break if chunk.size < page_size
if text_array.size > page_size
puts "\n<page break> --- Press enter to continue ( q<enter> to break ) --- <page break>"
break if $stdin.gets.chomp == "q"
end