Class Tk::Iwidgets::Scrolledtext
In: tk/lib/tkextlib/iwidgets/scrolledtext.rb
Parent: Tk::Iwidgets::Scrolledwidget

Methods

Included Modules

TkTextTagConfig

Constants

TkCommandNames = ['::iwidgets::scrolledtext'.freeze].freeze
WidgetClassName = 'Scrolledtext'.freeze

Public Class methods

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 24
  def initialize(*args)
    super(*args)
    @text = component_widget('text')
  end

Public Instance methods

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 75
  def bbox(index)
    list(tk_send('bbox', index))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 39
  def child_site
    window(tk_call(@path, 'childsite'))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 43
  def clear
    tk_call(@path, 'clear')
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 78
  def compare(idx1, op, idx2)
    bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1), 
                             op, _get_eval_enc_str(idx2)))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 216
  def current_image_configinfo(index, slot = nil)
    if TkComm::GET_CONFIGINFO_AS_ARRAY
      if slot
        conf = image_configinfo(index, slot)
        {conf[0] => conf[4]}
      else
        ret = {}
        image_configinfo(index).each{|conf|
          ret[conf[0]] = conf[4] if conf.size > 2
        }
        ret
      end
    else # ! TkComm::GET_CONFIGINFO_AS_ARRAY

      ret = {}
      image_configinfo(index, slot).each{|k, conf|
        ret[k] = conf[-1] if conf.kind_of?(Array)
      }
      ret
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 83
  def debug
    bool(tk_send_without_enc('debug'))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 86
  def debug=(boolean)
    tk_send_without_enc('debug', boolean)
    #self

    boolean
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 92
  def delete(first, last=None)
    tk_send_without_enc('delete', first, last)
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 97
  def dlineinfo(index)
    list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 57
  def export(file)
    tk_call(@path, 'export', file)
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 101
  def get(*index)
    _fromUTF8(tk_send_without_enc('get', *index))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 104
  def get_displaychars(*index)
    # Tk8.5 feature

    get('-displaychars', *index)
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 109
  def image_cget(index, slot)
    case slot.to_s
    when 'text', 'label', 'show', 'data', 'file'
      _fromUTF8(tk_send_without_enc('image', 'cget', 
                                    _get_eval_enc_str(index), "-#{slot}"))
    else
      tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget', 
                                                _get_eval_enc_str(index), 
                                                "-#{slot}")))
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 135
  def image_configinfo(index, slot = nil)
    if TkComm::GET_CONFIGINFO_AS_ARRAY
      if slot
        case slot.to_s
        when 'text', 'label', 'show', 'data', 'file'
          conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
        else
          conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
        end
        conf[0] = conf[0][1..-1]
        conf
      else
        tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
          conf = tk_split_simplelist(conflist)
          conf[0] = conf[0][1..-1]
          case conf[0]
          when 'text', 'label', 'show', 'data', 'file'
          else
            if conf[3]
              if conf[3].index('{')
                conf[3] = tk_split_list(conf[3]) 
              else
                conf[3] = tk_tcl2ruby(conf[3]) 
              end
            end
            if conf[4]
              if conf[4].index('{')
                conf[4] = tk_split_list(conf[4]) 
              else
                conf[4] = tk_tcl2ruby(conf[4]) 
              end
            end
          end
          conf[1] = conf[1][1..-1] if conf.size == 2 # alias info

          conf
        }
      end
    else # ! TkComm::GET_CONFIGINFO_AS_ARRAY

      if slot
        case slot.to_s
        when 'text', 'label', 'show', 'data', 'file'
          conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
        else
          conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
        end
        key = conf.shift[1..-1]
        { key => conf }
      else
        ret = {}
        tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
          conf = tk_split_simplelist(conflist)
          key = conf.shift[1..-1]
          case key
          when 'text', 'label', 'show', 'data', 'file'
          else
            if conf[2]
              if conf[2].index('{')
                conf[2] = tk_split_list(conf[2]) 
              else
                conf[2] = tk_tcl2ruby(conf[2]) 
              end
            end
            if conf[3]
              if conf[3].index('{')
                conf[3] = tk_split_list(conf[3]) 
              else
                conf[3] = tk_tcl2ruby(conf[3]) 
              end
            end
          end
          if conf.size == 1
            ret[key] = conf[0][1..-1]  # alias info

          else
            ret[key] = conf
          end
        }
        ret
      end
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 121
  def image_configure(index, slot, value=None)
    if slot.kind_of? Hash
      _fromUTF8(tk_send_without_enc('image', 'configure', 
                                    _get_eval_enc_str(index), 
                                    *hash_kv(slot, true)))
    else
      _fromUTF8(tk_send_without_enc('image', 'configure', 
                                    _get_eval_enc_str(index), 
                                    "-#{slot}", 
                                    _get_eval_enc_str(value)))
    end
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 237
  def image_names
    tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
      tagid2obj(elt)
    }
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 48
  def import(file, idx=nil)
    if idx
      tk_call(@path, 'import', file, index(idx))
    else
      tk_call(@path, 'import', file)
    end
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 243
  def index(index)
    tk_send_without_enc('index', _get_eval_enc_str(index))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 247
  def insert(index, *args)
    tk_send('insert', index, *args)
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 258
  def mark_gravity(mark, direction=nil)
    if direction
      tk_send_without_enc('mark', 'gravity', 
                          _get_eval_enc_str(mark), direction)
      self
    else
      tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 252
  def mark_names
    tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
      tagid2obj(elt)
    }
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 282
  def mark_next(index)
    tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next', 
                                            _get_eval_enc_str(index))))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 288
  def mark_previous(index)
    tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous', 
                                            _get_eval_enc_str(index))))
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 268
  def mark_set(mark, index)
    tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark), 
                        _get_eval_enc_str(index))
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 275
  def mark_unset(*marks)
    tk_send_without_enc('mark', 'unset', 
                        *(marks.collect{|mark| _get_eval_enc_str(mark)}))
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 29
  def method_missing(id, *args)
    if @text.methods.include?(id.id2name)
      @text.__send__(id, *args)
    else
      super(id, *args)
    end
  end
