The display logic has bugs (version 8.6), try this example:
pack [text .t -width 20 -height 4 -wrap word -padx 4 -pady 10]
.t configure -font {Courier -16 bold}
.t tag configure blue -foreground darkblue
.t tag configure red -foreground darkred
.t tag configure elide -elide 1
.t insert end "Line 1" blue
.t insert end "\nThis line is wrapping around two times." red
.t yview insert ;# without this statement wish8.6 works
.t tag add elide 1.3 2.0
This is the result:
wish8.6 | revised version |
![]() |
![]() |
The result in left text widget is obviously wrong, the revised version gives the correct result (in right widget).
The following script is even crashing, although this requires that debug mode is enabled:
pack [text .t -font {Courier -12} -width 20 -height 3 -wrap word]
.t debug on ;# enable debugging
.t tag configure elide -elide 1
.t insert end "Line 1\nThis line is wrapping around two times."
.t tag add elide 1.3 2.0
.t yview insert
update
.t yview scroll -1 pixels
Also the display of insert cursor has problems (version 8.6) when elided ranges are involved, try this example:
pack [text .t]
.t configure -width 16 -height 1
.t configure -font {sans -16}
.t configure -blockcursor on -insertofftime 0 -insertbackground yellow
.t configure -padx 5 -pady 5
focus .t
.t tag configure elide -elide on
.t insert end "Dummy text\n" elide
.t insert end "More dummy text"
.t mark set insert 1.0
The cursor should be visible at first character, but isn't visible. If you move the insert cursor to right, it will appear (at second character), and then move left two times, it will disappear again.
These are good examples that the implementation of the -elide feature in wish8.6 has severe problems – all these ugly hacks, and so many reported bugs – but in revised version this feature has been re-implemented in a proper way (but this feature still requires special handling at several places, and this is always problematic – meaning error-prone).
One more bug: after executing this script you will see an empty text widget (tested with X11):
pack [text .t -width 70 -font TkFixedFont]
.t insert end "Nach dem Einlegen des Papiers sollten die "
.t insert end "Druckereinstellungen überprüft werden."
focus .t
update
.t mark set insert 1.0
.t mark set insert "insert display lineend"
But after pressing any cursor key (left or right) the text content will re-appear. (Hint: TkTextFindDisplayLineStartEnd is returning a byte position inside the two-byte sequence "ü" when searching for end of the display line, and this is destroying the UTF-8 string.)
Try next example:
pack [text .t -width 8 -height 5 -font TkFixedFont]
for {set i 0} {$i <= 5} {incr i} { .t insert end "Line $i\n" }
focus .t
update
# now simulate a button click right from character "4"
lassign [split [.t bbox 5.end]] x y
incr x 10
event generate .t <ButtonPress-1> -x $x -y $y
event generate .t <ButtonRelease-1> -x $x -y $y
The revised version will show the insert cursor, but not wish8.6. Click with mouse only a few pixels right from character "4", and the insert cursor will be shown, but if you click near the right border at last line the insert cursor will disappear again.
This script is hanging, tested with X11 (although this is only a minor bug, nobody is doing such weird things like in this script):
pack [text .t -width 10 -height 4 -wrap char]
.t insert end "averyveryveryveryverylongword" wrap
.t tag bind wrap <Enter> { .t configure -wrap none }
.t tag bind wrap <Leave> { .t configure -wrap char }
# we need a mapped window
while {![winfo ismapped .t]} { update }
# now simulate mouse hovering
event generate .t <Motion> -x 15 -y 15
event generate .t <Motion> -x 20 -y 20
event generate .t <Motion> -x 15 -y 15
event generate .t <Motion> -x 20 -y 20
update
exit 0