class Textbringer::Face
Attributes
attributes[R]
name[R]
Public Class Methods
[](name)
click to toggle source
# File lib/textbringer/face.rb, line 10 def self.[](name) @@face_table[name] end
define(name, **opts)
click to toggle source
# File lib/textbringer/face.rb, line 14 def self.define(name, **opts) if @@face_table.key?(name) @@face_table[name].update(**opts) else @@face_table[name] = new(name, **opts) end end
delete(name)
click to toggle source
# File lib/textbringer/face.rb, line 22 def self.delete(name) @@face_table.delete(name) end
new(name, **opts)
click to toggle source
# File lib/textbringer/face.rb, line 26 def initialize(name, **opts) @name = name @color_pair = @@next_color_pair @@next_color_pair += 1 update(**opts) end
Public Instance Methods
update(foreground: -1, background: -1, bold: false, underline: false, reverse: false)
click to toggle source
# File lib/textbringer/face.rb, line 33 def update(foreground: -1, background: -1, bold: false, underline: false, reverse: false) @foreground = foreground @background = background @bold = bold @underline = underline @reverse = reverse Curses.init_pair(@color_pair, Color[foreground], Color[background]) @attributes = 0 @attributes |= Curses.color_pair(@color_pair) @attributes |= Curses::A_BOLD if bold @attributes |= Curses::A_UNDERLINE if underline @attributes |= Curses::A_REVERSE if reverse self end