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

Add and use Reline::Unicode.escape_for_print

This commit is contained in:
Takashi Kokubun 2019-05-25 06:52:10 -07:00
parent e691b4da5d
commit e2db9f4cc3
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD
4 changed files with 25 additions and 7 deletions

View file

@ -55,6 +55,17 @@ class Reline::Unicode
end
end
def self.escape_for_print(str)
str.chars.map! { |gr|
escaped = EscapedPairs[gr.ord]
if escaped && gr != "\n"
escaped
else
gr
end
}.join
end
def self.get_mbchar_width(mbchar)
case mbchar.encode(Encoding::UTF_8)
when *EscapedChars # ^ + char, such as ^M, ^H, ^[, ...