Method: Tk::Text#insert

Defined in:
lib/tk/text.rb

#insert(index, chars, *tags) ⇒ Object



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
# File 'lib/tk/text.rb', line 594

def insert(index, chars, *tags)
  if tags[0].kind_of?(Array)
    # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ...
    args = [chars]
    while tags.size > 0
      args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ')  # taglist
      args << tags.shift if tags.size > 0                           # chars
    end
    super(index, *args)
  else
    # single chars-taglist argument :: str, tag, tag, ...
    if tags.size == 0
      super(index, chars)
    else
      super(index, chars, tags.collect{|x|_get_eval_string(x)}.join(' '))
    end
  end
end