The ruby tktext documentation lists
insert(index, chars, ?tagList, chars, tagList, …?) :
[…] If tagList is specified then it consists of a list of tag names;
the new characters will receive all of the tags in this list and no
others, regardless of the tags present around the insertion point. If
multiple chars-tagList argument pairs are present, they produce the
same effect as if a separate insert widget command had been issued for
each pair, in order. The last tagList argument may be omitted.
I tried the following code (where a is an array of alternating text,
TkTextTag and pos = ‘end’):
insert(pos, *a)
insert(pos, "\n")
a.each_slice(2) {|i, j| insert(pos, i, j)}
which produces the following screenshot:
(The first line is not what I wanted, the second and third lines are
what should have been printed). It looks like it’s taking the first
text, and then merging all the tags via something analogous to
hash#update. Is this a bug or am I doing something wrong?
Here’s the value of a.inspect in case it reveals anything:
[“hello world”, #<TkTextTag:0x00000001c5b9c0
@t=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>,
@parent=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>, @tpath=“.w00003.w00004”, @id=“tag00000”,
@path=“tag00000”>, “Bold red text on blue:\n”,
#<TkTextTag:0x00000001c22dc8
@t=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>,
@parent=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>, @tpath=“.w00003.w00004”, @id=“tag00001”,
@path=“tag00001”>, “Green text on blue”, #<TkTextTag:0x000000023540b0
@t=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>,
@parent=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>, @tpath=“.w00003.w00004”, @id=“tag00002”,
@path=“tag00002”>, “none\n”, #<TkTextTag:0x0000000235f7f8
@t=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>,
@parent=#<Text::Markup::TkMarkupText:0x00000001bc2ef0
@path=“.w00003.w00004”>, @tpath=“.w00003.w00004”, @id=“tag00003”,
@path=“tag00003”>]
martin