class RubyText::Effects
Hande text effects (bold, normal, reverse, underline)
Constants
- Modes
Text modes
- Others
Other text modes “of our own”
Attributes
bg[R]
fg[R]
value[R]
Public Class Methods
new(*args, bg: nil)
click to toggle source
Initialize an Effects
object
# File lib/effects.rb, line 30 def initialize(*args, bg: nil) 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 @bg = bg || @bg @value = bits end
Public Instance Methods
reset(win)
click to toggle source
“Turn off” effect in specified window
# File lib/effects.rb, line 58 def reset(win) attr = self.value win.cwin.attroff(attr) win.set_colors(@old_fg, @old_bg) # Does restore logic work? end
set(win)
click to toggle source
“Turn on” effect to specified window
# File lib/effects.rb, line 47 def set(win) @old_fg, @old_bg = win.fg, win.bg # Save off current state? attr, fg, bg = self.value, self.fg, self.bg win.cwin.attron(attr) fg ||= win.fg bg ||= win.bg win.set_colors(fg, bg) end