Class TkTextMark
In: tk/lib/tk/textmark.rb
Parent: TkObject

Methods

+   -   destroy   exist?   gravity   gravity=   id   id2obj   new   next   previous   set   unset  

Constants

TMarkID_TBL = TkCore::INTERP.create_table
Tk_TextMark_ID = ['mark'.freeze, '00000'.taint].freeze

Public Class methods

[Source]

# File tk/lib/tk/textmark.rb, line 13
  def TkTextMark.id2obj(text, id)
    tpath = text.path
    return id unless TMarkID_TBL[tpath]
    TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
  end

[Source]

# File tk/lib/tk/textmark.rb, line 19
  def initialize(parent, index)
    #unless parent.kind_of?(TkText)

    #  fail ArguemntError, "expect TkText for 1st argument"

    #end

    @parent = @t = parent
    @tpath = parent.path
    # @path = @id = Tk_TextMark_ID.join('')

    @path = @id = Tk_TextMark_ID.join(TkCore::INTERP._ip_id_)
    TMarkID_TBL[@id] = self
    TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
    TMarkID_TBL[@tpath][@id] = self
    Tk_TextMark_ID[1].succ!
    tk_call_without_enc(@t.path, 'mark', 'set', @id, 
                        _get_eval_enc_str(index))
    @t._addtag id, self
  end

Public Instance methods

[Source]

# File tk/lib/tk/textmark.rb, line 48
  def +(mod)
    @id + ' + ' + mod
  end

[Source]

# File tk/lib/tk/textmark.rb, line 51
  def -(mod)
    @id + ' - ' + mod
  end
destroy()

Alias for unset

[Source]

# File tk/lib/tk/textmark.rb, line 40
  def exist?
    if ( tk_split_simplelist(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'names'))).find{|id| id == @id } )
      true
    else
      false
    end
  end

[Source]

# File tk/lib/tk/textmark.rb, line 67
  def gravity
    tk_call_without_enc(@t.path, 'mark', 'gravity', @id)
  end

[Source]

# File tk/lib/tk/textmark.rb, line 71
  def gravity=(direction)
    tk_call_without_enc(@t.path, 'mark', 'gravity', @id, direction)
    #self

    direction
  end

[Source]

# File tk/lib/tk/textmark.rb, line 36
  def id
    @id
  end

[Source]

# File tk/lib/tk/textmark.rb, line 77
  def next(index = nil)
    if index
      @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'next', _get_eval_enc_str(index))))
    else
      @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'next', @id)))
    end
  end

[Source]

# File tk/lib/tk/textmark.rb, line 85
  def previous(index = nil)
    if index
      @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'previous', _get_eval_enc_str(index))))
    else
      @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'previous', @id)))
    end
  end

[Source]

# File tk/lib/tk/textmark.rb, line 55
  def set(where)
    tk_call_without_enc(@t.path, 'mark', 'set', @id, 
                        _get_eval_enc_str(where))
    self
  end

[Source]

# File tk/lib/tk/textmark.rb, line 61
  def unset
    tk_call_without_enc(@t.path, 'mark', 'unset', @id)
    self
  end

[Validate]