Class: GLW::TermColors

Inherits:
Object
  • Object
show all
Defined in:
lib/glw/term_colors.rb

Instance Method Summary collapse

Constructor Details

#initialize(curses = Curses) ⇒ TermColors

Returns a new instance of TermColors.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/glw/term_colors.rb', line 3

def initialize(curses = Curses)
  index = 1

  @colors = Hash.new do |hash, key|
    fg, bg = *key

    curses.init_pair(index, fg, bg)
    hash[key] = curses.color_pair(index)

    index += 1

    hash[key]
  end
end

Instance Method Details

#[](fg, bg) ⇒ Object



18
19
20
# File 'lib/glw/term_colors.rb', line 18

def [](fg, bg)
  @colors[[fg, bg]]
end