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: textDisp.test,v 1.8.2.1 2004/02/14 01:54:49 hobbs Exp $
10
11package require tcltest 2.1
12namespace import -force tcltest::configure
13namespace import -force tcltest::testsDirectory
14configure -testdir [file join [pwd] [file dirname [info script]]]
15configure -loadfile [file join [testsDirectory] constraints.tcl]
16tcltest::loadTestedCommands
17
18namespace import -force tcltest::interpreter
19namespace import -force tcltest::makeFile
20namespace import -force tcltest::removeFile
21
22# The procedure below is used as the scrolling command for the text;
23# it just saves the scrolling information in a variable "scrollInfo".
24
25proc scroll args {
26    global scrollInfo
27    set scrollInfo $args
28}
29
30# The procedure below is used to generate errors during scrolling commands.
31
32proc scrollError args {
33    error "scrolling error"
34}
35
36# Create entries in the option database to be sure that geometry options
37# like border width have predictable values.
38
39option add *Text.borderWidth 2
40option add *Text.highlightThickness 2
41
42# The frame .f is needed to make sure that the overall window is always
43# fairly wide, even if the text window is very narrow.  This is needed
44# because some window managers don't allow the overall width of a window
45# to get very narrow.
46
47frame .f -width 100 -height 20
48pack append . .f left
49
50set fixedFont {Courier -12}
51set fixedHeight [font metrics $fixedFont -linespace]
52set fixedWidth [font measure $fixedFont m]
53
54set varFont {Times -14}
55set bigFont {Helvetica -24}
56text .t -font $fixedFont -width 20 -height 10 -yscrollcommand scroll
57pack append . .t {top expand fill}
58.t tag configure big -font $bigFont
59.t debug on
60wm geometry . {}
61
62# The statements below reset the main window;  it's needed if the window
63# manager is mwm to make mwm forget about a previous minimum size setting.
64
65wm withdraw .
66wm minsize . 1 1
67wm positionfrom . user
68wm deiconify .
69update
70
71# Some window managers (like olwm under SunOS 4.1.3) misbehave in a way
72# that tends to march windows off the top and left of the screen.  If
73# this happens, some tests will fail because parts of the window will
74# not need to be displayed (because they're off-screen).  To keep this
75# from happening, move the window if it's getting near the left or top
76# edges of the screen.
77
78if {([winfo rooty .] < 50) || ([winfo rootx .] < 50)} {
79    wm geom . +50+50
80}
81test textDisp-1.1 {GetStyle procedure, priorities and tab stops} {
82    .t delete 1.0 end
83    .t insert 1.0 "x\ty"
84    .t tag delete x y z
85    .t tag configure x -tabs {50}
86    .t tag configure y -foreground black
87    .t tag configure z -tabs {70}
88    .t tag add x 1.0 1.end
89    .t tag add y 1.0 1.end
90    .t tag add z 1.0 1.end
91    update idletasks
92    set x [lindex [.t bbox 1.2] 0]
93    .t tag configure z -tabs {}
94    lappend x [lindex [.t bbox 1.2] 0]
95    .t tag configure z -tabs {30}
96    .t tag raise x
97    update idletasks
98    lappend x [lindex [.t bbox 1.2] 0]
99} {75 55 55}
100.t tag delete x y z
101test textDisp-1.2 {GetStyle procedure, wrapmode} {fonts} {
102    .t configure -wrap char
103    .t delete 1.0 end
104    .t insert 1.0 "abcd\nefg hijkl mnop qrstuv wxyz"
105    .t tag configure x -wrap word
106    .t tag configure y -wrap none
107    .t tag raise y
108    update
109    set result [list [.t bbox 2.20]]
110    .t tag add x 2.0 2.1
111    lappend result [.t bbox 2.20]
112    .t tag add y 1.end 2.2
113    lappend result [.t bbox 2.20]
114} {{5 31 7 13} {40 31 7 13} {}}
115.t tag delete x y
116
117test textDisp-2.1 {LayoutDLine, basics} {
118    .t configure -wrap char
119    .t delete 1.0 end
120    .t insert 1.0 "This is some sample text for testing."
121    list [.t bbox 1.19] [.t bbox 1.20]
122} [list [list [expr 5 + $fixedWidth * 19] 5 $fixedWidth $fixedHeight] [list 5 [expr 5 + $fixedHeight] $fixedWidth $fixedHeight]]
123test textDisp-2.2 {LayoutDLine, basics} {fonts} {
124    .t configure -wrap char
125    .t delete 1.0 end
126    .t insert 1.0 "This isx some sample text for testing."
127    list [.t bbox 1.19] [.t bbox 1.20]
128} {{138 5 7 13} {5 18 7 13}}
129test textDisp-2.3 {LayoutDLine, basics} {fonts} {
130    .t configure -wrap char
131    .t delete 1.0 end
132    .t insert 1.0 "This isxxx some sample text for testing."
133    list [.t bbox 1.19] [.t bbox 1.20]
134} {{138 5 7 13} {5 18 7 13}}
135test textDisp-2.4 {LayoutDLine, word wrap} {fonts} {
136    .t configure -wrap word
137    .t delete 1.0 end
138    .t insert 1.0 "This is some sample text for testing."
139    list [.t bbox 1.19] [.t bbox 1.20]
140} {{138 5 7 13} {5 18 7 13}}
141test textDisp-2.5 {LayoutDLine, word wrap} {fonts} {
142    .t configure -wrap word
143    .t delete 1.0 end
144    .t insert 1.0 "This isx some sample text for testing."
145    list [.t bbox 1.13] [.t bbox 1.14] [.t bbox 1.19]
146} {{96 5 49 13} {5 18 7 13} {40 18 7 13}}
147test textDisp-2.6 {LayoutDLine, word wrap} {fonts} {
148    .t configure -wrap word
149    .t delete 1.0 end
150    .t insert 1.0 "This isxxx some sample text for testing."
151    list [.t bbox 1.15] [.t bbox 1.16]
152} {{110 5 35 13} {5 18 7 13}}
153test textDisp-2.7 {LayoutDLine, marks and tags} {fonts} {
154    .t configure -wrap word
155    .t delete 1.0 end
156    .t insert 1.0 "This isxxx some sample text for testing."
157    .t tag add foo 1.4 1.6
158    .t mark set insert 1.8
159    list [.t bbox 1.2] [.t bbox 1.5] [.t bbox 1.11]
160} {{19 5 7 13} {40 5 7 13} {82 5 7 13}}
161foreach m [.t mark names] {
162    catch {.t mark unset $m}
163}
164scan [wm geom .] %dx%d width height
165test textDisp-2.8 {LayoutDLine, extra chunk at end of dline} {fonts} {
166    wm geom . [expr $width+1]x$height
167    update
168    .t configure -wrap char
169    .t delete 1.0 end
170    .t insert 1.0 "This isxx some sample text for testing."
171    .t mark set foo 1.20
172    list [.t bbox 1.19] [.t bbox 1.20]
173} {{138 5 8 13} {5 18 7 13}}
174wm geom . {}
175update
176test textDisp-2.9 {LayoutDLine, marks and tags} {fonts} {
177    .t configure -wrap word
178    .t delete 1.0 end
179    .t insert 1.0 "This is a very_very_long_word_that_wraps."
180    list [.t bbox 1.9] [.t bbox 1.10] [.t bbox 1.25]
181} {{68 5 77 13} {5 18 7 13} {110 18 7 13}}
182test textDisp-2.10 {LayoutDLine, marks and tags} {fonts} {
183    .t configure -wrap word
184    .t delete 1.0 end
185    .t insert 1.0 "This is a very_very_long_word_that_wraps."
186    .t tag add foo 1.13
187    .t tag add foo 1.15
188    .t tag add foo 1.17
189    .t tag add foo 1.19
190    list [.t bbox 1.9] [.t bbox 1.10] [.t bbox 1.25]
191} {{68 5 77 13} {5 18 7 13} {110 18 7 13}}
192test textDisp-2.11 {LayoutDLine, newline width} {fonts} {
193    .t configure -wrap char
194    .t delete 1.0 end
195    .t insert 1.0 "a\nbb\nccc\ndddd"
196    list [.t bbox 2.2] [.t bbox 3.3]
197} {{19 18 126 13} {26 31 119 13}}
198test textDisp-2.12 {LayoutDLine, justification} {fonts} {
199    .t configure -wrap char
200    .t delete 1.0 end
201    .t insert 1.0 "\na\nbb\nccc\ndddd"
202    .t tag configure x -justify center
203    .t tag add x 1.0 end
204    .t tag add y 3.0 3.2
205    list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 4.0] [.t bbox 4.2]
206} {{75 5 70 13} {71 18 7 13} {64 44 7 13} {78 44 7 13}}
207test textDisp-2.13 {LayoutDLine, justification} {fonts} {
208    .t configure -wrap char
209    .t delete 1.0 end
210    .t insert 1.0 "\na\nbb\nccc\ndddd"
211    .t tag configure x -justify right
212    .t tag add x 1.0 end
213    .t tag add y 3.0 3.2
214    list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 4.0] [.t bbox 4.2]
215} {{145 5 0 13} {138 18 7 13} {124 44 7 13} {138 44 7 13}}
216test textDisp-2.14 {LayoutDLine, justification} {fonts} {
217    .t configure -wrap char
218    .t delete 1.0 end
219    .t insert 1.0 "\na\nbb\nccc\ndddd"
220    .t tag configure x -justify center
221    .t tag add x 2.0 3.1
222    .t tag configure y -justify right
223    .t tag add y 3.0 4.0
224    .t tag raise y
225    list [.t bbox 2.0] [.t bbox 3.0] [.t bbox 3.end] [.t bbox 4.0]
226} {{71 18 7 13} {131 31 7 13} {145 31 0 13} {5 44 7 13}}
227test textDisp-2.15 {LayoutDLine, justification} {fonts} {
228    .t configure -wrap char
229    .t delete 1.0 end
230    .t insert 1.0 "\na\nbb\nccc\ndddd"
231    .t tag configure x -justify center
232    .t tag add x 2.0 3.1
233    .t tag configure y -justify right
234    .t tag add y 3.0 4.0
235    .t tag lower y
236    list [.t bbox 2.0] [.t bbox 3.0] [.t bbox 3.end] [.t bbox 4.0]
237} {{71 18 7 13} {68 31 7 13} {82 31 63 13} {5 44 7 13}}
238test textDisp-2.16 {LayoutDLine, justification} {fonts} {
239    .t configure -wrap word
240    .t delete 1.0 end
241    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
242    .t tag configure x -justify center
243    .t tag add x 1.1 1.20
244    .t tag add x 1.21 1.end
245    list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.36] [.t bbox 2.0]
246} {{5 5 7 13} {5 18 7 13} {43 31 7 13} {5 44 7 13}}
247test textDisp-2.17 {LayoutDLine, justification} {fonts} {
248    .t configure -wrap word
249    .t delete 1.0 end
250    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
251    .t tag configure x -justify center
252    .t tag add x 1.20
253    list [.t bbox 1.0] [.t bbox 1.20] [.t bbox 1.36] [.t bbox 2.0]
254} {{5 5 7 13} {19 18 7 13} {5 31 7 13} {5 44 7 13}}
255test textDisp-2.18 {LayoutDLine, justification} {fonts} {
256    .t configure -wrap none
257    .t delete 1.0 end
258    .t insert 1.0 "Lots of long words, enough to extend out of the window\n"
259    .t insert end "Then\nmore lines\nThat are shorter"
260    .t tag configure x -justify center
261    .t tag configure y -justify right
262    .t tag add x 2.0
263    .t tag add y 3.0
264    .t xview scroll 5 units
265    list [.t bbox 2.0] [.t bbox 3.0]
266} {{26 18 7 13} {40 31 7 13}}
267.t tag delete x
268.t tag delete y
269test textDisp-2.19 {LayoutDLine, margins} {fonts} {
270    .t configure -wrap word
271    .t delete 1.0 end
272    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
273    .t tag configure x -lmargin1 20 -lmargin2 40 -rmargin 15
274    .t tag add x 1.0 end
275    list [.t bbox 1.0] [.t bbox 1.12] [.t bbox 1.13] [.t bbox 2.0]
276} {{25 5 7 13} {109 5 36 13} {45 18 7 13} {25 70 7 13}}
277test textDisp-2.20 {LayoutDLine, margins} {fonts} {
278    .t configure -wrap word
279    .t delete 1.0 end
280    .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
281    .t tag configure x -lmargin1 20 -lmargin2 10 -rmargin 3
282    .t tag configure y -lmargin1 15 -lmargin2 5 -rmargin 0
283    .t tag raise y
284    .t tag add x 1.0 end
285    .t tag add y 1.13
286    list [.t bbox 1.0] [.t bbox 1.13] [.t bbox 1.30] [.t bbox 2.0]
287} {{25 5 7 13} {10 18 7 13} {15 31 7 13} {25 44 7 13}}
288test textDisp-2.21 {LayoutDLine, margins} {fonts} {
289    .t configure -wrap word
290    .t delete 1.0 end
291    .t insert 1.0 "Sample text"
292    .t tag configure x -lmargin1 80 -lmargin2 80 -rmargin 100
293    .t tag add x 1.0 end
294    list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
295} {{85 5 60 13} {85 18 60 13} {85 31 60 13}}
296.t tag delete x
297.t tag delete y
298test textDisp-2.22 {LayoutDLine, spacing options} {fonts} {
299    .t configure -wrap word
300    .t delete 1.0 end
301    .t tag delete x y
302    .t insert end "Short line\nLine 2 is long enough "
303    .t insert end "to wrap around a couple of times"
304    .t insert end "\nLine 3\nLine 4"
305    set i [.t dlineinfo 1.0]
306    set b1 [expr [lindex $i 1] + [lindex $i 4]]
307    set i [.t dlineinfo 2.0]
308    set b2 [expr [lindex $i 1] + [lindex $i 4]]
309    set i [.t dlineinfo 2.end]
310    set b3 [expr [lindex $i 1] + [lindex $i 4]]
311    set i [.t dlineinfo 3.0]
312    set b4 [expr [lindex $i 1] + [lindex $i 4]]
313    .t configure -spacing1 2 -spacing2 1 -spacing3 3
314    set i [.t dlineinfo 1.0]
315    set b1 [expr [lindex $i 1] + [lindex $i 4] - $b1]
316    set i [.t dlineinfo 2.0]
317    set b2 [expr [lindex $i 1] + [lindex $i 4] - $b2]
318    set i [.t dlineinfo 2.end]
319    set b3 [expr [lindex $i 1] + [lindex $i 4] - $b3]
320    set i [.t dlineinfo 3.0]
321    set b4 [expr [lindex $i 1] + [lindex $i 4] - $b4]
322    list $b1 $b2 $b3 $b4
323} {2 7 10 15}
324.t configure -spacing1 0 -spacing2 0 -spacing3 0
325test textDisp-2.23 {LayoutDLine, spacing options} {fonts} {
326    .t configure -wrap word
327    .t delete 1.0 end
328    .t tag delete x y
329    .t insert end "Short line\nLine 2 is long enough "
330    .t insert end "to wrap around a couple of times"
331    .t insert end "\nLine 3\nLine 4"
332    set i [.t dlineinfo 1.0]
333    set b1 [expr [lindex $i 1] + [lindex $i 4]]
334    set i [.t dlineinfo 2.0]
335    set b2 [expr [lindex $i 1] + [lindex $i 4]]
336    set i [.t dlineinfo 2.end]
337    set b3 [expr [lindex $i 1] + [lindex $i 4]]
338    set i [.t dlineinfo 3.0]
339    set b4 [expr [lindex $i 1] + [lindex $i 4]]
340    .t configure -spacing1 4 -spacing2 4 -spacing3 4
341    .t tag configure x -spacing1 1 -spacing2 2 -spacing3 3
342    .t tag add x 1.0 end
343    .t tag configure y -spacing1 0 -spacing2 3
344    .t tag add y 2.19 end
345    .t tag raise y
346    set i [.t dlineinfo 1.0]
347    set b1 [expr [lindex $i 1] + [lindex $i 4] - $b1]
348    set i [.t dlineinfo 2.0]
349    set b2 [expr [lindex $i 1] + [lindex $i 4] - $b2]
350    set i [.t dlineinfo 2.end]
351    set b3 [expr [lindex $i 1] + [lindex $i 4] - $b3]
352    set i [.t dlineinfo 3.0]
353    set b4 [expr [lindex $i 1] + [lindex $i 4] - $b4]
354    list $b1 $b2 $b3 $b4
355} {1 5 13 16}
356.t configure -spacing1 0 -spacing2 0 -spacing3 0
357test textDisp-2.24 {LayoutDLine, tabs, saving from first chunk} {fonts} {
358    .t delete 1.0 end
359    .t tag delete x y
360    .t tag configure x -tabs 70
361    .t tag configure y -tabs 80
362    .t insert 1.0 "ab\tcde"
363    .t tag add x 1.0 end
364    .t tag add y 1.1 end
365    lindex [.t bbox 1.3] 0
366} {75}
367test textDisp-2.25 {LayoutDLine, tabs, breaking chunks at tabs} {fonts} {
368    .t delete 1.0 end
369    .t tag delete x
370    .t tag configure x -tabs {30 60 90 120}
371    .t insert 1.0 "a\tb\tc\td\te"
372    .t mark set dummy1 1.1
373    .t mark set dummy2 1.2
374    .t tag add x 1.0 end
375    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
376	    [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]
377} {35 65 95 125}
378test textDisp-2.26 {LayoutDLine, tabs, breaking chunks at tabs} {fonts} {
379    .t delete 1.0 end
380    .t tag delete x
381    .t tag configure x -tabs {30 60 90 120} -justify right
382    .t insert 1.0 "a\tb\tc\td\te"
383    .t mark set dummy1 1.1
384    .t mark set dummy2 1.2
385    .t tag add x 1.0 end
386    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
387	    [lindex [.t bbox 1.6] 0] [lindex [.t bbox 1.8] 0]
388} {117 124 131 138}
389test textDisp-2.27 {LayoutDLine, tabs, calling AdjustForTab} {fonts} {
390    .t delete 1.0 end
391    .t tag delete x
392    .t tag configure x -tabs {30 60}
393    .t insert 1.0 "a\tb\tcd"
394    .t tag add x 1.0 end
395    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0]
396} {35 65}
397test textDisp-2.28 {LayoutDLine, tabs, running out of space in dline} {fonts} {
398    .t delete 1.0 end
399    .t insert 1.0 "a\tb\tc\td"
400    .t bbox 1.6
401} {5 18 7 13}
402test textDisp-2.29 {LayoutDLine, tabs, running out of space in dline} {fonts} {
403    .t delete 1.0 end
404    .t insert 1.0 "a\tx\tabcd"
405    .t bbox 1.4
406} {117 5 7 13}
407test textDisp-2.30 {LayoutDLine, tabs, running out of space in dline} {fonts} {
408    .t delete 1.0 end
409    .t insert 1.0 "a\tx\tabc"
410    .t bbox 1.4
411} {117 5 7 13}
412
413test textDisp-3.1 {different character sizes} {fonts} {
414    .t configure -wrap word
415    .t delete 1.0 end
416    .t insert end "Some sample text, including both large\n"
417    .t insert end "characters and\nsmall\n"
418    .t insert end "abc\nd\ne\nfghij"
419    .t tag add big 1.5 1.10
420    .t tag add big 2.11 2.14
421    list [.t bbox 1.1] [.t bbox 1.6] [.t dlineinfo 1.0] [.t dlineinfo 3.0]
422} {{12 17 7 13} {52 5 13 27} {5 5 114 27 22} {5 85 35 13 10}}
423
424.t configure -wrap char
425test textDisp-4.1 {UpdateDisplayInfo, basic} {fonts} {
426    .t delete 1.0 end
427    .t insert end "Line 1\nLine 2\nLine 3\n"
428    update
429    .t delete 2.0 2.end
430    .t insert 2.0 "New Line 2"
431    update
432    list [.t bbox 1.0] [.t bbox 2.0] [.t bbox 3.0] $tk_textRelayout
433} {{5 5 7 13} {5 18 7 13} {5 31 7 13} 2.0}
434test textDisp-4.2 {UpdateDisplayInfo, re-use tail of text line} {fonts} {
435    .t delete 1.0 end
436    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
437    update
438    .t mark set x 2.21
439    .t delete 2.2
440    .t insert 2.0 X
441    update
442    list [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
443} {{5 18 7 13} {12 31 7 13} {5 44 7 13} {2.0 2.20}}
444test textDisp-4.3 {UpdateDisplayInfo, tail of text line shifts} {fonts} {
445    .t delete 1.0 end
446    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
447    update
448    .t mark set x 2.21
449    .t delete 2.2
450    update
451    list [.t bbox 2.0] [.t bbox x] [.t bbox 3.0] $tk_textRelayout
452} {{5 18 7 13} {5 31 7 13} {5 44 7 13} {2.0 2.20}}
453.t mark unset x
454test textDisp-4.4 {UpdateDisplayInfo, wrap-mode "none"} {fonts} {
455    .t configure -wrap none
456    .t delete 1.0 end
457    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
458    update
459    list [.t bbox 2.0] [.t bbox 2.25] [.t bbox 3.0] $tk_textRelayout
460} {{5 18 7 13} {} {5 31 7 13} {1.0 2.0 3.0}}
461test textDisp-4.5 {UpdateDisplayInfo, tiny window} {fonts} {
462    wm geom . 103x$height
463    update
464    .t configure -wrap none
465    .t delete 1.0 end
466    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
467    update
468    list [.t bbox 2.0] [.t bbox 2.1] [.t bbox 3.0] $tk_textRelayout
469} {{5 18 1 13} {} {5 31 1 13} {1.0 2.0 3.0}}
470test textDisp-4.6 {UpdateDisplayInfo, tiny window} {
471    # This test was failing on Windows because the title bar on .
472    # was a certain minimum size and it was interfering with the size
473    # requested.  The "overrideredirect" gets rid of the titlebar so 
474    # the toplevel can shrink to the appropriate size.  On Unix, setting
475    # the overrideredirect on "." confuses the window manager and
476    # causes subsequent tests to fail.
477
478    if {$tcl_platform(platform) == "windows"} {
479	wm overrideredirect . 1
480    }
481    frame .f2 -width 20 -height 100
482    pack before .f .f2 top
483    wm geom . 103x103
484    update
485    .t configure -wrap none -borderwidth 2
486    .t delete 1.0 end
487    .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
488    update
489    set x [list [.t bbox 1.0] [.t bbox 2.0] $tk_textRelayout]
490    wm overrideredirect . 0
491    update
492    set x
493} {{5 5 1 1} {} 1.0}
494catch {destroy .f2}
495.t configure -borderwidth 0 -wrap char
496wm geom . {}
497update
498test textDisp-4.7 {UpdateDisplayInfo, filling in extra vertical space} {
499    # This test was failing on Windows because the title bar on .
500    # was a certain minimum size and it was interfering with the size
501    # requested.  The "overrideredirect" gets rid of the titlebar so 
502    # the toplevel can shrink to the appropriate size.  On Unix, setting
503    # the overrideredirect on "." confuses the window manager and
504    # causes subsequent tests to fail.
505
506    if {$tcl_platform(platform) == "windows"} {
507	wm overrideredirect . 1
508    }
509    .t delete 1.0 end
510    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
511    .t yview 1.0
512    update
513    .t yview 16.0
514    update
515    set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
516    wm overrideredirect . 0
517    update 
518    set x
519} {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}}
520test textDisp-4.8 {UpdateDisplayInfo, filling in extra vertical space} {
521    .t delete 1.0 end
522    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
523    .t yview 16.0
524    update
525    .t delete 5.0 14.0
526    update
527    set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
528} {1.0 {5.0 4.0 3.0 2.0 1.0} {1.0 2.0 3.0 4.0 5.0 eof}}
529test textDisp-4.9 {UpdateDisplayInfo, filling in extra vertical space} {fonts} {
530    .t delete 1.0 end
531    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
532    .t yview 16.0
533    update
534    .t delete 15.0 end
535    list [.t bbox 7.0] [.t bbox 12.0]
536} {{3 29 7 13} {3 94 7 13}}
537test textDisp-4.10 {UpdateDisplayInfo, filling in extra vertical space} {
538    .t delete 1.0 end
539    .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"
540    .t yview end
541    update
542    .t delete 13.0 end
543    update
544    list [.t index @0,0] $tk_textRelayout $tk_textRedraw
545} {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}}
546test textDisp-4.11 {UpdateDisplayInfo, filling in extra vertical space} {
547    .t delete 1.0 end
548    .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"
549    .t yview end
550    update
551    .t delete 14.0 end
552    update
553    list [.t index @0,0] $tk_textRelayout $tk_textRedraw
554} {6.40 {13.0 7.0 6.80 6.60 6.40} {6.40 6.60 6.80 7.0 13.0}}
555test textDisp-4.12 {UpdateDisplayInfo, filling in extra vertical space} {
556    .t delete 1.0 end
557    .t insert end "1\n2\n3\n4\n5\n7\n8\n9\n10\n11\n12\n13"
558    button .b -text "Test" -bd 2 -highlightthickness 2
559    .t window create 3.end -window .b
560    .t yview moveto 1
561    update
562    .t yview moveto 0
563    update
564    .t yview moveto 1
565    update
566    winfo ismapped .b
567} {0}
568.t configure -wrap word
569.t delete 1.0 end
570.t insert end "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\n"
571.t insert end "Line 8\nLine 9\nLine 10\nLine 11\nLine 12\nLine 13\n"
572.t insert end "Line 14\nLine 15\nLine 16"
573.t tag delete x
574.t tag configure x -relief raised -borderwidth 2 -background white
575test textDisp-4.13 {UpdateDisplayInfo, special handling for top/bottom lines} {
576    .t tag add x 1.0 end
577    .t yview 1.0
578    update
579    .t yview scroll 3 units
580    update
581    list $tk_textRelayout $tk_textRedraw
582} {{11.0 12.0 13.0} {4.0 10.0 11.0 12.0 13.0}}
583test textDisp-4.14 {UpdateDisplayInfo, special handling for top/bottom lines} {
584    .t tag remove x 1.0 end
585    .t yview 1.0
586    update
587    .t yview scroll 3 units
588    update
589    list $tk_textRelayout $tk_textRedraw
590} {{11.0 12.0 13.0} {11.0 12.0 13.0}}
591test textDisp-4.15 {UpdateDisplayInfo, special handling for top/bottom lines} {
592    .t tag add x 1.0 end
593    .t yview 4.0
594    update
595    .t yview scroll -2 units
596    update
597    list $tk_textRelayout $tk_textRedraw
598} {{2.0 3.0} {2.0 3.0 4.0 11.0}}
599test textDisp-4.16 {UpdateDisplayInfo, special handling for top/bottom lines} {
600    .t tag remove x 1.0 end
601    .t yview 4.0
602    update
603    .t yview scroll -2 units
604    update
605    list $tk_textRelayout $tk_textRedraw
606} {{2.0 3.0} {2.0 3.0}}
607test textDisp-4.17 {UpdateDisplayInfo, horizontal scrolling} {fonts} {
608    .t configure -wrap none
609    .t delete 1.0 end
610    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
611    .t insert end "\nLine 3\nLine 4"
612    update
613    .t xview scroll 3 units
614    update
615    list $tk_textRelayout $tk_textRedraw [.t bbox 2.0] [.t bbox 2.5] \
616	    [.t bbox 2.23]
617} {{} {1.0 2.0 3.0 4.0} {} {17 16 7 13} {}}
618test textDisp-4.18 {UpdateDisplayInfo, horizontal scrolling} {fonts} {
619    .t configure -wrap none
620    .t delete 1.0 end
621    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
622    .t insert end "\nLine 3\nLine 4"
623    update
624    .t xview scroll 100 units
625    update
626    list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
627} {{} {1.0 2.0 3.0 4.0} {10 16 7 13}}
628test textDisp-4.19 {UpdateDisplayInfo, horizontal scrolling} {fonts} {
629    .t configure -wrap none
630    .t delete 1.0 end
631    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
632    .t insert end "\nLine 3\nLine 4"
633    update
634    .t xview moveto 0
635    .t xview scroll -10 units
636    update
637    list $tk_textRelayout $tk_textRedraw [.t bbox 2.5]
638} {{} {1.0 2.0 3.0 4.0} {38 16 7 13}}
639test textDisp-4.20 {UpdateDisplayInfo, horizontal scrolling} {fonts} {
640    .t configure -wrap none
641    .t delete 1.0 end
642    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
643    .t insert end "\nLine 3\nLine 4"
644    .t xview moveto 0.0
645    .t xview scroll 100 units
646    update
647    .t delete 2.30 2.44
648    update
649    list $tk_textRelayout $tk_textRedraw [.t bbox 2.25]
650} {2.0 {1.0 2.0 3.0 4.0} {108 16 7 13}}
651test textDisp-4.21 {UpdateDisplayInfo, horizontal scrolling} {fonts} {
652    .t configure -wrap none
653    .t delete 1.0 end
654    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
655    .t insert end "\nLine 3\nLine 4"
656    .t xview moveto .9
657    update
658    .t xview moveto .6
659    update
660    list $tk_textRelayout $tk_textRedraw
661} {{} {}}
662test textDisp-4.22 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {fonts} {
663    .t configure -wrap none
664    .t delete 1.0 end
665    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
666    .t insert end "\nLine 3\nLine 4"
667    .t xview scroll 25 units
668    update
669    .t configure -wrap word
670    list [.t bbox 2.0] [.t bbox 2.16]
671} {{3 16 7 13} {10 29 7 13}}
672test textDisp-4.23 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {fonts} {
673    .t configure -wrap none
674    .t delete 1.0 end
675    .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
676    .t insert end "\nLine 3\nLine 4"
677    .t xview scroll 25 units
678    update
679    .t configure -wrap char
680    list [.t bbox 2.0] [.t bbox 2.16]
681} {{3 16 7 13} {115 16 7 13}}
682
683test textDisp-5.1 {DisplayDLine, handling of spacing} {fonts} {
684    .t configure -wrap char
685    .t delete 1.0 end
686    .t insert 1.0 "abcdefghijkl\nmnopqrstuvwzyz"
687    .t tag configure spacing -spacing1 8 -spacing3 2
688    .t tag add spacing 1.0 end
689    frame .t.f1 -width 10 -height 4 -bg black
690    frame .t.f2 -width 10 -height 4 -bg black
691    frame .t.f3 -width 10 -height 4 -bg black
692    frame .t.f4 -width 10 -height 4 -bg black
693    .t window create 1.3 -window .t.f1 -align top
694    .t window create 1.7 -window .t.f2 -align center
695    .t window create 2.1 -window .t.f3 -align bottom
696    .t window create 2.10 -window .t.f4 -align baseline
697    update
698    list [winfo geometry .t.f1] [winfo geometry .t.f2] \
699	    [winfo geometry .t.f3] [winfo geometry .t.f4]
700} {10x4+24+11 10x4+55+15 10x4+10+43 10x4+76+40}
701.t tag delete spacing
702
703# Although the following test produces a useful result, its main
704# effect is to produce a core dump if Tk doesn't handle display
705# relayout that occurs during redisplay.
706
707test textDisp-5.2 {DisplayDLine, line resizes during display} {
708    .t delete 1.0 end
709    frame .t.f -width 20 -height 20 -bd 2 -relief raised
710    bind .t.f <Configure> {.t.f configure -width 30 -height 30}
711    .t window create insert -window .t.f
712    update
713    list [winfo width .t.f] [winfo height .t.f]
714} {30 30}
715
716.t configure -wrap char
717test textDisp-6.1 {scrolling in DisplayText, scroll up} {
718    .t delete 1.0 end
719    .t insert 1.0 "Line 1"
720    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
721	.t insert end "\nLine $i"
722    }
723    update
724    .t delete 2.0 3.0
725    update
726    list $tk_textRelayout $tk_textRedraw
727} {{2.0 10.0} {2.0 10.0}}
728test textDisp-6.2 {scrolling in DisplayText, scroll down} {
729    .t delete 1.0 end
730    .t insert 1.0 "Line 1"
731    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
732	.t insert end "\nLine $i"
733    }
734    update
735    .t insert 2.0 "New Line 2\n"
736    update
737    list $tk_textRelayout $tk_textRedraw
738} {{2.0 3.0} {2.0 3.0}}
739test textDisp-6.3 {scrolling in DisplayText, multiple scrolls} {
740    .t configure -wrap char
741    .t delete 1.0 end
742    .t insert 1.0 "Line 1"
743    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
744	.t insert end "\nLine $i"
745    }
746    update
747    .t insert 2.end "is so long that it wraps"
748    .t insert 4.end "is so long that it wraps"
749    update
750    list $tk_textRelayout $tk_textRedraw
751} {{2.0 2.20 4.0 4.20} {2.0 2.20 4.0 4.20}}
752test textDisp-6.4 {scrolling in DisplayText, scrolls interfere} {
753    .t configure -wrap char
754    .t delete 1.0 end
755    .t insert 1.0 "Line 1"
756    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
757	.t insert end "\nLine $i"
758    }
759    update
760    .t insert 2.end "is so long that it wraps around, not once but three times"
761    .t insert 4.end "is so long that it wraps"
762    update
763    list $tk_textRelayout $tk_textRedraw
764} {{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}}
765test textDisp-6.5 {scrolling in DisplayText, scroll source obscured} {nonPortable} {
766    .t configure -wrap char
767    frame .f2 -bg red
768    place .f2 -in .t -relx 0.5 -rely 0.5 -relwidth 0.5 -relheight 0.5
769    .t delete 1.0 end
770    .t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
771    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
772	.t insert end "\nLine $i"
773    }
774    update
775    .t delete 1.6 1.end
776    update
777    destroy .f2
778    list $tk_textRelayout $tk_textRedraw
779} {{1.0 9.0 10.0} {1.0 4.0 5.0 9.0 10.0}}
780test textDisp-6.6 {scrolling in DisplayText, Expose events after scroll} {unixOnly nonPortable} {
781    # this test depends on all of the expose events being handled at once
782    .t configure -wrap char
783    frame .f2 -bg #ff0000
784    place .f2 -in .t -relx 0.2 -rely 0.5 -relwidth 0.5 -relheight 0.5
785    .t configure -bd 2 -relief raised
786    .t delete 1.0 end
787    .t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
788    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
789	.t insert end "\nLine $i"
790    }
791    update
792    .t delete 1.6 1.end
793    destroy .f2
794    update
795    list $tk_textRelayout $tk_textRedraw
796} {{1.0 9.0 10.0} {borders 1.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0}}
797.t configure -bd 0
798test textDisp-6.7 {DisplayText, vertical scrollbar updates} {
799    .t configure -wrap char
800    .t delete 1.0 end
801    update
802    set scrollInfo
803} {0 1}
804test textDisp-6.8 {DisplayText, vertical scrollbar updates} {
805    .t configure -wrap char
806    .t delete 1.0 end
807    .t insert 1.0 "Line 1"
808    update
809    set scrollInfo "unchanged"
810    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
811	.t insert end "\nLine $i"
812    }
813    update
814    set scrollInfo
815} {0 0.769231}
816.t configure -yscrollcommand {} -xscrollcommand scroll
817test textDisp-6.9 {DisplayText, horizontal scrollbar updates} {
818    .t configure -wrap none
819    .t delete 1.0 end
820    update
821    set scrollInfo unchanged
822    .t insert end xxxxxxxxx\n
823    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
824    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
825    update
826    set scrollInfo
827} {0 0.363636}
828
829# The following group of tests is marked non-portable because
830# they result in a lot of extra redisplay under Ultrix.  I don't
831# know why this is so.
832
833.t configure -bd 2 -relief raised -wrap char
834.t delete 1.0 end
835.t insert 1.0 "Line 1 is so long that it wraps around, a couple of times"
836foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
837    .t insert end "\nLine $i"
838}
839test textDisp-7.1 {TkTextRedrawRegion} {nonPortable} {
840    frame .f2 -bg #ff0000
841    place .f2 -in .t -relx 0.2 -relwidth 0.6 -rely 0.22 -relheight 0.55
842    update
843    destroy .f2
844    update
845    list $tk_textRelayout $tk_textRedraw
846} {{} {1.40 2.0 3.0 4.0 5.0 6.0}}
847test textDisp-7.2 {TkTextRedrawRegion} {nonPortable} {
848    frame .f2 -bg #ff0000
849    place .f2 -in .t -relx 0 -relwidth 0.5 -rely 0 -relheight 0.5
850    update
851    destroy .f2
852    update
853    list $tk_textRelayout $tk_textRedraw
854} {{} {borders 1.0 1.20 1.40 2.0 3.0}}
855test textDisp-7.3 {TkTextRedrawRegion} {nonPortable} {
856    frame .f2 -bg #ff0000
857    place .f2 -in .t -relx 0.5 -relwidth 0.5 -rely 0.5 -relheight 0.5
858    update
859    destroy .f2
860    update
861    list $tk_textRelayout $tk_textRedraw
862} {{} {borders 4.0 5.0 6.0 7.0 8.0}}
863test textDisp-7.4 {TkTextRedrawRegion} {nonPortable} {
864    frame .f2 -bg #ff0000
865    place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 0 -relheight 0.2 \
866	    -bordermode ignore
867    update
868    destroy .f2
869    update
870    list $tk_textRelayout $tk_textRedraw
871} {{} {borders 1.0 1.20}}
872test textDisp-7.5 {TkTextRedrawRegion} {nonPortable} {
873    frame .f2 -bg #ff0000
874    place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 1.0 -relheight 0.2 \
875	    -anchor s -bordermode ignore
876    update
877    destroy .f2
878    update
879    list $tk_textRelayout $tk_textRedraw
880} {{} {borders 7.0 8.0}}
881test textDisp-7.6 {TkTextRedrawRegion} {nonPortable} {
882    frame .f2 -bg #ff0000
883    place .f2 -in .t -relx 0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
884	    -anchor w -bordermode ignore
885    update
886    destroy .f2
887    update
888    list $tk_textRelayout $tk_textRedraw
889} {{} {borders 3.0 4.0 5.0}}
890test textDisp-7.7 {TkTextRedrawRegion} {nonPortable} {
891    frame .f2 -bg #ff0000
892    place .f2 -in .t -relx 1.0 -relwidth 0.2 -rely 0.55 -relheight 0.2 \
893	    -anchor e -bordermode ignore
894    update
895    destroy .f2
896    update
897    list $tk_textRelayout $tk_textRedraw
898} {{} {borders 3.0 4.0 5.0}}
899test textDisp-7.8 {TkTextRedrawRegion} {nonPortable} {
900    .t delete 1.0 end
901    .t insert 1.0 "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\n"
902    frame .f2 -bg #ff0000
903    place .f2 -in .t -relx 0.0 -relwidth 0.4 -rely 0.35 -relheight 0.4 \
904	    -anchor nw -bordermode ignore
905    update
906    destroy .f2
907    update
908    list $tk_textRelayout $tk_textRedraw
909} {{} {borders 4.0 5.0 6.0 7.0 eof}}
910.t configure -bd 0
911
912test textDisp-8.1 {TkTextChanged: redisplay whole lines} {fonts} {
913    .t configure -wrap word
914    .t delete 1.0 end
915    .t insert 1.0 "Line 1\nLine 2 is so long that it wraps around, two times"
916    foreach i {3 4 5 6 7 8 9 10 11 12 13 14 15} {
917	.t insert end "\nLine $i"
918    }
919    update
920    .t delete 2.36 2.38
921    update
922    list $tk_textRelayout $tk_textRedraw [.t bbox 2.32]
923} {{2.0 2.18 2.38} {2.0 2.18 2.38} {101 29 7 13}}
924.t configure -wrap char
925test textDisp-8.2 {TkTextChanged, redisplay whole lines} {
926    .t delete 1.0 end
927    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
928    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
929	.t insert end "\nLine $i"
930    }
931    update
932    .t insert 1.2 xx
933    update
934    list $tk_textRelayout $tk_textRedraw
935} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
936test textDisp-8.3 {TkTextChanged} {
937    .t delete 1.0 end
938    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
939    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
940	.t insert end "\nLine $i"
941    }
942    update
943    .t insert 2.0 xx
944    update
945    list $tk_textRelayout $tk_textRedraw
946} {2.0 2.0}
947test textDisp-8.4 {TkTextChanged} {
948    .t delete 1.0 end
949    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
950    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
951	.t insert end "\nLine $i"
952    }
953    update
954    .t delete 1.5
955    update
956    list $tk_textRelayout $tk_textRedraw
957} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
958test textDisp-8.5 {TkTextChanged} {
959    .t delete 1.0 end
960    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
961    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
962	.t insert end "\nLine $i"
963    }
964    update
965    .t delete 1.40 1.44
966    update
967    list $tk_textRelayout $tk_textRedraw
968} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
969test textDisp-8.6 {TkTextChanged} {
970    .t delete 1.0 end
971    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
972    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
973	.t insert end "\nLine $i"
974    }
975    update
976    .t delete 1.41 1.44
977    update
978    list $tk_textRelayout $tk_textRedraw
979} {{1.0 1.20 1.40} {1.0 1.20 1.40}}
980test textDisp-8.7 {TkTextChanged} {
981    .t delete 1.0 end
982    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
983    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
984	.t insert end "\nLine $i"
985    }
986    update
987    .t delete 1.2 1.end
988    update
989    list $tk_textRelayout $tk_textRedraw
990} {{1.0 9.0 10.0} {1.0 9.0 10.0}}
991test textDisp-8.8 {TkTextChanged} {
992    .t delete 1.0 end
993    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
994    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
995	.t insert end "\nLine $i"
996    }
997    update
998    .t delete 2.2
999    update
1000    list $tk_textRelayout $tk_textRedraw
1001} {2.0 2.0}
1002test textDisp-8.9 {TkTextChanged} {
1003    .t delete 1.0 end
1004    .t insert 1.0 "Line 1 is so long that it wraps around, two times"
1005    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
1006	.t insert end "\nLine $i"
1007    }
1008    update
1009    .t delete 2.0 3.0
1010    update
1011    list $tk_textRelayout $tk_textRedraw
1012} {{2.0 8.0} {2.0 8.0}}
1013test textDisp-8.10 {TkTextChanged} {
1014    .t configure -wrap char
1015    .t delete 1.0 end
1016    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1017    .t tag add big 2.19
1018    update
1019    .t delete 2.19
1020    update
1021    set tk_textRedraw
1022} {2.0 2.20 eof}
1023test textDisp-8.11 {TkTextChanged, scrollbar notification when changes are off-screen} {
1024    .t delete 1.0 end
1025    .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n"
1026    .t configure -yscrollcommand scroll
1027    update
1028    set scrollInfo ""
1029    .t insert end "a\nb\nc\n"
1030    update
1031    .t configure -yscrollcommand ""
1032    set scrollInfo
1033} {0 0.625}
1034
1035test textDisp-9.1 {TkTextRedrawTag} {
1036    .t configure -wrap char
1037    .t delete 1.0 end
1038    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1039    update
1040    .t tag add big 2.2 2.4
1041    update
1042    list $tk_textRelayout $tk_textRedraw
1043} {{2.0 2.18} {2.0 2.18}}
1044test textDisp-9.2 {TkTextRedrawTag} {fonts} {
1045    .t configure -wrap char
1046    .t delete 1.0 end
1047    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1048    update
1049    .t tag add big 1.2 2.4
1050    update
1051    list $tk_textRelayout $tk_textRedraw
1052} {{1.0 2.0 2.17} {1.0 2.0 2.17}}
1053test textDisp-9.3 {TkTextRedrawTag} {
1054    .t configure -wrap char
1055    .t delete 1.0 end
1056    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1057    update
1058    .t tag add big 2.2 2.4
1059    .t tag remove big 1.0 end
1060    update
1061    list $tk_textRelayout $tk_textRedraw
1062} {2.0 2.0}
1063test textDisp-9.4 {TkTextRedrawTag} {
1064    .t configure -wrap char
1065    .t delete 1.0 end
1066    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1067    update
1068    .t tag add big 2.2 2.20
1069    .t tag remove big 1.0 end
1070    update
1071    list $tk_textRelayout $tk_textRedraw
1072} {2.0 2.0}
1073test textDisp-9.5 {TkTextRedrawTag} {
1074    .t configure -wrap char
1075    .t delete 1.0 end
1076    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1077    update
1078    .t tag add big 2.2 2.end
1079    .t tag remove big 1.0 end
1080    update
1081    list $tk_textRelayout $tk_textRedraw
1082} {{2.0 2.20} {2.0 2.20}}
1083test textDisp-9.6 {TkTextRedrawTag} {
1084    .t configure -wrap char
1085    .t delete 1.0 end
1086    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1087    update
1088    .t tag add big 2.2 3.5
1089    .t tag remove big 1.0 end
1090    update
1091    list $tk_textRelayout $tk_textRedraw
1092} {{2.0 2.20 3.0} {2.0 2.20 3.0}}
1093test textDisp-9.7 {TkTextRedrawTag} {
1094    .t configure -wrap char
1095    .t delete 1.0 end
1096    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1097    .t tag add big 2.19
1098    update
1099    .t tag remove big 2.19
1100    update
1101    set tk_textRedraw
1102} {2.0 2.20 eof}
1103test textDisp-9.8 {TkTextRedrawTag} {fonts} {
1104    .t configure -wrap char
1105    .t delete 1.0 end
1106    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1107    .t tag add big 1.0 2.0
1108    update
1109    .t tag add big 2.0 2.5
1110    update
1111    set tk_textRedraw
1112} {2.0 2.17}
1113test textDisp-9.9 {TkTextRedrawTag} {fonts} {
1114    .t configure -wrap char
1115    .t delete 1.0 end
1116    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1117    .t tag add big 1.0 2.0
1118    update
1119    .t tag add big 1.5 2.5
1120    update
1121    set tk_textRedraw
1122} {2.0 2.17}
1123test textDisp-9.10 {TkTextRedrawTag} {
1124    .t configure -wrap char
1125    .t delete 1.0 end
1126    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1127    .t tag add big 1.0 2.0
1128    update
1129    set tk_textRedraw {none}
1130    .t tag add big 1.3 1.5
1131    update
1132    set tk_textRedraw
1133} {none}
1134test textDisp-9.11 {TkTextRedrawTag} {
1135    .t configure -wrap char
1136    .t delete 1.0 end
1137    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1138    .t tag add big 1.0 2.0
1139    update
1140    .t tag add big 1.0 2.0
1141    update
1142    set tk_textRedraw
1143} {}
1144
1145test textDisp-10.1 {TkTextRelayoutWindow} {
1146    .t configure -wrap char
1147    .t delete 1.0 end
1148    .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1149    update
1150    .t configure -bg black
1151    update
1152    list $tk_textRelayout $tk_textRedraw
1153} {{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}}
1154.t configure -bg [lindex [.t configure -bg] 3]
1155test textDisp-10.2 {TkTextRelayoutWindow} {
1156    toplevel .top -width 300 -height 200
1157    wm geometry .top +0+0
1158    text .top.t -font $fixedFont -width 20 -height 10 -relief raised -bd 2
1159    place .top.t -x 0 -y 0 -width 20 -height 20
1160    .top.t insert end "First line"
1161    .top.t see insert
1162    tkwait visibility .top.t
1163    place .top.t -width 150 -height 100
1164    update
1165    .top.t index @0,0
1166} {1.0}
1167catch {destroy .top}
1168
1169.t delete 1.0 end
1170.t insert end "Line 1"
1171for {set i 2} {$i <= 200} {incr i} {
1172    .t insert end "\nLine $i"
1173}
1174update
1175test textDisp-11.1 {TkTextSetYView} {
1176    .t yview 30.0
1177    update
1178    .t index @0,0
1179} {30.0}
1180test textDisp-11.2 {TkTextSetYView} {
1181    .t yview 30.0
1182    update
1183    .t yview 32.0
1184    update
1185    list [.t index @0,0] $tk_textRedraw
1186} {32.0 {40.0 41.0}}
1187test textDisp-11.3 {TkTextSetYView} {
1188    .t yview 30.0
1189    update
1190    .t yview 28.0
1191    update
1192    list [.t index @0,0] $tk_textRedraw
1193} {28.0 {28.0 29.0}}
1194test textDisp-11.4 {TkTextSetYView} {
1195    .t yview 30.0
1196    update
1197    .t yview 31.4
1198    update
1199    list [.t index @0,0] $tk_textRedraw
1200} {31.0 40.0}
1201test textDisp-11.5 {TkTextSetYView} {
1202    .t yview 30.0
1203    update
1204    set tk_textRedraw {}
1205    .t yview -pickplace 31.0
1206    update
1207    list [.t index @0,0] $tk_textRedraw
1208} {30.0 {}}
1209test textDisp-11.6 {TkTextSetYView} {
1210    .t yview 30.0
1211    update
1212    set tk_textRedraw {}
1213    .t yview -pickplace 28.0
1214    update
1215    list [.t index @0,0] $tk_textRedraw
1216} {28.0 {28.0 29.0}}
1217test textDisp-11.7 {TkTextSetYView} {
1218    .t yview 30.0
1219    update
1220    set tk_textRedraw {}
1221    .t yview -pickplace 26.0
1222    update
1223    list [.t index @0,0] $tk_textRedraw
1224} {22.0 {22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0}}
1225test textDisp-11.8 {TkTextSetYView} {
1226    .t yview 30.0
1227    update
1228    set tk_textRedraw {}
1229    .t yview -pickplace 41.0
1230    update
1231    list [.t index @0,0] $tk_textRedraw
1232} {32.0 {40.0 41.0}}
1233test textDisp-11.9 {TkTextSetYView} {
1234    .t yview 30.0
1235    update
1236    set tk_textRedraw {}
1237    .t yview -pickplace 43.0
1238    update
1239    list [.t index @0,0] $tk_textRedraw
1240} {39.0 {40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0}}
1241test textDisp-11.10 {TkTextSetYView} {
1242    .t yview 30.0
1243    update
1244    set tk_textRedraw {}
1245    .t yview 10000.0
1246    update
1247    list [.t index @0,0] $tk_textRedraw
1248} {191.0 {191.0 192.0 193.0 194.0 195.0 196.0 197.0 198.0 199.0 200.0}}
1249test textDisp-11.11 {TkTextSetYView} {
1250    .t yview 195.0
1251    update
1252    set tk_textRedraw {}
1253    .t yview 197.0
1254    update
1255    list [.t index @0,0] $tk_textRedraw
1256} {191.0 {191.0 192.0 193.0 194.0 195.0 196.0}}
1257test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} {
1258    .t insert 10.0 "Long line with enough text to wrap\n"
1259    .t yview 1.0
1260    update
1261    set tk_textRedraw {}
1262    .t see 10.30
1263    update
1264    list [.t index @0,0] $tk_textRedraw
1265} {2.0 10.20}
1266.t delete 10.0 11.0
1267test textDisp-11.13 {TkTestSetYView, partially-visible last line} {
1268    catch {destroy .top}
1269    toplevel .top
1270    wm geometry .top +0+0
1271    text .top.t -width 20 -height 5
1272    pack .top.t
1273    .top.t insert end "Line 1"
1274    for {set i 2} {$i <= 100} {incr i} {
1275	.top.t insert end "\nLine $i"
1276    }
1277    update
1278    scan [wm geometry .top] "%dx%d" w2 h2
1279    wm geometry .top ${w2}x[expr $h2-2]
1280    update
1281    .top.t yview 1.0
1282    update
1283    set tk_textRedraw {}
1284    .top.t see 5.0
1285    update
1286    list [.top.t index @0,0] $tk_textRedraw
1287} {2.0 {5.0 6.0}}
1288catch {destroy .top}
1289toplevel .top
1290wm geometry .top +0+0
1291text .top.t -width 30 -height 3
1292pack .top.t
1293.top.t insert end "Line 1"
1294for {set i 2} {$i <= 20} {incr i} {
1295    .top.t insert end "\nLine $i"
1296}
1297update
1298test textDisp-11.14 {TkTextSetYView, only a few lines visible} {
1299    .top.t yview 5.0
1300    update
1301    .top.t see 10.0
1302    .top.t index @0,0
1303} {8.0}
1304test textDisp-11.15 {TkTextSetYView, only a few lines visible} {
1305    .top.t yview 5.0
1306    update
1307    .top.t see 11.0
1308    .top.t index @0,0
1309} {10.0}
1310test textDisp-11.16 {TkTextSetYView, only a few lines visible} {
1311    .top.t yview 8.0
1312    update
1313    .top.t see 5.0
1314    .top.t index @0,0
1315} {5.0}
1316test textDisp-11.17 {TkTextSetYView, only a few lines visible} {
1317    .top.t yview 8.0
1318    update
1319    .top.t see 4.0
1320    .top.t index @0,0
1321} {3.0}
1322destroy .top
1323
1324.t configure -wrap word
1325.t delete 50.0 51.0
1326.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
1327test textDisp-12.1 {MeasureUp} {
1328    .t yview 100.0
1329    update
1330    .t yview -pickplace 52.0
1331    update
1332    .t index @0,0
1333} {50.0}
1334test textDisp-12.2 {MeasureUp} {
1335    .t yview 100.0
1336    update
1337    .t yview -pickplace 53.0
1338    update
1339    .t index @0,0
1340} {50.15}
1341test textDisp-12.3 {MeasureUp} {
1342    .t yview 100.0
1343    update
1344    .t yview -pickplace 50.10
1345    update
1346    .t index @0,0
1347} {46.0}
1348.t configure -wrap none
1349test textDisp-12.4 {MeasureUp} {
1350    .t yview 100.0
1351    update
1352    .t yview -pickplace 53.0
1353    update
1354    .t index @0,0
1355} {49.0}
1356test textDisp-12.5 {MeasureUp} {
1357    .t yview 100.0
1358    update
1359    .t yview -pickplace 50.10
1360    update
1361    .t index @0,0
1362} {46.0}
1363
1364.t configure -wrap none
1365.t delete 1.0 end
1366for {set i 1} {$i < 99} {incr i} {
1367    .t insert end "Line $i\n"
1368}
1369.t insert end "Line 100"
1370.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.}
1371test textDisp-13.1 {TkTextSeeCmd procedure} {
1372    list [catch {.t see} msg] $msg
1373} {1 {wrong # args: should be ".t see index"}}
1374test textDisp-13.2 {TkTextSeeCmd procedure} {
1375    list [catch {.t see a b} msg] $msg
1376} {1 {wrong # args: should be ".t see index"}}
1377test textDisp-13.3 {TkTextSeeCmd procedure} {
1378    list [catch {.t see badIndex} msg] $msg
1379} {1 {bad text index "badIndex"}}
1380test textDisp-13.4 {TkTextSeeCmd procedure} {
1381    .t xview moveto 0
1382    .t yview moveto 0
1383    update
1384    .t see 4.2
1385    .t index @0,0
1386} {1.0}
1387test textDisp-13.5 {TkTextSeeCmd procedure} {
1388    .t configure -wrap char
1389    .t xview moveto 0
1390    .t yview moveto 0
1391    update
1392    .t see 12.1
1393    .t index @0,0
1394} {3.0}
1395test textDisp-13.6 {TkTextSeeCmd procedure} {
1396    .t configure -wrap char
1397    .t xview moveto 0
1398    .t yview moveto 0
1399    update
1400    .t see 30.50
1401    set x [.t index @0,0]
1402    .t configure -wrap none
1403    set x
1404} {28.0}
1405test textDisp-13.7 {TkTextSeeCmd procedure} {fonts} {
1406    .t xview moveto 0
1407    .t yview moveto 0
1408    .t tag add sel 30.20
1409    .t tag add sel 30.40
1410    update
1411    .t see 30.50
1412    set x [list [.t bbox 30.50]]
1413    .t see 30.39
1414    lappend x [.t bbox 30.39]
1415    .t see 30.38
1416    lappend x [.t bbox 30.38]
1417    .t see 30.20
1418    lappend x [.t bbox 30.20]
1419} {{73 55 7 13} {3 55 7 13} {3 55 7 13} {73 55 7 13}}
1420test textDisp-13.8 {TkTextSeeCmd procedure} {fonts} {
1421    .t xview moveto 0
1422    .t yview moveto 0
1423    .t tag add sel 30.20
1424    .t tag add sel 30.50
1425    update
1426    .t see 30.50
1427    set x [list [.t bbox 30.50]]
1428    .t see 30.60
1429    lappend x [.t bbox 30.60]
1430    .t see 30.65
1431    lappend x [.t bbox 30.65]
1432    .t see 30.90
1433    lappend x [.t bbox 30.90]
1434} {{73 55 7 13} {136 55 7 13} {136 55 7 13} {73 55 7 13}}
1435test textDisp-13.9 {TkTextSeeCmd procedure} {fonts} {
1436    wm geom . [expr $width-2]x$height
1437    .t xview moveto 0
1438    .t yview moveto 0
1439    .t tag add sel 30.20
1440    .t tag add sel 30.50
1441    update
1442    .t see 30.50
1443    set x [list [.t bbox 30.50]]
1444    .t see 30.60
1445    lappend x [.t bbox 30.60]
1446    .t see 30.65
1447    lappend x [.t bbox 30.65]
1448    .t see 30.90
1449    lappend x [.t bbox 30.90]
1450} {{80 55 7 13} {136 55 7 13} {136 55 7 13} {80 55 7 13}}
1451test textDisp-13.10 {TkTextSeeCmd procedure} {} {
1452    # SF Bug 641778
1453    set w .tsee
1454    destroy $w
1455    text $w -font {Helvetica 8 normal} -bd 16
1456    $w insert end Hello
1457    $w see end
1458    set res [$w bbox end]
1459    destroy $w
1460    set res
1461} {}
1462wm geom . {}
1463
1464.t configure -wrap none
1465test textDisp-14.1 {TkTextXviewCmd procedure} {
1466    .t delete 1.0 end
1467    update
1468    .t insert end xxxxxxxxx\n
1469    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1470    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1471    .t xview moveto .5
1472    .t xview
1473} {0.5 0.857143}
1474.t configure -wrap char
1475test textDisp-14.2 {TkTextXviewCmd procedure} {
1476    .t delete 1.0 end
1477    update
1478    .t insert end xxxxxxxxx\n
1479    .t insert end "xxxxx\n"
1480    .t insert end "xxxx"
1481    .t xview
1482} {0 1}
1483.t configure -wrap none
1484test textDisp-14.3 {TkTextXviewCmd procedure} {
1485    .t delete 1.0 end
1486    update
1487    .t insert end xxxxxxxxx\n
1488    .t insert end "xxxxx\n"
1489    .t insert end "xxxx"
1490    .t xview
1491} {0 1}
1492test textDisp-14.4 {TkTextXviewCmd procedure} {
1493    list [catch {.t xview moveto} msg] $msg
1494} {1 {wrong # args: should be ".t xview moveto fraction"}}
1495test textDisp-14.5 {TkTextXviewCmd procedure} {
1496    list [catch {.t xview moveto a b} msg] $msg
1497} {1 {wrong # args: should be ".t xview moveto fraction"}}
1498test textDisp-14.6 {TkTextXviewCmd procedure} {
1499    list [catch {.t xview moveto a} msg] $msg
1500} {1 {expected floating-point number but got "a"}}
1501test textDisp-14.7 {TkTextXviewCmd procedure} {
1502    .t delete 1.0 end
1503    .t insert end xxxxxxxxx\n
1504    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1505    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1506    .t xview moveto .3
1507    .t xview
1508} {0.303571 0.660714}
1509test textDisp-14.8 {TkTextXviewCmd procedure} {
1510    .t delete 1.0 end
1511    .t insert end xxxxxxxxx\n
1512    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1513    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1514    .t xview moveto -.4
1515    .t xview
1516} {0 0.357143}
1517test textDisp-14.9 {TkTextXviewCmd procedure} {
1518    .t delete 1.0 end
1519    .t insert end xxxxxxxxx\n
1520    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1521    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1522    .t xview m 1.4
1523    .t xview
1524} {0.642857 1}
1525test textDisp-14.10 {TkTextXviewCmd procedure} {
1526    list [catch {.t xview scroll a} msg] $msg
1527} {1 {wrong # args: should be ".t xview scroll number units|pages"}}
1528test textDisp-14.11 {TkTextXviewCmd procedure} {
1529    list [catch {.t xview scroll a b c} msg] $msg
1530} {1 {wrong # args: should be ".t xview scroll number units|pages"}}
1531test textDisp-14.12 {TkTextXviewCmd procedure} {
1532    list [catch {.t xview scroll gorp units} msg] $msg
1533} {1 {expected integer but got "gorp"}}
1534test textDisp-14.13 {TkTextXviewCmd procedure} {
1535    .t delete 1.0 end
1536    .t insert end xxxxxxxxx\n
1537    .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"
1538    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1539    .t xview moveto 0
1540    .t xview scroll 2 p
1541    set x [.t index @0,22]
1542    .t xview scroll -1 p
1543    lappend x [.t index @0,22]
1544    .t xview scroll -2 pages
1545    lappend x [.t index @0,22]
1546} {2.36 2.18 2.0}
1547test textDisp-14.14 {TkTextXviewCmd procedure} {
1548    .t delete 1.0 end
1549    .t insert end xxxxxxxxx\n
1550    .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"
1551    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1552    .t xview moveto 0
1553    .t xview scroll 21 u  
1554    set x [.t index @0,22]
1555    .t xview scroll -1 u
1556    lappend x [.t index @0,22]
1557    .t xview scroll 100 units
1558    lappend x [.t index @0,22]
1559    .t xview scroll -15 units
1560    lappend x [.t index @0,22]
1561} {2.21 2.20 2.99 2.84}
1562test textDisp-14.15 {TkTextXviewCmd procedure} {
1563    list [catch {.t xview scroll 14 globs} msg] $msg
1564} {1 {bad argument "globs": must be units or pages}}
1565test textDisp-14.16 {TkTextXviewCmd procedure} {
1566    list [catch {.t xview flounder} msg] $msg
1567} {1 {unknown option "flounder": must be moveto or scroll}}
1568
1569.t configure -wrap char
1570.t delete 1.0 end
1571for {set i 1} {$i < 99} {incr i} {
1572    .t insert end "Line $i\n"
1573}
1574.t insert end "Line 100"
1575.t delete 50.0 51.0
1576.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
1577test textDisp-15.1 {ScrollByLines procedure, scrolling backwards} {
1578    .t yview 45.0
1579    update
1580    .t yview scroll -3 units
1581    .t index @0,0
1582} {42.0}
1583test textDisp-15.2 {ScrollByLines procedure, scrolling backwards} {
1584    .t yview 51.0
1585    update
1586    .t yview scroll -2 units
1587    .t index @0,0
1588} {50.20}
1589test textDisp-15.3 {ScrollByLines procedure, scrolling backwards} {
1590    .t yview 51.0
1591    update
1592    .t yview scroll -4 units
1593    .t index @0,0
1594} {49.0}
1595test textDisp-15.4 {ScrollByLines procedure, scrolling backwards} {
1596    .t yview 50.20
1597    update
1598    .t yview scroll -2 units
1599    .t index @0,0
1600} {49.0}
1601test textDisp-15.5 {ScrollByLines procedure, scrolling backwards} {
1602    .t yview 50.40
1603    update
1604    .t yview scroll -2 units
1605    .t index @0,0
1606} {50.0}
1607test textDisp-15.6 {ScrollByLines procedure, scrolling backwards} {
1608    .t yview 3.2
1609    update
1610    .t yview scroll -5 units
1611    .t index @0,0
1612} {1.0}
1613test textDisp-15.7 {ScrollByLines procedure, scrolling forwards} {
1614    .t yview 48.0
1615    update
1616    .t yview scroll 4 units
1617    .t index @0,0
1618} {50.40}
1619
1620.t configure -wrap char
1621.t delete 1.0 end
1622.t insert insert "Line 1"
1623for {set i 2} {$i <= 200} {incr i} {
1624    .t insert end "\nLine $i"
1625}
1626.t tag add big 100.0 105.0
1627.t insert 151.end { has a lot of extra text, so that it wraps around on the screen several times over.}
1628.t insert 153.end { also has enoug extra text to wrap.}
1629update
1630test textDisp-16.1 {TkTextYviewCmd procedure} {
1631    .t yview 21.0
1632    set x [.t yview]
1633    .t yview 1.0
1634    set x
1635} {0.1 0.15}
1636test textDisp-16.2 {TkTextYviewCmd procedure} {
1637    list [catch {.t yview 2 3} msg] $msg
1638} {1 {unknown option "2": must be moveto or scroll}}
1639test textDisp-16.3 {TkTextYviewCmd procedure} {
1640    list [catch {.t yview -pickplace} msg] $msg
1641} {1 {wrong # args: should be ".t yview -pickplace lineNum|index"}}
1642test textDisp-16.4 {TkTextYviewCmd procedure} {
1643    list [catch {.t yview -pickplace 2 3} msg] $msg
1644} {1 {wrong # args: should be ".t yview -pickplace lineNum|index"}}
1645test textDisp-16.5 {TkTextYviewCmd procedure} {
1646    list [catch {.t yview -bogus 2} msg] $msg
1647} {1 {unknown option "-bogus": must be moveto or scroll}}
1648test textDisp-16.6 {TkTextYviewCmd procedure, integer position} {
1649    .t yview 100.0
1650    update
1651    .t yview 98
1652    .t index @0,0
1653} {99.0}
1654test textDisp-16.7 {TkTextYviewCmd procedure} {
1655    .t yview 2.0
1656    .t yv -pickplace 13.0
1657    .t index @0,0
1658} {4.0}
1659test textDisp-16.8 {TkTextYviewCmd procedure} {
1660    list [catch {.t yview bad_mark_name} msg] $msg
1661} {1 {bad text index "bad_mark_name"}}
1662test textDisp-16.9 {TkTextYviewCmd procedure, "moveto" option} {
1663    list [catch {.t yview moveto a b} msg] $msg
1664} {1 {wrong # args: should be ".t yview moveto fraction"}}
1665test textDisp-16.10 {TkTextYviewCmd procedure, "moveto" option} {
1666    list [catch {.t yview moveto gorp} msg] $msg
1667} {1 {expected floating-point number but got "gorp"}}
1668test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} {
1669    .t yview moveto 0.5
1670    .t index @0,0
1671} {101.0}
1672test textDisp-16.12 {TkTextYviewCmd procedure, "moveto" option} {
1673    .t yview moveto -1
1674    .t index @0,0
1675} {1.0}
1676test textDisp-16.13 {TkTextYviewCmd procedure, "moveto" option} {
1677    .t yview moveto 1.1
1678    .t index @0,0
1679} {191.0}
1680test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} {
1681    .t yview moveto .75
1682    .t index @0,0
1683} {151.0}
1684test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} {
1685    .t yview moveto .752
1686    .t index @0,0
1687} {151.20}
1688test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} {
1689    .t yview moveto .754
1690    .t index @0,0
1691} {151.60}
1692test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} {
1693    .t yview moveto .755
1694    .t index @0,0
1695} {152.0}
1696test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {fonts} {
1697    catch {destroy .top1}
1698    toplevel .top1
1699    wm geometry .top1 +0+0
1700    text .top1.t -height 3 -width 4 -wrap none -setgrid 1 -padx 6 \
1701	-spacing3 6
1702    .top1.t insert end "1\n2\n3\n4\n5\n6"
1703    pack .top1.t
1704    update
1705    .top1.t yview moveto 0.3333
1706    set result [.top1.t yview]
1707    destroy .top1
1708    set result
1709} {0.333333 0.833333}
1710test textDisp-16.19 {TkTextYviewCmd procedure, "scroll" option} {
1711    list [catch {.t yview scroll a} msg] $msg
1712} {1 {wrong # args: should be ".t yview scroll number units|pages"}}
1713test textDisp-16.20 {TkTextYviewCmd procedure, "scroll" option} {
1714    list [catch {.t yview scroll a b c} msg] $msg
1715} {1 {wrong # args: should be ".t yview scroll number units|pages"}}
1716test textDisp-16.21 {TkTextYviewCmd procedure, "scroll" option} {
1717    list [catch {.t yview scroll badInt bogus} msg] $msg
1718} {1 {expected integer but got "badInt"}}
1719test textDisp-16.22 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1720    .t yview 50.0
1721    update
1722    .t yview scroll -1 pages
1723    .t index @0,0
1724} {42.0}
1725test textDisp-16.23 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1726    .t yview 50.0
1727    update
1728    .t yview scroll -3 p
1729    .t index @0,0
1730} {26.0}
1731test textDisp-16.24 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1732    .t yview 5.0
1733    update
1734    .t yview scroll -3 p
1735    .t index @0,0
1736} {1.0}
1737test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1738    .t configure -height 1
1739    update
1740    .t yview 50.0
1741    update
1742    .t yview scroll -1 pages
1743    set x [.t index @0,0]
1744    .t configure -height 10
1745    update
1746    set x
1747} {49.0}
1748test textDisp-16.26 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1749    .t yview 50.0
1750    update
1751    .t yview scroll 1 pages
1752    .t index @0,0
1753} {58.0}
1754test textDisp-16.27 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1755    .t yview 50.0
1756    update
1757    .t yview scroll 2 pages
1758    .t index @0,0
1759} {66.0}
1760test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {fonts} {
1761    .t yview 98.0
1762    update
1763    .t yview scroll 1 page
1764    .t index @0,0
1765} {103.0}
1766test textDisp-16.29 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1767    .t configure -height 1
1768    update
1769    .t yview 50.0
1770    update
1771    .t yview scroll 1 pages
1772    set x [.t index @0,0]
1773    .t configure -height 10
1774    update
1775    set x
1776} {51.0}
1777test textDisp-16.30 {TkTextYviewCmd procedure, "scroll units" option} {
1778    .t yview 45.0
1779    update
1780    .t yview scroll -3 units
1781    .t index @0,0
1782} {42.0}
1783test textDisp-16.31 {TkTextYviewCmd procedure, "scroll units" option} {
1784    .t yview 149.0
1785    update
1786    .t yview scroll 4 units
1787    .t index @0,0
1788} {151.40}
1789test textDisp-16.32 {TkTextYviewCmd procedure} {
1790    list [catch {.t yview scroll 12 bogoids} msg] $msg
1791} {1 {bad argument "bogoids": must be units or pages}}
1792test textDisp-16.33 {TkTextYviewCmd procedure} {
1793    list [catch {.t yview bad_arg 1 2} msg] $msg
1794} {1 {unknown option "bad_arg": must be moveto or scroll}}
1795
1796.t delete 1.0 end
1797foreach 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} {
1798    .t insert end "\nLine $i 11111 $i 22222 $i 33333 $i 44444 $i 55555"
1799    .t insert end " $i 66666 $i 77777 $i 88888 $i"
1800}
1801.t configure -wrap none
1802test textDisp-17.1 {TkTextScanCmd procedure} {
1803    list [catch {.t scan a b} msg] $msg
1804} {1 {wrong # args: should be ".t scan mark x y" or ".t scan dragto x y ?gain?"}}
1805test textDisp-17.2 {TkTextScanCmd procedure} {
1806    list [catch {.t scan a b c d} msg] $msg
1807} {1 {expected integer but got "b"}}
1808test textDisp-17.3 {TkTextScanCmd procedure} {
1809    list [catch {.t scan stupid b 20} msg] $msg
1810} {1 {expected integer but got "b"}}
1811test textDisp-17.4 {TkTextScanCmd procedure} {
1812    list [catch {.t scan stupid -2 bogus} msg] $msg
1813} {1 {expected integer but got "bogus"}}
1814test textDisp-17.5 {TkTextScanCmd procedure} {
1815    list [catch {.t scan stupid 123 456} msg] $msg
1816} {1 {bad scan option "stupid": must be mark or dragto}}
1817test textDisp-17.6 {TkTextScanCmd procedure} {fonts} {
1818    .t yview 1.0
1819    .t xview moveto 0
1820    .t scan mark 40 60
1821    .t scan dragto 35 55
1822    .t index @0,0
1823} {4.7}
1824test textDisp-17.7 {TkTextScanCmd procedure} {fonts} {
1825    .t yview 10.0
1826    .t xview moveto 0
1827    .t xview scroll 20 units
1828    .t scan mark -10 60
1829    .t scan dragto -5 65
1830    .t index @0,0
1831    set x [.t index @0,0]
1832    .t scan dragto 0 70
1833    list $x [.t index @0,0]
1834} {7.13 3.6}
1835test textDisp-17.8 {TkTextScanCmd procedure} {fonts} {
1836    .t yview 1.0
1837    .t xview moveto 0
1838    .t scan mark 0 60
1839    .t scan dragto 30 100
1840    .t scan dragto 25 95 
1841    .t index @0,0
1842} {4.7}
1843test textDisp-17.9 {TkTextScanCmd procedure} {fonts} {
1844    .t yview end
1845    .t xview moveto 0
1846    .t xview scroll 100 units
1847    .t scan mark 90 60
1848    .t scan dragto 10 0
1849    .t scan dragto 15 5
1850    .t index @0,0
1851} {18.44}
1852.t configure -wrap word
1853test textDisp-17.10 {TkTextScanCmd procedure, word wrapping} {fonts} {
1854    .t yview 10.0
1855    .t scan mark -10 60
1856    .t scan dragto -5 65
1857    set x [.t index @0,0]
1858    .t scan dragto 0 70
1859    list $x [.t index @0,0]
1860} {9.31 8.47}
1861
1862.t configure -xscrollcommand scroll -yscrollcommand {}
1863test textDisp-18.1 {GetXView procedure} {
1864    .t configure -wrap none
1865    .t delete 1.0 end
1866    .t insert end xxxxxxxxx\n
1867    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1868    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1869    update
1870    set scrollInfo
1871} {0 0.363636}
1872test textDisp-18.2 {GetXView procedure} {
1873    .t configure -wrap char
1874    .t delete 1.0 end
1875    .t insert end xxxxxxxxx\n
1876    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1877    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1878    update
1879    set scrollInfo
1880} {0 1}
1881test textDisp-18.3 {GetXView procedure} {
1882    .t configure -wrap none
1883    .t delete 1.0 end
1884    update
1885    set scrollInfo
1886} {0 1}
1887test textDisp-18.4 {GetXView procedure} {
1888    .t configure -wrap none
1889    .t delete 1.0 end
1890    .t insert end xxxxxxxxx\n
1891    .t insert end xxxxxx\n
1892    .t insert end xxxxxxxxxxxxxxxxx
1893    update
1894    set scrollInfo
1895} {0 1}
1896test textDisp-18.5 {GetXView procedure} {
1897    .t configure -wrap none
1898    .t delete 1.0 end
1899    .t insert end xxxxxxxxx\n
1900    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1901    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1902    .t xview scroll 31 units
1903    update
1904    set scrollInfo
1905} {0.563636 0.927273}
1906test textDisp-18.6 {GetXView procedure} {
1907    .t configure -wrap none
1908    .t delete 1.0 end
1909    .t insert end xxxxxxxxx\n
1910    .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1911    .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1912    .t xview moveto 0
1913    .t xview scroll 31 units
1914    update
1915    set x {}
1916    lappend x $scrollInfo
1917    .t configure -wrap char
1918    update
1919    lappend x $scrollInfo
1920    .t configure -wrap word
1921    update
1922    lappend x $scrollInfo
1923    .t configure -wrap none
1924    update
1925    lappend x $scrollInfo
1926} {{0.553571 0.910714} {0 1} {0 1} {0 0.357143}}
1927test textDisp-18.7 {GetXView procedure} {
1928    .t configure -wrap none
1929    .t delete 1.0 end
1930    update
1931    set scrollInfo unchanged
1932    .t insert end xxxxxx\n
1933    .t insert end xxx
1934    update
1935    set scrollInfo
1936} {unchanged}
1937test textDisp-18.8 {GetXView procedure} {
1938    proc bgerror msg {
1939	global x errorInfo
1940	set x [list $msg $errorInfo]
1941    }
1942    proc bogus args {
1943	error "bogus scroll proc"
1944    }
1945    .t configure -wrap none
1946    .t delete 1.0 end
1947    .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1948    update
1949    .t delete 1.0 end
1950    .t configure -xscrollcommand scrollError
1951    update
1952    set x
1953} {{scrolling error} {scrolling error
1954    while executing
1955"error "scrolling error""
1956    (procedure "scrollError" line 2)
1957    invoked from within
1958"scrollError 0 1"
1959    (horizontal scrolling command executed by text)}}
1960catch {rename bgerror {}}
1961catch {rename bogus {}}
1962.t configure -xscrollcommand {} -yscrollcommand scroll
1963
1964.t configure -xscrollcommand {} -yscrollcommand scroll
1965test textDisp-19.1 {GetYView procedure} {
1966    .t configure -wrap char
1967    .t delete 1.0 end
1968    update
1969    set scrollInfo
1970} {0 1}
1971test textDisp-19.2 {GetYView procedure} {
1972    .t configure -wrap char
1973    .t delete 1.0 end
1974    update
1975    set scrollInfo "unchanged"
1976    .t insert 1.0 "Line1\nLine2"
1977    update
1978    set scrollInfo
1979} {unchanged}
1980test textDisp-19.3 {GetYView procedure} {
1981    .t configure -wrap char
1982    .t delete 1.0 end
1983    update
1984    set scrollInfo "unchanged"
1985    .t insert 1.0 "Line 1\nLine 2 is so long that it wraps around\nLine 3"
1986    update
1987    set scrollInfo
1988} {unchanged}
1989test textDisp-19.4 {GetYView procedure} {
1990    .t configure -wrap char
1991    .t delete 1.0 end
1992    .t insert 1.0 "Line 1"
1993    update
1994    set scrollInfo "unchanged"
1995    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
1996	.t insert end "\nLine $i"
1997    }
1998    update
1999    set scrollInfo
2000} {0 0.769231}
2001test textDisp-19.5 {GetYView procedure} {
2002    .t configure -wrap char
2003    .t delete 1.0 end
2004    .t insert 1.0 "Line 1"
2005    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2006	.t insert end "\nLine $i"
2007    }
2008    .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2009    update
2010    set x $scrollInfo
2011} {0 0.538462}
2012test textDisp-19.6 {GetYView procedure} {
2013    .t configure -wrap char
2014    .t delete 1.0 end
2015    .t insert 1.0 "Line 1"
2016    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2017	.t insert end "\nLine $i"
2018    }
2019    .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2020    .t yview 4.0
2021    update
2022    set x $scrollInfo
2023} {0.230769 1}
2024test textDisp-19.7 {GetYView procedure} {
2025    .t configure -wrap char
2026    .t delete 1.0 end
2027    .t insert 1.0 "Line 1"
2028    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2029	.t insert end "\nLine $i"
2030    }
2031    .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2032    .t yview 2.26
2033    update
2034    set x $scrollInfo
2035} {0.097166 0.692308}
2036test textDisp-19.8 {GetYView procedure} {
2037    .t configure -wrap char
2038    .t delete 1.0 end
2039    .t insert 1.0 "Line 1"
2040    foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2041	.t insert end "\nLine $i"
2042    }
2043    .t insert 10.end " is really quite long; in fact it's so long that it wraps three times"
2044    .t yview 2.0
2045    update
2046    set x $scrollInfo
2047} {0.0769231 0.732268}
2048test textDisp-19.9 {GetYView procedure} {
2049    .t configure -wrap char
2050    .t delete 1.0 end
2051    .t insert 1.0 "Line 1"
2052    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2053	.t insert end "\nLine $i"
2054    }
2055    .t yview 3.0
2056    update
2057    set scrollInfo
2058} {0.133333 0.8}
2059test textDisp-19.10 {GetYView procedure} {
2060    .t configure -wrap char
2061    .t delete 1.0 end
2062    .t insert 1.0 "Line 1"
2063    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2064	.t insert end "\nLine $i"
2065    }
2066    .t yview 11.0
2067    update
2068    set scrollInfo
2069} {0.333333 1}
2070test textDisp-19.11 {GetYView procedure} {
2071    .t configure -wrap word
2072    .t delete 1.0 end
2073    .t insert 1.0 "Line 1"
2074    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2075	.t insert end "\nLine $i"
2076    }
2077    .t insert end "\nThis last line wraps around four "
2078    .t insert end "times with a bit left on the last line."
2079    .t yview insert
2080    update
2081    set scrollInfo
2082} {0.625 1}
2083test textDisp-19.12 {GetYView procedure, partially visible last line} {
2084    catch {destroy .top}
2085    toplevel .top
2086    wm geometry .top +0+0
2087    text .top.t -width 40 -height 5
2088    pack .top.t -expand yes -fill both
2089    .top.t insert end "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
2090    update
2091    scan [wm geom .top] %dx%d twidth theight
2092    wm geom .top ${twidth}x[expr $theight - 3]
2093    update
2094    .top.t yview
2095} {0 0.8}
2096test textDisp-19.13 {GetYView procedure, partially visible last line} {fonts} {
2097    catch {destroy .top}
2098    toplevel .top
2099    wm geometry .top +0+0
2100    text .top.t -width 40 -height 5
2101    pack .top.t -expand yes -fill both
2102    .top.t insert end "Line 1\nLine 2\nLine 3\nLine 4 has enough text to wrap around at least once"
2103    update
2104    scan [wm geom .top] %dx%d twidth theight
2105    wm geom .top ${twidth}x[expr $theight - 3]
2106    update
2107    .top.t yview
2108} {0 0.942308}
2109catch {destroy .top}
2110test textDisp-19.14 {GetYView procedure} {
2111    .t configure -wrap word
2112    .t delete 1.0 end
2113    .t insert 1.0 "Line 1"
2114    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2115	.t insert end "\nLine $i"
2116    }
2117    .t insert end "\nThis last line wraps around four "
2118    .t insert end "times with a bit left on the last line."
2119    update
2120    set scrollInfo "unchanged"
2121    .t mark set insert 3.0
2122    .t tag configure x -background red
2123    .t tag add x 1.0 5.0
2124    update
2125    .t tag delete x
2126    set scrollInfo
2127} {unchanged}
2128test textDisp-19.15 {GetYView procedure} {
2129    .t configure -wrap word
2130    .t delete 1.0 end
2131    .t insert 1.0 "Line 1"
2132    foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2133	.t insert end "\nLine $i"
2134    }
2135    .t insert end "\nThis last line wraps around four "
2136    .t insert end "times with a bit left on the last line."
2137    update
2138    .t configure -yscrollcommand scrollError
2139    proc bgerror args {
2140	global x errorInfo errorCode
2141	set x [list $args $errorInfo $errorCode]
2142    }
2143    .t delete 1.0 end
2144    update
2145    rename bgerror {}
2146    .t configure -yscrollcommand scroll
2147    set x
2148} {{{scrolling error}} {scrolling error
2149    while executing
2150"error "scrolling error""
2151    (procedure "scrollError" line 2)
2152    invoked from within
2153"scrollError 0 1"
2154    (vertical scrolling command executed by text)} NONE}
2155
2156.t delete 1.0 end
2157.t insert end "Line 1"
2158for {set i 2} {$i <= 200} {incr i} {
2159    .t insert end "\nLine $i"
2160}
2161.t configure -wrap word
2162.t delete 50.0 51.0
2163.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2164test textDisp-20.1 {FindDLine} {fonts} {
2165    .t yview 48.0
2166    list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \
2167	    [.t dlineinfo 58.0]
2168} {{} {} {3 16 49 13 10} {}}
2169test textDisp-20.2 {FindDLine} {fonts} {
2170    .t yview 100.0
2171    .t yview -pickplace 53.0
2172    list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.15]
2173} {{} {} {3 3 140 13 10}}
2174test textDisp-20.3 {FindDLine} {fonts} {
2175    .t yview 100.0
2176    .t yview 49.0
2177    list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 57.0]
2178} {{3 16 105 13 10} {3 29 140 13 10} {}}
2179test textDisp-20.4 {FindDLine} {fonts} {
2180    .t yview 100.0
2181    .t yview 42.0
2182    list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
2183} {{3 107 105 13 10} {3 120 140 13 10} {}}
2184.t config -wrap none
2185test textDisp-20.5 {FindDLine} {fonts} {
2186    .t yview 100.0
2187    .t yview 48.0
2188    list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
2189} {{3 29 371 13 10} {3 29 371 13 10} {3 29 371 13 10}}
2190
2191.t config -wrap word
2192test textDisp-21.1 {TkTextPixelIndex} {fonts} {
2193    .t yview 48.0
2194    list [.t index @-10,-10] [.t index @6,6] [.t index @22,6] \
2195	    [.t index @102,6] [.t index @38,55] [.t index @44,67]
2196} {48.0 48.0 48.2 48.7 50.40 50.40}
2197.t insert end \n
2198test textDisp-21.2 {TkTextPixelIndex} {fonts} {
2199    .t yview 195.0
2200    list [.t index @11,70] [.t index @11,84] [.t index @11,102] \
2201	    [.t index @11,1002]
2202} {197.1 198.1 199.1 201.0}
2203test textDisp-21.3 {TkTextPixelIndex, horizontal scrolling} {fonts} {
2204    .t configure -wrap none
2205    .t delete 1.0 end
2206    .t insert end "12345\n"
2207    .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
2208    .t xview scroll 2 units
2209    list [.t index @-5,7] [.t index @5,7] [.t index @33,20]
2210} {1.2 1.2 2.6}
2211
2212.t delete 1.0 end
2213.t insert end "Line 1"
2214for {set i 2} {$i <= 200} {incr i} {
2215    .t insert end "\nLine $i"
2216}
2217.t configure -wrap word
2218.t delete 50.0 51.0
2219.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2220update
2221.t tag add x 50.1
2222test textDisp-22.1 {TkTextCharBbox} {fonts} {
2223    .t config -wrap word
2224    .t yview 48.0
2225    list [.t bbox 47.2] [.t bbox 48.0] [.t bbox 50.5] [.t bbox 50.40] \
2226	    [.t bbox 58.0]
2227} {{} {3 3 7 13} {38 29 7 13} {38 55 7 13} {}}
2228test textDisp-22.2 {TkTextCharBbox} {fonts} {
2229    .t config -wrap none
2230    .t yview 48.0
2231    list [.t bbox 50.5] [.t bbox 50.40] [.t bbox 57.0]
2232} {{38 29 7 13} {} {3 120 7 13}}
2233test textDisp-22.3 {TkTextCharBbox, cut-off lines} {fonts} {
2234    .t config -wrap char
2235    .t yview 10.0
2236    wm geom . ${width}x[expr $height-1]
2237    update
2238    list [.t bbox 19.1] [.t bbox 20.1]
2239} {{10 120 7 13} {10 133 7 3}}
2240test textDisp-22.4 {TkTextCharBbox, cut-off lines} {fonts} {
2241    .t config -wrap char
2242    .t yview 10.0
2243    wm geom . ${width}x[expr $height+1]
2244    update
2245    list [.t bbox 19.1] [.t bbox 20.1]
2246} {{10 120 7 13} {10 133 7 5}}
2247test textDisp-22.5 {TkTextCharBbox, cut-off char} {fonts} {
2248    .t config -wrap none
2249    .t yview 10.0
2250    wm geom . [expr $width-95]x$height
2251    update
2252    .t bbox 15.6
2253} {45 68 7 13}
2254test textDisp-22.6 {TkTextCharBbox, line visible but not char} {fonts} {
2255    .t config -wrap char
2256    .t yview 10.0
2257    .t tag add big 20.2 20.5
2258    wm geom . ${width}x[expr $height+3]
2259    update
2260    list [.t bbox 19.1] [.t bbox 20.1] [.t bbox 20.2]
2261} {{10 120 7 13} {} {17 133 14 7}}
2262wm geom . {}
2263update
2264test textDisp-22.7 {TkTextCharBbox, different character sizes} {fonts} {
2265    .t config -wrap char
2266    .t yview 10.0
2267    .t tag add big 12.2 12.5
2268    update
2269    list [.t bbox 12.1] [.t bbox 12.2]
2270} {{10 41 7 13} {17 29 14 27}}
2271.t tag remove big 1.0 end
2272test textDisp-22.8 {TkTextCharBbox, horizontal scrolling} {fonts} {
2273    .t configure -wrap none
2274    .t delete 1.0 end
2275    .t insert end "12345\n"
2276    .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
2277    .t xview scroll 4 units
2278    list [.t bbox 1.3] [.t bbox 1.4] [.t bbox 2.3] [.t bbox 2.4] \
2279	    [.t bbox 2.23] [.t bbox 2.24]
2280} {{} {3 3 7 13} {} {3 16 7 13} {136 16 7 13} {}}
2281test textDisp-22.9 {TkTextCharBbox, handling of spacing} {fonts} {
2282    .t configure -wrap char
2283    .t delete 1.0 end
2284    .t insert 1.0 "abcdefghijkl\nmnopqrstuvwzyz"
2285    .t tag configure spacing -spacing1 8 -spacing3 2
2286    .t tag add spacing 1.0 end
2287    frame .t.f1 -width 10 -height 4 -bg black
2288    frame .t.f2 -width 10 -height 4 -bg black
2289    frame .t.f3 -width 10 -height 4 -bg black
2290    frame .t.f4 -width 10 -height 4 -bg black
2291    .t window create 1.3 -window .t.f1 -align top
2292    .t window create 1.7 -window .t.f2 -align center
2293    .t window create 2.1 -window .t.f3 -align bottom
2294    .t window create 2.10 -window .t.f4 -align baseline
2295    update
2296    list [.t bbox .t.f1] [.t bbox .t.f2] [.t bbox .t.f3] [.t bbox .t.f4] \
2297	    [.t bbox 1.1] [.t bbox 2.9]
2298} {{24 11 10 4} {55 15 10 4} {10 43 10 4} {76 40 10 4} {10 11 7 13} {69 34 7 13}}
2299.t tag delete spacing
2300
2301.t delete 1.0 end
2302.t insert end "Line 1"
2303for {set i 2} {$i <= 200} {incr i} {
2304    .t insert end "\nLine $i"
2305}
2306.t configure -wrap word
2307.t delete 50.0 51.0
2308.t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2309update
2310test textDisp-23.1 {TkTextDLineInfo} {fonts} {
2311    .t config -wrap word
2312    .t yview 48.0
2313    list [.t dlineinfo 47.3] [.t dlineinfo 48.0] [.t dlineinfo 50.40] \
2314	    [.t dlineinfo 56.0]
2315} {{} {3 3 49 13 10} {3 55 126 13 10} {}}
2316test textDisp-23.2 {TkTextDLineInfo} {fonts} {
2317    .t config -bd 4 -wrap word
2318    update
2319    .t yview 48.0
2320    .t dlineinfo 50.40
2321} {7 59 126 13 10}
2322.t config -bd 0
2323test textDisp-23.3 {TkTextDLineInfo} {fonts} {
2324    .t config -wrap none
2325    update
2326    .t yview 48.0
2327    list [.t dlineinfo 50.40] [.t dlineinfo 57.3]
2328} {{3 29 371 13 10} {3 120 49 13 10}}
2329test textDisp-23.4 {TkTextDLineInfo, cut-off lines} {fonts} {
2330    .t config -wrap char
2331    .t yview 10.0
2332    wm geom . ${width}x[expr $height-1]
2333    update
2334    list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
2335} {{3 120 49 13 10} {3 133 49 3 10}}
2336test textDisp-23.5 {TkTextDLineInfo, cut-off lines} {fonts} {
2337    .t config -wrap char
2338    .t yview 10.0
2339    wm geom . ${width}x[expr $height+1]
2340    update
2341    list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
2342} {{3 120 49 13 10} {3 133 49 5 10}}
2343wm geom . {}
2344update
2345test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {fonts} {
2346    .t config -wrap none
2347    .t delete 1.0 end
2348    .t insert end "First line\n"
2349    .t insert end "Second line is a very long one that doesn't all fit.\n"
2350    .t insert end "Third"
2351    .t xview scroll 6 units
2352    update
2353    list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
2354} {{-39 3 70 13 10} {-39 16 364 13 10} {-39 29 35 13 10}}
2355.t xview moveto 0
2356test textDisp-23.7 {TkTextDLineInfo, centering} {fonts} {
2357    .t config -wrap word
2358    .t delete 1.0 end
2359    .t insert end "First line\n"
2360    .t insert end "Second line is a very long one that doesn't all fit.\n"
2361    .t insert end "Third"
2362    .t tag configure x -justify center
2363    .t tag configure y -justify right
2364    .t tag add x 1.0
2365    .t tag add y 3.0
2366    list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
2367} {{38 3 70 13 10} {3 16 119 13 10} {108 55 35 13 10}}
2368.t tag delete x y
2369
2370test textDisp-24.1 {TkTextCharLayoutProc} {fonts} {
2371    .t configure -wrap char
2372    .t delete 1.0 end
2373    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2374    list [.t bbox 1.19] [.t bbox 1.20]
2375} {{136 3 7 13} {3 16 7 13}}
2376test textDisp-24.2 {TkTextCharLayoutProc} {fonts} {
2377    .t configure -wrap char
2378    .t delete 1.0 end
2379    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2380    wm geom . [expr $width+1]x$height
2381    update
2382    list [.t bbox 1.19] [.t bbox 1.20]
2383} {{136 3 12 13} {3 16 7 13}}
2384test textDisp-24.3 {TkTextCharLayoutProc} {fonts} {
2385    .t configure -wrap char
2386    .t delete 1.0 end
2387    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2388    wm geom . [expr $width-1]x$height
2389    update
2390    list [.t bbox 1.19] [.t bbox 1.20]
2391} {{136 3 10 13} {3 16 7 13}}
2392test textDisp-24.4 {TkTextCharLayoutProc, newline not visible} {fonts} {
2393    .t configure -wrap char
2394    .t delete 1.0 end
2395    .t insert 1.0 01234567890123456789\n012345678901234567890
2396    wm geom . {}
2397    update
2398    list [.t bbox 1.19] [.t bbox 1.20] [.t bbox 2.20]
2399} {{136 3 7 13} {143 3 0 13} {3 29 7 13}}
2400test textDisp-24.5 {TkTextCharLayoutProc, char doesn't fit, newline not visible} {fonts} {
2401    .t configure -wrap char
2402    .t delete 1.0 end
2403    .t insert 1.0 0\n1\n
2404    wm geom . 110x$height
2405    update
2406    list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 2.0]
2407} {{3 3 4 13} {7 3 0 13} {3 16 4 13}}
2408test textDisp-24.6 {TkTextCharLayoutProc, line ends with space} {fonts} {
2409    .t configure -wrap char
2410    .t delete 1.0 end
2411    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2412    wm geom . {}
2413    update
2414    list [.t bbox 1.19] [.t bbox 1.20]
2415} {{136 3 7 13} {3 16 7 13}}
2416test textDisp-24.7 {TkTextCharLayoutProc, line ends with space} {fonts} {
2417    .t configure -wrap char
2418    .t delete 1.0 end
2419    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2420    wm geom . [expr $width+1]x$height
2421    update
2422    list [.t bbox 1.19] [.t bbox 1.20]
2423} {{136 3 12 13} {3 16 7 13}}
2424test textDisp-24.8 {TkTextCharLayoutProc, line ends with space} {fonts} {
2425    .t configure -wrap char
2426    .t delete 1.0 end
2427    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2428    wm geom . [expr $width-1]x$height
2429    update
2430    list [.t bbox 1.19] [.t bbox 1.20]
2431} {{136 3 10 13} {3 16 7 13}}
2432test textDisp-24.9 {TkTextCharLayoutProc, line ends with space} {fonts} {
2433    .t configure -wrap char
2434    .t delete 1.0 end
2435    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2436    wm geom . [expr $width-6]x$height
2437    update
2438    list [.t bbox 1.19] [.t bbox 1.20]
2439} {{136 3 5 13} {3 16 7 13}}
2440test textDisp-24.10 {TkTextCharLayoutProc, line ends with space} {fonts} {
2441    .t configure -wrap char
2442    .t delete 1.0 end
2443    .t insert 1.0 "a b c d e f g h i j k l m n o p"
2444    wm geom . [expr $width-7]x$height
2445    update
2446    list [.t bbox 1.19] [.t bbox 1.20]
2447} {{136 3 4 13} {3 16 7 13}}
2448test textDisp-24.11 {TkTextCharLayoutProc, line ends with space that doesn't quite fit} {fonts} {
2449    .t configure -wrap char
2450    .t delete 1.0 end
2451    .t insert 1.0 "01234567890123456789 \nabcdefg"
2452    wm geom . [expr $width-2]x$height
2453    update
2454    set result {}
2455    lappend result [.t bbox 1.21] [.t bbox 2.0]
2456    .t mark set insert 1.21
2457    lappend result [.t bbox 1.21] [.t bbox 2.0]
2458} {{145 3 0 13} {3 16 7 13} {145 3 0 13} {3 16 7 13}}
2459test textDisp-24.12 {TkTextCharLayoutProc, tab causes wrap} {fonts} {
2460    .t configure -wrap char
2461    .t delete 1.0 end
2462    .t insert 1.0 "abcdefghi"
2463    .t mark set insert 1.4
2464    .t insert insert \t\t\t
2465    list [.t bbox {insert -1c}] [.t bbox insert]
2466} {{115 3 30 13} {3 16 7 13}}
2467test textDisp-24.13 {TkTextCharLayoutProc, -wrap none} {fonts} {
2468    .t configure -wrap none
2469    .t delete 1.0 end
2470    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2471    wm geom . {}
2472    update
2473    list [.t bbox 1.19] [.t bbox 1.20]
2474} {{136 3 7 13} {}}
2475test textDisp-24.14 {TkTextCharLayoutProc, -wrap none} {fonts} {
2476    .t configure -wrap none
2477    .t delete 1.0 end
2478    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2479    wm geom . [expr $width+1]x$height
2480    update
2481    list [.t bbox 1.19] [.t bbox 1.20]
2482} {{136 3 7 13} {143 3 5 13}}
2483test textDisp-24.15 {TkTextCharLayoutProc, -wrap none} {fonts} {
2484    .t configure -wrap none
2485    .t delete 1.0 end
2486    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2487    wm geom . [expr $width-1]x$height
2488    update
2489    list [.t bbox 1.19] [.t bbox 1.20]
2490} {{136 3 7 13} {143 3 3 13}}
2491test textDisp-24.16 {TkTextCharLayoutProc, no chars fit} {fonts} {
2492    .t configure -wrap char
2493    .t delete 1.0 end
2494    .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2495    wm geom . 103x$height
2496    update
2497    list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
2498} {{3 3 1 13} {3 16 1 13} {3 29 1 13}}
2499test textDisp-24.17 {TkTextCharLayoutProc, -wrap word} {fonts} {
2500    .t configure -wrap word
2501    .t delete 1.0 end
2502    .t insert 1.0 "This is a line that wraps around"
2503    wm geom . {}
2504    update
2505    list [.t bbox 1.19] [.t bbox 1.20]
2506} {{136 3 7 13} {3 16 7 13}}
2507test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {fonts} {
2508    .t configure -wrap word
2509    .t delete 1.0 end
2510    .t insert 1.0 "xThis is a line that wraps around"
2511    wm geom . {}
2512    update
2513    list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
2514} {{101 3 7 13} {108 3 35 13} {3 16 7 13}}
2515test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {fonts} {
2516    .t configure -wrap word
2517    .t delete 1.0 end
2518    .t insert 1.0 "xxThis is a line that wraps around"
2519    wm geom . {}
2520    update
2521    list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
2522} {{101 3 7 13} {108 3 7 13} {115 3 28 13}}
2523test textDisp-24.20 {TkTextCharLayoutProc, vertical offset} {fonts} {
2524    .t configure -wrap none
2525    .t delete 1.0 end
2526    .t insert 1.0 "Line 1\nLine 2\nLine 3"
2527    set result {}
2528    lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2529    .t tag configure up -offset 6
2530    .t tag add up 2.1
2531    lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2532    .t tag configure  up -offset -2
2533    lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2534    .t tag delete up
2535    set result
2536} {{10 16 7 13} {3 16 42 13 10} {10 16 7 13} {3 16 42 19 16} {10 18 7 13} {3 16 42 15 10}}
2537.t configure -width 30
2538update
2539test textDisp-24.21 {TkTextCharLayoutProc, word breaks} {fonts} {
2540    .t configure -wrap word
2541    .t delete 1.0 end
2542    .t insert 1.0 "Sample text xxxxxxx yyyyy zzzzzzz qqqqq rrrr ssss tt u vvvvv"
2543    frame .t.f -width 30 -height 20 -bg black
2544    .t window create 1.36 -window .t.f
2545    .t bbox 1.26
2546} {3 19 7 13}
2547test textDisp-24.22 {TkTextCharLayoutProc, word breaks} {fonts} {
2548    .t configure -wrap word
2549    .t delete 1.0 end
2550    frame .t.f -width 30 -height 20 -bg black
2551    .t insert 1.0 "Sample text xxxxxxx yyyyyyy"
2552    .t window create end -window .t.f
2553    .t insert end "zzzzzzz qqqqq rrrr ssss tt u vvvvv"
2554    .t bbox 1.28
2555} {33 19 7 13}
2556test textDisp-24.23 {TkTextCharLayoutProc, word breaks} {fonts} {
2557    .t configure -wrap word
2558    .t delete 1.0 end
2559    frame .t.f -width 30 -height 20 -bg black
2560    .t insert 1.0 "Sample text xxxxxxx yyyyyyy "
2561    .t insert end "zzzzzzz qqqqq rrrr ssss tt"
2562    .t window create end -window .t.f
2563    .t insert end "u vvvvv"
2564    .t bbox .t.f
2565} {3 29 30 20}
2566catch {destroy .t.f}
2567.t configure -width 20
2568update
2569test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} {fonts} {
2570    .t delete 1.0 end
2571    .t tag configure x -justify center
2572    .t insert 1.0 aa\tbb\tcc\tdd\t
2573    .t tag add x 1.0 end
2574    list [.t bbox 1.0] [.t bbox 1.10]
2575} {{45 3 7 13} {94 3 7 13}}
2576
2577.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
2578    -tabs 100
2579update
2580test textDisp-25.1 {CharBboxProc procedure, check tab width} {fonts} {
2581    .t delete 1.0 end
2582    .t insert 1.0 abc\td\tfgh
2583    list [.t bbox 1.3] [.t bbox 1.5] [.t bbox 1.6]
2584} {{21 1 79 13} {107 1 93 13} {200 1 7 13}}
2585
2586.t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
2587	-tabs {}
2588update
2589test textDisp-26.1 {AdjustForTab procedure, no tabs} {fonts} {
2590    .t delete 1.0 end
2591    .t insert 1.0 a\tbcdefghij\tc\td
2592    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
2593	    [lindex [.t bbox 1.14] 0]
2594} {56 168 224}
2595test textDisp-26.2 {AdjustForTab procedure, not enough tabs specified} {
2596    .t delete 1.0 end
2597    .t insert 1.0 a\tb\tc\td
2598    .t tag delete x
2599    .t tag configure x -tabs 40
2600    .t tag add x 1.0 end
2601    list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
2602	    [lindex [.t bbox 1.6] 0]
2603} {40 80 120}
2604test textDisp-26.3 {AdjustForTab procedure, not enough tabs specified} {
2605    .t delete 1.0 end
2606    .t insert 1.0 a\tb\tc\td\te
2607    .t tag delete x
2608    .t tag configure x -tabs {40 70 right}
2609    .t tag add x 1.0 end
2610    list [lindex [.t bbox 1.2] 0] \
2611	    [expr [lindex [.t bbox 1.4] 0] + [lindex [.t bbox 1.4] 2]] \
2612	    [expr [lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]] \
2613	    [expr [lindex [.t bbox 1.8] 0] + [lindex [.t bbox 1.8] 2]]
2614} {40 70 100 130}
2615test textDisp-26.4 {AdjustForTab procedure, different alignments} {
2616    .t delete 1.0 end
2617    .t insert 1.0 a\tbc\tde\tfg\thi
2618    .t tag delete x
2619    .t tag configure x -tabs {40 center 80 left 130 right}
2620    .t tag add x 1.0 end
2621    .t tag add y 1.2
2622    .t tag add y 1.5
2623    .t tag add y 1.8
2624    list [lindex [.t bbox 1.3] 0] [lindex [.t bbox 1.5] 0] \
2625	    [lindex [.t bbox 1.10] 0]
2626} {40 80 130}
2627test textDisp-26.5 {AdjustForTab procedure, numeric alignment} {
2628    .t delete 1.0 end
2629    .t insert 1.0 a\t1.234
2630    .t tag delete x
2631    .t tag configure x -tabs {120 numeric}
2632    .t tag add x 1.0 end
2633    .t tag add y 1.2
2634    .t tag add y 1.5
2635    lindex [.t bbox 1.3] 0
2636} {120}
2637test textDisp-26.6 {AdjustForTab procedure, numeric alignment} {
2638    .t delete 1.0 end
2639    .t insert 1.0 a\t1,456.234
2640    .t tag delete x
2641    .t tag configure x -tabs {120 numeric}
2642    .t tag add x 1.0 end
2643    .t tag add y 1.2
2644    lindex [.t bbox 1.7] 0
2645} {120}
2646test textDisp-26.7 {AdjustForTab procedure, numeric alignment} {
2647    .t delete 1.0 end
2648    .t insert 1.0 a\t1.456.234,7
2649    .t tag delete x
2650    .t tag configure x -tabs {120 numeric}
2651    .t tag add x 1.0 end
2652    .t tag add y 1.2
2653    lindex [.t bbox 1.11] 0
2654} {120}
2655test textDisp-26.8 {AdjustForTab procedure, numeric alignment} {
2656    .t delete 1.0 end
2657    .t insert 1.0 a\ttest
2658    .t tag delete x
2659    .t tag configure x -tabs {120 numeric}
2660    .t tag add x 1.0 end
2661    .t tag add y 1.2
2662    lindex [.t bbox 1.6] 0
2663} {120}
2664test textDisp-26.9 {AdjustForTab procedure, numeric alignment} {
2665    .t delete 1.0 end
2666    .t insert 1.0 a\t1234
2667    .t tag delete x
2668    .t tag configure x -tabs {120 numeric}
2669    .t tag add x 1.0 end
2670    .t tag add y 1.2
2671    lindex [.t bbox 1.6] 0
2672} {120}
2673test textDisp-26.10 {AdjustForTab procedure, numeric alignment} {
2674    .t delete 1.0 end
2675    .t insert 1.0 a\t1.234567
2676    .t tag delete x
2677    .t tag configure x -tabs {120 numeric}
2678    .t tag add x 1.0 end
2679    .t tag add y 1.5
2680    lindex [.t bbox 1.3] 0
2681} {120}
2682test textDisp-26.11 {AdjustForTab procedure, numeric alignment} {
2683    .t delete 1.0 end
2684    .t insert 1.0 a\tx=1.234567
2685    .t tag delete x
2686    .t tag configure x -tabs {120 numeric}
2687    .t tag add x 1.0 end
2688    .t tag add y 1.7
2689    .t tag add y 1.9
2690    lindex [.t bbox 1.5] 0
2691} {120}
2692test textDisp-26.12 {AdjustForTab procedure, adjusting chunks} {
2693    .t delete 1.0 end
2694    .t insert 1.0 a\tx1.234567
2695    .t tag delete x
2696    .t tag configure x -tabs {120 numeric}
2697    .t tag add x 1.0 end
2698    .t tag add y 1.7
2699    .t tag add y 1.9
2700    button .b -text "="
2701    .t window create 1.3 -window .b
2702    update
2703    lindex [.t bbox 1.5] 0
2704} {120}
2705test textDisp-26.13 {AdjustForTab procedure, not enough space} {fonts} {
2706    .t delete 1.0 end
2707    .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
2708    .t tag delete x
2709    .t tag configure x -tabs {10 30 center 50 right 120}
2710    .t tag add x 1.0 end
2711    list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
2712	    [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]
2713} {28 56 84 120}
2714
2715.t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
2716	-wrap char
2717update
2718test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {fonts} {
2719    .t delete 1.0 end
2720    .t insert 1.0 a\tbcdefghij\tc\td
2721    list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]
2722} {{60 5 7 13} {116 5 7 13} {4 18 7 13}}
2723test textDisp-27.2 {SizeOfTab procedure, choosing tabX and alignment} {fonts} {
2724    .t delete 1.0 end
2725    .t insert 1.0 a\tbcd
2726    .t tag delete x
2727    .t tag configure x -tabs 120
2728    .t tag add x 1.0 end
2729    list [.t bbox 1.3] [.t bbox 1.4]
2730} {{131 5 13 13} {4 18 7 13}}
2731test textDisp-27.3 {SizeOfTab procedure, choosing tabX and alignment} {fonts} {
2732    .t delete 1.0 end
2733    .t insert 1.0 a\t\t\tbcd
2734    .t tag delete x
2735    .t tag configure x -tabs 40
2736    .t tag add x 1.0 end
2737    list [.t bbox 1.5] [.t bbox 1.6]
2738} {{131 5 13 13} {4 18 7 13}}
2739test textDisp-27.4 {SizeOfTab procedure, choosing tabX and alignment} {fonts} {
2740    .t delete 1.0 end
2741    .t insert 1.0 a\t\t\tbcd
2742    .t tag delete x
2743    .t tag configure x -tabs {20 center 70 left}
2744    .t tag add x 1.0 end
2745    list [.t bbox 1.5] [.t bbox 1.6]
2746} {{131 5 13 13} {4 18 7 13}}
2747test textDisp-27.5 {SizeOfTab procedure, center alignment} {fonts} {
2748    .t delete 1.0 end
2749    .t insert 1.0 a\txyzzyabc
2750    .t tag delete x
2751    .t tag configure x -tabs {120 center}
2752    .t tag add x 1.0 end
2753    list [.t bbox 1.6] [.t bbox 1.7]
2754} {{135 5 9 13} {4 18 7 13}}
2755test textDisp-27.6 {SizeOfTab procedure, center alignment} {fonts} {
2756    .t delete 1.0 end
2757    .t insert 1.0 a\txyzzyabc
2758    .t tag delete x
2759    .t tag configure x -tabs {150 center}
2760    .t tag add x 1.0 end
2761    list [.t bbox 1.6] [.t bbox 1.7]
2762} {{32 18 7 13} {39 18 7 13}}
2763test textDisp-27.7 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {fonts} {
2764    .t delete 1.0 end
2765    .t configure -tabs {1c 2c center 3c 4c} -wrap none -width 40
2766    .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
2767    update
2768    .t bbox 2.24
2769} {172 18 7 13}
2770.t configure -wrap char -tabs {} -width 20
2771update
2772test textDisp-27.8 {SizeOfTab procedure, right alignment} {fonts} {
2773    .t delete 1.0 end
2774    .t insert 1.0 a\t\txyzzyabc
2775    .t tag delete x
2776    .t tag configure x -tabs {100 left 140 right}
2777    .t tag add x 1.0 end
2778    list [.t bbox 1.6] [.t bbox 1.7]
2779} {{137 5 7 13} {4 18 7 13}}
2780test textDisp-27.9 {SizeOfTab procedure, left alignment} {fonts} {
2781    .t delete 1.0 end
2782    .t insert 1.0 a\txyzzyabc
2783    .t tag delete x
2784    .t tag configure x -tabs {120}
2785    .t tag add x 1.0 end
2786    list [.t bbox 1.3] [.t bbox 1.4]
2787} {{131 5 13 13} {4 18 7 13}}
2788test textDisp-27.10 {SizeOfTab procedure, numeric alignment} {fonts} {
2789    .t delete 1.0 end
2790    .t insert 1.0 a\t123.4
2791    .t tag delete x
2792    .t tag configure x -tabs {120 numeric}
2793    .t tag add x 1.0 end
2794    list [.t bbox 1.3] [.t bbox 1.4]
2795} {{117 5 27 13} {4 18 7 13}}
2796test textDisp-27.11 {SizeOfTab procedure, making tabs at least as wide as a space} {fonts} {
2797    .t delete 1.0 end
2798    .t insert 1.0 abc\tdefghijklmnopqrst
2799    .t tag delete x
2800    .t tag configure x -tabs {120}
2801    .t tag add x 1.0 end
2802    list [.t bbox 1.5] [.t bbox 1.6]
2803} {{131 5 13 13} {4 18 7 13}}
2804
2805proc bizarre_scroll args {
2806    .t2.t delete 5.0 end
2807}
2808test textDisp-28.1 {"yview" option with bizarre scroll command} {
2809    catch {destroy .t2}
2810    toplevel .t2
2811    text .t2.t -width 40 -height 4
2812    .t2.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n"
2813    pack .t2.t
2814    wm geometry .t2 +0+0
2815    update
2816    .t2.t configure -yscrollcommand bizarre_scroll
2817    .t2.t yview 100.0
2818    set result [.t2.t index @0,0]
2819    update
2820    lappend result [.t2.t index @0,0]
2821} {6.0 1.0}
2822
2823test textDisp-29.1 {miscellaneous: lines wrap but are still too long} {fonts} {
2824    catch {destroy .t2}
2825    toplevel .t2
2826    wm geometry .t2 +0+0
2827    text .t2.t -width 20 -height 10 -font $fixedFont \
2828	    -wrap char -xscrollcommand ".t2.s set"
2829    pack .t2.t -side top
2830    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
2831    pack .t2.s -side bottom -fill x
2832    .t2.t insert end 123
2833    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
2834    .t2.t window create 1.1 -window .t2.t.f
2835    update
2836    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
2837} {{0 0.466667} 300x50+5+18 {12 68 7 13}}
2838test textDisp-29.2 {miscellaneous: lines wrap but are still too long} {fonts} {
2839    catch {destroy .t2}
2840    toplevel .t2
2841    wm geometry .t2 +0+0
2842    text .t2.t -width 20 -height 10 -font $fixedFont \
2843	    -wrap char -xscrollcommand ".t2.s set"
2844    pack .t2.t -side top
2845    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
2846    pack .t2.s -side bottom -fill x
2847    .t2.t insert end 123
2848    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
2849    .t2.t window create 1.1 -window .t2.t.f
2850    .t2.t xview scroll 1 unit
2851    update
2852    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
2853} {{0.0233333 0.49} 300x50+-2+18 {5 68 7 13}}
2854test textDisp-29.3 {miscellaneous: lines wrap but are still too long} {fonts} {
2855    catch {destroy .t2}
2856    toplevel .t2
2857    wm geometry .t2 +0+0
2858    text .t2.t -width 20 -height 10 -font $fixedFont \
2859	    -wrap char -xscrollcommand ".t2.s set"
2860    pack .t2.t -side top
2861    scrollbar .t2.s -orient horizontal -command ".t2.t xview"
2862    pack .t2.s -side bottom -fill x
2863    .t2.t insert end 123
2864    frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
2865    .t2.t window create 1.1 -window .t2.t.f
2866    update
2867    .t2.t xview scroll 200 units
2868    update
2869    list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
2870} {{0.536667 1} 300x50+-156+18 {}}
2871
2872test textDisp-33.5 {bold or italic fonts} {winOnly} {
2873    destroy .tt
2874    pack [text .tt -wrap char -font {{MS Sans Serif} 15}]
2875    font create no -family [lindex [.tt cget -font] 0] -size 24
2876    font create bi -family [lindex [.tt cget -font] 0] -size 24
2877    font configure bi -weight bold -slant italic
2878    .tt tag configure bi -font bi
2879    .tt tag configure no -font no
2880    .tt insert end abcd no efgh bi ijkl\n no
2881    update
2882    set bb {}
2883    for {set i 0} {$i < 12} {incr i 4} {
2884	lappend bb [lindex [.tt bbox 1.$i] 0]
2885    }
2886    foreach {a b c} $bb {}
2887    unset bb
2888    if {($b - $a) * 1.5 < ($c - $b)} {
2889	set result "italic font has much too much space"
2890    } else {
2891	set result "italic font measurement ok"
2892    }
2893} {italic font measurement ok}
2894destroy .tt
2895
2896deleteWindows
2897option clear
2898
2899# cleanup
2900::tcltest::cleanupTests
2901return
2902