summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mair <jrmair@gmail.com>2017-11-01 14:47:22 +0100
committerGitHub <noreply@github.com>2017-11-01 14:47:22 +0100
commit295e3f2ffd65f80c28deb5fca65c716e50882d34 (patch)
treeed75cfea331814b0478be269ab0d17158ac74385
parentdf348e31aab7d89bd5c96523bbb74b63484a421c (diff)
parent954259a513f01e27ca72958d4d8157df1708d9f7 (diff)
downloadpry-295e3f2ffd65f80c28deb5fca65c716e50882d34.tar.gz
Merge branch 'master' into restore-jruby-as-first-class-citizen
-rw-r--r--CHANGELOG.md3
-rw-r--r--lib/pry/helpers/text.rb10
2 files changed, 13 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8483977..3251927d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,9 @@
* Add `mac_osx?` and `linux?` utility functions to Pry::Helpers::BaseHelpers.
[#1668](https://github.com/pry/pry/pull/1668)
+* Add utility functions for drawing colorised text on a colorised background.
+[#1673](https://github.com/pry/pry/pull/1673)
+
#### Bug fixes
* Fix `String#pp` output color. [#1674](https://github.com/pry/pry/pull/1674)
diff --git a/lib/pry/helpers/text.rb b/lib/pry/helpers/text.rb
index 22aecccd..6c171da7 100644
--- a/lib/pry/helpers/text.rb
+++ b/lib/pry/helpers/text.rb
@@ -24,6 +24,16 @@ class Pry
define_method "bright_#{color}" do |text|
"\033[1;#{30+value}m#{text}\033[0m"
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"
+ end
+
+ define_method "bright_#{color}_on_#{bg_color}" do |text|
+ "\033[1;#{30 + value};#{40 + bg_value}m#{text}\033[0m"
+ end
+ end
end
# Remove any color codes from _text_.