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:
parent
2e17c21a1a
commit
9488494e6b
1 changed files with 24 additions and 5 deletions
|
@ -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(*)
|
||||
|
|
Loading…
Reference in a new issue