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

Some fixes to the pager.

We didn't send any flags to the pager, as a result ansi codes
were not applied unless the user had properly set up their LESS
env variable. This was often not the case, resulting in broken
and ugly output. This commit sends along the proper flags whenever
we use the pager, regardless of the user's LESS variable
This commit is contained in:
epitron 2013-01-18 20:58:11 -05:00 committed by John Mair
parent 2e17c21a1a
commit 9488494e6b

View file

@ -24,7 +24,12 @@ class Pry::Pager
end
def self.page_size
27
@page_size ||= begin
require 'io/console'
$stdout.winsize.first
rescue
27
end
end
def initialize(text)
@ -47,13 +52,27 @@ class Pry::Pager
class SystemPager < Pry::Pager
def self.default_pager
ENV["PAGER"] || "less -R -S -F -X"
pager = ENV["PAGER"] || ""
# Default to less, and make sure less is being passed the correct options
if pager.strip.empty? or pager =~ /^less\s*/
pager = "less -R -S -F -X"
end
pager
end
def self.available?
pager_executable = default_pager.split(' ').first
`which #{ pager_executable }`
rescue
if @system_pager.nil?
@system_pager = begin
pager_executable = default_pager.split(' ').first
`which #{ pager_executable }`
rescue
false
end
else
@system_pager
end
end
def initialize(*)