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

Add utility functions for drawing colorised (#1673)

text on a colorised background.
This commit is contained in:
r-obert 2017-10-23 22:46:32 +02:00 committed by GitHub
parent 7de521b94c
commit 954259a513
2 changed files with 13 additions and 0 deletions

View file

@ -4,6 +4,9 @@
* Add `mac_osx?` and `linux?` utility functions to Pry::Helpers::BaseHelpers. * Add `mac_osx?` and `linux?` utility functions to Pry::Helpers::BaseHelpers.
[#1668](https://github.com/pry/pry/pull/1668) [#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 #### Bug fixes
* Fix `String#pp` output color. [#1674](https://github.com/pry/pry/pull/1674) * Fix `String#pp` output color. [#1674](https://github.com/pry/pry/pull/1674)

View file

@ -24,6 +24,16 @@ class Pry
define_method "bright_#{color}" do |text| define_method "bright_#{color}" do |text|
"\033[1;#{30+value}m#{text}\033[0m" "\033[1;#{30+value}m#{text}\033[0m"
end 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 end
# Remove any color codes from _text_. # Remove any color codes from _text_.