| Class | TkTextTag |
| In: |
tk/lib/tk/texttag.rb
|
| Parent: | TkObject |
| TTagID_TBL | = | TkCore::INTERP.create_table |
| Tk_TextTag_ID | = | ['tag'.freeze, '00000'.taint].freeze |
# File tk/lib/tk/texttag.rb, line 16 def TkTextTag.id2obj(text, id) tpath = text.path return id unless TTagID_TBL[tpath] TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id end
# File tk/lib/tk/texttag.rb, line 22 def initialize(parent, *args) #unless parent.kind_of?(TkText) # fail ArguemntError, "expect TkText for 1st argument" #end @parent = @t = parent @tpath = parent.path # @path = @id = Tk_TextTag_ID.join('') @path = @id = Tk_TextTag_ID.join(TkCore::INTERP._ip_id_) # TTagID_TBL[@id] = self TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath] TTagID_TBL[@tpath][@id] = self Tk_TextTag_ID[1].succ! #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys) if args != [] then keys = args.pop if keys.kind_of? Hash then add(*args) if args != [] configure(keys) else args.push keys add(*args) end end @t._addtag id, self end
# File tk/lib/tk/texttag.rb, line 68 def add(*indices) tk_call_without_enc(@t.path, 'tag', 'add', @id, *(indices.collect{|idx| _get_eval_enc_str(idx)})) self end
# File tk/lib/tk/texttag.rb, line 165 def bind(seq, cmd=Proc.new, *args) _bind([@t.path, 'tag', 'bind', @id], seq, cmd, *args) self end
# File tk/lib/tk/texttag.rb, line 170 def bind_append(seq, cmd=Proc.new, *args) _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, *args) self end
# File tk/lib/tk/texttag.rb, line 175 def bind_remove(seq) _bind_remove([@t.path, 'tag', 'bind', @id], seq) self end
# File tk/lib/tk/texttag.rb, line 180 def bindinfo(context=nil) _bindinfo([@t.path, 'tag', 'bind', @id], context) end
def configure(key, val=None)
if key.kind_of? Hash
tk_call @t.path, 'tag', 'configure', @id, *hash_kv(key)
else
tk_call @t.path, 'tag', 'configure', @id, "-#{key}", val
end
end def configure(key, value)
if value == FALSE
value = "0"
elsif value.kind_of? Proc
value = install_cmd(value)
end
tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value
end
# File tk/lib/tk/texttag.rb, line 157 def configinfo(key=nil) @t.tag_configinfo @id, key end
# File tk/lib/tk/texttag.rb, line 138 def configure(key, val=None) @t.tag_configure @id, key, val end
# File tk/lib/tk/texttag.rb, line 161 def current_configinfo(key=nil) @t.current_tag_configinfo @id, key end
# File tk/lib/tk/texttag.rb, line 196 def destroy tk_call_without_enc(@t.path, 'tag', 'delete', @id) TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath] self end
# File tk/lib/tk/texttag.rb, line 52 def exist? if ( tk_split_simplelist(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'names'))).find{|id| id == @id } ) true else false end end
# File tk/lib/tk/texttag.rb, line 190 def lower(below=None) tk_call_without_enc(@t.path, 'tag', 'lower', @id, _get_eval_enc_str(below)) self end
# File tk/lib/tk/texttag.rb, line 89 def nextrange(first, last=None) tk_split_list(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id, _get_eval_enc_str(first), _get_eval_enc_str(last))) end
# File tk/lib/tk/texttag.rb, line 95 def prevrange(first, last=None) tk_split_list(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id, _get_eval_enc_str(first), _get_eval_enc_str(last))) end
# File tk/lib/tk/texttag.rb, line 184 def raise(above=None) tk_call_without_enc(@t.path, 'tag', 'raise', @id, _get_eval_enc_str(above)) self end
# File tk/lib/tk/texttag.rb, line 80 def ranges l = tk_split_simplelist(tk_call_without_enc(@t.path, 'tag', 'ranges', @id)) r = [] while key=l.shift r.push [key, l.shift] end r end