diff options
author | Conrad Irwin <conrad.irwin@gmail.com> | 2014-05-01 01:39:12 -0700 |
---|---|---|
committer | Conrad Irwin <conrad.irwin@gmail.com> | 2014-05-01 01:51:02 -0700 |
commit | 2285a83330cc70c7553a58be8046699023969c9f (patch) | |
tree | 15ca535128886c10b56817adc213ab5e75403bc9 | |
parent | 5d7c887129f8ce1fccd50f112995fc8284044432 (diff) | |
download | pry-2285a83330cc70c7553a58be8046699023969c9f.tar.gz |
Pager should also respect _pry_.config.color
-rw-r--r-- | lib/pry/output.rb | 16 | ||||
-rw-r--r-- | lib/pry/pager.rb | 8 |
2 files changed, 17 insertions, 7 deletions
diff --git a/lib/pry/output.rb b/lib/pry/output.rb index 7661a379..a4cf8484 100644 --- a/lib/pry/output.rb +++ b/lib/pry/output.rb @@ -2,6 +2,7 @@ class Pry class Output attr_reader :_pry_ + def initialize(_pry_) @_pry_ = _pry_ end @@ -10,15 +11,20 @@ class Pry print "#{str.chomp}\n" end - def print str + def print(str) + _pry_.config.output.print decolorize_maybe(str) + end + alias << print + alias write print + + # If _pry_.config.color is currently false, removes ansi escapes from the string. + def decolorize_maybe(str) if _pry_.config.color - _pry_.config.output.print str + str else - _pry_.config.output.print Helpers::Text.strip_color str + Helpers::Text.strip_color str end end - alias << print - alias write print def method_missing(name, *args, &block) _pry_.config.output.send(name, *args, &block) diff --git a/lib/pry/pager.rb b/lib/pry/pager.rb index aedb9b20..9ca9b209 100644 --- a/lib/pry/pager.rb +++ b/lib/pry/pager.rb @@ -153,13 +153,13 @@ class Pry::Pager def write(str) if invoked_pager? - pager.write str + write_to_pager str else @tracker.record str @buffer << str if @tracker.page? - pager.write @buffer + write_to_pager @buffer end end rescue Errno::EPIPE @@ -176,6 +176,10 @@ class Pry::Pager private + def write_to_pager(text) + pager.write @out.decolorize_maybe(text) + end + def invoked_pager? @pager end |