Class: Soundcloud9000::UI::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/soundcloud9000/ui/color.rb

Overview

this class stores our text color configurations

Constant Summary collapse

PAIRS =
{
  white: 0,
  red: 1,
  blue: 2,
  green: 3,
  cyan: 4
}.freeze
DEFINITION =
{
  PAIRS[:white] => [Curses::COLOR_WHITE, Curses::COLOR_BLACK],
  PAIRS[:red] => [Curses::COLOR_RED, Curses::COLOR_BLACK],
  PAIRS[:blue] => [Curses::COLOR_BLUE, Curses::COLOR_WHITE],
  PAIRS[:green] => [Curses::COLOR_GREEN, Curses::COLOR_BLACK],
  PAIRS[:cyan] => [Curses::COLOR_BLACK, Curses::COLOR_CYAN]
}.freeze
COLORS =
{
  white: Curses.color_pair(PAIRS[:white]),
  black: Curses.color_pair(PAIRS[:white]) | Curses::A_REVERSE,
  red: Curses.color_pair(PAIRS[:red]),
  blue: Curses.color_pair(PAIRS[:blue]),
  green: Curses.color_pair(PAIRS[:green]),
  green_reverse: Curses.color_pair(PAIRS[:green]) | Curses::A_REVERSE,
  cyan: Curses.color_pair(PAIRS[:cyan])
}.freeze

Class Method Summary collapse

Class Method Details

.get(name) ⇒ Object



41
42
43
# File 'lib/soundcloud9000/ui/color.rb', line 41

def self.get(name)
  COLORS[name]
end

.initObject



33
34
35
36
37
38
39
# File 'lib/soundcloud9000/ui/color.rb', line 33

def self.init
  Curses.start_color

  DEFINITION.each do |definition, (color, background)|
    Curses.init_pair(definition, color, background)
  end
end