next_mark(index)

Alias for mark_next

previous_mark(index)

Alias for mark_previous

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 478
  def rsearch(pat,start,stop=None)
    rsearch_with_length(pat,start,stop)[0]
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 426
  def rsearch_with_length(pat,start,stop=None)
    pat = pat.chr if pat.kind_of? Integer
    if stop != None
      return ["", 0] if compare(start,'<=',stop)
      txt = get(stop,start)
      if (pos = txt.rindex(pat))
        match = $&
        #pos = txt[0..(pos-1)].split('').length if pos > 0

        pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
        if pat.kind_of? String
          #return [index(stop + " + #{pos} chars"), pat.split('').length]

          return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
        else
          #return [index(stop + " + #{pos} chars"), $&.split('').length]

          return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
        end
      else
        return ["", 0]
      end
    else
      txt = get('1.0',start)
      if (pos = txt.rindex(pat))
        match = $&
        #pos = txt[0..(pos-1)].split('').length if pos > 0

        pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
        if pat.kind_of? String
          #return [index("1.0 + #{pos} chars"), pat.split('').length]

          return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
        else
          #return [index("1.0 + #{pos} chars"), $&.split('').length]

          return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
        end
      else
        txt = get('1.0','end - 1 char')
        if (pos = txt.rindex(pat))
          match = $&
          #pos = txt[0..(pos-1)].split('').length if pos > 0

          pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
          if pat.kind_of? String
            #return [index("1.0 + #{pos} chars"), pat.split('').length]

            return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
          else
            #return [index("1.0 + #{pos} chars"), $&.split('').length]

            return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
          end
        else
          return ["", 0]
        end
      end
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 298
  def scan_dragto(x, y)
    tk_send_without_enc('scan', 'dragto', x, y)
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 294
  def scan_mark(x, y)
    tk_send_without_enc('scan', 'mark', x, y)
    self
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 422
  def search(pat,start,stop=None)
    search_with_length(pat,start,stop)[0]
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 365
  def search_with_length(pat,start,stop=None)
    pat = pat.chr if pat.kind_of? Integer
    if stop != None
      return ["", 0] if compare(start,'>=',stop)
      txt = get(start,stop)
      if (pos = txt.index(pat))
        match = $&
        #pos = txt[0..(pos-1)].split('').length if pos > 0

        pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
        if pat.kind_of? String
          #return [index(start + " + #{pos} chars"), pat.split('').length]

          return [index(start + " + #{pos} chars"), 
                  _ktext_length(pat), pat.dup]
        else
          #return [index(start + " + #{pos} chars"), $&.split('').length]

          return [index(start + " + #{pos} chars"), 
                  _ktext_length(match), match]
        end
      else
        return ["", 0]
      end
    else
      txt = get(start,'end - 1 char')
      if (pos = txt.index(pat))
        match = $&
        #pos = txt[0..(pos-1)].split('').length if pos > 0

        pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
        if pat.kind_of? String
          #return [index(start + " + #{pos} chars"), pat.split('').length]

          return [index(start + " + #{pos} chars"), 
                  _ktext_length(pat), pat.dup]
        else
          #return [index(start + " + #{pos} chars"), $&.split('').length]

          return [index(start + " + #{pos} chars"), 
                  _ktext_length(match), match]
        end
      else
        txt = get('1.0','end - 1 char')
        if (pos = txt.index(pat))
          match = $&
          #pos = txt[0..(pos-1)].split('').length if pos > 0

          pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
          if pat.kind_of? String
            #return [index("1.0 + #{pos} chars"), pat.split('').length]

            return [index("1.0 + #{pos} chars"), 
                    _ktext_length(pat), pat.dup]
          else
            #return [index("1.0 + #{pos} chars"), $&.split('').length]

            return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
          end
        else
          return ["", 0]
        end
      end
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 482
  def see(index)
    tk_send_without_enc('see', index)
    self
  end
