summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr-obert <r-obert@users.noreply.github.com>2017-08-20 03:35:58 +0100
committerGitHub <noreply@github.com>2017-08-20 03:35:58 +0100
commit36eaae83b04b47d36395a022b0534fd0edddddf5 (patch)
treee7248cf7fbd50319063b34a9ee3c33279ac46538
parent590976efc75b502ab1fbd1f9b284ae8845de01cd (diff)
parent9578c8daba1e57136240794a98ca22170ff3f53e (diff)
downloadpry-36eaae83b04b47d36395a022b0534fd0edddddf5.tar.gz
Merge pull request #1624 from SaladFork/feature/background-color-helpers
Add text helpers for background colors
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pry/helpers/text.rb10
2 files changed, 11 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6006416..bb8faefb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
### HEAD
+* Add text helpers for background colors ([#1624](https://github.com/pry/pry/pull/1624))
* Fix string literal methods completion. ([#1590](https://github.com/pry/pry/pull/1590))
* Add alias 'whereami[?!]+' for 'whereami' command. ([#1597](https://github.com/pry/pry/pull/1597))
* Improve Ruby 2.4 support ([#1611](https://github.com/pry/pry/pull/1611)):
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_.