In Files

  • tk/lib/tk/texttag.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

TkTextNamedTag

Public Class Methods

new(parent, name, *args) click to toggle source
 
               # File tk/lib/tk/texttag.rb, line 255
def self.new(parent, name, *args)
  tagobj = nil
  TTagID_TBL.mutex.synchronize{
    if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name]
      tagobj = TTagID_TBL[parent.path][name]
    else
      # super(parent, name, *args)
      (tagobj = self.allocate).instance_eval{
        @parent = @t = parent
        @tpath = parent.path
        @path = @id = name
        TTagID_TBL[@id] = self
        TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
        TTagID_TBL[@tpath][@id] = self unless TTagID_TBL[@tpath][@id]
        @t._addtag @id, self
      }
    end
  }

  if args != []
    keys = args.pop
    if keys.kind_of?(Hash)
      tagobj.add(*args) if args != []
      tagobj.configure(keys)
    else
      args.push keys
      tagobj.add(*args)
    end
  end

  tagobj
end
            
new(parent, name, *args) click to toggle source
 
               # File tk/lib/tk/texttag.rb, line 288
def initialize(parent, name, *args)
  # dummy:: not called by 'new' method

  #unless parent.kind_of?(Tk::Text)
  #  fail ArgumentError, "expect Tk::Text for 1st argument"
  #end
  @parent = @t = parent
  @tpath = parent.path
  @path = @id = name

  #if mode
  #  tk_call @t.path, "addtag", @id, *args
  #end
  if args != []
    keys = args.pop
    if keys.kind_of?(Hash)
      add(*args) if args != []
      configure(keys)
    else
      args.push keys
      add(*args)
    end
  end
  @t._addtag @id, self
end