Sha256: 77ca40b87b0f017a9cefed14893c2d7d4be8b9d354f30eca8243e37968e51b8b

Contents?: true

Size: 1001 Bytes

Versions: 5

Compression:

Stored size: 1001 Bytes

Contents

class Shoes
  class App
    [:code, :del, :em, :ins, :strong, :sub, :sup].each do |m|
      define_method m do |*str|
        Text.new m, str
      end
    end

    [:bg, :fg].each do |m|
      define_method m do |*str|
        color = str.pop
        Text.new m, str, color
      end
    end

    def link *str, &blk
      Link.new :link, str, &blk
    end

    def font name
      @font_family = name
    end
  end

  class Text
    def initialize m, str, color=nil
      @style, @str, @color = m, str, color
      @to_s = str.map(&:to_s).join
    end
    attr_reader :to_s, :style, :str, :color
  end

  class Link < Text
    def initialize m, str, color=nil, &blk
      @blk = blk
      super m, str, color
    end
    attr_reader :blk
    attr_accessor :ln, :lh, :sx, :sy, :ex, :ey, :pl, :pt, :pw, :ph, :clickabled, :parent

    def clear
      @parent.app.cs.removeListener Swt::SWT::MouseDown, @ln
      @parent.links.delete self
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
purple_shoes-0.6.153 lib/shoes/text.rb
purple_shoes-0.5.149 lib/shoes/text.rb
purple_shoes-0.0.126 lib/shoes/text.rb
purple_shoes-0.0.115 lib/shoes/text.rb
purple_shoes-0.0.101 lib/shoes/text.rb