In Files

  • tk/lib/tk/textmark.rb

Class/Module Index [+]

Quicksearch

TktMark

Public Class Methods

id2obj(text, id) click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 22
def TkTextMark.id2obj(text, id)
  tpath = text.path
  TMarkID_TBL.mutex.synchronize{
    if TMarkID_TBL[tpath]
      TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
    else
      id 
    end
  }
end
            
new(parent, index) click to toggle source
 
               # File tk/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
            

Public Instance Methods

destroy() click to toggle source
Alias for: unset
exist?() click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 58
def exist?
  #if ( tk_split_simplelist(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'names'))).find{|id| id == @id } )
  if ( tk_split_simplelist(tk_call_without_enc(@t.path, 'mark', 'names'), false, true).find{|id| id == @id } )
    true
  else
    false
  end
end
            
gravity() click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 114
def gravity
  tk_call_without_enc(@t.path, 'mark', 'gravity', @id)
end
            
gravity=(direction) click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 118
def gravity=(direction)
  tk_call_without_enc(@t.path, 'mark', 'gravity', @id, direction)
  #self
  direction
end
            
id() click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 54
def id
  Tk::Text::IndexString.new(@id)
end
            
mutex() click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 14
def mutex; @mutex; end
            
next(index = nil) click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 124
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
            
pos() click to toggle source

# move to Tk::Text::IndexModMethods module def +(mod)

return chars(mod) if mod.kind_of?(Numeric)

mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
  Tk::Text::IndexString.new(@id + ' + ' + mod)
else
  Tk::Text::IndexString.new(@id + ' ' + mod)
end

end

def -(mod)

return chars(-mod) if mod.kind_of?(Numeric)

mod = mod.to_s
if mod =~ /^\s*[+-]?\d/
  Tk::Text::IndexString.new(@id + ' - ' + mod)
elsif mod =~ /^\s*[-]\s+(\d.*)$/
  Tk::Text::IndexString.new(@id + ' - -' + $1)
else
  Tk::Text::IndexString.new(@id + ' ' + mod)
end

end

 
               # File tk/lib/tk/textmark.rb, line 94
def pos
  @t.index(@id)
end
            
pos=(where) click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 98
def pos=(where)
  set(where)
end
            
previous(index = nil) click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 132
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
            
set(where) click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 102
def set(where)
  tk_call_without_enc(@t.path, 'mark', 'set', @id, 
                      _get_eval_enc_str(where))
  self
end
            
unset() click to toggle source
 
               # File tk/lib/tk/textmark.rb, line 108
def unset
  tk_call_without_enc(@t.path, 'mark', 'unset', @id)
  self
end
            
Also aliased as: destroy

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus