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:
parent
2e17c21a1a
commit
9488494e6b
|
@ -24,8 +24,13 @@ class Pry::Pager
|
|||
end
|
||||
|
||||
def self.page_size
|
||||
@page_size ||= begin
|
||||
require 'io/console'
|
||||
$stdout.winsize.first
|
||||
rescue
|
||||
27
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(text)
|
||||
@text = 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?
|
||||
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(*)
|
||||
|
|
Loading…
Reference in New Issue