Sha256: ab0a0a96ce80954c88d1dbb27d6403be947c79435190a0ce2cf727d60f32a2b1
Contents?: true
Size: 1.39 KB
Versions: 4
Compression:
Stored size: 1.39 KB
Contents
require File.dirname(__FILE__) + "/../../node/base" module FN module SWF module Node def Text(node, alt_text) out = FN::Node::Base("text", node.attributes.to_h) out.extend(Text) out.text = node.children.to_s out.text = alt_text if out.text.empty? out end module Text include FN::Node::Base SPACE = /\s+/ def text (child && child.content).to_s end def text=(s) self.children.map{|c| c.remove! } self << XML::Node.new_cdata(s) end def escaped_text text.gsub("\\", "\\\\").gsub("\"", "\\\"").gsub(SPACE, " ") end def visit(struct) has_no_children name = "#{self[:text]}_#{self[:index]}" x = self[:x] y = self[:y] w = self[:width] h = self[:height].to_i + 20 # Fudge struct.<< ".action:" do struct << "this.createTextField('#{name}', #{$depth+=1}, #{x}, #{y}, #{w}, #{h});" struct << "id = this['#{name}'];" struct << "id.html=true;" struct << "id.multiline=true;" struct << "id.wordWrap=true;" struct << "id.htmlText = \"#{escaped_text}\";" struct << "id.selectable = false;" end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fn_document-0.9.6 | lib/fn/swf/node/text.rb |
fn_document-0.9.4 | lib/fn/swf/node/text.rb |
fn_document-0.9.3 | lib/fn/swf/node/text.rb |
fn_document-0.9.2 | lib/fn/swf/node/text.rb |