Permalink
Browse files

colorize cleanup and fixes for light colors

  • Loading branch information...
1 parent 801d35a commit 2e7c30837ee19ef0ed11beb2e88bbb5ed736c067 Wesley Beary committed with Dec 2, 2009
Showing with 19 additions and 20 deletions.
  1. +19 −20 irb/colorize.rb
View
@@ -1,34 +1,33 @@
module IRB
class ColoredShellString
COLORS = {
- :"\\/" => '0;0',
- :nothing => '0;0',
- :black => '0;30',
- :red => '0;31',
- :green => '0;32',
- :brown => '0;33',
- :blue => '0;34',
- :cyan => '0;36',
- :purple => '0;35',
- :light_gray => '0;37',
- :dark_gray => '1;30',
- :light_red => '1;31',
- :light_green => '1;32',
- :yellow => '1;33',
- :light_blue => '1;34',
- :light_cyan => '1;36',
- :light_purple => '1;35',
- :white => '1;37',
+ :"\\/" => '0',
+ :nothing => '0',
+ :black => '30',
+ :red => '31',
+ :green => '32',
+ :yellow => '33',
+ :blue => '34',
+ :purple => '35',
+ :cyan => '36',
+ :white => '37',
+ :dark_gray => '90',
+ :light_red => '91',
+ :light_green => '92',
+ :light_yellow => '93',
+ :light_blue => '94',
+ :light_purple => '95',
+ :light_cyan => '96',
}
- COLORS_REGEX = Regexp.new("\\[(" + COLORS.keys.join("|") + ")\\]")
+ COLORS_REGEX = /\[(#{ COLORS.keys.join('|') })\]/
def initialize(str)
@string = str
end
def to_s
- @string.gsub(COLORS_REGEX) { "\033[#{COLORS[$1.to_sym]}m" }
+ @string.gsub(COLORS_REGEX) { "\e[#{COLORS[$1.to_sym]}m" }
end
end
end

0 comments on commit 2e7c308

Please sign in to comment.