aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2019-05-25 06:52:10 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2019-05-25 07:10:09 -0700
commite2db9f4cc35dacdca1c0d1f1ae79772dae093c34 (patch)
treee571a3467e69b5ae9eca3ee26c84cb9e9921d206 /lib/irb
parente691b4da5d1d70216be3e8853d18bcb6a62a617c (diff)
downloadruby-e2db9f4cc35dacdca1c0d1f1ae79772dae093c34.tar.gz
Add and use Reline::Unicode.escape_for_print
Diffstat (limited to 'lib/irb')
-rw-r--r--lib/irb/color.rb5
-rw-r--r--lib/irb/input-method.rb15
2 files changed, 13 insertions, 7 deletions
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index 30a8fb5973..8cee483261 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+require 'reline'
require 'ripper'
module IRB # :nodoc:
@@ -80,11 +81,11 @@ module IRB # :nodoc:
length = 0
Ripper.lex(code).each do |(_line, _col), token, str, expr|
if seq = dispatch_seq(token, expr, str)
- str.each_line do |line|
+ Reline::Unicode.escape_for_print(str).each_line do |line|
colored << "#{seq.map { |s| "\e[#{s}m" }.join('')}#{line}#{clear}"
end
else
- colored << str
+ colored << Reline::Unicode.escape_for_print(str)
end
length += str.length
end
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index 9dd8ca26c8..64b1e018d9 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -222,12 +222,17 @@ module IRB
end
Reline.completion_append_character = nil
Reline.completion_proc = IRB::InputCompletor::CompletionProc
- if IRB.conf[:USE_COLORIZE]
- Reline.output_modifier_proc = proc do |output|
- next unless IRB::Color.colorable?
- IRB::Color.colorize_code(output)
+ Reline.output_modifier_proc =
+ if IRB.conf[:USE_COLORIZE]
+ proc do |output|
+ next unless IRB::Color.colorable?
+ IRB::Color.colorize_code(output)
+ end
+ else
+ proc do |output|
+ Reline::Unicode.escape_for_print(output)
+ end
end
- end
Reline.dig_perfect_match_proc = IRB::InputCompletor::PerfectMatchedProc
end