Sha256: 5054ed4bdad68061b3930237f16fa4e5a519d35ceb30f3bc5841e63964ad8ab0
Contents?: true
Size: 793 Bytes
Versions: 1
Compression:
Stored size: 793 Bytes
Contents
def fx(str, *args) eff = RubyText::Effects.new(*args) str.define_singleton_method(:effect) { eff } str # must return str end class RubyText::Effects # dumb name? Modes = {bold: X::A_BOLD, normal: X::A_NORMAL, reverse: X::A_REVERSE, under: X::A_UNDERLINE} Others = %[:show, :hide] # show/hide cursor; more later?? attr_reader :value, :fg 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 def set(win) attr, fg = self.value, self.fg win.cwin.attron(attr) win.set_colors(fg, win.bg) if fg end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubytext-0.0.74 | lib/effects.rb |