1# This file is a Tcl script to test the code in the file tkTextDisp.c.
2# This file is organized in the standard fashion for Tcl tests.
3#
4# Copyright (c) 1994 The Regents of the University of California.
5# Copyright (c) 1994-1997 Sun Microsystems, Inc.
6# Copyright (c) 1998-1999 by Scriptics Corporation.
7# All rights reserved.
8#
9# RCS: @(#) $Id$
10
11package require tcltest 2.1
12eval tcltest::configure $argv
13tcltest::loadTestedCommands
14namespace import -force tcltest::test
15
16# The procedure below is used as the scrolling command for the text;
17# it just saves the scrolling information in a variable "scrollInfo".
18
19proc scroll args {
20    global scrollInfo
21    set scrollInfo $args
22}
23
24# The procedure below is used to generate errors during scrolling commands.
25
26proc scrollError args {
27    error "scrolling error"
28}
29
30# Create entries in the option database to be sure that geometry options
31# like border width have predictable values.
32
33option add *Text.borderWidth 2
34option add *Text.highlightThickness 2
35
36# The frame .f is needed to make sure that the overall window is always
37# fairly wide, even if the text window is very narrow.  This is needed
38# because some window managers don't allow the overall width of a window
39# to get very narrow.
40
41catch {destroy .f .t}
42frame .f -width 100 -height 20
43pack append . .f left
44
45set fixedFont {Courier -12}
46# 15 on XP, 13 on Solaris 8
47set fixedHeight [font metrics $fixedFont -linespace]
48# 7 on all platforms
49set fixedWidth [font measure $fixedFont m]
50# 12 on XP
51set fixedAscent [font metrics $fixedFont -ascent]
52set fixedDiff [expr {$fixedHeight - 13}] ;# 2 on XP
53
54set varFont {Times -14}
55# 16 on XP, 15 on Solaris 8
56set varHeight [font metrics $varFont -linespace]
57# 13 on XP
58set varAscent [font metrics $varFont -ascent]
59set varDiff [expr {$varHeight - 15}] ;# 1 on XP
60
61set bigFont {Helvetica -24}
62# 27 on XP, 27 on Solaris 8
63set bigHeight [font metrics $bigFont -linespace]
64# 21 on XP
65set bigAscent [font metrics $bigFont -ascent]
66set ascentDiff [expr {$bigAscent - $fixedAscent}]
67
68text .t -font $fixedFont -width 20 -height 10 -yscrollcommand scroll
69pack append . .t {top expand fill}
70.t tag configure big -font $bigFont
71.t debug on
72wm geometry . {}
73
74# The statements below reset the main window;  it's needed if the window
75# manager is mwm to make mwm forget about a previous minimum size setting.
76
77wm withdraw .
78wm minsize . 1 1
79wm positionfrom . user
80wm deiconify .
81update
82
83# Some window managers (like olwm under SunOS 4.1.3) misbehave in a way
84# that tends to march windows off the top and left of the screen.  If
85# this happens, some tests will fail because parts of the window will
86# not need to be displayed (because they're off-screen).  To keep this
87# from happening, move the window if it's getting near the left or top
88# edges of the screen.
89
90if {([winfo rooty .] < 50) || ([winfo rootx .] < 50)} {
91    wm geom . +50+50
92}
93
94test textDisp-0.1 {double tag elide transition} {
95    # Example from tkchat crash.  For some reason can only
96    # get this test case to crash when first.
97    catch {destroy .top}
98    pack [text .top]
99
100    foreach val {0 1 2 3} {
101	.top insert 1.0 "hello\n"
102	.top tag configure tag$val
103	.top tag add tag$val 1.0 2.0
104	set ::Options(tag$val) 0
105    }
106
107    proc DoVis {tag} {
108	.top tag config $tag -elide $::Options($tag)
109    }
110
111    proc NickVis {val} {
112	foreach t [array names ::Options ] {
113	    if {$::Options($t) != $val} {
114		set ::Options($t) $val
115		DoVis $t
116	    }
117	}
118    }
119    NickVis 1
120    unset ::Options
121    destroy .top
122} {}
123
124test textDisp-0.2 {double tag elide transition} {
125    # Example from tkchat crash.  For some reason can only
126    # get this test case to crash when first.
127    catch {destroy .top}
128    pack [text .top]
129
130    foreach val {0 1 2 3} {
131	.top insert 1.0 "hello"
132	.top tag configure tag$val
133	.top tag add tag$val 1.0 1.5
134	set ::Options(tag$val) 0
135    }
136
137    proc DoVis {tag} {
138	.top tag config $tag -elide $::Options($tag)
139    }
140
141    proc NickVis {val} {
142	foreach t [array names ::Options ] {
143	    if {$::Options($t) != $val} {
144		set ::Options($t) $val
145		DoVis $t
146	    }
147	}
148    }
149    NickVis 1
150    unset ::Options
151    destroy .top
152} {}
153
154test textDisp-0.3 {double tag elide transition} {
155    catch {destroy .txt}
156    pack [text .txt]
157    # Note that TRAFFIC should have a higher priority than SYSTEM
158    # in terms of the tag effects.
159    .txt tag configure SYSTEM -elide 0
160    .txt tag configure TRAFFIC -elide 1
161    .txt insert end "\n" {TRAFFIC SYSTEM}
162    update
163    destroy .txt
164} {}
165
166test textDisp-0.4 {double tag elide transition} {
167    catch {destroy .txt}
168    pack [text .txt]
169    # Note that TRAFFIC should have a higher priority than SYSTEM
170    # in terms of the tag effects.
171    .txt tag configure SYSTEM -elide 0
172    .txt tag configure TRAFFIC -elide 1
173    .txt insert end "\n" {SYSTEM TRAFFIC}
174    # Crash was here.
175    update
176    destroy .txt
177} {}
178
179test textDisp-0.5 {double tag elide transition} {
180    catch {destroy .txt}
181    pack [text .txt]
182    .txt tag configure WELCOME -elide 1
183    .txt tag configure SYSTEM -elide 0
184    .txt tag configure TRAFFIC -elide 1
185
186    .txt insert end "\n" {SYSTEM TRAFFIC}
187    .txt insert end "\n" WELCOME
188    # Crash was here.
189    update
190    destroy .txt
191} {}
192
193test textDisp-1.1 {GetStyle procedure, priorities and tab stops} {
194    .t delete 1.0 end
195    .t insert 1.0 "x\ty"
196    .t tag delete x y z
197    .t tag configure x -tabs {50}
198    .t tag configure y -foreground black
199    .t tag configure z -tabs {70}
200    .t tag add x 1.0 1.end
201    .t tag add y 1.0 1.end
202    .t tag add z 1.0 1.end
203    update idletasks
204    set x [lindex [.t bbox 1.2] 0]
205    .t tag configure z -tabs {}
206    lappend x [lindex [.t bbox 1.2] 0]
207    .t tag configure z -tabs {30}
208    .t tag raise x
209    update idletasks
210    lappend x [lindex [.t bbox 1.2] 0]
211} [list 75 55 55]
212.t tag delete x y z
213test textDisp-1.2 {GetStyle procedure, wrapmode} {textfonts} {
214    .t configure -wrap char
215    .t delete 1.0 end
216    .t insert 1.0 "abcd\nefg hijkl mnop qrstuv wxyz"
217    .t tag configure x -wrap word
218    .t tag configure y -wrap none
219    .t tag raise y
220    update
221    set result [list [.t bbox 2.20]]
222    .t tag add x 2.0 2.1
223    lappend result [.t bbox 2.20]
224    .t tag add y 1.end 2.2
225    lappend result [.t bbox 2.20]
226} [list [list 5 [expr {5+2*$fixedHeight}] 7 $fixedHeight] [list 40 [expr {5+2*$fixedHeight}] 7 $fixedHeight] {}]
227.t tag delete x y
228
229test textDisp-2.1 {LayoutDLine, basics} {
230    .t configure -wrap char
231    .t delete 1.0 end
232    .t insert 1.0 "This is some sample text for testing."
233    list [.t bbox 1.19] [.t bbox 1.20]
234} [list [list [expr 5 + $fixedWidth * 19] 5 $fixedWidth $fixedHeight] [list 5 [expr 5 + $fixedHeight] $fixedWidth $fixedHeight]]
235test textDisp-2.2 {LayoutDLine, basics} {textfonts} {
236    .t configure -wrap char
237    .t delete 1.0 end
238    .t insert 1.0 "This isx some sample text for testing."
239    list [.t bbox 1.19] [.t bbox 1.20]
240} [list [list 138 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
241test textDisp-2.3 {LayoutDLine, basics} {textfonts} {
242    .t configure -wrap char
243    .t delete 1.0 end
244    .t insert 1.0 "This isxxx some sample text for testing."
245    list [.t bbox 1.19] [.t bbox 1.20]
246} [list [list 138 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
247test textDisp-2.4 {LayoutDLine, word wrap} {textfonts} {
248    .t configure -wrap word
249    .t delete 1.0 end
250    .t insert 1.0 "This is some sample text for testing."
251    list [.t bbox 1.19] [.t bbox 1.20]
252} [list [list 138 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
253test textDisp-2.5 {LayoutDLine, word wrap} {textfonts} {
254    .t configure -wrap word
255    .t delete 1.0 end
256    .t insert 1.0 "This isx some sample text for testing."
257    list [.t bbox 1.13] [.t bbox 1.14] [.t bbox 1.19]
258} [list [list 96 5 49 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 40 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
259test textDisp-2.6 {LayoutDLine, word wrap} {
260    .t configure -wrap word
261    .t delete 1.0 end
262    .t insert 1.0 "This isxxx some sample text for testing."
263    list [.t bbox 1.15] [.t bbox 1.16]
264} [list [list 110 5 35 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
265test textDisp-2.7 {LayoutDLine, marks and tags} {textfonts} {
266    .t configure -wrap word
267    .t delete 1.0 end
268    .t insert 1.0 "This isxxx some sample text for testing."
269    .t tag add foo 1.4 1.6
270    .t mark set insert 1.8
271    list [.t bbox 1.2] [.t bbox 1.5] [.t bbox 1.11]
272} [list [list 19 5 7 $fixedHeight] [list 40 5 7 $fixedHeight] [list 82 5 7 $fixedHeight]]
273foreach m [.t mark names] {
274    catch {.t mark unset $m}
275}
276scan [wm geom .] %dx%d width height
277test textDisp-2.8 {LayoutDLine, extra chunk at end of dline} {textfonts} {
278    wm geom . [expr $width+1]x$height
279    update
280    .t configure -wrap char
281    .t delete 1.0 end
282    .t insert 1.0 "This isxx some sample text for testing."
283    .t mark set foo 1.20
284    list [.t bbox 1.19] [.t bbox 1.20]
285} [list [list 138 5 8 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
286wm geom . {}
287update
288test textDisp-2.9 {LayoutDLine, marks and tags} {textfonts} {
289    .t configure -wrap word
290    .t delete 1.0 end
291    .t insert 1.0 "This is a very_very_long_word_that_wraps."
292    list [.t bbox 1.9] [.t bbox 1.10] [.t bbox 1.25]
293} [list [list 68 5 77 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 110 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
294test textDisp-2.10 {LayoutDLine, marks and tags} {textfonts} {
295    .t configure -wrap word
296    .t delete 1.0 end
297    .t insert 1.0 "This is a very_very_long_word_that_wraps."
298    .t tag add foo 1.13
299    .t tag add foo 1.15
300    .t tag add foo 1.17
301    .t tag add foo 1.19
302    list [.t bbox 1.9] [.t bbox 1.10] [.t bbox 1.25]
303} [list [list 68 5 77 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 110 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
304test textDisp-2.11 {LayoutDLine, newline width} {textfonts} {
305    .t configure -wrap char
306    .t delete 1.0 end
307    .t insert 1.0 "a\nbb\nccc\ndddd"
308    list [.t bbox 2.2] [.t bbox 3.3]
309} [list [list 19 [expr {$fixedDiff + 18}] 126 $fixedHeight] [list 26 [expr {2*$fixedDiff + 31}] 119 $fixedHeight]]
310test textDisp-2.12 {LayoutDLine, justification} {textfonts} {
311    .t configure -wrap char
312    .t delete 1.0 end
313    .t insert 1.0 "\na\nbb\nccc\ndddd"
314    .t tag configure x -justify center
315    .t tag add x 1.0 end
316    .t tag add y 3.0 3.2
317    list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 4.0] [.t bbox 4.2]
318} [list [list 75 5 70 $fixedHeight] [list 71 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 64 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] [list 78 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
319test textDisp-2.13 {LayoutDLine, justification} {textfonts} {
320    .t configure -wrap char
321    .t delete 1.0 end
322    .t insert 1.0 "\na\nbb\nccc\ndddd"
323    .t tag configure x -justify right
324    .t tag add x 1.0 end
325    .t tag add y 3.0 3.2
326    list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 4.0] [.t bbox 4.2]
327} [list [list 145 5 0 $fixedHeight] [list 138 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 124 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] [list 138 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
328test textDisp-2.14 {LayoutDLine, justification} {textfonts} {
329    .t configure -wrap char
330    .t delete 1.0 end
331    .t insert 1.0 "\na\nbb\nccc\ndddd"
332    .t tag configure x -justify center
333    .t tag add x 2.0 3.1
334    .t tag configure y -justify right
335    .t tag add y 3.0 4.0
336    .t tag raise y
337    list [.t bbox 2.0] [.t bbox 3.0] [.t bbox 3.end] [.t bbox 4.0]
338} [list [list 71 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 131 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 145 [expr {2*$fixedDiff + 31}] 0 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
339test textDisp-2.15 {LayoutDLine, justification} {textfonts} {
340    .t configure -wrap char
341    .t delete 1.0 end
342    .t insert 1.0 "\na\nbb\nccc\ndddd"
343    .t tag configure x -justify center
344    .t tag add x 2.0 3.1
345    .t tag configure y -justify right
346    .t tag add y 3.0 4.0
347    .t tag lower y
348    list [.t bbox 2.0] [.t bbox 3.0] [.t bbox 3.end] [.t bbox 4.0]
349} [list [list 71 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 68 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 82 [expr {2*$fixedDiff + 31}] 63 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
350test textDisp-2.16 {LayoutDLine, justification} {textfonts} {
351    .t configure -wrap word
352    .t delete 1.0 end
353    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
354    .t tag configure x -justify center
355    .t tag add x 1.1 1.20
356    .t tag add x 1.21 1.end
357    list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.36] [.t bbox 2.0]
358} [list [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 43 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
359test textDisp-2.17 {LayoutDLine, justification} {textfonts} {
360    .t configure -wrap word
361    .t delete 1.0 end
362    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
363    .t tag configure x -justify center
364    .t tag add x 1.20
365    list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.36] [.t bbox 2.0]
366} [list [list 5 5 7 $fixedHeight] [list 19 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
367test textDisp-2.18 {LayoutDLine, justification} {textfonts} {
368    .t configure -wrap none
369    .t delete 1.0 end
370    .t insert 1.0 "Lots of long words, enough to extend out of the window\n"
371    .t insert end "Then\nmore lines\nThat are shorter"
372    .t tag configure x -justify center
373    .t tag configure y -justify right
374    .t tag add x 2.0
375    .t tag add y 3.0
376    .t xview scroll 5 units
377    list [.t bbox 2.0] [.t bbox 3.0]
378} [list [list 26 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 40 [expr {2*$fixedDiff + 31}] 7 $fixedHeight]]
379.t tag delete x
380.t tag delete y
381test textDisp-2.19 {LayoutDLine, margins} {textfonts} {
382    .t configure -wrap word
383    .t delete 1.0 end
384    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
385    .t tag configure x -lmargin1 20 -lmargin2 40 -rmargin 15
386    .t tag add x 1.0 end
387    list [.t bbox 1.0] [.t bbox 1.12] [.t bbox 1.13] [.t bbox 2.0]
388} [list [list 25 5 7 $fixedHeight] [list 109 5 36 $fixedHeight] [list 45 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 25 [expr {5*$fixedDiff + 70}] 7 $fixedHeight]]
389test textDisp-2.20 {LayoutDLine, margins} {textfonts} {
390    .t configure -wrap word
391    .t delete 1.0 end
392    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
393    .t tag configure x -lmargin1 20 -lmargin2 10 -rmargin 3
394    .t tag configure y -lmargin1 15 -lmargin2 5 -rmargin 0
395    .t tag raise y
396    .t tag add x 1.0 end
397    .t tag add y 1.13
398    list [.t bbox 1.0] [.t bbox 1.13] [.t bbox 1.30] [.t bbox 2.0]
399} [list [list 25 5 7 $fixedHeight] [list 10 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 15 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 25 [expr {3*$fixedDiff + 44}] 7 $fixedHeight]]
400test textDisp-2.21 {LayoutDLine, margins} {textfonts} {
401    .t configure -wrap word
402    .t delete 1.0 end
403    .t insert 1.0 "Sample text"
404    .t tag configure x -lmargin1 80 -lmargin2 80 -rmargin 100
405    .t tag add x 1.0 end
406    list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
407} [list [list 85 5 60 $fixedHeight] [list 85 [expr {$fixedDiff + 18}] 60 $fixedHeight] [list 85 [expr {2*$fixedDiff + 31}] 60 $fixedHeight]]
408.t tag delete x
409.t tag delete y
410test textDisp-2.22 {LayoutDLine, spacing options} {textfonts} {
411    .t configure -wrap word
412    .t delete 1.0 end
413    .t tag delete x y
414    .t insert end "Short line\nLine 2 is long enough "
415    .t insert end "to wrap around a couple of times"
416    .t insert end "\nLine 3\nLine 4"
417    set i [.t dlineinfo 1.0]
418    set b1 [expr [lindex $i 1] + [lindex $i 4]]
419    set i [.t dlineinfo 2.0]
420    set b2 [expr [lindex $i 1] + [lindex $i 4]]
421    set i [.t dlineinfo 2.end]
422    set b3 [expr [lindex $i 1] + [lindex $i 4]]
423    set i [.t dlineinfo 3.0]
424    set b4 [expr [lindex $i 1] + [lindex $i 4]]
425    .t configure -spacing1 2 -spacing2 1 -spacing3 3
426    set i [.t dlineinfo 1.0]
427    set b1 [expr [lindex $i 1] + [lindex $i 4] - $b1]
428    set i [.t dlineinfo 2.0]
429    set b2 [expr [lindex $i 1] + [lindex $i 4] - $b2]
430    set i [.t dlineinfo 2.end]
431    set b3 [expr [lindex $i 1] + [lindex $i 4] - $b3]
432    set i [.t dlineinfo 3.0]
433    set b4 [expr [lindex $i 1] + [lindex $i 4] - $b4]
434    list $b1 $b2 $b3 $b4
435} [list 2 7 10 15]
436.t configure -spacing1 0 -spacing2 0 -spacing3 0
437test textDisp-2.23 {LayoutDLine, spacing options} {textfonts} {
438    .t configure -wrap word
439    .t delete 1.0 end
440    .t tag delete x y
441    .t insert end "Short line\nLine 2 is long enough "
442    .t insert end "to wrap around a couple of times"
443    .t insert end "\nLine 3\nLine 4"
444    set i [.t dlineinfo 1.0]
445    set b1 [expr [lindex $i 1] + [lindex $i 4]]
446    set i [.t dlineinfo 2.0]
447    set b2 [expr [lindex $i 1] + [lindex $i 4]]
448    set i [.t dlineinfo 2.end]
449    set b3 [expr [lindex $i 1] + [lindex $i 4]]
450    set i [.t dlineinfo 3.0]
451    set b4 [expr [lindex $i 1] + [lindex $i 4]]
452    .t configure -spacing1 4 -spacing2 4 -spacing3 4
453    .t tag configure x -spacing1 1 -spacing2 2 -spacing3 3
454    .t tag add x 1.0 end
455    .t tag configure y -spacing1 0 -spacing2 3
456    .t tag add y 2.19 end
457    .t tag raise y
458    set i [.t dlineinfo 1.0]
459    set b1 [expr [lindex $i 1] + [lindex $i 4] - $b1]
460    set i [.t dlineinfo 2.0]
461    set b2 [expr [lindex $i 1] + [lindex $i 4] - $b2]
462    set i [.t dlineinfo 2.end]
463    set b3 [expr [lindex $i 1] + [lindex $i 4] - $b3]
464    set i [.t dlineinfo 3.0]
465    set b4 [expr [lindex $i 1] + [lindex $i 4] - $b4]
466    list $b1 $b2 $b3 $b4
467} [list 1 5 13 16]
468.t configure -spacing1 0 -spacing2 0 -spacing3 0
469test textDisp-2.24 {LayoutDLine, tabs, saving from first chunk} {textfonts} {
470    .t delete 1.0 end
471    .t tag delete x y
472    .t tag configure x -tabs 70
473    .t tag configure y -tabs 80
474    .t insert 1.0 "ab\tcde"
475    .t tag add x 1.0 end
476    .t tag add y 1.1 end
477    lindex [.t bbox 1.3] 0
478} {75}
479test textDisp-2.25 {LayoutDLine, tabs, breaking chunks at tabs} {textfonts} {
480    .t delete 1.0 end
481    .t tag delete x
482    .t tag configure x -tabs [list 30 60 90 120]
483    .t insert 1.0 "a\tb\tc\td\te"
484    .t mark set dummy1 1.1
485    .t mark set dummy2 1.2
486    .t tag add x 1.0 end
487    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
488	    [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]
489} [list 35 65 95 125]
490test textDisp-2.26 {LayoutDLine, tabs, breaking chunks at tabs} {textfonts} {
491    .t delete 1.0 end
492    .t tag delete x
493    .t tag configure x -tabs [list 30 60 90 120] -justify right
494    .t insert 1.0 "a\tb\tc\td\te"
495    .t mark set dummy1 1.1
496    .t mark set dummy2 1.2
497    .t tag add x 1.0 end
498    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
499	    [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]
500} [list 117 124 131 138]
501test textDisp-2.27 {LayoutDLine, tabs, calling AdjustForTab} {textfonts} {
502    .t delete 1.0 end
503    .t tag delete x
504    .t tag configure x -tabs [list 30 60]
505    .t insert 1.0 "a\tb\tcd"
506    .t tag add x 1.0 end
507    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0]
508} [list 35 65]
509test textDisp-2.28 {LayoutDLine, tabs, running out of space in dline} {textfonts} {
510    .t delete 1.0 end
511    .t insert 1.0 "a\tb\tc\td"
512    .t bbox 1.6
513} [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight]
514test textDisp-2.29 {LayoutDLine, tabs, running out of space in dline} {textfonts} {
515    .t delete 1.0 end
516    .t insert 1.0 "a\tx\tabcd"
517    .t bbox 1.4
518} [list 117 5 7 $fixedHeight]
519test textDisp-2.30 {LayoutDLine, tabs, running out of space in dline} {textfonts} {
520    .t delete 1.0 end
521    .t insert 1.0 "a\tx\tabc"
522    .t bbox 1.4
523} [list 117 5 7 $fixedHeight]
524
525test textDisp-3.1 {different character sizes} {textfonts} {
526    .t configure -wrap word
527    .t delete 1.0 end
528    .t insert end "Some sample text, including both large\n"
529    .t insert end "characters and\nsmall\n"
530    .t insert end "abc\nd\ne\nfghij"
531    .t tag add big 1.5 1.10
532    .t tag add big 2.11 2.14
533    list [.t bbox 1.1] [.t bbox 1.6] [.t dlineinfo 1.0] [.t dlineinfo 3.0]
534} [list [list 12 [expr {5+$ascentDiff}] 7 $fixedHeight] [list 52 5 13 27] [list 5 5 114 27 [font metrics $bigFont -ascent]] [list 5 [expr {2* $fixedDiff + 85}] 35 $fixedHeight [expr {$fixedDiff + 10}]]]
535.t configure -wrap char
536test textDisp-4.1 {UpdateDisplayInfo, basic} {textfonts} {
537    .t delete 1.0 end
538    .t insert end "Line 1\nLine 2\nLine 3\n"
539    update
540    .t delete 2.0 2.end
541    .t insert 2.0 "New Line 2"
542    update
543    list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 3.0] $tk_textRelayout
544} [list [list 5 5 7 $fixedHeight] [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] 2.0]
545test textDisp-4.2 {UpdateDisplayInfo, re-use tail of text line} {textfonts} {
546    .t delete 1.0 end
547    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
548    update
549    .t mark set x 2.21
550    .t delete 2.2
551    .t insert 2.0 X
552    update
553    list [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
554} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 12 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}]
555test textDisp-4.3 {UpdateDisplayInfo, tail of text line shifts} {textfonts} {
556    .t delete 1.0 end
557    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
558    update
559    .t mark set x 2.21
560    .t delete 2.2
561    update
562    list [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
563} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] [list 5 [expr {3*$fixedDiff + 44}] 7 $fixedHeight] {2.0 2.20}]
564.t mark unset x
565test textDisp-4.4 {UpdateDisplayInfo, wrap-mode "none"} {textfonts} {
566    .t configure -wrap none
567    .t delete 1.0 end
568    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
569    update
570    list [.t bbox 2.0] [.t bbox 2.25] [.t bbox 3.0] $tk_textRelayout
571} [list [list 5 [expr {$fixedDiff + 18}] 7 $fixedHeight] {} [list 5 [expr {2*$fixedDiff + 31}] 7 $fixedHeight] {1.0 2.0 3.0}]
572test textDisp-4.5 {UpdateDisplayInfo, tiny window} {textfonts} {
573    if {$tcl_platform(platform) == "windows"} {
574	wm overrideredirect . 1
575    }
576    wm geom . 103x$height
577    update
578    .t configure -wrap none
579    .t delete 1.0 end
580    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
581    update
582    list [.t bbox 2.0] [.t bbox 2.1] [.t bbox 3.0] $tk_textRelayout
583} [list [list 5 [expr {$fixedDiff + 18}] 1 $fixedHeight] {} [list 5 [expr {2*$fixedDiff + 31}] 1 $fixedHeight] {1.0 2.0 3.0}]
584if {$tcl_platform(platform) == "windows"} {
585    wm overrideredirect . 0
586}
587test textDisp-4.6 {UpdateDisplayInfo, tiny window} {
588    # This test was failing on Windows because the title bar on .
589    # was a certain minimum size and it was interfering with the size
590    # requested.  The "overrideredirect" gets rid of the titlebar so 
591    # the toplevel can shrink to the appropriate size.  On Unix, setting
592    # the overrideredirect on "." confuses the window manager and
593    # causes subsequent tests to fail.
594
595    if {$tcl_platform(platform) == "windows"} {
596	wm overrideredirect . 1
597    }
598    frame .f2 -width 20 -height 100
599    pack before .f .f2 top
600    wm geom . 103x103
601    update
602    .t configure -wrap none -borderwidth 2
603    .t delete 1.0 end
604    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
605    update
606    set x [list [.t bbox 1.0] [.t bbox 2.0] $tk_textRelayout]
607    wm overrideredirect . 0
608    update
609    set x
610} [list [list 5 5 1 1] {} 1.0]
611catch {destroy .f2}
612.t configure -borderwidth 0 -wrap char
613wm geom . {}
614update
615test textDisp-4.7 {UpdateDisplayInfo, filling in extra vertical space} {
616    # This test was failing on Windows because the title bar on .
617    # was a certain minimum size and it was interfering with the size
618    # requested.  The "overrideredirect" gets rid of the titlebar so 
619    # the toplevel can shrink to the appropriate size.  On Unix, setting
620    # the overrideredirect on "." confuses the window manager and
621    # causes subsequent tests to fail.
622
623    if {$tcl_platform(platform) == "windows"} {
624	wm overrideredirect . 1
625    }
626    .t delete 1.0 end
627    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
628    .t yview 1.0
629    update
630    .t yview 16.0
631    update
632    set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
633    wm overrideredirect . 0
634    update 
635    set x
636} {8.0 {16.0 17.0 15.0 14.0 13.0 12.0 11.0 10.0 9.0 8.0} {8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0}}
637test textDisp-4.8 {UpdateDisplayInfo, filling in extra vertical space} {
638    .t delete 1.0 end
639    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
640    .t yview 16.0
641    update
642    .t delete 5.0 14.0
643    update
644    set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
645} {1.0 {5.0 4.0 3.0 2.0 1.0} {1.0 2.0 3.0 4.0 5.0 eof}}
646test textDisp-4.9 {UpdateDisplayInfo, filling in extra vertical space} {textfonts} {
647    .t delete 1.0 end
648    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
649    .t yview 16.0
650    update
651    .t delete 15.0 end
652    list [.t bbox 7.0] [.t bbox 12.0]
653} [list [list 3 [expr {2*$fixedDiff + 29}] 7 $fixedHeight] [list 3 [expr {7*$fixedDiff + 94}] 7 $fixedHeight]]
654test textDisp-4.10 {UpdateDisplayInfo, filling in extra vertical space} {
655    .t delete 1.0 end
656    .t insert end "1\n2\n3\n4\n5\nLine 6 is such a long line that it wraps around.\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
657    .t yview end
658    update
659    .t delete 13.0 end
660    update
661    list [.t index @0,0] $tk_textRelayout $tk_textRedraw
662} {5.0 {12.0 7.0 6.40 6.20 6.0 5.0} {5.0 6.0 6.20 6.40 7.0 12.0}}
663test textDisp-4.11 {UpdateDisplayInfo, filling in extra vertical space} {
664    .t delete 1.0 end
665    .t insert end "1\n2\n3\n4\n5\nLine 6 is such a long line that it wraps around, not once but really quite a few times.\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
666    .t yview end
667    update
668    .t delete 14.0 end
669    update
670    list [.t index @0,0] $tk_textRelayout $tk_textRedraw
671} {6.40 {13.0 7.0 6.80 6.60 6.40} {6.40 6.60 6.80 7.0 13.0}}
672test textDisp-4.12 {UpdateDisplayInfo, filling in extra vertical space} {
673    .t delete 1.0 end
674    .t insert end "1\n2\n3\n4\n5\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16"
675    button .b -text "Test" -bd 2 -highlightthickness 2
676    .t window create 3.end -window .b
677    .t yview moveto 1
678    update
679    .t yview moveto 0
680    update
681    .t yview moveto 1
682    update
683    winfo ismapped .b
684} {0}
685.t configure -wrap word
686.t delete 1.0 end
687.t insert end "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\n"
688.t insert end "Line 8\nLine 9\nLine 10\nLine 11\nLine 12\nLine 13\n"
689.t insert end "Line 14\nLine 15\nLine 16"
690.t tag delete x
691.t tag configure x -relief raised -borderwidth 2 -background white
692test textDisp-4.13 {UpdateDisplayInfo, special handling for top/bottom lines} {
693    .t tag add x 1.0 end
694    .t yview 1.0
695    update
696    .t yview scroll 3 units
697    update
698    list $tk_textRelayout $tk_textRedraw
699} {{11.0 12.0 13.0} {4.0 10.0 11.0 12.0 13.0}}
700test textDisp-4.14 {UpdateDisplayInfo, special handling for top/bottom lines} {
701    .t tag remove x 1.0 end
702    .t yview 1.0
703    update
704    .t yview scroll 3 units
705    update
706    list $tk_textRelayout $tk_textRedraw
707} {{11.0 12.0 13.0} {11.0 12.0 13.0}}
708test textDisp-4.15 {UpdateDisplayInfo, special handling for top/bottom lines} {
709    .t tag add x 1.0 end
710    .t yview 4.0
711    update
712    .t yview scroll -2 units
713    update
714    list $tk_textRelayout $tk_textRedraw
715} {{2.0 3.0} {2.0 3.0 4.0 11.0}}
716test textDisp-4.16 {UpdateDisplayInfo, special handling for top/bottom lines} {
717    .t tag remove x 1.0 end
718    .t yview 4.0
719    update
720    .t yview scroll -2 units
721    update
722    list $tk_textRelayout $tk_textRedraw
723} {{2.0 3.0} {2.0 3.0}}
724test textDisp-4.17 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
725    .t configure -wrap none
726    .t delete 1.0 end
727    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
728    .t insert end "\nLine 3\nLine 4"
729    update
730    .t xview scroll 3 units
731    update
732    list $tk_textRelayout $tk_textRedraw [.t bbox 2.0] [.t bbox 2.5] \
733	    [.t bbox 2.23]
734} [list {} {1.0 2.0 3.0 4.0} {} [list 17 [expr {$fixedDiff + 16}] 7 $fixedHeight] {}]
735test textDisp-4.18 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
736    .t configure -wrap none
737    .t delete 1.0 end
738    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
739    .t insert end "\nLine 3\nLine 4"
740    update
741    .t xview scroll 100 units
742    update
743    list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
744} [list {} {1.0 2.0 3.0 4.0} [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
745test textDisp-4.19 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
746    .t configure -wrap none
747    .t delete 1.0 end
748    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
749    .t insert end "\nLine 3\nLine 4"
750    update
751    .t xview moveto 0
752    .t xview scroll -10 units
753    update
754    list $tk_textRelayout $tk_textRedraw [.t bbox 2.5]
755} [list {} {1.0 2.0 3.0 4.0} [list 38 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
756test textDisp-4.20 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
757    .t configure -wrap none
758    .t delete 1.0 end
759    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
760    .t insert end "\nLine 3\nLine 4"
761    .t xview moveto 0.0
762    .t xview scroll 100 units
763    update
764    .t delete 2.30 2.44
765    update
766    list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
767} [list 2.0 {1.0 2.0 3.0 4.0} [list 108 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
768test textDisp-4.21 {UpdateDisplayInfo, horizontal scrolling} {textfonts} {
769    .t configure -wrap none
770    .t delete 1.0 end
771    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
772    .t insert end "\nLine 3\nLine 4"
773    .t xview moveto .9
774    update
775    .t xview moveto .6
776    update
777    list $tk_textRelayout $tk_textRedraw
778} {{} {}}
779test textDisp-4.22 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {textfonts} {
780    .t configure -wrap none
781    .t delete 1.0 end
782    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
783    .t insert end "\nLine 3\nLine 4"
784    .t xview scroll 25 units
785    update
786    .t configure -wrap word
787    list [.t bbox 2.0] [.t bbox 2.16]
788} [list [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 10 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
789test textDisp-4.23 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {textfonts} {
790    .t configure -wrap none
791    .t delete 1.0 end
792    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
793    .t insert end "\nLine 3\nLine 4"
794    .t xview scroll 25 units
795    update
796    .t configure -wrap char
797    list [.t bbox 2.0] [.t bbox 2.16]
798} [list [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 115 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
799test textDisp-5.1 {DisplayDLine, handling of spacing} {textfonts} {
800    .t configure -wrap char
801    .t delete 1.0 end
802    .t insert 1.0 "abcdefghijkl\nmnopqrstuvwzyz"
803    .t tag configure spacing -spacing1 8 -spacing3 2
804    .t tag add spacing 1.0 end
805    frame .t.f1 -width 10 -height 4 -bg black
806    frame .t.f2 -width 10 -height 4 -bg black
807    frame .t.f3 -width 10 -height 4 -bg black
808    frame .t.f4 -width 10 -height 4 -bg black
809    .t window create 1.3 -window .t.f1 -align top
810    .t window create 1.7 -window .t.f2 -align center
811    .t window create 2.1 -window .t.f3 -align bottom
812    .t window create 2.10 -window .t.f4 -align baseline
813    update
814    list [winfo geometry .t.f1] [winfo geometry .t.f2] \
815	    [winfo geometry .t.f3] [winfo geometry .t.f4]
816} [list 10x4+24+11 10x4+55+[expr {$fixedDiff/2 + 15}] 10x4+10+[expr {2*$fixedDiff + 43}] 10x4+76+[expr {2*$fixedDiff + 40}]]
817.t tag delete spacing
818
819# Although the following test produces a useful result, its main
820# effect is to produce a core dump if Tk doesn't handle display
821# relayout that occurs during redisplay.
822
823test textDisp-5.2 {DisplayDLine, line resizes during display} {
824    .t delete 1.0 end
825    frame .t.f -width 20 -height 20 -bd 2 -relief raised
826    bind .t.f <Configure> {.t.f configure -width 30 -height 30}
827    .t window create insert -window .t.f
828    update
829    list [winfo width .t.f] [winfo height .t.f]
830} [list 30 30]
831
832.t configure -wrap char
833test textDisp-6.1 {scrolling in DisplayText, scroll up} {
834    .t delete 1.0 end
835    .t insert 1.0 "Line 1"
836    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
837	.t insert end "\nLine $i"
838    }
839    update
840    .t delete 2.0 3.0
841    update
842    list $tk_textRelayout $tk_textRedraw
843} {{2.0 10.0} {2.0 10.0}}
844test textDisp-6.2 {scrolling in DisplayText, scroll down} {
845    .t delete 1.0 end
846    .t insert 1.0 "Line 1"
847    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
848	.t insert end "\nLine $i"
849    }
850    update
851    .t insert 2.0 "New Line 2\n"
852    update
853    list $tk_textRelayout $tk_textRedraw
854} {{2.0 3.0} {2.0 3.0}}
855test textDisp-6.3 {scrolling in DisplayText, multiple scrolls} {
856    .t configure -wrap char
857    .t delete 1.0 end
858    .t insert 1.0 "Line 1"
859    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
860	.t insert end "\nLine $i"
861    }
862    update
863    .t insert 2.end "is so long that it wraps"
864    .t insert 4.end "is so long that it wraps"
865    update
866    list $tk_textRelayout $tk_textRedraw
867} {{2.0 2.20 4.0 4.20} {2.0 2.20 4.0 4.20}}
868test textDisp-6.4 {scrolling in DisplayText, scrolls interfere} {
869    .t configure -wrap char
870    .t delete 1.0 end
871    .t insert 1.0 "Line 1"
872    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
873	.t insert end "\nLine $i"
874    }
875    update
876    .t insert 2.end "is so long that it wraps around, not once but three times"
877    .t insert 4.end "is so long that it wraps"
878    update
879    list $tk_textRelayout $tk_textRedraw
880} {{2.0 2.20 2.40 2.60 4.0 4.20} {2.0 2.20 2.40 2.60 4.0 4.20 6.0}}
881test textDisp-6.5 {scrolling in DisplayText, scroll source obscured} {nonPortable} {
882    .t configure -wrap char
883    frame .f2 -bg red
884    place .f2 -in .t -relx 0.5 -rely 0.5 -relwidth 0.5 -relheight 0.5
885    .t delete 1.0 end
886    .t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
887    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
888	.t insert end "\nLine $i"
889    }
890    update
891    .t delete 1.6 1.end
892    update
893    destroy .f2
894    list $tk_textRelayout $tk_textRedraw
895} {{1.0 9.0 10.0} {1.0 4.0 5.0 9.0 10.0}}
896test textDisp-6.6 {scrolling in DisplayText, Expose events after scroll} {unix nonPortable} {
897    # this test depends on all of the expose events being handled at once
898    .t configure -wrap char
899    frame .f2 -bg #ff0000
900    place .f2 -in .t -relx 0.2 -rely 0.5 -relwidth 0.5 -relheight 0.5
901    .t configure -bd 2 -relief raised
902    .t delete 1.0 end
903    .t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
904    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
905	.t insert end "\nLine $i"
906    }
907    update
908    .t delete 1.6 1.end
909    destroy .f2
910    update
911    list $tk_textRelayout $tk_textRedraw
912} {{1.0 9.0 10.0} {borders 1.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0}}
913.t configure -bd 0
914test textDisp-6.7 {DisplayText, vertical scrollbar updates} {
915    .t configure -wrap char
916    .t delete 1.0 end
917    update ; .t count -update -ypixels 1.0 end ; update
918    set scrollInfo
919} {0.0 1.0}
920test textDisp-6.8 {DisplayText, vertical scrollbar updates} {
921    .t configure -wrap char
922    .t delete 1.0 end
923    .t insert 1.0 "Line 1"
924    update
925    set scrollInfo "unchanged"
926    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
927	.t insert end "\nLine $i"
928    }
929    update ; .t count -update -ypixels 1.0 end ; update
930    set scrollInfo
931} [list 0.0 [expr {10.0/13}]]
932.t configure -yscrollcommand {} -xscrollcommand scroll
933test textDisp-6.9 {DisplayText, horizontal scrollbar updates} {
934    .t configure -wrap none
935    .t delete 1.0 end
936    update
937    set scrollInfo unchanged
938    .t insert end xxxxxxxxx\n
939    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
940    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
941    update
942    set scrollInfo
943} [list 0.0 [expr {4.0/11}]]
944
945# The following group of tests is marked non-portable because
946# they result in a lot of extra redisplay under Ultrix.  I don't
947# know why this is so.
948
949.t configure -bd 2 -relief raised -wrap char
950.t delete 1.0 end
951.t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
952foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
953    .t insert end "\nLine $i"
954}
955test textDisp-7.1 {TkTextRedrawRegion} {nonPortable} {
956    frame .f2 -bg #ff0000
957    place .f2 -in .t -relx 0.2 -relwidth 0.6 -rely 0.22 -relheight 0.55
958    update
959    destroy .f2
960    update
961    list $tk_textRelayout $tk_textRedraw
962} {{} {1.40 2.0 3.0 4.0 5.0 6.0}}
963test textDisp-7.2 {TkTextRedrawRegion} {nonPortable} {
964    frame .f2 -bg #ff0000
965    place .f2 -in .t -relx 0 -relwidth 0.5 -rely 0 -relheight 0.5
966    update
967    destroy .f2
968    update
969    list $tk_textRelayout $tk_textRedraw
970} {{} {borders 1.0 1.20 1.40 2.0 3.0}}
971test textDisp-7.3 {TkTextRedrawRegion} {nonPortable} {
972    frame .f2 -bg #ff0000
973    place .f2 -in .t -relx 0.5 -relwidth 0.5 -rely 0.5 -relheight 0.5
974    update
975    destroy .f2
976    update
977    list $tk_textRelayout $tk_textRedraw
978} {{} {borders 4.0 5.0 6.0 7.0 8.0}}
979test textDisp-7.4 {TkTextRedrawRegion} {nonPortable} {
980    frame .f2 -bg #ff0000
981    place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 0 -relheight 0.2 \
982	    -bordermode ignore
983    update
984    destroy .f2
985    update
986    list $tk_textRelayout $tk_textRedraw
987} {{} {borders 1.0 1.20}}
988test textDisp-7.5 {TkTextRedrawRegion} {nonPortable} {
989    frame .f2 -bg #ff0000
990    place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 1.0 -relheight 0.2 \
991	    -anchor s -bordermode ignore
992    update
993    destroy .f2
994    update
995    list $tk_textRelayout $tk_textRedraw
996} {{} {borders 7.0 8.0}}
997test textDisp-7.6 {TkTextRedrawRegion} {nonPortable} {
998    frame .f2 -bg #ff0000
999    place .f2 -in .t -relx 0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
1000	    -anchor w -bordermode ignore
1001    update
1002    destroy .f2
1003    update
1004    list $tk_textRelayout $tk_textRedraw
1005} {{} {borders 3.0 4.0 5.0}}
1006test textDisp-7.7 {TkTextRedrawRegion} {nonPortable} {
1007    frame .f2 -bg #ff0000
1008    place .f2 -in .t -relx 1.0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
1009	    -anchor e -bordermode ignore
1010    update
1011    destroy .f2
1012    update
1013    list $tk_textRelayout $tk_textRedraw
1014} {{} {borders 3.0 4.0 5.0}}
1015test textDisp-7.8 {TkTextRedrawRegion} {nonPortable} {
1016    .t delete 1.0 end
1017    .t insert 1.0 "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\n"
1018    frame .f2 -bg #ff0000
1019    place .f2 -in .t -relx 0.0 -relwidth 0.4 -rely 0.35 -relheight 0.4 \
1020	    -anchor nw -bordermode ignore
1021    update
1022    destroy .f2
1023    update
1024    list $tk_textRelayout $tk_textRedraw
1025} {{} {borders 4.0 5.0 6.0 7.0 eof}}
1026.t configure -bd 0
1027
1028test textDisp-8.1 {TkTextChanged: redisplay whole lines} {textfonts} {
1029    .t configure -wrap word
1030    .t delete 1.0 end
1031    .t insert 1.0 "Line 1\nLine 2 is so long that it wraps around, two times"
1032    foreach i {3 4 5 6 7 8 9 10 11 12 13 14 15} {
1033	.t insert end "\nLine $i"
1034    }
1035    update
1036    .t delete 2.36 2.38
1037    update
1038    list $tk_textRelayout $tk_textRedraw [.t bbox 2.32]
1039} [list {2.0 2.18 2.38} {2.0 2.18 2.38} [list 101 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
1040.t configure -wrap char
1041test textDisp-8.2 {TkTextChanged, redisplay whole lines} {
1042    .t delete 1.0 end
1043    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1044    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1045	.t insert end "\nLine $i"
1046    }
1047    update
1048    .t insert 1.2 xx
1049    update
1050    list $tk_textRelayout $tk_textRedraw
1051} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
1052test textDisp-8.3 {TkTextChanged} {
1053    .t delete 1.0 end
1054    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1055    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1056	.t insert end "\nLine $i"
1057    }
1058    update
1059    .t insert 2.0 xx
1060    update
1061    list $tk_textRelayout $tk_textRedraw
1062} {2.0 2.0}
1063test textDisp-8.4 {TkTextChanged} {
1064    .t delete 1.0 end
1065    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1066    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1067	.t insert end "\nLine $i"
1068    }
1069    update
1070    .t delete 1.5
1071    update
1072    list $tk_textRelayout $tk_textRedraw
1073} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
1074test textDisp-8.5 {TkTextChanged} {
1075    .t delete 1.0 end
1076    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1077    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1078	.t insert end "\nLine $i"
1079    }
1080    update
1081    .t delete 1.40 1.44
1082    update
1083    list $tk_textRelayout $tk_textRedraw
1084} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
1085test textDisp-8.6 {TkTextChanged} {
1086    .t delete 1.0 end
1087    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1088    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1089	.t insert end "\nLine $i"
1090    }
1091    update
1092    .t delete 1.41 1.44
1093    update
1094    list $tk_textRelayout $tk_textRedraw
1095} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
1096test textDisp-8.7 {TkTextChanged} {
1097    .t delete 1.0 end
1098    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1099    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1100	.t insert end "\nLine $i"
1101    }
1102    update
1103    .t delete 1.2 1.end
1104    update
1105    list $tk_textRelayout $tk_textRedraw
1106} {{1.0 9.0 10.0} {1.0 9.0 10.0}}
1107test textDisp-8.8 {TkTextChanged} {
1108    .t delete 1.0 end
1109    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1110    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1111	.t insert end "\nLine $i"
1112    }
1113    update
1114    .t delete 2.2
1115    update
1116    list $tk_textRelayout $tk_textRedraw
1117} {2.0 2.0}
1118test textDisp-8.9 {TkTextChanged} {
1119    .t delete 1.0 end
1120    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1121    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1122	.t insert end "\nLine $i"
1123    }
1124    update
1125    .t delete 2.0 3.0
1126    update
1127    list $tk_textRelayout $tk_textRedraw
1128} {{2.0 8.0} {2.0 8.0}}
1129test textDisp-8.10 {TkTextChanged} {
1130    .t configure -wrap char
1131    .t delete 1.0 end
1132    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1133    .t tag add big 2.19
1134    update
1135    .t delete 2.19
1136    update
1137    set tk_textRedraw
1138} {2.0 2.20 eof}
1139test textDisp-8.11 {TkTextChanged, scrollbar notification when changes are off-screen} {
1140    .t delete 1.0 end
1141    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n"
1142    .t configure -yscrollcommand scroll
1143    update
1144    set scrollInfo ""
1145    .t insert end "a\nb\nc\n"
1146    # We need to wait for our asychronous callbacks to update the
1147    # scrollbar
1148    update ; .t count -update -ypixels 1.0 end ; update
1149    .t configure -yscrollcommand ""
1150    set scrollInfo
1151} {0.0 0.625}
1152
1153test textDisp-9.1 {TkTextRedrawTag} {
1154    .t configure -wrap char
1155    .t delete 1.0 end
1156    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1157    update
1158    .t tag add big 2.2 2.4
1159    update
1160    list $tk_textRelayout $tk_textRedraw
1161} {{2.0 2.18} {2.0 2.18}}
1162test textDisp-9.2 {TkTextRedrawTag} {textfonts} {
1163    .t configure -wrap char
1164    .t delete 1.0 end
1165    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1166    update
1167    .t tag add big 1.2 2.4
1168    update
1169    list $tk_textRelayout $tk_textRedraw
1170} {{1.0 2.0 2.17} {1.0 2.0 2.17}}
1171test textDisp-9.3 {TkTextRedrawTag} {
1172    .t configure -wrap char
1173    .t delete 1.0 end
1174    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1175    update
1176    .t tag add big 2.2 2.4
1177    .t tag remove big 1.0 end
1178    update
1179    list $tk_textRelayout $tk_textRedraw
1180} {2.0 2.0}
1181test textDisp-9.4 {TkTextRedrawTag} {
1182    .t configure -wrap char
1183    .t delete 1.0 end
1184    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1185    update
1186    .t tag add big 2.2 2.20
1187    .t tag remove big 1.0 end
1188    update
1189    list $tk_textRelayout $tk_textRedraw
1190} {2.0 2.0}
1191test textDisp-9.5 {TkTextRedrawTag} {
1192    .t configure -wrap char
1193    .t delete 1.0 end
1194    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1195    update
1196    .t tag add big 2.2 2.end
1197    .t tag remove big 1.0 end
1198    update
1199    list $tk_textRelayout $tk_textRedraw
1200} {{2.0 2.20} {2.0 2.20}}
1201test textDisp-9.6 {TkTextRedrawTag} {
1202    .t configure -wrap char
1203    .t delete 1.0 end
1204    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1205    update
1206    .t tag add big 2.2 3.5
1207    .t tag remove big 1.0 end
1208    update
1209    list $tk_textRelayout $tk_textRedraw
1210} {{2.0 2.20 3.0} {2.0 2.20 3.0}}
1211test textDisp-9.7 {TkTextRedrawTag} {
1212    .t configure -wrap char
1213    .t delete 1.0 end
1214    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1215    .t tag add big 2.19
1216    update
1217    .t tag remove big 2.19
1218    update
1219    set tk_textRedraw
1220} {2.0 2.20 eof}
1221test textDisp-9.8 {TkTextRedrawTag} {textfonts} {
1222    .t configure -wrap char
1223    .t delete 1.0 end
1224    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1225    .t tag add big 1.0 2.0
1226    update
1227    .t tag add big 2.0 2.5
1228    update
1229    set tk_textRedraw
1230} {2.0 2.17}
1231test textDisp-9.9 {TkTextRedrawTag} {textfonts} {
1232    .t configure -wrap char
1233    .t delete 1.0 end
1234    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1235    .t tag add big 1.0 2.0
1236    update
1237    .t tag add big 1.5 2.5
1238    update
1239    set tk_textRedraw
1240} {2.0 2.17}
1241test textDisp-9.10 {TkTextRedrawTag} {
1242    .t configure -wrap char
1243    .t delete 1.0 end
1244    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1245    .t tag add big 1.0 2.0
1246    update
1247    set tk_textRedraw {none}
1248    .t tag add big 1.3 1.5
1249    update
1250    set tk_textRedraw
1251} {none}
1252test textDisp-9.11 {TkTextRedrawTag} {
1253    .t configure -wrap char
1254    .t delete 1.0 end
1255    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1256    .t tag add big 1.0 2.0
1257    update
1258    .t tag add big 1.0 2.0
1259    update
1260    set tk_textRedraw
1261} {}
1262
1263test textDisp-10.1 {TkTextRelayoutWindow} {
1264    .t configure -wrap char
1265    .t delete 1.0 end
1266    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1267    update
1268    .t configure -bg black
1269    update
1270    list $tk_textRelayout $tk_textRedraw
1271} {{1.0 2.0 2.20 3.0 3.20 4.0} {borders 1.0 2.0 2.20 3.0 3.20 4.0 eof}}
1272.t configure -bg [lindex [.t configure -bg] 3]
1273catch {destroy .top}
1274test textDisp-10.2 {TkTextRelayoutWindow} {
1275    toplevel .top -width 300 -height 200
1276    wm geometry .top +0+0
1277    text .top.t -font $fixedFont -width 20 -height 10 -relief raised -bd 2
1278    place .top.t -x 0 -y 0 -width 20 -height 20
1279    .top.t insert end "First line"
1280    .top.t see insert
1281    tkwait visibility .top.t
1282    place .top.t -width 150 -height 100
1283    update
1284    .top.t index @0,0
1285} {1.0}
1286catch {destroy .top}
1287
1288.t delete 1.0 end
1289.t insert end "Line 1"
1290for {set i 2} {$i <= 200} {incr i} {
1291    .t insert end "\nLine $i"
1292}
1293update
1294test textDisp-11.1 {TkTextSetYView} {
1295    .t yview 30.0
1296    update
1297    .t index @0,0
1298} {30.0}
1299test textDisp-11.2 {TkTextSetYView} {
1300    .t yview 30.0
1301    update
1302    .t yview 32.0
1303    update
1304    list [.t index @0,0] $tk_textRedraw
1305} {32.0 {40.0 41.0}}
1306test textDisp-11.3 {TkTextSetYView} {
1307    .t yview 30.0
1308    update
1309    .t yview 28.0
1310    update
1311    list [.t index @0,0] $tk_textRedraw
1312} {28.0 {28.0 29.0}}
1313test textDisp-11.4 {TkTextSetYView} {
1314    .t yview 30.0
1315    update
1316    .t yview 31.4
1317    update
1318    list [.t index @0,0] $tk_textRedraw
1319} {31.0 40.0}
1320test textDisp-11.5 {TkTextSetYView} {
1321    .t yview 30.0
1322    update
1323    set tk_textRedraw {}
1324    .t yview -pickplace 31.0
1325    update
1326    list [.t index @0,0] $tk_textRedraw
1327} {30.0 {}}
1328test textDisp-11.6 {TkTextSetYView} {
1329    .t yview 30.0
1330    update
1331    set tk_textRedraw {}
1332    .t yview -pickplace 28.0
1333    update
1334    list [.t index @0,0] $tk_textRedraw
1335} {28.0 {28.0 29.0}}
1336test textDisp-11.7 {TkTextSetYView} {
1337    .t yview 30.0
1338    update ; update
1339    set tk_textRedraw {}
1340    .t yview -pickplace 26.0
1341    update
1342    list [.t index @0,0] $tk_textRedraw
1343} {21.0 {21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0}}
1344test textDisp-11.8 {TkTextSetYView} {
1345    .t yview 30.0
1346    update
1347    set tk_textRedraw {}
1348    .t yview -pickplace 41.0
1349    update
1350    list [.t index @0,0] $tk_textRedraw
1351} {32.0 {40.0 41.0}}
1352test textDisp-11.9 {TkTextSetYView} {
1353    .t yview 30.0
1354    update
1355    set tk_textRedraw {}
1356    .t yview -pickplace 43.0
1357    update
1358    list [.t index @0,0] $tk_textRedraw
1359} {38.0 {40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0}}
1360test textDisp-11.10 {TkTextSetYView} {
1361    .t yview 30.0
1362    update
1363    set tk_textRedraw {}
1364    .t yview 10000.0
1365    update
1366    list [.t index @0,0] $tk_textRedraw
1367} {191.0 {191.0 192.0 193.0 194.0 195.0 196.0 197.0 198.0 199.0 200.0}}
1368test textDisp-11.11 {TkTextSetYView} {
1369    .t yview 195.0
1370    update
1371    set tk_textRedraw {}
1372    .t yview 197.0
1373    update
1374    list [.t index @0,0] $tk_textRedraw
1375} {191.0 {191.0 192.0 193.0 194.0 195.0 196.0}}
1376test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} {
1377    .t insert 10.0 "Long line with enough text to wrap\n"
1378    .t yview 1.0
1379    update
1380    set tk_textRedraw {}
1381    .t see 10.30
1382    update
1383    list [.t index @0,0] $tk_textRedraw
1384} {2.0 10.20}
1385.t delete 10.0 11.0
1386test textDisp-11.13 {TkTestSetYView, partially visible last line} {
1387    catch {destroy .top}
1388    toplevel .top
1389    wm geometry .top +0+0
1390    text .top.t -width 20 -height 5
1391    pack .top.t
1392    .top.t insert end "Line 1"
1393    for {set i 2} {$i <= 100} {incr i} {
1394	.top.t insert end "\nLine $i"
1395    }
1396    update
1397    scan [wm geometry .top] "%dx%d" w2 h2
1398    wm geometry .top ${w2}x[expr $h2-2]
1399    update
1400    .top.t yview 1.0
1401    update
1402    set tk_textRedraw {}
1403    .top.t see 5.0
1404    update
1405    # Note, with smooth scrolling, the results of this test
1406    # have changed, and the old '2.0 {5.0 6.0}' is quite wrong.
1407    list [.top.t index @0,0] $tk_textRedraw
1408} {1.0 5.0}
1409catch {destroy .top}
1410toplevel .top
1411wm geometry .top +0+0
1412text .top.t -width 30 -height 3
1413pack .top.t
1414.top.t insert end "Line 1"
1415for {set i 2} {$i <= 20} {incr i} {
1416    .top.t insert end "\nLine $i"
1417}
1418update
1419test textDisp-11.14 {TkTextSetYView, only a few lines visible} {
1420    .top.t yview 5.0
1421    update
1422    .top.t see 10.0
1423    .top.t index @0,0
1424} {8.0}
1425test textDisp-11.15 {TkTextSetYView, only a few lines visible} {
1426    .top.t yview 5.0
1427    update
1428    .top.t see 11.0
1429    .top.t index @0,0
1430    # Thie index 9.0 should be just visible by a couple of pixels
1431} {9.0}
1432test textDisp-11.16 {TkTextSetYView, only a few lines visible} {
1433    .top.t yview 8.0
1434    update
1435    .top.t see 5.0
1436    .top.t index @0,0
1437} {5.0}
1438test textDisp-11.17 {TkTextSetYView, only a few lines visible} {
1439    .top.t yview 8.0
1440    update
1441    .top.t see 4.0
1442    .top.t index @0,0
1443    # Thie index 2.0 should be just visible by a couple of pixels
1444} {2.0}
1445destroy .top
1446
1447.t configure -wrap word
1448.t delete 50.0 51.0
1449.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
1450test textDisp-12.1 {MeasureUp} {
1451    .t yview 100.0
1452    update
1453    .t yview -pickplace 52.0
1454    update
1455    .t index @0,0
1456} {49.0}
1457test textDisp-12.2 {MeasureUp} {
1458    .t yview 100.0
1459    update
1460    .t yview -pickplace 53.0
1461    update
1462    .t index @0,0
1463} {50.0}
1464test textDisp-12.3 {MeasureUp} {
1465    .t yview 100.0
1466    update
1467    .t yview -pickplace 50.10
1468    update
1469    .t index @0,0
1470} {45.0}
1471.t configure -wrap none
1472test textDisp-12.4 {MeasureUp} {
1473    .t yview 100.0
1474    update
1475    .t yview -pickplace 53.0
1476    update
1477    .t index @0,0
1478} {48.0}
1479test textDisp-12.5 {MeasureUp} {
1480    .t yview 100.0
1481    update
1482    .t yview -pickplace 50.10
1483    update
1484    .t index @0,0
1485} {45.0}
1486
1487.t configure -wrap none
1488.t delete 1.0 end
1489for {set i 1} {$i < 99} {incr i} {
1490    .t insert end "Line $i\n"
1491}
1492.t insert end "Line 100"
1493.t insert 30.end { is quite long, so that it flows way off the end of the window and we can use it to test out the horizontal positioning features of the "see" command.}
1494test textDisp-13.1 {TkTextSeeCmd procedure} {
1495    list [catch {.t see} msg] $msg
1496} {1 {wrong # args: should be ".t see index"}}
1497test textDisp-13.2 {TkTextSeeCmd procedure} {
1498    list [catch {.t see a b} msg] $msg
1499} {1 {wrong # args: should be ".t see index"}}
1500test textDisp-13.3 {TkTextSeeCmd procedure} {
1501    list [catch {.t see badIndex} msg] $msg
1502} {1 {bad text index "badIndex"}}
1503test textDisp-13.4 {TkTextSeeCmd procedure} {
1504    .t xview moveto 0
1505    .t yview moveto 0
1506    update
1507    .t see 4.2
1508    .t index @0,0
1509} {1.0}
1510test textDisp-13.5 {TkTextSeeCmd procedure} {
1511    .t configure -wrap char
1512    .t xview moveto 0
1513    .t yview moveto 0
1514    update
1515    .t see 12.1
1516    .t index @0,0
1517} {3.0}
1518test textDisp-13.6 {TkTextSeeCmd procedure} {
1519    .t configure -wrap char
1520    .t xview moveto 0
1521    .t yview moveto 0
1522    update
1523    .t see 30.50
1524    set x [.t index @0,0]
1525    .t configure -wrap none
1526    set x
1527} {27.0}
1528test textDisp-13.7 {TkTextSeeCmd procedure} {textfonts} {
1529    .t xview moveto 0
1530    .t yview moveto 0
1531    .t tag add sel 30.20
1532    .t tag add sel 30.40
1533    update
1534    .t see 30.50
1535    .t yview 25.0
1536    .t see 30.50
1537    set x [list [.t bbox 30.50]]
1538    .t see 30.39
1539    lappend x [.t bbox 30.39]
1540    .t see 30.38
1541    lappend x [.t bbox 30.38]
1542    .t see 30.20
1543    lappend x [.t bbox 30.20]
1544} [list [list 73 [expr {5*$fixedDiff + 68}] 7 $fixedHeight] [list 3 [expr {5*$fixedDiff + 68}] 7 $fixedHeight] [list 3 [expr {5*$fixedDiff + 68}] 7 $fixedHeight] [list 73 [expr {5*$fixedDiff + 68}] 7 $fixedHeight]]
1545test textDisp-13.8 {TkTextSeeCmd procedure} {textfonts} {
1546    .t xview moveto 0
1547    .t yview moveto 0
1548    .t tag add sel 30.20
1549    .t tag add sel 30.50
1550    update
1551    .t see 30.50
1552    set x [list [.t bbox 30.50]]
1553    .t see 30.60
1554    lappend x [.t bbox 30.60]
1555    .t see 30.65
1556    lappend x [.t bbox 30.65]
1557    .t see 30.90
1558    lappend x [.t bbox 30.90]
1559} [list [list 73 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 136 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 136 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight] [list 73 [expr {9*$fixedDiff/2 + 64}] 7 $fixedHeight]]
1560test textDisp-13.9 {TkTextSeeCmd procedure} {textfonts} {
1561    wm geom . [expr $width-2]x$height
1562    .t xview moveto 0
1563    .t yview moveto 0
1564    .t tag add sel 30.20
1565    .t tag add sel 30.50
1566    update
1567    .t see 30.50
1568    set x [list [.t bbox 30.50]]
1569    .t see 30.60
1570    lappend x [.t bbox 30.60]
1571    .t see 30.65
1572    lappend x [.t bbox 30.65]
1573    .t see 30.90
1574    lappend x [.t bbox 30.90]
1575} [list [list 74 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight] [list 138 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight] [list 138 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight] [list 74 [expr {9*$fixedDiff/2 + 66}] 7 $fixedHeight]]
1576test textDisp-13.10 {TkTextSeeCmd procedure} {} {
1577    # SF Bug 641778
1578    set w .tsee
1579    destroy $w
1580    text $w -font {Helvetica 8 normal} -bd 16
1581    $w insert end Hello
1582    $w see end
1583    set res [$w bbox end]
1584    destroy $w
1585    set res
1586} {}
1587wm geom . {}
1588
1589.t configure -wrap none
1590test textDisp-14.1 {TkTextXviewCmd procedure} {
1591    .t delete 1.0 end
1592    update
1593    .t insert end xxxxxxxxx\n
1594    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1595    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1596    .t xview moveto .5
1597    .t xview
1598} [list 0.5 [expr {6./7.}]]
1599.t configure -wrap char
1600test textDisp-14.2 {TkTextXviewCmd procedure} {
1601    .t delete 1.0 end
1602    update
1603    .t insert end xxxxxxxxx\n
1604    .t insert end "xxxxx\n"
1605    .t insert end "xxxx"
1606    .t xview
1607} {0.0 1.0}
1608.t configure -wrap none
1609test textDisp-14.3 {TkTextXviewCmd procedure} {
1610    .t delete 1.0 end
1611    update
1612    .t insert end xxxxxxxxx\n
1613    .t insert end "xxxxx\n"
1614    .t insert end "xxxx"
1615    .t xview
1616} {0.0 1.0}
1617test textDisp-14.4 {TkTextXviewCmd procedure} {
1618    list [catch {.t xview moveto} msg] $msg
1619} {1 {wrong # args: should be ".t xview moveto fraction"}}
1620test textDisp-14.5 {TkTextXviewCmd procedure} {
1621    list [catch {.t xview moveto a b} msg] $msg
1622} {1 {wrong # args: should be ".t xview moveto fraction"}}
1623test textDisp-14.6 {TkTextXviewCmd procedure} {
1624    list [catch {.t xview moveto a} msg] $msg
1625} {1 {expected floating-point number but got "a"}}
1626test textDisp-14.7 {TkTextXviewCmd procedure} {
1627    .t delete 1.0 end
1628    .t insert end xxxxxxxxx\n
1629    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1630    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1631    .t xview moveto .3
1632    .t xview
1633} [list [expr {118.0/392}] [expr {258.0/392}]]
1634test textDisp-14.8 {TkTextXviewCmd procedure} {
1635    .t delete 1.0 end
1636    .t insert end xxxxxxxxx\n
1637    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1638    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1639    .t xview moveto -.4
1640    .t xview
1641} [list 0.0 [expr {5.0/14}]]
1642test textDisp-14.9 {TkTextXviewCmd procedure} {
1643    .t delete 1.0 end
1644    .t insert end xxxxxxxxx\n
1645    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1646    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1647    .t xview m 1.4
1648    .t xview
1649} [list [expr {9.0/14}] 1.0]
1650test textDisp-14.10 {TkTextXviewCmd procedure} {
1651    list [catch {.t xview scroll a} msg] $msg
1652} {1 {wrong # args: should be ".t xview scroll number units|pages|pixels"}}
1653test textDisp-14.11 {TkTextXviewCmd procedure} {
1654    list [catch {.t xview scroll a b c} msg] $msg
1655} {1 {wrong # args: should be ".t xview scroll number units|pages|pixels"}}
1656test textDisp-14.12 {TkTextXviewCmd procedure} {
1657    list [catch {.t xview scroll gorp units} msg] $msg
1658} {1 {expected integer but got "gorp"}}
1659test textDisp-14.13 {TkTextXviewCmd procedure} {
1660    .t delete 1.0 end
1661    .t insert end xxxxxxxxx\n
1662    .t insert end "a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9\n"
1663    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1664    .t xview moveto 0
1665    .t xview scroll 2 pa
1666    set x [.t index @0,22]
1667    .t xview scroll -1 pa
1668    lappend x [.t index @0,22]
1669    .t xview scroll -2 pages
1670    lappend x [.t index @0,22]
1671} {2.36 2.18 2.0}
1672test textDisp-14.14 {TkTextXviewCmd procedure} {
1673    .t delete 1.0 end
1674    .t insert end xxxxxxxxx\n
1675    .t insert end "a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9\n"
1676    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1677    .t xview moveto 0
1678    .t xview scroll 21 u  
1679    set x [.t index @0,22]
1680    .t xview scroll -1 u
1681    lappend x [.t index @0,22]
1682    .t xview scroll 100 units
1683    lappend x [.t index @0,22]
1684    .t xview scroll -15 units
1685    lappend x [.t index @0,22]
1686} {2.21 2.20 2.99 2.84}
1687test textDisp-14.15 {TkTextXviewCmd procedure} {
1688    list [catch {.t xview scroll 14 globs} msg] $msg
1689} {1 {bad argument "globs": must be units, pages, or pixels}}
1690test textDisp-14.16 {TkTextXviewCmd procedure} {
1691    list [catch {.t xview flounder} msg] $msg
1692} {1 {bad option "flounder": must be moveto or scroll}}
1693
1694.t configure -wrap char
1695.t delete 1.0 end
1696for {set i 1} {$i < 99} {incr i} {
1697    .t insert end "Line $i\n"
1698}
1699.t insert end "Line 100"
1700.t delete 50.0 51.0
1701.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
1702test textDisp-15.1 {ScrollByLines procedure, scrolling backwards} {
1703    .t yview 45.0
1704    update
1705    .t yview scroll -3 units
1706    .t index @0,0
1707} {42.0}
1708test textDisp-15.2 {ScrollByLines procedure, scrolling backwards} {
1709    .t yview 51.0
1710    update
1711    .t yview scroll -2 units
1712    .t index @0,0
1713} {50.20}
1714test textDisp-15.3 {ScrollByLines procedure, scrolling backwards} {
1715    .t yview 51.0
1716    update
1717    .t yview scroll -4 units
1718    .t index @0,0
1719} {49.0}
1720test textDisp-15.4 {ScrollByLines procedure, scrolling backwards} {
1721    .t yview 50.20
1722    update
1723    .t yview scroll -2 units
1724    .t index @0,0
1725} {49.0}
1726test textDisp-15.5 {ScrollByLines procedure, scrolling backwards} {
1727    .t yview 50.40
1728    update
1729    .t yview scroll -2 units
1730    .t index @0,0
1731} {50.0}
1732test textDisp-15.6 {ScrollByLines procedure, scrolling backwards} {
1733    .t yview 3.2
1734    update
1735    .t yview scroll -5 units
1736    .t index @0,0
1737} {1.0}
1738test textDisp-15.7 {ScrollByLines procedure, scrolling forwards} {
1739    .t yview 48.0
1740    update
1741    .t yview scroll 4 units
1742    .t index @0,0
1743} {50.40}
1744
1745test textDisp-15.8 {Scrolling near end of window} {
1746    set textheight 12
1747    set textwidth 30
1748
1749    toplevel .tf
1750    frame .tf.f -relief sunken -borderwidth 2
1751    pack .tf.f -padx 10 -pady 10
1752
1753    text .tf.f.t -font {Courier 9} -height $textheight \
1754      -width $textwidth -yscrollcommand ".tf.f.sb set"
1755    scrollbar .tf.f.sb -command ".tf.f.t yview"
1756    pack .tf.f.t -side left -expand 1 -fill both
1757    pack .tf.f.sb -side right -fill y
1758
1759    .tf.f.t tag configure Header -font {Helvetica 14 bold italic} \
1760      -wrap word -spacing1 12 -spacing3 4
1761
1762    .tf.f.t insert end "Foo" Header
1763    for {set i 1} {$i < $textheight} {incr i} {
1764	.tf.f.t insert end "\nLine $i"
1765    }
1766    update ; after 1000 ; update
1767    # Should scroll and should not crash!
1768    .tf.f.t yview scroll 1 unit
1769    # Check that it has scrolled
1770    set res [.tf.f.t index @0,[expr [winfo height .tf.f.t] - 15]]
1771    destroy .tf
1772    set res
1773} {12.0}
1774
1775.t configure -wrap char
1776.t delete 1.0 end
1777.t insert insert "Line 1"
1778for {set i 2} {$i <= 200} {incr i} {
1779    .t insert end "\nLine $i"
1780}
1781.t tag add big 100.0 105.0
1782.t insert 151.end { has a lot of extra text, so that it wraps around on the screen several times over.}
1783.t insert 153.end { also has enoug extra text to wrap.}
1784update ; .t count -update -ypixels 1.0 end
1785test textDisp-16.1 {TkTextYviewCmd procedure} {
1786    .t yview 21.0
1787    set x [.t yview]
1788    .t yview 1.0
1789    list [expr {int([lindex $x 0]*100)}] [expr {int ([lindex $x 1] * 100)}]
1790} {9 14}
1791test textDisp-16.2 {TkTextYviewCmd procedure} {
1792    list [catch {.t yview 2 3} msg] $msg
1793} {1 {bad option "2": must be moveto or scroll}}
1794test textDisp-16.3 {TkTextYviewCmd procedure} {
1795    list [catch {.t yview -pickplace} msg] $msg
1796} {1 {wrong # args: should be ".t yview -pickplace lineNum|index"}}
1797test textDisp-16.4 {TkTextYviewCmd procedure} {
1798    list [catch {.t yview -pickplace 2 3} msg] $msg
1799} {1 {wrong # args: should be ".t yview -pickplace lineNum|index"}}
1800test textDisp-16.5 {TkTextYviewCmd procedure} {
1801    list [catch {.t yview -bogus 2} msg] $msg
1802} {1 {bad option "-bogus": must be moveto or scroll}}
1803test textDisp-16.6 {TkTextYviewCmd procedure, integer position} {
1804    .t yview 100.0
1805    update
1806    .t yview 98
1807    .t index @0,0
1808} {99.0}
1809test textDisp-16.7 {TkTextYviewCmd procedure} {
1810    .t yview 2.0
1811    .t yv -pickplace 13.0
1812    .t index @0,0
1813} {4.0}
1814test textDisp-16.8 {TkTextYviewCmd procedure} {
1815    list [catch {.t yview bad_mark_name} msg] $msg
1816} {1 {bad text index "bad_mark_name"}}
1817test textDisp-16.9 {TkTextYviewCmd procedure, "moveto" option} {
1818    list [catch {.t yview moveto a b} msg] $msg
1819} {1 {wrong # args: should be ".t yview moveto fraction"}}
1820test textDisp-16.10 {TkTextYviewCmd procedure, "moveto" option} {
1821    list [catch {.t yview moveto gorp} msg] $msg
1822} {1 {expected floating-point number but got "gorp"}}
1823test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} {
1824    .t yview moveto 0.5
1825    .t index @0,0
1826} {103.0}
1827test textDisp-16.12 {TkTextYviewCmd procedure, "moveto" option} {
1828    .t yview moveto -1
1829    .t index @0,0
1830} {1.0}
1831test textDisp-16.13 {TkTextYviewCmd procedure, "moveto" option} {
1832    .t yview moveto 1.1
1833    .t index @0,0
1834} {191.0}
1835test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} {
1836    .t yview moveto .75
1837    .t index @0,0
1838} {151.60}
1839test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} {
1840    .t yview moveto .752
1841    .t index @0,0
1842} {151.60}
1843test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} {textfonts} {
1844    set count [expr {5 * $bigHeight + 150 * $fixedHeight}]
1845    set extra [expr {0.04 * double($fixedDiff * 150) / double($count)}]
1846    .t yview moveto [expr {.753 - $extra}]
1847    .t index @0,0
1848} {151.60}
1849test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} {
1850    .t yview moveto .755
1851    .t index @0,0
1852} {151.80}
1853test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {textfonts} {
1854    catch {destroy .top1}
1855    toplevel .top1
1856    wm geometry .top1 +0+0
1857    text .top1.t -height 3 -width 4 -wrap none -setgrid 1 -padx 6 \
1858	-spacing3 6
1859    .top1.t insert end "1\n2\n3\n4\n5\n6"
1860    pack .top1.t
1861    update
1862    .top1.t yview moveto 0.3333
1863    set result [.top1.t yview]
1864    destroy .top1
1865    set result
1866} [list [expr {1.0/3}] [expr {5.0/6}]]
1867test textDisp-16.19 {TkTextYviewCmd procedure, "scroll" option} {
1868    list [catch {.t yview scroll a} msg] $msg
1869} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}}
1870test textDisp-16.20 {TkTextYviewCmd procedure, "scroll" option} {
1871    list [catch {.t yview scroll a b c} msg] $msg
1872} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}}
1873test textDisp-16.21 {TkTextYviewCmd procedure, "scroll" option} {
1874    list [catch {.t yview scroll badInt bogus} msg] $msg
1875} {1 {bad argument "bogus": must be units, pages, or pixels}}
1876test textDisp-16.21.2 {TkTextYviewCmd procedure, "scroll" option} {
1877    list [catch {.t yview scroll badInt units} msg] $msg
1878} {1 {expected integer but got "badInt"}}
1879test textDisp-16.22 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1880    .t yview 50.0
1881    update
1882    .t yview scroll -1 pages
1883    .t index @0,0
1884} {42.0}
1885test textDisp-16.22.1 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1886    list [catch {.t yview scroll -3 p} res] $res
1887} {1 {ambiguous argument "p": must be units, pages, or pixels}}
1888test textDisp-16.23 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1889    .t yview 50.0
1890    update
1891    .t yview scroll -3 pa
1892    .t index @0,0
1893} {26.0}
1894test textDisp-16.24 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1895    .t yview 5.0
1896    update
1897    .t yview scroll -3 pa
1898    .t index @0,0
1899} {1.0}
1900test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1901    .t configure -height 1
1902    update
1903    .t yview 50.0
1904    update
1905    .t yview scroll -1 pages
1906    set x [.t index @0,0]
1907    .t configure -height 10
1908    update
1909    set x
1910} {49.0}
1911test textDisp-16.26 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1912    .t yview 50.0
1913    update
1914    .t yview scroll 1 pages
1915    .t index @0,0
1916} {58.0}
1917test textDisp-16.27 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1918    .t yview 50.0
1919    update
1920    .t yview scroll 2 pages
1921    .t index @0,0
1922} {66.0}
1923test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {textfonts} {
1924    .t yview 98.0
1925    update
1926    .t yview scroll 1 page
1927    set res [expr int([.t index @0,0])]
1928    if {$fixedDiff > 1} {
1929	incr res -1
1930    }
1931    set res
1932} {102}
1933test textDisp-16.29 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1934    .t configure -height 1
1935    update
1936    .t yview 50.0
1937    update
1938    .t yview scroll 1 pages
1939    set x [.t index @0,0]
1940    .t configure -height 10
1941    update
1942    set x
1943} {51.0}
1944test textDisp-16.30 {TkTextYviewCmd procedure, "scroll units" option} {
1945    .t yview 45.0
1946    update
1947    .t yview scroll -3 units
1948    .t index @0,0
1949} {42.0}
1950test textDisp-16.31 {TkTextYviewCmd procedure, "scroll units" option} {
1951    .t yview 149.0
1952    update
1953    .t yview scroll 4 units
1954    .t index @0,0
1955} {151.40}
1956test textDisp-16.32 {TkTextYviewCmd procedure} {
1957    list [catch {.t yview scroll 12 bogoids} msg] $msg
1958} {1 {bad argument "bogoids": must be units, pages, or pixels}}
1959test textDisp-16.33 {TkTextYviewCmd procedure} {
1960    list [catch {.t yview bad_arg 1 2} msg] $msg
1961} {1 {bad option "bad_arg": must be moveto or scroll}}
1962test textDisp-16.34 {TkTextYviewCmd procedure} {
1963    set res {}
1964    .t yview 1.0
1965    lappend res [format %.12g [expr {[lindex [.t yview] 0]
1966	* [.t count -ypixels 1.0 end]}]]
1967    .t yview scroll 1 pixels
1968    lappend res [format %.12g [expr {[lindex [.t yview] 0]
1969	* [.t count -ypixels 1.0 end]}]]
1970    .t yview scroll 1 pixels
1971    lappend res [format %.12g [expr {[lindex [.t yview] 0]
1972	* [.t count -ypixels 1.0 end]}]]
1973    .t yview scroll 1 pixels
1974    lappend res [format %.12g [expr {[lindex [.t yview] 0]
1975	* [.t count -ypixels 1.0 end]}]]
1976    .t yview scroll 1 pixels
1977    lappend res [format %.12g [expr {[lindex [.t yview] 0]
1978	* [.t count -ypixels 1.0 end]}]]
1979    .t yview scroll 1 pixels
1980    lappend res [format %.12g [expr {[lindex [.t yview] 0]
1981	* [.t count -ypixels 1.0 end]}]]
1982} {0 1 2 3 4 5}
1983test textDisp-16.35 {TkTextYviewCmd procedure} {
1984    set res {}
1985    .t yview 1.0
1986    lappend res [expr {round([lindex [.t yview] 0] * [.t count -ypixels 1.0 end])}]
1987    .t yview scroll 13 pixels
1988    lappend res [expr {round([lindex [.t yview] 0] * [.t count -ypixels 1.0 end])}]
1989    .t yview scroll -4 pixels
1990    lappend res [expr {round([lindex [.t yview] 0] * [.t count -ypixels 1.0 end])}]
1991    .t yview scroll -9 pixels
1992    lappend res [expr {round([lindex [.t yview] 0] * [.t count -ypixels 1.0 end])}]
1993} {0 13 9 0}
1994test textDisp-16.36 {TkTextYviewCmd procedure} {
1995    set res {}
1996    .t yview 1.0
1997    .t yview scroll 5 pixels
1998    .t yview scroll -1 pages
1999    lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
2000    .t yview scroll 5 pixels
2001    .t yview scroll -1 units
2002    lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
2003} {0.0 0.0}
2004test textDisp-16.37 {TkTextYviewCmd procedure} {
2005    list [catch {.t yview scroll 1.3 pixels} msg] $msg
2006} {0 {}}
2007test textDisp-16.38 {TkTextYviewCmd procedure} {
2008    list [catch {.t yview scroll 1.3blah pixels} msg] $msg
2009} {1 {bad screen distance "1.3blah"}}
2010test textDisp-16.39 {TkTextYviewCmd procedure} {
2011    list [catch {.t yview scroll 1.3i pixels} msg] $msg
2012} {0 {}}
2013test textDisp-16.40 {text count -xpixels} {
2014    set res {}
2015    lappend res [.t count -xpixels 1.0 1.5] \
2016      [.t count -xpixels 1.5 1.0] \
2017      [.t count -xpixels 1.0 13.0] \
2018      [.t count -xpixels 1.0 "1.0 displaylineend"] \
2019      [.t count -xpixels 1.0 "1.0 lineend"] \
2020      [.t count -xpixels 1.0 "1.0 displaylineend"] \
2021      [.t count -xpixels 1.0 end]
2022} {35 -35 0 42 42 42 0}
2023
2024.t delete 1.0 end
2025foreach i {a b c d e f g h i j k l m n o p q r s t u v w x y z} {
2026    .t insert end "\nLine $i 11111 $i 22222 $i 33333 $i 44444 $i 55555"
2027    .t insert end " $i 66666 $i 77777 $i 88888 $i"
2028}
2029.t configure -wrap none
2030test textDisp-17.1 {TkTextScanCmd procedure} {
2031    list [catch {.t scan a b} msg] $msg
2032} {1 {wrong # args: should be ".t scan mark x y" or ".t scan dragto x y ?gain?"}}
2033test textDisp-17.2 {TkTextScanCmd procedure} {
2034    list [catch {.t scan a b c d} msg] $msg
2035} {1 {expected integer but got "b"}}
2036test textDisp-17.3 {TkTextScanCmd procedure} {
2037    list [catch {.t scan stupid b 20} msg] $msg
2038} {1 {expected integer but got "b"}}
2039test textDisp-17.4 {TkTextScanCmd procedure} {
2040    list [catch {.t scan stupid -2 bogus} msg] $msg
2041} {1 {expected integer but got "bogus"}}
2042test textDisp-17.5 {TkTextScanCmd procedure} {
2043    list [catch {.t scan stupid 123 456} msg] $msg
2044} {1 {bad scan option "stupid": must be mark or dragto}}
2045test textDisp-17.6 {TkTextScanCmd procedure} {textfonts} {
2046    .t yview 1.0
2047    .t xview moveto 0
2048    .t scan mark 40 60
2049    .t scan dragto 35 55
2050    .t index @0,0
2051} {4.7}
2052test textDisp-17.7 {TkTextScanCmd procedure} {textfonts} {
2053    .t yview 10.0
2054    .t xview moveto 0
2055    .t xview scroll 20 units
2056    .t scan mark -10 60
2057    .t scan dragto -5 65
2058    .t index @0,0
2059    set x [.t index @0,0]
2060    .t scan dragto 0 [expr {70 + $fixedDiff}]
2061    list $x [.t index @0,0]
2062} {6.12 2.5}
2063test textDisp-17.8 {TkTextScanCmd procedure} {textfonts} {
2064    .t yview 1.0
2065    .t xview moveto 0
2066    .t scan mark 0 60
2067    .t scan dragto 30 100
2068    .t scan dragto 25 95 
2069    .t index @0,0
2070} {4.7}
2071test textDisp-17.9 {TkTextScanCmd procedure} {textfonts} {
2072    .t yview end
2073    .t xview moveto 0
2074    .t xview scroll 100 units
2075    .t scan mark 90 60
2076    .t scan dragto 10 0
2077    .t scan dragto 14 5
2078    .t index @0,0
2079} {18.44}
2080.t configure -wrap word
2081test textDisp-17.10 {TkTextScanCmd procedure, word wrapping} {textfonts} {
2082    .t yview 10.0
2083    .t scan mark -10 60
2084    .t scan dragto -5 65
2085    set x [.t index @0,0]
2086    .t scan dragto 0 [expr {70 + $fixedDiff}]
2087    list $x [.t index @0,0]
2088} {9.15 8.31}
2089.t configure -xscrollcommand scroll -yscrollcommand {}
2090test textDisp-18.1 {GetXView procedure} {
2091    .t configure -wrap none
2092    .t delete 1.0 end
2093    .t insert end xxxxxxxxx\n
2094    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
2095    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
2096    update
2097    set scrollInfo
2098} [list 0.0 [expr {4.0/11}]]
2099test textDisp-18.2 {GetXView procedure} {
2100    .t configure -wrap char
2101    .t delete 1.0 end
2102    .t insert end xxxxxxxxx\n
2103    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
2104    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
2105    update
2106    set scrollInfo
2107} {0.0 1.0}
2108test textDisp-18.3 {GetXView procedure} {
2109    .t configure -wrap none
2110    .t delete 1.0 end
2111    update
2112    set scrollInfo
2113} {0.0 1.0}
2114test textDisp-18.4 {GetXView procedure} {
2115    .t configure -wrap none
2116    .t delete 1.0 end
2117    .t insert end xxxxxxxxx\n
2118    .t insert end xxxxxx\n
2119    .t insert end xxxxxxxxxxxxxxxxx
2120    update
2121    set scrollInfo
2122} {0.0 1.0}
2123test textDisp-18.5 {GetXView procedure} {
2124    .t configure -wrap none
2125    .t delete 1.0 end
2126    .t insert end xxxxxxxxx\n
2127    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
2128    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
2129    .t xview scroll 31 units
2130    update
2131    set scrollInfo
2132} [list [expr {31.0/55}] [expr {51.0/55}]]
2133test textDisp-18.6 {GetXView procedure} {
2134    .t configure -wrap none
2135    .t delete 1.0 end
2136    .t insert end xxxxxxxxx\n
2137    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
2138    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
2139    .t xview moveto 0
2140    .t xview scroll 31 units
2141    update
2142    set x {}
2143    lappend x $scrollInfo
2144    .t configure -wrap char
2145    update
2146    lappend x $scrollInfo
2147    .t configure -wrap word
2148    update
2149    lappend x $scrollInfo
2150    .t configure -wrap none
2151    update
2152    lappend x $scrollInfo
2153} [list [list [expr {31.0/56}] [expr {51.0/56}]] {0.0 1.0} {0.0 1.0} [list 0.0 [expr {5.0/14}]]]
2154test textDisp-18.7 {GetXView procedure} {
2155    .t configure -wrap none
2156    .t delete 1.0 end
2157    update
2158    set scrollInfo unchanged
2159    .t insert end xxxxxx\n
2160    .t insert end xxx
2161    update
2162    set scrollInfo
2163} {unchanged}
2164test textDisp-18.8 {GetXView procedure} {
2165    proc bgerror msg {
2166	global x errorInfo
2167	set x [list $msg $errorInfo]
2168    }
2169    proc bogus args {
2170	error "bogus scroll proc"
2171    }
2172    .t configure -wrap none
2173    .t delete 1.0 end
2174    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
2175    update
2176    .t delete 1.0 end
2177    .t configure -xscrollcommand scrollError
2178    update
2179    set x
2180} {{scrolling error} {scrolling error
2181    while executing
2182"error "scrolling error""
2183    (procedure "scrollError" line 2)
2184    invoked from within
2185"scrollError 0.0 1.0"
2186    (horizontal scrolling command executed by text)}}
2187catch {rename bgerror {}}
2188catch {rename bogus {}}
2189.t configure -xscrollcommand {} -yscrollcommand scroll
2190
2191.t configure -xscrollcommand {} -yscrollcommand scroll
2192test textDisp-19.1 {GetYView procedure} {
2193    .t configure -wrap char
2194    .t delete 1.0 end
2195    update
2196    set scrollInfo
2197} {0.0 1.0}
2198test textDisp-19.2 {GetYView procedure} {
2199    .t configure -wrap char
2200    .t delete 1.0 end
2201    update
2202    set scrollInfo "unchanged"
2203    .t insert 1.0 "Line1\nLine2"
2204    update
2205    set scrollInfo
2206} {unchanged}
2207test textDisp-19.3 {GetYView procedure} {
2208    .t configure -wrap char
2209    .t delete 1.0 end
2210    update; after 10 ; update
2211    set scrollInfo "unchanged"
2212    .t insert 1.0 "Line 1\nLine 2 is so long that it wraps around\nLine 3"
2213    update
2214    set scrollInfo
2215} {unchanged}
2216test textDisp-19.4 {GetYView procedure} {
2217    .t configure -wrap char
2218    .t delete 1.0 end
2219    .t insert 1.0 "Line 1"
2220    update
2221    set scrollInfo "unchanged"
2222    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2223	.t insert end "\nLine $i"
2224    }
2225    update
2226    set scrollInfo
2227} [list 0.0 [expr {70.0/91}]]
2228test textDisp-19.5 {GetYView procedure} {
2229    .t configure -wrap char
2230    .t delete 1.0 end
2231    .t insert 1.0 "Line 1"
2232    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2233	.t insert end "\nLine $i"
2234    }
2235    .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2236    update ; after 100
2237    set x $scrollInfo
2238} {0.0 0.625}
2239test textDisp-19.6 {GetYView procedure} {
2240    .t configure -wrap char
2241    .t delete 1.0 end
2242    .t insert 1.0 "Line 1"
2243    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2244	.t insert end "\nLine $i"
2245    }
2246    .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2247    .t yview 4.0
2248    update
2249    set x $scrollInfo
2250} {0.375 1.0}
2251test textDisp-19.7 {GetYView procedure} {
2252    .t configure -wrap char
2253    .t delete 1.0 end
2254    .t insert 1.0 "Line 1"
2255    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2256	.t insert end "\nLine $i"
2257    }
2258    .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2259    .t yview 2.26
2260    update; after 1; update
2261    set x $scrollInfo
2262} {0.125 0.75}
2263test textDisp-19.8 {GetYView procedure} {
2264    .t configure -wrap char
2265    .t delete 1.0 end
2266    .t insert 1.0 "Line 1"
2267    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2268	.t insert end "\nLine $i"
2269    }
2270    .t insert 10.end " is really quite long; in fact it's so long that it wraps three times"
2271    .t yview 2.0
2272    update
2273    .t count -update -ypixels 1.0 end
2274    set x $scrollInfo
2275} {0.0625 0.6875}
2276test textDisp-19.9 {GetYView procedure} {
2277    .t configure -wrap char
2278    .t delete 1.0 end
2279    .t insert 1.0 "Line 1"
2280    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2281	.t insert end "\nLine $i"
2282    }
2283    .t yview 3.0
2284    update
2285    set scrollInfo
2286} [list [expr {4.0/30}] 0.8]
2287test textDisp-19.10 {GetYView procedure} {
2288    .t configure -wrap char
2289    .t delete 1.0 end
2290    .t insert 1.0 "Line 1"
2291    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2292	.t insert end "\nLine $i"
2293    }
2294    .t yview 11.0
2295    update
2296    set scrollInfo
2297} [list [expr {1.0/3}] 1.0]
2298test textDisp-19.10.1 {Widget manipulation causes height miscount} {
2299    .t configure -wrap char
2300    .t delete 1.0 end
2301    .t insert 1.0 "Line 1"
2302    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2303	.t insert end "\nLine $i"
2304    }
2305    .t yview 11.0
2306    update
2307    .t configure -wrap word
2308    .t delete 1.0 end
2309    .t insert 1.0 "Line 1"
2310    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2311	.t insert end "\nLine $i"
2312    }
2313    .t insert end "\nThis last line wraps around four "
2314    .t insert end "times with a bit left on the last line."
2315    .t yview insert
2316    update
2317    .t count -update -ypixels 1.0 end
2318    set scrollInfo
2319} {0.5 1.0}
2320test textDisp-19.11 {GetYView procedure} {
2321    .t configure -wrap word
2322    .t delete 1.0 end
2323    .t insert 1.0 "Line 1"
2324    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2325	.t insert end "\nLine $i"
2326    }
2327    .t insert end "\nThis last line wraps around four "
2328    .t insert end "times with a bit left on the last line."
2329    .t yview insert
2330    update
2331    .t count -update -ypixels 1.0 end
2332    set scrollInfo
2333} {0.5 1.0}
2334test textDisp-19.11.2 {TextWidgetCmd procedure, "count -displaylines"} {
2335    .t count -displaylines 1.0 end
2336} {20}
2337test textDisp-19.11.3 {TextWidgetCmd procedure, "count -displaylines"} {
2338    .t count -displaylines end 1.0
2339} {-20}
2340test textDisp-19.11.4 {TextWidgetCmd procedure, "count -displaylines"} {
2341    .t count -displaylines 1.1 1.3
2342} {0}
2343test textDisp-19.11.5 {TextWidgetCmd procedure, "count -displaylines"} {
2344    .t count -displaylines 16.0 16.1
2345} {0}
2346test textDisp-19.11.5.1 {TextWidgetCmd procedure, "count -displaylines"} {
2347    .t count -displaylines 16.0 16.5
2348} {0}
2349test textDisp-19.11.6 {TextWidgetCmd procedure, "count -displaylines"} {
2350    .t count -displaylines 16.0 16.20
2351} {1}
2352test textDisp-19.11.7 {TextWidgetCmd procedure, "count -displaylines"} {
2353    .t count -displaylines 16.0 16.40
2354} {2}
2355test textDisp-19.11.8 {TextWidgetCmd procedure, "count -displaylines"} {
2356    .t count -displaylines "16.0 displaylineend +1c" "16.0 lineend"
2357} {3}
2358test textDisp-19.11.9 {TextWidgetCmd procedure, "count -displaylines"} {
2359    .t count -displaylines 16.0 "16.0 lineend"
2360} {4}
2361test textDisp-19.11.10 {TextWidgetCmd procedure, "count -displaylines"} {
2362    .t count -displaylines 16.0 "16.0 +4displaylines"
2363} {4}
2364test textDisp-19.11.11 {TextWidgetCmd procedure, "count -displaylines"} {
2365    .t count -displaylines 16.0 "16.0 +2displaylines"
2366} {2}
2367test textDisp-19.11.12 {TextWidgetCmd procedure, "count -displaylines"} {
2368    .t count -displaylines "16.0 +1displayline" "16.0 +2displaylines -1c"
2369} {0}
2370.t tag configure elide -elide 1
2371test textDisp-19.11.13 {TextWidgetCmd procedure, "count -displaylines"} {
2372    .t tag remove elide 1.0 end
2373    .t tag add elide "16.0 +1displaylines" "16.0 +1displaylines +6c"
2374    .t count -displaylines 16.0 "16.0 +4displaylines"
2375} {4}
2376test textDisp-19.11.14 {TextWidgetCmd procedure, "count -displaylines"} {
2377    .t tag remove elide 1.0 end
2378    .t tag add elide "16.0 +1displaylines" "16.0 +1displaylines displaylineend"
2379    .t count -displaylines 16.0 "16.0 +4displaylines"
2380} {4}
2381test textDisp-19.11.15 {TextWidgetCmd procedure, "count -displaylines"} {
2382    .t tag remove elide 1.0 end
2383    .t tag add elide "16.0 +1displaylines" "16.0 +2displaylines"
2384    .t count -displaylines 16.0 "16.0 +4displaylines -1c"
2385} {3}
2386test textDisp-19.11.15a {TextWidgetCmd procedure, "count -displaylines"} {
2387    .t tag remove elide 1.0 end
2388    .t tag add elide "16.0 +1displaylines" "16.0 +2displaylines"
2389    .t count -displaylines 16.0 "16.0 +4displaylines"
2390} {4}
2391test textDisp-19.11.16 {TextWidgetCmd procedure, "count -displaylines"} {
2392    .t tag remove elide 1.0 end
2393    .t tag add elide "12.0" "14.0"
2394    .t count -displaylines 12.0 16.0
2395} {2}
2396test textDisp-19.11.17 {TextWidgetCmd procedure, "index +displaylines"} {
2397    .t tag remove elide 1.0 end
2398    .t tag add elide "12.0" "14.0"
2399    list [.t index "11.5 +2d lines"] \
2400      [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \
2401      [.t index "13.0 +2d lines"] [.t index "13.1 +3d lines"] \
2402      [.t index "13.0 +4d lines"]
2403} {15.5 16.0 15.0 16.0 16.15 16.33}
2404test textDisp-19.11.18 {TextWidgetCmd procedure, "index +displaylines"} {
2405    .t tag remove elide 1.0 end
2406    .t tag add elide "12.0" "14.0"
2407    list [.t index "15.5 -2d lines"] \
2408      [.t index "16.0 -2d lines"] [.t index "15.0 -2d lines"] \
2409      [.t index "16.0 -3d lines"] [.t index "16.17 -4d lines"] \
2410      [.t index "16.36 -5d lines"]
2411} {11.5 14.0 11.0 11.0 11.2 11.3}
2412test textDisp-19.11.19 {TextWidgetCmd procedure, "count -displaylines"} {
2413    .t tag remove elide 1.0 end
2414    .t tag add elide "12.0" "16.0 +1displaylines"
2415    .t count -displaylines 12.0 17.0
2416} {4}
2417test textDisp-19.11.20 {TextWidgetCmd procedure, "index +displaylines"} {
2418    .t tag remove elide 1.0 end
2419    .t tag add elide "12.0" "16.0 +1displaylines"
2420    list [.t index "11.5 +2d lines"] \
2421      [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \
2422      [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \
2423      [.t index "13.0 +4d lines"]
2424} {16.38 16.50 16.33 16.50 16.67 17.0}
2425test textDisp-19.11.21 {TextWidgetCmd procedure, "index +displaylines"} {
2426    .t tag remove elide 1.0 end
2427    .t tag add elide "12.0" "16.0 +1displaylines"
2428    list [.t index "16.38 -2d lines"] \
2429      [.t index "16.50 -3d lines"] [.t index "16.33 -2d lines"] \
2430      [.t index "16.53 -4d lines"] [.t index "16.69 -4d lines"] \
2431      [.t index "17.1 -5d lines"]
2432} {11.5 11.0 11.0 10.3 11.2 11.0}
2433test textDisp-19.11.22 {TextWidgetCmd procedure, "index +displaylines"} {
2434    .t tag remove elide 1.0 end
2435    list [.t index "end +5d lines"] \
2436      [.t index "end -3d lines"] [.t index "1.0 -2d lines"] \
2437      [.t index "1.0 +4d lines"] [.t index "1.0 +50d lines"] \
2438      [.t index "end -50d lines"]
2439} {17.0 16.33 1.0 5.0 17.0 1.0}
2440test textDisp-19.11.23 {TextWidgetCmd procedure, "index +displaylines"} {
2441    .t tag remove elide 1.0 end
2442    .t tag add elide "12.3" "16.0 +1displaylines"
2443    list [.t index "11.5 +1d lines"] [.t index "11.5 +2d lines"] \
2444      [.t index "12.0 +1d lines"] \
2445      [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \
2446      [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \
2447      [.t index "13.0 +4d lines"]
2448} {16.17 16.33 16.28 16.46 16.28 16.49 16.65 17.0}
2449.t tag remove elide 1.0 end
2450test textDisp-19.11.24 {TextWidgetCmd procedure, "index +/-displaylines"} {
2451    list [.t index "11.5 + -1 display lines"] \
2452      [.t index "11.5 + +1 disp lines"] \
2453      [.t index "11.5 - -1 disp lines"] \
2454      [.t index "11.5 - +1 disp lines"] \
2455      [.t index "11.5 -1 disp lines"] \
2456      [.t index "11.5 +1 disp lines"] \
2457      [.t index "11.5 +0 disp lines"]
2458} {10.5 12.5 12.5 10.5 10.5 12.5 11.5}
2459.t tag remove elide 1.0 end
2460test textDisp-19.12 {GetYView procedure, partially visible last line} {
2461    catch {destroy .top}
2462    toplevel .top
2463    wm geometry .top +0+0
2464    text .top.t -width 40 -height 5 -font $fixedFont
2465    pack .top.t -expand yes -fill both
2466    .top.t insert end "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
2467    # Need to wait for asychronous calculations to complete.
2468    update ; after 10
2469    scan [wm geom .top] %dx%d twidth theight
2470    wm geom .top ${twidth}x[expr $theight - 3]
2471    update
2472    .top.t yview
2473} [list 0.0 [expr {(5.0 * $fixedHeight - 3.0)/ (5.0 * $fixedHeight)}]]
2474test textDisp-19.13 {GetYView procedure, partially visible last line} {textfonts} {
2475    catch {destroy .top}
2476    toplevel .top
2477    wm geometry .top +0+0
2478    text .top.t -width 40 -height 5 -font $fixedFont
2479    pack .top.t -expand yes -fill both
2480    .top.t insert end "Line 1\nLine 2\nLine 3\nLine 4 has enough text to wrap around at least once"
2481    # Need to wait for asychronous calculations to complete.
2482    update ; after 10
2483    scan [wm geom .top] %dx%d twidth theight
2484    wm geom .top ${twidth}x[expr $theight - 3]
2485    update
2486    .top.t yview
2487} [list 0.0 [expr {(5.0 * $fixedHeight - 3.0)/ (5.0 * $fixedHeight)}]]
2488catch {destroy .top}
2489test textDisp-19.14 {GetYView procedure} {
2490    .t configure -wrap word
2491    .t delete 1.0 end
2492    .t insert 1.0 "Line 1"
2493    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2494	.t insert end "\nLine $i"
2495    }
2496    .t insert end "\nThis last line wraps around four "
2497    .t insert end "times with a bit left on the last line."
2498    # Need to update so everything is calculated.
2499    update ; .t count -update -ypixels 1.0 end
2500    update ; after 10 ; update
2501    set scrollInfo "unchanged"
2502    .t mark set insert 3.0
2503    .t tag configure x -background red
2504    .t tag add x 1.0 5.0
2505    update
2506    .t tag delete x
2507    set scrollInfo
2508} {unchanged}
2509test textDisp-19.15 {GetYView procedure} {
2510    .t configure -wrap word
2511    .t delete 1.0 end
2512    .t insert 1.0 "Line 1"
2513    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2514	.t insert end "\nLine $i"
2515    }
2516    .t insert end "\nThis last line wraps around four "
2517    .t insert end "times with a bit left on the last line."
2518    update
2519    .t configure -yscrollcommand scrollError
2520    proc bgerror args {
2521	global x errorInfo errorCode
2522	set x [list $args $errorInfo $errorCode]
2523    }
2524    .t delete 1.0 end
2525    update
2526    rename bgerror {}
2527    .t configure -yscrollcommand scroll
2528    set x
2529} {{{scrolling error}} {scrolling error
2530    while executing
2531"error "scrolling error""
2532    (procedure "scrollError" line 2)
2533    invoked from within
2534"scrollError 0.0 1.0"
2535    (vertical scrolling command executed by text)} NONE}
2536
2537test textDisp-19.16 {count -ypixels} {
2538    .t configure -wrap word
2539    .t delete 1.0 end
2540    .t insert 1.0 "Line 1"
2541    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2542	.t insert end "\nLine $i"
2543    }
2544    .t insert end "\nThis last line wraps around four "
2545    .t insert end "times with a bit left on the last line."
2546    # Need to update so everything is calculated.
2547    update ; .t count -update -ypixels 1.0 end ; update
2548    set res {}
2549    lappend res \
2550      [.t count -ypixels 1.0 end] \
2551      [.t count -update -ypixels 1.0 end] \
2552      [.t count -ypixels 15.0 16.0] \
2553      [.t count -ypixels 15.0 "16.0 displaylineend +1c"] \
2554      [.t count -ypixels 16.0 "16.0 displaylineend +1c"] \
2555      [.t count -ypixels "16.0 +1 displaylines" "16.0 +4 displaylines +3c"]
2556} [list [expr {260 + 20 * $fixedDiff}] [expr {260 + 20 * $fixedDiff}] $fixedHeight [expr {2*$fixedHeight}] $fixedHeight [expr {3*$fixedHeight}]]
2557.t delete 1.0 end
2558.t insert end "Line 1"
2559for {set i 2} {$i <= 200} {incr i} {
2560    .t insert end "\nLine $i"
2561}
2562.t configure -wrap word
2563.t delete 50.0 51.0
2564.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2565test textDisp-20.1 {FindDLine} {textfonts} {
2566    .t yview 48.0
2567    list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \
2568	    [.t dlineinfo 58.0]
2569} [list {} {} [list 3 [expr {$fixedDiff + 16}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
2570test textDisp-20.2 {FindDLine} {textfonts} {
2571    .t yview 100.0
2572    .t yview -pickplace 53.0
2573    list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.15]
2574} [list [list 3 [expr {-1 - $fixedDiff/2}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {-1 - $fixedDiff/2}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {12 + $fixedDiff/2}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
2575test textDisp-20.3 {FindDLine} {textfonts} {
2576    .t yview 100.0
2577    .t yview 49.0
2578    list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 57.0]
2579} [list [list 3 [expr {$fixedDiff + 16}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {2*$fixedDiff + 29}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
2580test textDisp-20.4 {FindDLine} {textfonts} {
2581    .t yview 100.0
2582    .t yview 42.0
2583    list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
2584} [list [list 3 [expr {8*$fixedDiff + 107}] 105 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 140 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
2585.t config -wrap none
2586test textDisp-20.5 {FindDLine} {textfonts} {
2587    .t yview 100.0
2588    .t yview 48.0
2589    list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
2590} [list [list 3 [expr {3+2*$fixedHeight}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {3+2*$fixedHeight}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {3+2*$fixedHeight}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
2591
2592.t config -wrap word
2593test textDisp-21.1 {TkTextPixelIndex} {textfonts} {
2594    .t yview 48.0
2595    list [.t index @-10,-10] [.t index @6,6] [.t index @22,6] \
2596	    [.t index @102,6] [.t index @38,[expr {$fixedHeight * 4 + 3}]] [.t index @44,67]
2597} {48.0 48.0 48.2 48.7 50.40 50.40}
2598.t insert end \n
2599test textDisp-21.2 {TkTextPixelIndex} {textfonts} {
2600    .t yview 195.0
2601    list [.t index @11,[expr {$fixedHeight * 5 + 5}]] [.t index @11,[expr {$fixedHeight * 6 + 5}]] [.t index @11,[expr {$fixedHeight * 7 + 5}]] \
2602	    [.t index @11,1002]
2603} {197.1 198.1 199.1 201.0}
2604test textDisp-21.3 {TkTextPixelIndex, horizontal scrolling} {textfonts} {
2605    .t configure -wrap none
2606    .t delete 1.0 end
2607    .t insert end "12345\n"
2608    .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
2609    .t xview scroll 2 units
2610    list [.t index @-5,7] [.t index @5,7] [.t index @33,20]
2611} {1.2 1.2 2.6}
2612test textDisp-21.4 {count -displaylines regression} {
2613    set message {
2614   QOTW:  "C/C++, which is used by 16% of users, is the most popular programming language, but Tcl, used by 0%, seems to be the language of choice for the highest scoring users."
2615(new line)
2616Use the Up (cursor) key to scroll up one line at a time.  At the second press, the cursor either gets locked or jumps several lines.
2617
2618Connect with Tkcon.  The command
2619.u count -displaylines \ 
26203.10 2.173
2621should give answer -1; it gives me 5.
2622
2623Using 8.5a4 (ActiveState beta 4) under Linux.  No problem with ActiveState beta 3.
2624}
2625
2626toplevel .tt
2627pack [text .tt.u] -side right
2628.tt.u configure -width 30 -height 27 -wrap word -bg #FFFFFF
2629.tt.u insert end $message
2630.tt.u mark set insert 3.10
2631tkwait visibility .tt.u
2632set res [.tt.u count -displaylines 3.10 2.173]
2633destroy .tt
2634unset message
2635set res
2636} {-1}
2637
2638.t delete 1.0 end
2639.t insert end "Line 1"
2640for {set i 2} {$i <= 200} {incr i} {
2641    .t insert end "\nLine $i"
2642}
2643.t configure -wrap word
2644.t delete 50.0 51.0
2645.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2646update
2647.t tag add x 50.1
2648test textDisp-22.1 {TkTextCharBbox} {textfonts} {
2649    .t config -wrap word
2650    .t yview 48.0
2651    list [.t bbox 47.2] [.t bbox 48.0] [.t bbox 50.5] [.t bbox 50.40] \
2652	    [.t bbox 58.0]
2653} [list {} [list 3 3 7 $fixedHeight] [list 38 [expr {3+2*$fixedHeight}] 7 $fixedHeight] [list 38 [expr {3+4*$fixedHeight}] 7 $fixedHeight] {}]
2654test textDisp-22.2 {TkTextCharBbox} {textfonts} {
2655    .t config -wrap none
2656    .t yview 48.0
2657    list [.t bbox 50.5] [.t bbox 50.40] [.t bbox 57.0]
2658} [list [list 38 [expr {3+2*$fixedHeight}] 7 $fixedHeight] {} [list 3 [expr {3+9*$fixedHeight}] 7 $fixedHeight]]
2659test textDisp-22.3 {TkTextCharBbox, cut-off lines} {textfonts} {
2660    .t config -wrap char
2661    .t yview 10.0
2662    wm geom . ${width}x[expr $height-1]
2663    update
2664    list [.t bbox 19.1] [.t bbox 20.1]
2665} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] [list 10 [expr {3+10*$fixedHeight}] 7 3]]
2666test textDisp-22.4 {TkTextCharBbox, cut-off lines} {textfonts} {
2667    .t config -wrap char
2668    .t yview 10.0
2669    wm geom . ${width}x[expr $height+1]
2670    update
2671    list [.t bbox 19.1] [.t bbox 20.1]
2672} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] [list 10 [expr {3+10*$fixedHeight}] 7 5]]
2673test textDisp-22.5 {TkTextCharBbox, cut-off char} {textfonts} {
2674    .t config -wrap none
2675    .t yview 10.0
2676    wm geom . [expr $width-95]x$height
2677    update
2678    .t bbox 15.6
2679} [list 45 [expr {3+5*$fixedHeight}] 7 $fixedHeight]
2680test textDisp-22.6 {TkTextCharBbox, line visible but not char} {textfonts} {
2681    .t config -wrap char
2682    .t yview 10.0
2683    .t tag add big 20.2 20.5
2684    wm geom . ${width}x[expr $height+3]
2685    update
2686    list [.t bbox 19.1] [.t bbox 20.1] [.t bbox 20.2]
2687} [list [list 10 [expr {3+9*$fixedHeight}] 7 $fixedHeight] {} [list 17 [expr {3+10*$fixedHeight}] 14 7]]
2688wm geom . {}
2689update
2690test textDisp-22.7 {TkTextCharBbox, different character sizes} {textfonts} {
2691    .t config -wrap char
2692    .t yview 10.0
2693    .t tag add big 12.2 12.5
2694    update
2695    list [.t bbox 12.1] [.t bbox 12.2]
2696} [list [list 10 [expr {3 + 2*$fixedHeight + $ascentDiff}] 7 $fixedHeight] [list 17 [expr {3+ 2*$fixedHeight}] 14 27]]
2697.t tag remove big 1.0 end
2698test textDisp-22.8 {TkTextCharBbox, horizontal scrolling} {textfonts} {
2699    .t configure -wrap none
2700    .t delete 1.0 end
2701    .t insert end "12345\n"
2702    .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
2703    .t xview scroll 4 units
2704    list [.t bbox 1.3] [.t bbox 1.4] [.t bbox 2.3] [.t bbox 2.4] \
2705	    [.t bbox 2.23] [.t bbox 2.24]
2706} [list {} [list 3 3 7 $fixedHeight] {} [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 136 [expr {$fixedDiff + 16}] 7 $fixedHeight] {}]
2707test textDisp-22.9 {TkTextCharBbox, handling of spacing} {textfonts} {
2708    .t configure -wrap char
2709    .t delete 1.0 end
2710    .t insert 1.0 "abcdefghijkl\nmnopqrstuvwzyz"
2711    .t tag configure spacing -spacing1 8 -spacing3 2
2712    .t tag add spacing 1.0 end
2713    frame .t.f1 -width 10 -height 4 -bg black
2714    frame .t.f2 -width 10 -height 4 -bg black
2715    frame .t.f3 -width 10 -height 4 -bg black
2716    frame .t.f4 -width 10 -height 4 -bg black
2717    .t window create 1.3 -window .t.f1 -align top
2718    .t window create 1.7 -window .t.f2 -align center
2719    .t window create 2.1 -window .t.f3 -align bottom
2720    .t window create 2.10 -window .t.f4 -align baseline
2721    update
2722    list [.t bbox .t.f1] [.t bbox .t.f2] [.t bbox .t.f3] [.t bbox .t.f4] \
2723	    [.t bbox 1.1] [.t bbox 2.9]
2724} [list [list 24 11 10 4] [list 55 [expr {$fixedDiff/2 + 15}] 10 4] [list 10 [expr {2*$fixedDiff + 43}] 10 4] [list 76 [expr {2*$fixedDiff + 40}] 10 4] [list 10 11 7 $fixedHeight] [list 69 [expr {$fixedDiff + 34}] 7 $fixedHeight]]
2725.t tag delete spacing
2726
2727.t delete 1.0 end
2728.t insert end "Line 1"
2729for {set i 2} {$i <= 200} {incr i} {
2730    .t insert end "\nLine $i"
2731}
2732.t configure -wrap word
2733.t delete 50.0 51.0
2734.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2735update
2736test textDisp-23.1 {TkTextDLineInfo} {textfonts} {
2737    .t config -wrap word
2738    .t yview 48.0
2739    list [.t dlineinfo 47.3] [.t dlineinfo 48.0] [.t dlineinfo 50.40] \
2740	    [.t dlineinfo 56.0]
2741} [list {} [list 3 3 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {4*$fixedDiff + 55}] 126 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] {}]
2742test textDisp-23.2 {TkTextDLineInfo} {textfonts} {
2743    .t config -bd 4 -wrap word
2744    update
2745    .t yview 48.0
2746    .t dlineinfo 50.40
2747} [list 7 [expr {4*$fixedDiff + 59}] 126 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]
2748.t config -bd 0
2749test textDisp-23.3 {TkTextDLineInfo} {textfonts} {
2750    .t config -wrap none
2751    update
2752    .t yview 48.0
2753    list [.t dlineinfo 50.40] [.t dlineinfo 57.3]
2754} [list [list 3 [expr {2*$fixedDiff + 29}] 371 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
2755test textDisp-23.4 {TkTextDLineInfo, cut-off lines} {textfonts} {
2756    .t config -wrap char
2757    .t yview 10.0
2758    wm geom . ${width}x[expr $height-1]
2759    update
2760    list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
2761} [list [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {10*$fixedDiff + 133}] 49 3 [expr {$fixedDiff + 10}]]]
2762test textDisp-23.5 {TkTextDLineInfo, cut-off lines} {textfonts} {
2763    .t config -wrap char
2764    .t yview 10.0
2765    wm geom . ${width}x[expr $height+1]
2766    update
2767    list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
2768} [list [list 3 [expr {9*$fixedDiff + 120}] 49 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {10*$fixedDiff + 133}] 49 5 [expr {$fixedDiff + 10}]]]
2769wm geom . {}
2770update
2771test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {textfonts} {
2772    .t config -wrap none
2773    .t delete 1.0 end
2774    .t insert end "First line\n"
2775    .t insert end "Second line is a very long one that doesn't all fit.\n"
2776    .t insert end "Third"
2777    .t xview scroll 6 units
2778    update
2779    list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
2780} [list [list -39 3 70 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list -39 [expr {$fixedDiff + 16}] 364 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list -39 [expr {2*$fixedDiff + 29}] 35 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
2781.t xview moveto 0
2782test textDisp-23.7 {TkTextDLineInfo, centering} {textfonts} {
2783    .t config -wrap word
2784    .t delete 1.0 end
2785    .t insert end "First line\n"
2786    .t insert end "Second line is a very long one that doesn't all fit.\n"
2787    .t insert end "Third"
2788    .t tag configure x -justify center
2789    .t tag configure y -justify right
2790    .t tag add x 1.0
2791    .t tag add y 3.0
2792    list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
2793} [list [list 38 3 70 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 3 [expr {$fixedDiff + 16}] 119 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 108 [expr {4*$fixedDiff + 55}] 35 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]]]
2794.t tag delete x y
2795
2796test textDisp-24.1 {TkTextCharLayoutProc} {textfonts} {
2797    .t configure -wrap char
2798    .t delete 1.0 end
2799    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2800    list [.t bbox 1.19] [.t bbox 1.20]
2801} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2802test textDisp-24.2 {TkTextCharLayoutProc} {textfonts} {
2803    .t configure -wrap char
2804    .t delete 1.0 end
2805    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2806    wm geom . [expr $width+1]x$height
2807    update
2808    list [.t bbox 1.19] [.t bbox 1.20]
2809} [list [list 136 3 12 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2810test textDisp-24.3 {TkTextCharLayoutProc} {textfonts} {
2811    .t configure -wrap char
2812    .t delete 1.0 end
2813    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2814    wm geom . [expr $width-1]x$height
2815    update
2816    list [.t bbox 1.19] [.t bbox 1.20]
2817} [list [list 136 3 10 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2818test textDisp-24.4 {TkTextCharLayoutProc, newline not visible} {textfonts} {
2819    .t configure -wrap char
2820    .t delete 1.0 end
2821    .t insert 1.0 01234567890123456789\n012345678901234567890
2822    wm geom . {}
2823    update
2824    list [.t bbox 1.19] [.t bbox 1.20] [.t bbox 2.20]
2825} [list [list 136 3 7 $fixedHeight] [list 143 3 0 $fixedHeight] [list 3 [expr {2*$fixedDiff + 29}] 7 $fixedHeight]]
2826test textDisp-24.5 {TkTextCharLayoutProc, char doesn't fit, newline not visible} {unix textfonts} {
2827    .t configure -wrap char
2828    .t delete 1.0 end
2829    .t insert 1.0 0\n1\n
2830    wm geom . 110x$height
2831    update
2832    list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 2.0]
2833} [list [list 3 3 4 $fixedHeight] [list 7 3 0 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 4 $fixedHeight]]
2834test textDisp-24.6 {TkTextCharLayoutProc, line ends with space} {textfonts} {
2835    .t configure -wrap char
2836    .t delete 1.0 end
2837    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2838    wm geom . {}
2839    update
2840    list [.t bbox 1.19] [.t bbox 1.20]
2841} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2842test textDisp-24.7 {TkTextCharLayoutProc, line ends with space} {textfonts} {
2843    .t configure -wrap char
2844    .t delete 1.0 end
2845    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2846    wm geom . [expr $width+1]x$height
2847    update
2848    list [.t bbox 1.19] [.t bbox 1.20]
2849} [list [list 136 3 12 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2850test textDisp-24.8 {TkTextCharLayoutProc, line ends with space} {textfonts} {
2851    .t configure -wrap char
2852    .t delete 1.0 end
2853    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2854    wm geom . [expr $width-1]x$height
2855    update
2856    list [.t bbox 1.19] [.t bbox 1.20]
2857} [list [list 136 3 10 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2858test textDisp-24.9 {TkTextCharLayoutProc, line ends with space} {textfonts} {
2859    .t configure -wrap char
2860    .t delete 1.0 end
2861    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2862    wm geom . [expr $width-6]x$height
2863    update
2864    list [.t bbox 1.19] [.t bbox 1.20]
2865} [list [list 136 3 5 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2866test textDisp-24.10 {TkTextCharLayoutProc, line ends with space} {textfonts} {
2867    .t configure -wrap char
2868    .t delete 1.0 end
2869    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2870    wm geom . [expr $width-7]x$height
2871    update
2872    list [.t bbox 1.19] [.t bbox 1.20]
2873} [list [list 136 3 4 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2874test textDisp-24.11 {TkTextCharLayoutProc, line ends with space that doesn't quite fit} {textfonts} {
2875    .t configure -wrap char
2876    .t delete 1.0 end
2877    .t insert 1.0 "01234567890123456789 \nabcdefg"
2878    wm geom . [expr $width-2]x$height
2879    update
2880    set result {}
2881    lappend result [.t bbox 1.21] [.t bbox 2.0]
2882    .t mark set insert 1.21
2883    lappend result [.t bbox 1.21] [.t bbox 2.0]
2884} [list [list 145 3 0 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 145 3 0 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2885test textDisp-24.12 {TkTextCharLayoutProc, tab causes wrap} {textfonts} {
2886    .t configure -wrap char
2887    .t delete 1.0 end
2888    .t insert 1.0 "abcdefghi"
2889    .t mark set insert 1.4
2890    .t insert insert \t\t\t
2891    list [.t bbox {insert -1c}] [.t bbox insert]
2892} [list [list 115 3 30 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2893test textDisp-24.13 {TkTextCharLayoutProc, -wrap none} {textfonts} {
2894    .t configure -wrap none
2895    .t delete 1.0 end
2896    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2897    wm geom . {}
2898    update
2899    list [.t bbox 1.19] [.t bbox 1.20]
2900} [list [list 136 3 7 $fixedHeight] {}]
2901test textDisp-24.14 {TkTextCharLayoutProc, -wrap none} {textfonts} {
2902    .t configure -wrap none
2903    .t delete 1.0 end
2904    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2905    wm geom . [expr $width+1]x$height
2906    update
2907    list [.t bbox 1.19] [.t bbox 1.20]
2908} [list [list 136 3 7 $fixedHeight] [list 143 3 5 $fixedHeight]]
2909test textDisp-24.15 {TkTextCharLayoutProc, -wrap none} {textfonts} {
2910    .t configure -wrap none
2911    .t delete 1.0 end
2912    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2913    wm geom . [expr $width-1]x$height
2914    update
2915    list [.t bbox 1.19] [.t bbox 1.20]
2916} [list [list 136 3 7 $fixedHeight] [list 143 3 3 $fixedHeight]]
2917test textDisp-24.16 {TkTextCharLayoutProc, no chars fit} {textfonts} {
2918    if {$tcl_platform(platform) == "windows"} {
2919	wm overrideredirect . 1
2920    }
2921    .t configure -wrap char
2922    .t delete 1.0 end
2923    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2924    wm geom . 103x$height
2925    update
2926    list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
2927} [list [list 3 3 1 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 1 $fixedHeight] [list 3 [expr {2*$fixedDiff + 29}] 1 $fixedHeight]]
2928if {$tcl_platform(platform) == "windows"} {
2929    wm overrideredirect . 0
2930}
2931test textDisp-24.17 {TkTextCharLayoutProc, -wrap word} {textfonts} {
2932    .t configure -wrap word
2933    .t delete 1.0 end
2934    .t insert 1.0 "This is a line that wraps around"
2935    wm geom . {}
2936    update
2937    list [.t bbox 1.19] [.t bbox 1.20]
2938} [list [list 136 3 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2939test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {textfonts} {
2940    .t configure -wrap word
2941    .t delete 1.0 end
2942    .t insert 1.0 "xThis is a line that wraps around"
2943    wm geom . {}
2944    update
2945    list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
2946} [list [list 101 3 7 $fixedHeight] [list 108 3 35 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 7 $fixedHeight]]
2947test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {textfonts} {
2948    .t configure -wrap word
2949    .t delete 1.0 end
2950    .t insert 1.0 "xxThis is a line that wraps around"
2951    wm geom . {}
2952    update
2953    list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
2954} [list [list 101 3 7 $fixedHeight] [list 108 3 7 $fixedHeight] [list 115 3 28 $fixedHeight]]
2955test textDisp-24.20 {TkTextCharLayoutProc, vertical offset} {textfonts} {
2956    .t configure -wrap none
2957    .t delete 1.0 end
2958    .t insert 1.0 "Line 1\nLine 2\nLine 3"
2959    set result {}
2960    lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2961    .t tag configure up -offset 6
2962    .t tag add up 2.1
2963    lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2964    .t tag configure  up -offset -2
2965    lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2966    .t tag delete up
2967    set result
2968} [list [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 13}] [expr {$fixedDiff + 10}]] [list 10 [expr {$fixedDiff + 16}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 19}] [expr {$fixedDiff + 16}]] [list 10 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 3 [expr {$fixedDiff + 16}] 42 [expr {$fixedDiff + 15}] [expr {$fixedDiff + 10}]]]
2969.t configure -width 30
2970update
2971test textDisp-24.21 {TkTextCharLayoutProc, word breaks} {textfonts} {
2972    .t configure -wrap word
2973    .t delete 1.0 end
2974    .t insert 1.0 "Sample text xxxxxxx yyyyy zzzzzzz qqqqq rrrr ssss tt u vvvvv"
2975    frame .t.f -width 30 -height 20 -bg black
2976    .t window create 1.36 -window .t.f
2977    .t bbox 1.26
2978} [list 3 [expr {$fixedDiff/2 + 19}] 7 $fixedHeight]
2979test textDisp-24.22 {TkTextCharLayoutProc, word breaks} {textfonts} {
2980    .t configure -wrap word
2981    .t delete 1.0 end
2982    frame .t.f -width 30 -height 20 -bg black
2983    .t insert 1.0 "Sample text xxxxxxx yyyyyyy"
2984    .t window create end -window .t.f
2985    .t insert end "zzzzzzz qqqqq rrrr ssss tt u vvvvv"
2986    .t bbox 1.28
2987} [list 33 [expr {$fixedDiff/2 + 19}] 7 $fixedHeight]
2988test textDisp-24.23 {TkTextCharLayoutProc, word breaks} {textfonts} {
2989    .t configure -wrap word
2990    .t delete 1.0 end
2991    frame .t.f -width 30 -height 20 -bg black
2992    .t insert 1.0 "Sample text xxxxxxx yyyyyyy "
2993    .t insert end "zzzzzzz qqqqq rrrr ssss tt"
2994    .t window create end -window .t.f
2995    .t insert end "u vvvvv"
2996    .t bbox .t.f
2997} [list 3 [expr {2*$fixedDiff + 29}] 30 20]
2998catch {destroy .t.f}
2999.t configure -width 20
3000update
3001test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} {textfonts} {
3002    .t delete 1.0 end
3003    .t tag configure x -justify center
3004    .t insert 1.0 aa\tbb\tcc\tdd\t
3005    .t tag add x 1.0 end
3006    list [.t bbox 1.0] [.t bbox 1.10]
3007} [list [list 45 3 7 $fixedHeight] [list 94 3 7 $fixedHeight]]
3008
3009.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
3010    -tabs 100
3011update
3012test textDisp-25.1 {CharBboxProc procedure, check tab width} {textfonts} {
3013    .t delete 1.0 end
3014    .t insert 1.0 abc\td\tfgh
3015    list [.t bbox 1.3] [.t bbox 1.5] [.t bbox 1.6]
3016} [list [list 21 1 79 $fixedHeight] [list 107 1 93 $fixedHeight] [list 200 1 7 $fixedHeight]]
3017
3018.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
3019	-tabs {}
3020update
3021test textDisp-26.1 {AdjustForTab procedure, no tabs} {textfonts} {
3022    .t delete 1.0 end
3023    .t insert 1.0 a\tbcdefghij\tc\td
3024    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
3025	    [lindex [.t bbox 1.14] 0]
3026} [list 56 126 168]
3027test textDisp-26.1.2 {AdjustForTab procedure, no tabs} {textfonts} {
3028    .t delete 1.0 end
3029    .t insert 1.0 a\tbcdefghij\tc\td
3030    .t configure -tabstyle wordprocessor
3031    set res [list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
3032      [lindex [.t bbox 1.14] 0]]
3033    .t configure -tabstyle tabular
3034    set res
3035} [list 56 168 224]
3036test textDisp-26.2 {AdjustForTab procedure, not enough tabs specified} {
3037    .t delete 1.0 end
3038    .t insert 1.0 a\tb\tc\td
3039    .t tag delete x
3040    .t tag configure x -tabs 40
3041    .t tag add x 1.0 end
3042    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
3043	    [lindex [.t bbox 1.6] 0]
3044} [list 40 80 120]
3045test textDisp-26.3 {AdjustForTab procedure, not enough tabs specified} {
3046    .t delete 1.0 end
3047    .t insert 1.0 a\tb\tc\td\te
3048    .t tag delete x
3049    .t tag configure x -tabs {40 70 right}
3050    .t tag add x 1.0 end
3051    list [lindex [.t bbox 1.2] 0] \
3052	    [expr [lindex [.t bbox 1.4] 0] + [lindex [.t bbox 1.4] 2]] \
3053	    [expr [lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]] \
3054	    [expr [lindex [.t bbox 1.8] 0] + [lindex [.t bbox 1.8] 2]]
3055} [list 40 70 100 130]
3056test textDisp-26.4 {AdjustForTab procedure, different alignments} {
3057    .t delete 1.0 end
3058    .t insert 1.0 a\tbc\tde\tfg\thi
3059    .t tag delete x
3060    .t tag configure x -tabs {40 center 80 left 130 right}
3061    .t tag add x 1.0 end
3062    .t tag add y 1.2
3063    .t tag add y 1.5
3064    .t tag add y 1.8
3065    list [lindex [.t bbox 1.3] 0] [lindex [.t bbox 1.5] 0] \
3066	    [lindex [.t bbox 1.10] 0]
3067} [list 40 80 130]
3068test textDisp-26.5 {AdjustForTab procedure, numeric alignment} {
3069    .t delete 1.0 end
3070    .t insert 1.0 a\t1.234
3071    .t tag delete x
3072    .t tag configure x -tabs {120 numeric}
3073    .t tag add x 1.0 end
3074    .t tag add y 1.2
3075    .t tag add y 1.5
3076    lindex [.t bbox 1.3] 0
3077} {120}
3078test textDisp-26.6 {AdjustForTab procedure, numeric alignment} {
3079    .t delete 1.0 end
3080    .t insert 1.0 a\t1,456.234
3081    .t tag delete x
3082    .t tag configure x -tabs {120 numeric}
3083    .t tag add x 1.0 end
3084    .t tag add y 1.2
3085    lindex [.t bbox 1.7] 0
3086} {120}
3087test textDisp-26.7 {AdjustForTab procedure, numeric alignment} {
3088    .t delete 1.0 end
3089    .t insert 1.0 a\t1.456.234,7
3090    .t tag delete x
3091    .t tag configure x -tabs {120 numeric}
3092    .t tag add x 1.0 end
3093    .t tag add y 1.2
3094    lindex [.t bbox 1.11] 0
3095} {120}
3096test textDisp-26.8 {AdjustForTab procedure, numeric alignment} {
3097    .t delete 1.0 end
3098    .t insert 1.0 a\ttest
3099    .t tag delete x
3100    .t tag configure x -tabs {120 numeric}
3101    .t tag add x 1.0 end
3102    .t tag add y 1.2
3103    lindex [.t bbox 1.6] 0
3104} {120}
3105test textDisp-26.9 {AdjustForTab procedure, numeric alignment} {
3106    .t delete 1.0 end
3107    .t insert 1.0 a\t1234
3108    .t tag delete x
3109    .t tag configure x -tabs {120 numeric}
3110    .t tag add x 1.0 end
3111    .t tag add y 1.2
3112    lindex [.t bbox 1.6] 0
3113} {120}
3114test textDisp-26.10 {AdjustForTab procedure, numeric alignment} {
3115    .t delete 1.0 end
3116    .t insert 1.0 a\t1.234567
3117    .t tag delete x
3118    .t tag configure x -tabs {120 numeric}
3119    .t tag add x 1.0 end
3120    .t tag add y 1.5
3121    lindex [.t bbox 1.3] 0
3122} {120}
3123test textDisp-26.11 {AdjustForTab procedure, numeric alignment} {
3124    .t delete 1.0 end
3125    .t insert 1.0 a\tx=1.234567
3126    .t tag delete x
3127    .t tag configure x -tabs {120 numeric}
3128    .t tag add x 1.0 end
3129    .t tag add y 1.7
3130    .t tag add y 1.9
3131    lindex [.t bbox 1.5] 0
3132} {120}
3133test textDisp-26.12 {AdjustForTab procedure, adjusting chunks} {
3134    .t delete 1.0 end
3135    .t insert 1.0 a\tx1.234567
3136    .t tag delete x
3137    .t tag configure x -tabs {120 numeric}
3138    .t tag add x 1.0 end
3139    .t tag add y 1.7
3140    .t tag add y 1.9
3141    button .b -text "="
3142    .t window create 1.3 -window .b
3143    update
3144    lindex [.t bbox 1.5] 0
3145} {120}
3146test textDisp-26.13 {AdjustForTab procedure, not enough space} {textfonts} {
3147    .t delete 1.0 end
3148    .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
3149    .t tag delete x
3150    .t tag configure x -tabs {10 30 center 50 right 120}
3151    .t tag add x 1.0 end
3152    list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
3153	    [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]
3154} [list 28 56 84 120]
3155test textDisp-26.13.2 {AdjustForTab procedure, not enough space} {textfonts} {
3156    .t delete 1.0 end
3157    .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
3158    .t tag delete x
3159    .t tag configure x -tabs {10 30 center 50 right 120} -tabstyle wordprocessor
3160    .t tag add x 1.0 end
3161    set res [list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
3162      [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]]
3163    .t tag configure x -tabstyle tabular
3164    set res
3165} [list 28 56 120 190]
3166test textDisp-26.14 {AdjustForTab procedure, not enough space} {textfonts} {
3167    .t delete 1.0 end
3168    .t insert end "a \tb \tc \td \te \tf \tg\n"
3169    .t insert end "Watch the \tX and the \t\t\tY\n"
3170    .t tag configure moop -tabs [expr {8*$fixedWidth}]
3171    .t insert end "Watch the \tX and the \t\t\tY\n" moop
3172    list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
3173	    [lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]
3174} [list 77 224 77 224]
3175test textDisp-26.14.2 {AdjustForTab procedure, not enough space} {textfonts} {
3176    .t delete 1.0 end
3177    .t configure -tabstyle wordprocessor
3178    .t insert end "a \tb \tc \td \te \tf \tg\n"
3179    .t insert end "Watch the \tX and the \t\t\tY\n"
3180    .t tag configure moop -tabs [expr {8*$fixedWidth}]
3181    .t insert end "Watch the \tX and the \t\t\tY\n" moop
3182    set res [list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
3183      [lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]]
3184    .t configure -tabstyle tabular
3185    set res
3186} [list 112 56 112 56]
3187
3188.t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
3189	-wrap char
3190update
3191test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
3192    .t delete 1.0 end
3193    .t insert 1.0 a\tbcdefghij\tc\td
3194    list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]
3195} [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 130 5 7 $fixedHeight]]
3196test textDisp-27.1.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
3197    .t delete 1.0 end
3198    .t insert 1.0 a\tbcdefghij\tc\td
3199    .t configure -tabstyle wordprocessor
3200    set res [list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]]
3201    .t configure -tabstyle tabular
3202    set res
3203} [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3204test textDisp-27.2 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
3205    .t delete 1.0 end
3206    .t insert 1.0 a\tbcd
3207    .t tag delete x
3208    .t tag configure x -tabs 120
3209    .t tag add x 1.0 end
3210    list [.t bbox 1.3] [.t bbox 1.4]
3211} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3212test textDisp-27.3 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
3213    .t delete 1.0 end
3214    .t insert 1.0 a\t\t\tbcd
3215    .t tag delete x
3216    .t tag configure x -tabs 40
3217    .t tag add x 1.0 end
3218    list [.t bbox 1.5] [.t bbox 1.6]
3219} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3220test textDisp-27.4 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
3221    .t delete 1.0 end
3222    .t insert 1.0 a\t\t\tbcd
3223    .t tag delete x
3224    .t tag configure x -tabs {20 center 70 left}
3225    .t tag add x 1.0 end
3226    list [.t bbox 1.5] [.t bbox 1.6]
3227} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3228test textDisp-27.5 {SizeOfTab procedure, center alignment} {textfonts} {
3229    .t delete 1.0 end
3230    .t insert 1.0 a\txyzzyabc
3231    .t tag delete x
3232    .t tag configure x -tabs {120 center}
3233    .t tag add x 1.0 end
3234    list [.t bbox 1.6] [.t bbox 1.7]
3235} [list [list 135 5 9 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3236test textDisp-27.6 {SizeOfTab procedure, center alignment} {textfonts} {
3237    .t delete 1.0 end
3238    .t insert 1.0 a\txyzzyabc
3239    .t tag delete x
3240    .t tag configure x -tabs {150 center}
3241    .t tag add x 1.0 end
3242    list [.t bbox 1.6] [.t bbox 1.7]
3243} [list [list 32 [expr {$fixedDiff + 18}] 7 $fixedHeight] [list 39 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3244test textDisp-27.7 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {textfonts} {
3245    .t delete 1.0 end
3246    set cm [winfo fpixels .t 1c]
3247    .t configure -tabs {1c 2c center 3c 4c 5c 6c 7c 8c} -wrap none -width 40
3248    .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
3249    set width [expr {$fixedWidth * 19}]
3250    set tab $cm
3251    while {$tab < $width} {
3252	set tab [expr {$tab + $cm}]
3253    }
3254    # Now we've calculated to the end of the tab after 'a', add one
3255    # more for 'bb\t' and we're there, with 4 for the border.  Since
3256    # Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
3257    # so must we.
3258    set tab [expr {4 + int(0.5 + $tab + $cm)}]
3259    update
3260    set res [.t bbox 2.23]
3261    lset res 0 [expr {[lindex $res 0] - $tab}]
3262    set res
3263} [list -28 [expr {$fixedDiff + 18}] 7 $fixedHeight]
3264test textDisp-27.7.1 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {textfonts} {
3265    .t delete 1.0 end
3266    .t configure -tabstyle wordprocessor
3267    set cm [winfo fpixels .t 1c]
3268    .t configure -tabs {1c 2c center 3c 4c 5c 6c 7c 8c} -wrap none -width 40
3269    .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
3270    set width [expr {$fixedWidth * 19}]
3271    set tab $cm
3272    while {$tab < $width} {
3273	set tab [expr {$tab + $cm}]
3274    }
3275    # Now we've calculated to the end of the tab after 'a', add one
3276    # more for 'bb\t' and we're there, with 4 for the border.  Since
3277    # Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
3278    # so must we.
3279    set tab [expr {4 + int(0.5 + $tab + $cm)}]
3280    update
3281    set res [.t bbox 2.23]
3282    .t configure -tabstyle tabular
3283    lset res 0 [expr {[lindex $res 0] - $tab}]
3284    set res
3285} [list 0 [expr {$fixedDiff + 18}] 7 $fixedHeight]
3286test textDisp-27.7.2 {SizeOfTab procedure, fractional tab interpolation problem} {
3287    .t delete 1.0 end
3288    set interpolatetab {1c 2c}
3289    set precisetab {}
3290    for {set i 1} {$i < 20} {incr i} {
3291	lappend precisetab "${i}c"
3292    }
3293    .t configure -tabs $interpolatetab -wrap none -width 150
3294    .t insert 1.0 [string repeat "a\t" 20]
3295    update
3296    set res [.t bbox 1.20]
3297    # Now, Tk's interpolated tabs should be the same as
3298    # non-interpolated.
3299    .t configure -tabs $precisetab
3300    update
3301    expr {[lindex $res 0] - [lindex [.t bbox 1.20] 0]}
3302} {0}
3303
3304.t configure -wrap char -tabs {} -width 20
3305update
3306test textDisp-27.8 {SizeOfTab procedure, right alignment} {textfonts} {
3307    .t delete 1.0 end
3308    .t insert 1.0 a\t\txyzzyabc
3309    .t tag delete x
3310    .t tag configure x -tabs {100 left 140 right}
3311    .t tag add x 1.0 end
3312    list [.t bbox 1.6] [.t bbox 1.7]
3313} [list [list 137 5 7 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3314test textDisp-27.9 {SizeOfTab procedure, left alignment} {textfonts} {
3315    .t delete 1.0 end
3316    .t insert 1.0 a\txyzzyabc
3317    .t tag delete x
3318    .t tag configure x -tabs {120}
3319    .t tag add x 1.0 end
3320    list [.t bbox 1.3] [.t bbox 1.4]
3321} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3322test textDisp-27.10 {SizeOfTab procedure, numeric alignment} {textfonts} {
3323    .t delete 1.0 end
3324    .t insert 1.0 a\t123.4
3325    .t tag delete x
3326    .t tag configure x -tabs {120 numeric}
3327    .t tag add x 1.0 end
3328    list [.t bbox 1.3] [.t bbox 1.4]
3329} [list [list 117 5 27 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3330test textDisp-27.11 {SizeOfTab procedure, making tabs at least as wide as a space} {textfonts} {
3331    .t delete 1.0 end
3332    .t insert 1.0 abc\tdefghijklmnopqrst
3333    .t tag delete x
3334    .t tag configure x -tabs {120}
3335    .t tag add x 1.0 end
3336    list [.t bbox 1.5] [.t bbox 1.6]
3337} [list [list 131 5 13 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
3338
3339proc bizarre_scroll args {
3340    .t2.t delete 5.0 end
3341}
3342test textDisp-28.1 {"yview" option with bizarre scroll command} {
3343    catch {destroy .t2}
3344    toplevel .t2
3345    text .t2.t -width 40 -height 4
3346    .t2.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n"
3347    pack .t2.t
3348    wm geometry .t2 +0+0
3349    update
3350    .t2.t configure -yscrollcommand bizarre_scroll
3351    .t2.t yview 100.0
3352    set result [.t2.t index @0,0]
3353    update
3354    lappend result [.t2.t index @0,0]
3355} {6.0 1.0}
3356
3357test textDisp-29.1 {miscellaneous: lines wrap but are still too long} {textfonts} {
3358    catch {destroy .t2}
3359    toplevel .t2
3360    wm geometry .t2 +0+0
3361    text .t2.t -width 20 -height 10 -font $fixedFont \
3362	    -wrap char -xscrollcommand ".t2.s set"
3363    pack .t2.t -side top
3364    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3365    pack .t2.s -side bottom -fill x
3366    .t2.t insert end 123
3367    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
3368    .t2.t window create 1.1 -window .t2.t.f
3369    update
3370    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
3371} [list [list 0.0 [expr {14.0/30}]] 300x50+5+[expr {$fixedDiff + 18}] [list 12 [expr {$fixedDiff + 68}] 7 $fixedHeight]]
3372test textDisp-29.2 {miscellaneous: lines wrap but are still too long} {textfonts} {
3373    catch {destroy .t2}
3374    toplevel .t2
3375    wm geometry .t2 +0+0
3376    text .t2.t -width 20 -height 10 -font $fixedFont \
3377	    -wrap char -xscrollcommand ".t2.s set"
3378    pack .t2.t -side top
3379    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3380    pack .t2.s -side bottom -fill x
3381    .t2.t insert end 123
3382    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
3383    .t2.t window create 1.1 -window .t2.t.f
3384    .t2.t xview scroll 1 unit
3385    update
3386    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
3387} [list [list [expr {7.0/300}] 0.49] 300x50+-2+[expr {$fixedDiff + 18}] [list 5 [expr {$fixedDiff + 68}] 7 $fixedHeight]]
3388test textDisp-29.2.1 {miscellaneous: lines wrap but are still too long} {textfonts} {
3389    catch {destroy .t2}
3390    toplevel .t2
3391    wm geometry .t2 +0+0
3392    text .t2.t -width 20 -height 10 -font $fixedFont \
3393	    -wrap none -xscrollcommand ".t2.s set"
3394    pack .t2.t -side top
3395    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3396    pack .t2.s -side bottom -fill x
3397    .t2.t insert end 1\n
3398    .t2.t insert end [string repeat "abc" 30]
3399    .t2.t xview scroll 5 unit
3400    update
3401    .t2.t xview
3402} [list [expr {5.0/90}] [expr {25.0/90}]]
3403test textDisp-29.2.2 {miscellaneous: lines wrap but are still too long} {textfonts} {
3404    catch {destroy .t2}
3405    toplevel .t2
3406    wm geometry .t2 +0+0
3407    text .t2.t -width 20 -height 10 -font $fixedFont \
3408	    -wrap char -xscrollcommand ".t2.s set"
3409    pack .t2.t -side top
3410    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3411    pack .t2.s -side bottom -fill x
3412    .t2.t insert end 123
3413    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
3414    .t2.t window create 1.1 -window .t2.t.f
3415    .t2.t xview scroll 2 unit
3416    update
3417    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
3418} [list [list [expr {14.0/300}] [expr {154.0/300}]] 300x50+-9+[expr {$fixedDiff + 18}] {}]
3419test textDisp-29.2.3 {miscellaneous: lines wrap but are still too long} {textfonts} {
3420    catch {destroy .t2}
3421    toplevel .t2
3422    wm geometry .t2 +0+0
3423    text .t2.t -width 20 -height 10 -font $fixedFont \
3424	    -wrap char -xscrollcommand ".t2.s set"
3425    pack .t2.t -side top
3426    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3427    pack .t2.s -side bottom -fill x
3428    .t2.t insert end 123
3429    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
3430    .t2.t window create 1.1 -window .t2.t.f
3431    .t2.t xview scroll 7 pixels
3432    update
3433    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
3434} [list [list [expr {7.0/300}] 0.49] 300x50+-2+[expr {$fixedDiff + 18}] [list 5 [expr {$fixedDiff + 68}] 7 $fixedHeight]]
3435test textDisp-29.2.4 {miscellaneous: lines wrap but are still too long} {textfonts} {
3436    catch {destroy .t2}
3437    toplevel .t2
3438    wm geometry .t2 +0+0
3439    text .t2.t -width 20 -height 10 -font $fixedFont \
3440	    -wrap char -xscrollcommand ".t2.s set"
3441    pack .t2.t -side top
3442    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3443    pack .t2.s -side bottom -fill x
3444    .t2.t insert end 123
3445    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
3446    .t2.t window create 1.1 -window .t2.t.f
3447    .t2.t xview scroll 17 pixels
3448    update
3449    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
3450} [list [list [expr {17.0/300}] [expr {157.0/300}]] 300x50+-12+[expr {$fixedDiff + 18}] {}]
3451test textDisp-29.2.5 {miscellaneous: can show last character} {
3452    catch {destroy .t2}
3453    toplevel .t2
3454    wm geometry .t2 121x141+200+200
3455    text .t2.t -width 5 -height 5 -font {Arial 10} \
3456      -wrap none -xscrollcommand ".t2.s set" \
3457      -bd 2 -highlightthickness 0 -padx 1
3458    .t2.t insert end "WWWWWWWWWWWWi"
3459    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3460    grid .t2.t -row 0 -column 0 -sticky nsew
3461    grid .t2.s -row 1 -column 0 -sticky ew
3462    grid columnconfigure .t2 0 -weight 1
3463    grid rowconfigure .t2 0 -weight 1
3464    grid rowconfigure .t2 1 -weight 0
3465    update ; update
3466    set xv [.t2.t xview]
3467    set xd [expr {[lindex $xv 1] - [lindex $xv 0]}]
3468    .t2.t xview moveto [expr {1.0-$xd}]
3469    set iWidth [lindex [.t2.t bbox end-2c] 2]
3470    .t2.t xview scroll 2 units
3471    set iWidth2 [lindex [.t2.t bbox end-2c] 2]
3472    
3473    if {($iWidth == $iWidth2) && $iWidth >= 2} {
3474	set result "correct"
3475    } else {
3476	set result "last character is not completely visible when it should be"
3477    }
3478} {correct}
3479test textDisp-29.3 {miscellaneous: lines wrap but are still too long} {textfonts} {
3480    catch {destroy .t2}
3481    toplevel .t2
3482    wm geometry .t2 +0+0
3483    text .t2.t -width 20 -height 10 -font $fixedFont \
3484	    -wrap char -xscrollcommand ".t2.s set"
3485    pack .t2.t -side top
3486    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
3487    pack .t2.s -side bottom -fill x
3488    .t2.t insert end 123
3489    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
3490    .t2.t window create 1.1 -window .t2.t.f
3491    update
3492    .t2.t xview scroll 200 units
3493    update
3494    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
3495} [list [list [expr {16.0/30}] 1.0] 300x50+-155+[expr {$fixedDiff + 18}] {}]
3496test textDisp-30.1 {elidden text joining multiple logical lines} {
3497    .t2.t delete 1.0 end
3498    .t2.t insert 1.0 "1111\n2222\n3333"
3499    .t2.t tag configure elidden -elide 1 -background red
3500    .t2.t tag add elidden 1.2 3.2
3501    .t2.t count -displaylines 1.0 end
3502} {1}
3503test textDisp-30.2 {elidden text joining multiple logical lines} {
3504    .t2.t delete 1.0 end
3505    .t2.t insert 1.0 "1111\n2222\n3333"
3506    .t2.t tag configure elidden -elide 1 -background red
3507    .t2.t tag add elidden 1.2 2.2
3508    .t2.t count -displaylines 1.0 end
3509} {2}
3510catch {destroy .t2}
3511
3512.t configure -height 1
3513update
3514
3515test textDisp-31.1 {line embedded window height update} {
3516    set res {}
3517    .t delete 1.0 end
3518    .t insert end "abcd\nefgh\nijkl\nmnop\nqrst\nuvwx\nyx"
3519    frame .t.f -background red -width 100 -height 100
3520    .t window create 3.0 -window .t.f
3521    lappend res [.t count -update -ypixels 1.0 end]
3522    .t.f configure -height 10
3523    lappend res [.t count -ypixels 1.0 end]
3524    lappend res [.t count -update -ypixels 1.0 end]
3525    set res
3526} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 6}] [expr {$fixedHeight * 7}]]
3527
3528test textDisp-31.2 {line update index shifting} {
3529    set res {}
3530    .t.f configure -height 100
3531    update
3532    lappend res [.t count -update -ypixels 1.0 end]
3533    .t.f configure -height 10
3534    .t insert 1.0 "abc\n"
3535    .t insert 1.0 "abc\n"
3536    lappend res [.t count -ypixels 1.0 end]
3537    lappend res [.t count -update -ypixels 1.0 end]
3538    .t.f configure -height 100
3539    .t delete 1.0 3.0
3540    lappend res [.t count -ypixels 1.0 end]
3541    lappend res [.t count -update -ypixels 1.0 end]
3542    set res
3543} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
3544
3545test textDisp-31.3 {line update index shifting} {
3546    # Should do exactly the same as the above, as long
3547    # as we are correctly tagging the correct lines for
3548    # recalculation.  The 'update' and 'delay' must be
3549    # long enough to ensure all asynchronous updates
3550    # have been performed.
3551    set res {}
3552    .t.f configure -height 100
3553    update
3554    lappend res [.t count -update -ypixels 1.0 end]
3555    .t.f configure -height 10
3556    .t insert 1.0 "abc\n"
3557    .t insert 1.0 "abc\n"
3558    lappend res [.t count -ypixels 1.0 end]
3559    update ; after 1000 ; update
3560    lappend res [.t count -ypixels 1.0 end]
3561    .t.f configure -height 100
3562    .t delete 1.0 3.0
3563    lappend res [.t count -ypixels 1.0 end]
3564    update ; after 1000 ; update
3565    lappend res [.t count -ypixels 1.0 end]
3566    set res
3567} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
3568
3569test textDisp-31.4 {line embedded image height update} {
3570    set res {}
3571    image create photo textest -height 100 -width 10
3572    .t delete 3.0
3573    .t image create 3.0 -image textest
3574    update
3575    lappend res [.t count -update -ypixels 1.0 end]
3576    textest configure -height 10
3577    lappend res [.t count -ypixels 1.0 end]
3578    lappend res [.t count -update -ypixels 1.0 end]
3579    set res
3580} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 6}] [expr {$fixedHeight * 7}]]
3581
3582test textDisp-31.5 {line update index shifting} {
3583    set res {}
3584    textest configure -height 100
3585    update ; after 1000 ; update
3586    lappend res [.t count -update -ypixels 1.0 end]
3587    textest configure -height 10
3588    .t insert 1.0 "abc\n"
3589    .t insert 1.0 "abc\n"
3590    lappend res [.t count -ypixels 1.0 end]
3591    lappend res [.t count -update -ypixels 1.0 end]
3592    textest configure -height 100
3593    .t delete 1.0 3.0
3594    lappend res [.t count -ypixels 1.0 end]
3595    lappend res [.t count -update -ypixels 1.0 end]
3596    set res
3597} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
3598
3599test textDisp-31.6 {line update index shifting} {
3600    # Should do exactly the same as the above, as long
3601    # as we are correctly tagging the correct lines for
3602    # recalculation.  The 'update' and 'delay' must be
3603    # long enough to ensure all asynchronous updates
3604    # have been performed.
3605    set res {}
3606    textest configure -height 100
3607    update ; after 1000 ; update
3608    lappend res [.t count -update -ypixels 1.0 end]
3609    textest configure -height 10
3610    .t insert 1.0 "abc\n"
3611    .t insert 1.0 "abc\n"
3612    lappend res [.t count -ypixels 1.0 end]
3613    update ; after 1000 ; update
3614    lappend res [.t count -ypixels 1.0 end]
3615    textest configure -height 100
3616    .t delete 1.0 3.0
3617    lappend res [.t count -ypixels 1.0 end]
3618    update ; after 1000 ; update
3619    lappend res [.t count -ypixels 1.0 end]
3620    set res
3621} [list [expr {100 + $fixedHeight * 6}] [expr {100 + $fixedHeight * 8}] [expr {$fixedHeight * 9}] [expr {$fixedHeight * 7}] [expr {100 + $fixedHeight * 6}]]
3622
3623test textDisp-31.7 {line update index shifting, elided} {
3624    # The 'update' and 'delay' must be long enough to ensure all
3625    # asynchronous updates have been performed.
3626    set res {}
3627    .t delete 1.0 end
3628    lappend res [.t count -update -ypixels 1.0 end]
3629    .t insert 1.0 "abc\nabc"
3630    .t insert 1.0 "abc\n"
3631    lappend res [.t count -update -ypixels 1.0 end]
3632    .t tag configure elide -elide 1
3633    .t tag add elide 1.3 2.1
3634    lappend res [.t count -ypixels 1.0 end]
3635    update ; after 1000 ; update
3636    lappend res [.t count -ypixels 1.0 end]
3637    .t delete 1.0 3.0
3638    lappend res [.t count -ypixels 1.0 end]
3639    update ; after 1000 ; update
3640    lappend res [.t count -ypixels 1.0 end]
3641    set res
3642} [list [expr {$fixedHeight * 1}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 3}] [expr {$fixedHeight * 2}] [expr {$fixedHeight * 1}] [expr {$fixedHeight * 1}]]
3643
3644test textDisp-32.0 {everything elided} {
3645    # Must not crash
3646    pack [text .tt]
3647    .tt insert 0.0 HELLO
3648    .tt tag configure HIDE -elide 1
3649    .tt tag add HIDE 0.0 end
3650    update ; update ; update ; update
3651    destroy .tt
3652} {}
3653test textDisp-32.1 {everything elided} {
3654    # Must not crash
3655    pack [text .tt]
3656    update
3657    .tt insert 0.0 HELLO
3658    update
3659    .tt tag configure HIDE -elide 1
3660    update
3661    .tt tag add HIDE 0.0 end
3662    update ; update ; update ; update
3663    destroy .tt
3664} {}
3665test textDisp-32.2 {elide and tags} {
3666    pack [text .tt -height 30 -width 100 -bd 0 \
3667      -highlightthickness 0 -padx 0]
3668    .tt insert end \
3669      {test text using tags 1 and 3 } \
3670      {testtag1 testtag3} \
3671      {[this bit here uses tags 2 and 3]} \
3672      {testtag2 testtag3}
3673    update
3674    # indent left margin of tag 1 by 20 pixels
3675    # text should be indented
3676    .tt tag configure testtag1 -lmargin1 20 ; update
3677    #1
3678    set res {}
3679    lappend res [list [.tt index "1.0 + 0 displaychars"] \
3680      [lindex [.tt bbox 1.0] 0] \
3681      [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
3682    # hide tag 1, remaining text should not be indented, since
3683    # the indented tag and character is hidden.
3684    .tt tag configure testtag1 -elide 1 ; update
3685    #2
3686    lappend res [list [.tt index "1.0 + 0 displaychars"] \
3687      [lindex [.tt bbox 1.0] 0] \
3688      [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
3689    # reset
3690    .tt tag configure testtag1 -lmargin1 0
3691    .tt tag configure testtag1 -elide 0
3692    # indent left margin of tag 2 by 20 pixels
3693    # text should not be indented, since tag1 has lmargin1 of 0.
3694    .tt tag configure testtag2 -lmargin1 20 ; update
3695    #3
3696    lappend res [list [.tt index "1.0 + 0 displaychars"] \
3697      [lindex [.tt bbox 1.0] 0] \
3698      [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
3699    # hide tag 1, remaining text should now be indented, but
3700    # the bbox of 1.0 should have zero width and zero indent,
3701    # since it is elided at that position.
3702    .tt tag configure testtag1 -elide 1 ; update
3703    #4
3704    lappend res [list [.tt index "1.0 + 0 displaychars"] \
3705      [lindex [.tt bbox 1.0] 0] \
3706      [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
3707    # reset
3708    .tt tag configure testtag2 -lmargin1 {}
3709    .tt tag configure testtag1 -elide 0
3710    # indent left margin of tag 3 by 20 pixels
3711    # text should be indented, since this tag takes
3712    # precedence over testtag1, and is applied to the
3713    # start of the text.
3714    .tt tag configure testtag3 -lmargin1 20 ; update
3715    #5
3716    lappend res [list [.tt index "1.0 + 0 displaychars"] \
3717      [lindex [.tt bbox 1.0] 0] \
3718      [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
3719    # hide tag 1, remaining text should still be indented,
3720    # since it still has testtag3 on it.  Again the
3721    # bbox of 1.0 should have 0.
3722    .tt tag configure testtag1 -elide 1 ; update
3723    #6
3724    lappend res [list [.tt index "1.0 + 0 displaychars"] \
3725      [lindex [.tt bbox 1.0] 0] \
3726      [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
3727    .tt tag configure testtag3 -lmargin1 {} -elide 0
3728    .tt tag configure testtag1 -elide 1 -lmargin1 20
3729    #7
3730    lappend res [list [.tt index "1.0 + 0 displaychars"] \
3731      [lindex [.tt bbox 1.0] 0] \
3732      [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
3733    destroy .tt
3734    set res
3735} {{1.0 20 20} {1.29 0 0} {1.0 0 0} {1.29 0 20}\
3736  {1.0 20 20} {1.29 0 20} {1.0 20 20}}
3737test textDisp-32.3 "NULL undisplayProc problems: #1791052" -setup {
3738    set img [image create photo -data {
3739	R0lGODlhEgASANUAAAAAAP/////iHP/mIPrWDPraEP/eGPfOAPbKAPbOBPrS
3740	CP/aFPbGAPLCAPLGAN62ANauAMylAPbCAPW/APK+AN6uALKNAPK2APK5ANal
3741	AOyzArGHBZp3B+6uAHFVBFVACO6qAOqqAOalAMGMAbF+Am1QBG5QBeuiAOad
3742	AM6NAJ9vBW1MBFlACFQ9CVlBCuaZAOKVANyVAZlpBMyFAKZtBJVhBEAUEP//
3743	/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADcALAAAAAASABIAAAa+
3744	wJtw+Ckah0iiZwNhODKk0icp/HAShEKBoEBgVFOkK0Iw2GyCs+BAGbGIlrIt
3745	EJjXBYgL6X3zJMx1Z2d3EyEmNx9xaYGCdwgaNEUPBYt0do4XKUUOlAOCnmcD
3746	CwcXMZsEAgOqq6oLBY+mHxUKBqysCwQSIDNFJAidtgKjFyeRfRQHB2ipAmZs
3747	IDArVSTIyoI2bB0oxkIsIxcNyeIXICh7SR8yIhoXFxogJzE1YegrNCkoLzM0
3748	K/RUiEY+tKASBAA7
3749    }]
3750    destroy .tt
3751} -body {
3752    text .tt
3753    .tt tag configure emoticon -elide 1
3754    .tt insert end X
3755    .tt mark set MSGLEFT "end - 1 char"
3756    .tt mark gravity MSGLEFT left
3757    .tt insert end ":)" emoticon
3758    .tt image create end -image $img
3759    pack .tt
3760    update; update; update
3761} -cleanup {
3762    image delete $img
3763    destroy .tt
3764}
3765
3766test textDisp-33.0 {one line longer than fits in the widget} {
3767    pack [text .tt -wrap char]
3768    .tt insert 1.0 [string repeat "more wrap + " 300]
3769    update ; update ; update
3770    .tt see 1.0
3771    lindex [.tt yview] 0
3772} {0.0}
3773test textDisp-33.1 {one line longer than fits in the widget} {
3774    destroy .tt
3775    pack [text .tt -wrap char]
3776    .tt insert 1.0 [string repeat "more wrap + " 300]
3777    update ; update ; update
3778    .tt yview "1.0 +1 displaylines"
3779    if {[lindex [.tt yview] 0] > 0.1} {
3780	set result "window should be scrolled to the top"
3781    } else {
3782	set result "ok"
3783    }
3784} {ok}
3785test textDisp-33.2 {one line longer than fits in the widget} {
3786    destroy .tt
3787    pack [text .tt -wrap char]
3788    .tt debug 1
3789    set tk_textHeightCalc ""
3790    .tt insert 1.0 [string repeat "more wrap + " 1]
3791    after 100 ; update
3792    # Nothing should have been recalculated.
3793    set tk_textHeightCalc
3794} {}
3795test textDisp-33.3 {one line longer than fits in the widget} {
3796    destroy .tt
3797    pack [text .tt -wrap char]
3798    .tt debug 1
3799    set tk_textHeightCalc ""
3800    .tt insert 1.0 [string repeat "more wrap + " 300]
3801    update ; .tt count -update -ypixels 1.0 end ; update
3802    # Each line should have been recalculated just once
3803    .tt debug 0
3804    expr {[llength $tk_textHeightCalc] == [.tt count -displaylines 1.0 end]}
3805} {1}
3806test textDisp-33.4 {one line longer than fits in the widget} {
3807    destroy .tt
3808    pack [text .tt -wrap char]
3809    .tt debug 1
3810    set tk_textHeightCalc ""
3811    .tt insert 1.0 [string repeat "more wrap + " 300]
3812    update ; update ; update
3813    set idx [.tt index "1.0 + 1 displaylines"]
3814    .tt yview $idx
3815    if {[lindex [.tt yview] 0] > 0.1} {
3816	set result "window should be scrolled to the top"
3817    } else {
3818	set result "ok"
3819    }
3820    set idx [.tt index "1.0 + 1 displaylines"]
3821    .tt debug 0
3822    set result
3823} {ok}
3824destroy .tt
3825test textDisp-33.5 {bold or italic fonts} win {
3826    destroy .tt
3827    pack [text .tt -wrap char -font {{MS Sans Serif} 15}]
3828    font create no -family [lindex [.tt cget -font] 0] -size 24
3829    font create bi -family [lindex [.tt cget -font] 0] -size 24
3830    font configure bi -weight bold -slant italic
3831    .tt tag configure bi -font bi
3832    .tt tag configure no -font no
3833    .tt insert end abcd no efgh bi ijkl\n no
3834    update
3835    set bb {}
3836    for {set i 0} {$i < 12} {incr i 4} {
3837	lappend bb [lindex [.tt bbox 1.$i] 0]
3838    }
3839    foreach {a b c} $bb {}
3840    unset bb
3841    if {($b - $a) * 1.5 < ($c - $b)} {
3842	set result "italic font has much too much space"
3843    } else {
3844	set result "italic font measurement ok"
3845    }
3846} {italic font measurement ok}
3847destroy .tt
3848
3849test textDisp-34.1 {Text widgets multi-scrolling problem: Bug 2677890} -setup {
3850    pack [text .t1 -width 10 -yscrollcommand {.sy set}] \
3851	[ttk::scrollbar .sy -orient vertical -command {.t1 yview}] \
3852	-side left -fill both
3853    bindtags .sy {}; # No clicky!
3854    set txt ""
3855    for {set i 0} {$i < 99} {incr i} {
3856	lappend txt "$i" [list pc $i] "\n" ""
3857    }
3858    set result {}
3859} -body {
3860    .t1 insert end {*}$txt
3861    update
3862    lappend result [.sy get]
3863    .t1 replace 6.0 6.0+1c "*"
3864    lappend result [.sy get]
3865    after 0 {lappend result [.sy get]}
3866    after 1000 {lappend result [.sy get]}
3867    vwait result;vwait result
3868    return $result
3869} -cleanup {
3870    destroy .t1 .sy
3871} -result {{0.0 1.0} {0.0 1.0} {0.0 1.0} {0.0 0.24}}
3872
3873deleteWindows
3874option clear
3875
3876# cleanup
3877cleanupTests
3878return
3879