summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCarlos Palhares <chjunior@gmail.com>2020-09-06 17:37:52 -0300
committerGitHub <noreply@github.com>2020-09-06 17:37:52 -0300
commit97be53b426f7f0a762130b54623faa6946f2c09a (patch)
tree88b235ed6c3bd40892b925f0bdfe696ba3767621 /lib
parentb548784b4a31b49026b69849430a9ec9072ae94a (diff)
downloadpry-97be53b426f7f0a762130b54623faa6946f2c09a.tar.gz
Escape non-printing characters
Diffstat (limited to 'lib')
-rw-r--r--lib/pry/helpers/text.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/pry/helpers/text.rb b/lib/pry/helpers/text.rb
index b1fee03f..b7301e99 100644
--- a/lib/pry/helpers/text.rb
+++ b/lib/pry/helpers/text.rb
@@ -21,20 +21,20 @@ class Pry
COLORS.each_pair do |color, value|
define_method color do |text|
- "\033[0;#{30 + value}m#{text}\033[0m"
+ "\001\033[0;#{30 + value}m\002#{text}\001\033[0m\002"
end
define_method "bright_#{color}" do |text|
- "\033[1;#{30 + value}m#{text}\033[0m"
+ "\001\033[1;#{30 + value}m\002#{text}\001\033[0m\002"
end
COLORS.each_pair do |bg_color, bg_value|
define_method "#{color}_on_#{bg_color}" do |text|
- "\033[0;#{30 + value};#{40 + bg_value}m#{text}\033[0m"
+ "\001\033[0;#{30 + value};#{40 + bg_value}m\002#{text}\001\033[0m\002"
end
define_method "bright_#{color}_on_#{bg_color}" do |text|
- "\033[1;#{30 + value};#{40 + bg_value}m#{text}\033[0m"
+ "\001\033[1;#{30 + value};#{40 + bg_value}m\002#{text}\001\033[0m\002"
end
end
end
@@ -52,7 +52,7 @@ class Pry
# @param [String, #to_s] text
# @return [String] _text_
def bold(text)
- "\e[1m#{text}\e[0m"
+ "\001\e[1m\002#{text}\001\e[0m\002"
end
# Returns `text` in the default foreground colour.