class RubyText::Color

Handles color constants and fg/bg pairs

Constants

Colors

Public Class Methods

index(color) click to toggle source

Find “our” color number

# File lib/color.rb, line 25
def self.index(color)
  Colors.find_index(color)  # "our" number
end
pair(fg, bg) click to toggle source

Define a fg/bg color pair

# File lib/color.rb, line 31
def self.pair(fg, bg)
  nf, nb = index(fg), index(bg)
  num = 8*nf + nb
  Curses.init_pair(num, sym2const(fg), sym2const(bg))
  num
end
sym2const(color) click to toggle source

Convert Ruby symbol to curses color constant name

# File lib/color.rb, line 19
def self.sym2const(color)   # to curses constant
  Curses.const_get("COLOR_#{color.to_s.upcase}")
end