set_mark(mark, index)

Alias for mark_set

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 325
  def tksearch(*args)
    # call 'search' subcommand of text widget

    #   args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]

    # If <pattern> is regexp, then it must be a regular expression of Tcl

    if args[0].kind_of?(Array)
      opts = args.shift.collect{|opt| '-' + opt.to_s }
    else
      opts = []
    end

    opts << '--'

    ret = tk_send('search', *(opts + args))
    if ret == ""
      nil
    else
      ret
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 345
  def tksearch_with_count(*args)
    # call 'search' subcommand of text widget

    #   args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]

    # If <pattern> is regexp, then it must be a regular expression of Tcl

    if args[0].kind_of?(Array)
      opts = args.shift.collect{|opt| '-' + opt.to_s }
    else
      opts = []
    end

    opts << '-count' << args.shift << '--'

    ret = tk_send('search', *(opts + args))
    if ret == ""
      nil
    else
      ret
    end
  end
unset_mark(*marks)

Alias for mark_unset

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 489
  def xview(*index)
    if index.size == 0
      list(tk_send_without_enc('xview'))
    else
      tk_send_without_enc('xview', *index)
      self
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 497
  def xview_moveto(*index)
    xview('moveto', *index)
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 500
  def xview_scroll(*index)
    xview('scroll', *index)
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 504
  def yview(*index)
    if index.size == 0
      list(tk_send_without_enc('yview'))
    else
      tk_send_without_enc('yview', *index)
      self
    end
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 512
  def yview_moveto(*index)
    yview('moveto', *index)
  end

[Source]

# File tk/lib/tkextlib/iwidgets/scrolledtext.rb, line 515
  def yview_scroll(*index)
    yview('scroll', *index)
  end

[Validate]