Class: TkTextTag

Class | TkTextTag
In: | tk/lib/tk/texttag.rb
Parent: | TkObject

### Methods

[] []= add bind bind_append bind_remove bindinfo cget configinfo configure current_configinfo destroy exist? first id id2obj last lower new nextrange prevrange raise ranges remove

### Included Modules

TkTreatTagFont TkText::IndexModMethods

### Constants

TTagID_TBL | = | TkCore::INTERP.create_table
Tk_TextTag_ID | = | ['tag'.freeze, '00000'.taint].freeze

### Public Class methods

id2obj(text, id)

[Source]

    # File tk/lib/tk/texttag.rb, line 17
      def TkTextTag.id2obj(text, id)
        tpath = text.path
        return id unless TTagID_TBL[tpath]
        TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
      end

new(parent, *args)

[Source]

    # File tk/lib/tk/texttag.rb, line 23
      def initialize(parent, *args)
        #unless parent.kind_of?(TkText)
        #  fail ArgumentError, "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_).freeze
        # 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 != []
          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

### Public Instance methods

[](key)

[Source]

    # File tk/lib/tk/texttag.rb, line 107
      def [](key)
        cget key
      end

[]=(key,val)

[Source]

    # File tk/lib/tk/texttag.rb, line 111
      def []=(key,val)
        configure key, val
        val
      end

add(*indices)

[Source]

    # File tk/lib/tk/texttag.rb, line 70
      def add(*indices)
        tk_call_without_enc(@t.path, 'tag', 'add', @id,
                            *(indices.collect{|idx| _get_eval_enc_str(idx)}))
        self
      end

bind(seq, *args)

def bind(seq, cmd=Proc.new, *args)

      _bind([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
      self

end

[Source]

    # File tk/lib/tk/texttag.rb, line 175
      def bind(seq, *args)
        # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
        if TkComm._callback_entry?(args[0]) || !block_given?
          cmd = args.shift
        else
          cmd = Proc.new
        end
        _bind([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
        self
      end

bind_append(seq, *args)

def bind_append(seq, cmd=Proc.new, *args)

      _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
      self

end

[Source]

    # File tk/lib/tk/texttag.rb, line 190
      def bind_append(seq, *args)
        # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
        if TkComm._callback_entry?(args[0]) || !block_given?
          cmd = args.shift
        else
          cmd = Proc.new
        end
        _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
        self
      end

bind_remove(seq)

[Source]

    # File tk/lib/tk/texttag.rb, line 201
      def bind_remove(seq)
        _bind_remove([@t.path, 'tag', 'bind', @id], seq)
        self
      end

bindinfo(context=nil)

[Source]

    # File tk/lib/tk/texttag.rb, line 206
      def bindinfo(context=nil)
        _bindinfo([@t.path, 'tag', 'bind', @id], context)
      end

cget(key)

[Source]

    # File tk/lib/tk/texttag.rb, line 116
      def cget(key)
        @t.tag_cget @id, key
      end

configinfo(key=nil)

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

[Source]

    # File tk/lib/tk/texttag.rb, line 163
      def configinfo(key=nil)
        @t.tag_configinfo @id, key
      end

configure(key, val=None)

[Source]

    # File tk/lib/tk/texttag.rb, line 144
      def configure(key, val=None)
        @t.tag_configure @id, key, val
      end

current_configinfo(key=nil)

[Source]

    # File tk/lib/tk/texttag.rb, line 167
      def current_configinfo(key=nil)
        @t.current_tag_configinfo @id, key
      end

destroy()

[Source]

    # File tk/lib/tk/texttag.rb, line 222
      def destroy
        tk_call_without_enc(@t.path, 'tag', 'delete', @id)
        TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath]
        self
      end

exist?()

[Source]

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

first()

[Source]

    # File tk/lib/tk/texttag.rb, line 62
      def first
        TkText::IndexString.new(@id + '.first')
      end

id()

[Source]

    # File tk/lib/tk/texttag.rb, line 49
      def id
        TkText::IndexString.new(@id)
      end

last()

[Source]

    # File tk/lib/tk/texttag.rb, line 66
      def last
        TkText::IndexString.new(@id + '.last')
      end

lower(below=None)

[Source]

    # File tk/lib/tk/texttag.rb, line 216
      def lower(below=None)
        tk_call_without_enc(@t.path, 'tag', 'lower', @id,
                            _get_eval_enc_str(below))
        self
      end

nextrange(first, last=None)

[Source]

    # File tk/lib/tk/texttag.rb, line 91
      def nextrange(first, last=None)
        simplelist(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
                                       _get_eval_enc_str(first),
                                       _get_eval_enc_str(last))).collect{|idx|
          TkText::IndexString.new(idx)
        }
      end

prevrange(first, last=None)

[Source]

    # File tk/lib/tk/texttag.rb, line 99
      def prevrange(first, last=None)
        simplelist(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
                                       _get_eval_enc_str(first),
                                       _get_eval_enc_str(last))).collect{|idx|
          TkText::IndexString.new(idx)
        }
      end

raise(above=None)

[Source]

    # File tk/lib/tk/texttag.rb, line 210
      def raise(above=None)
        tk_call_without_enc(@t.path, 'tag', 'raise', @id,
                            _get_eval_enc_str(above))
        self
      end

ranges()

[Source]

    # File tk/lib/tk/texttag.rb, line 82
      def ranges
        l = tk_split_simplelist(tk_call_without_enc(@t.path, 'tag', 'ranges', @id))
        r = []
        while key=l.shift
          r.push [TkText::IndexString.new(key), TkText::IndexString.new(l.shift)]
        end
        r
      end

remove(*indices)

[Source]

    # File tk/lib/tk/texttag.rb, line 76
      def remove(*indices)
        tk_call_without_enc(@t.path, 'tag', 'remove', @id,
                            *(indices.collect{|idx| _get_eval_enc_str(idx)}))
        self
      end

[Validate]