f



Tk text search and elided text

All,

I'm having trouble understanding the following text widget behavior.
I'm using Tcl/Tk 8.4.9.

I've got a text widget with some elided text.  A search returns the
position L.C (properly), but a subsequent search starting at L.C for
the same string fails to return L.C. However, a search with the option
-elide does return L.C.  The elided text is at the beginning of the
line, a good 60 characters before the text in question.

Here's the example:

#  -------------------------------- end
toplevel .bfw
pack [set t [text .bfw.t]] -expand 1 -fill both

set elidetext "to elide"

$t tag configure toelide -elide 1

$t insert end "random\n"
$t insert end ${elidetext} toelide "something
here                                missing instantiation\n"
$t insert end ${elidetext} toelide "other
text                               missing instantiation\n"

puts [set res [$t search inst 1.0]]
# prints 2.62 - proper starting point for 'inst'
puts [$t search inst $res]
# prints 3.57 - second occurrence of 'inst'
puts [$t search -elide inst $res]
# prints 2.62 - first occurrence of 'inst'
#  -------------------------------- end

Am I doing something wrong?  Is there some expectation I shouldn't
have?
I figured that all 3 searches should return 2.62.


thanks,

TJ
0
11/10/2008 10:38:04 PM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

4 Replies
1186 Views

Similar Articles

[PageSpeed] 15

bigfaceworm wrote:
> All,
> 
> I'm having trouble understanding the following text widget behavior.
> I'm using Tcl/Tk 8.4.9.
> 
> I've got a text widget with some elided text.  A search returns the
> position L.C (properly), but a subsequent search starting at L.C for
> the same string fails to return L.C. However, a search with the option
> -elide does return L.C.  The elided text is at the beginning of the
> line, a good 60 characters before the text in question.
> 
> Here's the example:
> 
> #  -------------------------------- end
> toplevel .bfw
> pack [set t [text .bfw.t]] -expand 1 -fill both
> 
> set elidetext "to elide"
> 
> $t tag configure toelide -elide 1
> 
> $t insert end "random\n"
> $t insert end ${elidetext} toelide "something
> here                                missing instantiation\n"
> $t insert end ${elidetext} toelide "other
> text                               missing instantiation\n"
> 
> puts [set res [$t search inst 1.0]]
> # prints 2.62 - proper starting point for 'inst'
> puts [$t search inst $res]
> # prints 3.57 - second occurrence of 'inst'
> puts [$t search -elide inst $res]
> # prints 2.62 - first occurrence of 'inst'
> #  -------------------------------- end
> 
> Am I doing something wrong?  Is there some expectation I shouldn't
> have?
> I figured that all 3 searches should return 2.62.
> 
> 
> thanks,
> 
> TJ

FYI,
   Tried on XP with 8.5.3
works fine: same answer all 3 times

Bruce
0
11/10/2008 10:55:20 PM
On Nov 10, 2:55=A0pm, Bruce <doNOTmai...@example.com> wrote:
> > I'm having trouble understanding the following text widget behavior.
> > I'm using Tcl/Tk 8.4.9.
>
> > I've got a text widget with some elided text. =A0A search returns the
> > position L.C (properly), but a subsequent search starting at L.C for
> > the same string fails to return L.C. However, a search with the option
> > -elide does return L.C. =A0The elided text is at the beginning of the
> > line, a good 60 characters before the text in question.
   ....
> FYI,
> =A0 =A0Tried on XP with 8.5.3
> works fine: same answer all 3 times

This was something corrected and noted in the changes for 8.5.  The
text widget updates were too vast to backport for 8.4.

Jeff
0
jeff.hobbs (444)
11/11/2008 2:00:56 AM
bigfaceworm wrote:
> I'm having trouble understanding the following text widget behavior.
> I'm using Tcl/Tk 8.4.9.

Upgrade to 8.5. Many things were fixed then, and there's no way that
we want to backport due to the substantial internal changes.

Donal.
0
11/11/2008 11:34:26 AM
On Nov 10, 6:00=A0pm, Jeff Hobbs <jeff.ho...@gmail.com> wrote:
> This was something corrected and noted in the changes for 8.5. =A0The
> text widget updates were too vast to backport for 8.4.

Thanks for the info.  I'll just work around it for now (upgrading is
not an option unfortunately).
Something to look forward to.


TJ
0
11/11/2008 8:54:07 PM
Reply: