Method: TkTextMark#initialize

Defined in:
ext/lib/tk/textmark.rb

#initialize(parent, index) ⇒ TkTextMark

Returns a new instance of TkTextMark.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'ext/lib/tk/textmark.rb', line 33

def initialize(parent, index)
  #unless parent.kind_of?(Tk::Text)
  #  fail ArgumentError, "expect Tk::Text for 1st argument"
  #end
  @parent = @t = parent
  @tpath = parent.path
  Tk_TextMark_ID.mutex.synchronize{
    # @path = @id = Tk_TextMark_ID.join('')
    @path = @id = Tk_TextMark_ID.join(TkCore::INTERP._ip_id_).freeze
    Tk_TextMark_ID[1].succ!
  }
  TMarkID_TBL.mutex.synchronize{
    TMarkID_TBL[@id] = self
    TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
    TMarkID_TBL[@tpath][@id] = self
  }
  tk_call_without_enc(@t.path, 'mark', 'set', @id, 
                      _get_eval_enc_str(index))
  @t._addtag id, self
end