Module: Curses::Color
- Defined in:
- lib/curses_extensions.rb,
lib/curses_color.rb
Overview
Curses::Color
Constant Summary collapse
- RED =
Curses::COLOR_RED
- BLUE =
Curses::COLOR_BLUE
- GREEN =
Curses::COLOR_GREEN
- YELLOW =
Curses::COLOR_YELLOW
- MAGENTA =
Curses::COLOR_MAGENTA
- CYAN =
Curses::COLOR_CYAN
- WHITE =
Curses::COLOR_WHITE
- BLACK =
Curses::COLOR_BLACK
- COLOR_STYLES =
{ # :name => [foreground, background], :default => [WHITE, BLACK], :red => [RED, BLACK], :blue => [BLUE, BLACK], :green => [GREEN, BLACK], :yellow => [YELLOW, BLACK], :magenta => [MAGENTA, BLACK], :cyan => [CYAN, BLACK], :wrong => [RED, BLACK], :wrong_space => [RED, RED], :correct => [BLUE, BLACK], :ok => [CYAN, BLACK], :highscore => [GREEN, BLACK], :mistype => [RED, BLACK], }
- @@color_pair =
{}
- @@use_color =
false
Class Method Summary collapse
- .init ⇒ Object
-
.pair(name) ⇒ Object
Return the result of Curses::color_pair, or nil if the specified name is not defined or the terminal doesn’t support color.
Class Method Details
.init ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/curses_extensions.rb', line 69 def init @@use_color = Curses.has_colors? return if @@use_color == false Curses::start_color # background becomes black n = 1 defined_pair = {} COLOR_STYLES.each do |name, pair| if defined_pair.include?(pair) @@color_pair[name] = Curses::color_pair(defined_pair[pair]) else Curses::init_pair(n, pair[0], pair[1]) @@color_pair[name] = Curses::color_pair(n) defined_pair[pair] = n n += 1 end end end |
.pair(name) ⇒ Object
Return the result of Curses::color_pair, or nil if the specified name is not defined or the terminal doesn’t support color
93 94 95 |
# File 'lib/curses_extensions.rb', line 93 def pair(name) @@use_color ? @@color_pair[name] : nil end |