Class: Twterm::ColorManager
- Inherits:
-
Object
- Object
- Twterm::ColorManager
- Includes:
- Curses, Singleton
- Defined in:
- lib/twterm/color_manager.rb
Constant Summary collapse
- COLORS =
[:black, :white, :red, :green, :blue, :yellow, :cyan, :magenta, :transparent]
- CURSES_COLORS =
{ black: COLOR_BLACK, white: COLOR_WHITE, red: COLOR_RED, green: COLOR_GREEN, blue: COLOR_BLUE, yellow: COLOR_YELLOW, cyan: COLOR_CYAN, magenta: COLOR_MAGENTA, transparent: -1 }
Instance Method Summary collapse
- #get_color_pair_index(fg, bg) ⇒ Object
-
#initialize ⇒ ColorManager
constructor
A new instance of ColorManager.
Constructor Details
#initialize ⇒ ColorManager
Returns a new instance of ColorManager.
30 31 32 33 34 35 36 37 |
# File 'lib/twterm/color_manager.rb', line 30 def initialize @colors = { black: {}, white: {}, red: {}, green: {}, blue: {}, yellow: {}, cyan: {}, magenta: {}, transparent: {} } @count = 0 end |
Instance Method Details
#get_color_pair_index(fg, bg) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/twterm/color_manager.rb', line 19 def get_color_pair_index(fg, bg) fail ArgumentError, 'invalid color name for foreground' unless COLORS.include? fg fail ArgumentError, 'invalid color name for background' unless COLORS.include? bg return @colors[bg][fg] unless @colors[bg][fg].nil? add_color(fg, bg) end |