Class: Colors

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

Class Method Summary collapse

Class Method Details

.add(key, fg, bg) ⇒ Object



249
250
251
252
253
# File 'lib/ncurses_ui.rb', line 249

def self.add(key, fg, bg)
  Curses.init_pair $counter, ncg(fg), ncg(bg)
  $map[key] = Curses.color_pair $counter
  $counter += 1
end

.debugObject



255
256
257
258
# File 'lib/ncurses_ui.rb', line 255

def self.debug
  puts "colors supported: #{Curses.colors}"
  puts "map: #{$map}"
end

.init(colormap = {}) ⇒ Object



239
240
241
242
243
# File 'lib/ncurses_ui.rb', line 239

def self.init colormap = {}
  colormap.each do |key, colors|
    self.add(key, colors[0], colors[1])
  end
end

.map(key) ⇒ Object



245
246
247
# File 'lib/ncurses_ui.rb', line 245

def self.map(key)
  $map[key] || $map[:default]
end

.ncg(color) ⇒ Object

get ncurses color constant



260
261
262
263
# File 'lib/ncurses_ui.rb', line 260

def self.ncg(color)
  color = :black unless color
  Curses.const_get "COLOR_#{color.upcase}"
end