Module: IRB::ColoredFormatter::Color

Defined in:
lib/irb/ext/colorize.rb

Overview

Terminal escape codes for colors.

Constant Summary collapse

COLORS =
{
  :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',
}
CLEAR =
escape(:nothing)

Class Method Summary collapse

Class Method Details

.escape(name) ⇒ Object

Return the escape code for a given color.



136
137
138
# File 'lib/irb/ext/colorize.rb', line 136

def self.escape(name)
  COLORS.key?(name) && "\e[#{COLORS[name]}m"
end