Class: RubyText::Effects
- Inherits:
-
Object
- Object
- RubyText::Effects
- Defined in:
- lib/effects.rb
Overview
dumb name?
Constant Summary collapse
- Modes =
{bold: X::A_BOLD, normal: X::A_NORMAL, reverse: X::A_REVERSE, under: X::A_UNDERLINE}
- Others =
show/hide cursor; more later??
%[:show, :hide]
Instance Attribute Summary collapse
-
#fg ⇒ Object
readonly
Returns the value of attribute fg.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Effects
constructor
A new instance of Effects.
- #reset(win) ⇒ Object
- #set(win) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Effects
Returns a new instance of Effects.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/effects.rb', line 19 def initialize(*args) bits = 0 @list = args args.each do |arg| if Modes.keys.include?(arg) val = Modes[arg] bits |= val elsif ::Colors.include?(arg) @fg = arg # symbol end end @value = bits end |
Instance Attribute Details
#fg ⇒ Object (readonly)
Returns the value of attribute fg.
17 18 19 |
# File 'lib/effects.rb', line 17 def fg @fg end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
17 18 19 |
# File 'lib/effects.rb', line 17 def value @value end |
Instance Method Details
#reset(win) ⇒ Object
41 42 43 44 45 |
# File 'lib/effects.rb', line 41 def reset(win) attr = self.value win.cwin.attroff(attr) win.set_colors(@old_fg, win.bg) if fg end |
#set(win) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/effects.rb', line 33 def set(win) # Save off current state? @old_fg = win.fg attr, fg = self.value, self.fg win.cwin.attron(attr) win.set_colors(fg, win.bg) if fg end |