OSDN Git Service

Merge branch 'master' of git://github.com/monaka/binutils
[pf3gnuchains/pf3gnuchains3x.git] / tk / tests / textDisp.test
1 # This file is a Tcl script to test the code in the file tkTextDisp.c.
2 # This file is organized in the standard fashion for Tcl tests.
3 #
4 # Copyright (c) 1994 The Regents of the University of California.
5 # Copyright (c) 1994-1997 Sun Microsystems, Inc.
6 # Copyright (c) 1998-1999 by Scriptics Corporation.
7 # All rights reserved.
8 #
9 # RCS: @(#) $Id$
10
11 package require tcltest 2.1
12 namespace import -force tcltest::configure
13 namespace import -force tcltest::testsDirectory
14 configure -testdir [file join [pwd] [file dirname [info script]]]
15 configure -loadfile [file join [testsDirectory] constraints.tcl]
16 tcltest::loadTestedCommands
17
18 namespace import -force tcltest::interpreter
19 namespace import -force tcltest::makeFile
20 namespace 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
25 proc scroll args {
26     global scrollInfo
27     set scrollInfo $args
28 }
29
30 # The procedure below is used to generate errors during scrolling commands.
31
32 proc 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
39 option add *Text.borderWidth 2
40 option 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
47 frame .f -width 100 -height 20
48 pack append . .f left
49
50 set fixedFont {Courier -12}
51 set fixedHeight [font metrics $fixedFont -linespace]
52 set fixedWidth [font measure $fixedFont m]
53
54 set varFont {Times -14}
55 set bigFont {Helvetica -24}
56 text .t -font $fixedFont -width 20 -height 10 -yscrollcommand scroll
57 pack append . .t {top expand fill}
58 .t tag configure big -font $bigFont
59 .t debug on
60 wm 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
65 wm withdraw .
66 wm minsize . 1 1
67 wm positionfrom . user
68 wm deiconify .
69 update
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
78 if {([winfo rooty .] < 50) || ([winfo rootx .] < 50)} {
79     wm geom . +50+50
80 }
81 test 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
101 test 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
117 test 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]]
123 test 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}}
129 test 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}}
135 test 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}}
141 test 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}}
147 test 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}}
153 test 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}}
161 foreach m [.t mark names] {
162     catch {.t mark unset $m}
163 }
164 scan [wm geom .] %dx%d width height
165 test 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}}
174 wm geom . {}
175 update
176 test 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}}
182 test 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}}
192 test 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}}
198 test 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}}
207 test 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}}
216 test 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}}
227 test 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}}
238 test 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}}
247 test 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}}
255 test 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
269 test 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}}
277 test 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}}
288 test 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
298 test 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
325 test 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
357 test 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}
367 test 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}
378 test 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}
389 test 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}
397 test 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}
402 test 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}
407 test 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
413 test 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
425 test 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}
434 test 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}}
444 test 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
454 test 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}}
461 test 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}}
470 test 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}
494 catch {destroy .f2}
495 .t configure -borderwidth 0 -wrap char
496 wm geom . {}
497 update
498 test 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}}
520 test 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}}
529 test 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}}
537 test 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}}
546 test 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}}
555 test 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
575 test 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}}
583 test 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}}
591 test 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}}
599 test 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}}
607 test 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} {}}
618 test 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}}
628 test 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}}
639 test 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}}
651 test 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 } {{} {}}
662 test 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}}
672 test 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
683 test 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
707 test 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
717 test 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}}
728 test 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}}
739 test 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}}
752 test 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}}
765 test 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}}
780 test 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
798 test 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}
804 test 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
817 test 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"
836 foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
837     .t insert end "\nLine $i"
838 }
839 test 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}}
847 test 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}}
855 test 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}}
863 test 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}}
872 test 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}}
881 test 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}}
890 test 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}}
899 test 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
912 test 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
925 test 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}}
936 test 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}
947 test 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}}
958 test 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}}
969 test 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}}
980 test 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}}
991 test 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}
1002 test 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}}
1013 test 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}
1023 test 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
1035 test 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}}
1044 test 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}}
1053 test 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}
1063 test 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}
1073 test 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}}
1083 test 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}}
1093 test 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}
1103 test 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}
1113 test 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}
1123 test 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}
1134 test 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
1145 test 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]
1155 test 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}
1167 catch {destroy .top}
1168
1169 .t delete 1.0 end
1170 .t insert end "Line 1"
1171 for {set i 2} {$i <= 200} {incr i} {
1172     .t insert end "\nLine $i"
1173 }
1174 update
1175 test textDisp-11.1 {TkTextSetYView} {
1176     .t yview 30.0
1177     update
1178     .t index @0,0
1179 } {30.0}
1180 test 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}}
1187 test 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}}
1194 test 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}
1201 test 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 {}}
1209 test 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}}
1217 test 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}}
1225 test 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}}
1233 test 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}}
1241 test 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}}
1249 test 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}}
1257 test 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
1267 test 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}}
1288 catch {destroy .top}
1289 toplevel .top
1290 wm geometry .top +0+0
1291 text .top.t -width 30 -height 3
1292 pack .top.t
1293 .top.t insert end "Line 1"
1294 for {set i 2} {$i <= 20} {incr i} {
1295     .top.t insert end "\nLine $i"
1296 }
1297 update
1298 test 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}
1304 test 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}
1310 test 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}
1316 test 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}
1322 destroy .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"
1327 test 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}
1334 test 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}
1341 test 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
1349 test 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}
1356 test 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
1366 for {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.}
1371 test textDisp-13.1 {TkTextSeeCmd procedure} {
1372     list [catch {.t see} msg] $msg
1373 } {1 {wrong # args: should be ".t see index"}}
1374 test textDisp-13.2 {TkTextSeeCmd procedure} {
1375     list [catch {.t see a b} msg] $msg
1376 } {1 {wrong # args: should be ".t see index"}}
1377 test textDisp-13.3 {TkTextSeeCmd procedure} {
1378     list [catch {.t see badIndex} msg] $msg
1379 } {1 {bad text index "badIndex"}}
1380 test 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}
1387 test 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}
1395 test 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}
1405 test 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}}
1420 test 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}}
1435 test 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}}
1451 wm geom . {}
1452
1453 .t configure -wrap none
1454 test textDisp-14.1 {TkTextXviewCmd procedure} {
1455     .t delete 1.0 end
1456     update
1457     .t insert end xxxxxxxxx\n
1458     .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1459     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1460     .t xview moveto .5
1461     .t xview
1462 } {0.5 0.857143}
1463 .t configure -wrap char
1464 test textDisp-14.2 {TkTextXviewCmd procedure} {
1465     .t delete 1.0 end
1466     update
1467     .t insert end xxxxxxxxx\n
1468     .t insert end "xxxxx\n"
1469     .t insert end "xxxx"
1470     .t xview
1471 } {0 1}
1472 .t configure -wrap none
1473 test textDisp-14.3 {TkTextXviewCmd procedure} {
1474     .t delete 1.0 end
1475     update
1476     .t insert end xxxxxxxxx\n
1477     .t insert end "xxxxx\n"
1478     .t insert end "xxxx"
1479     .t xview
1480 } {0 1}
1481 test textDisp-14.4 {TkTextXviewCmd procedure} {
1482     list [catch {.t xview moveto} msg] $msg
1483 } {1 {wrong # args: should be ".t xview moveto fraction"}}
1484 test textDisp-14.5 {TkTextXviewCmd procedure} {
1485     list [catch {.t xview moveto a b} msg] $msg
1486 } {1 {wrong # args: should be ".t xview moveto fraction"}}
1487 test textDisp-14.6 {TkTextXviewCmd procedure} {
1488     list [catch {.t xview moveto a} msg] $msg
1489 } {1 {expected floating-point number but got "a"}}
1490 test textDisp-14.7 {TkTextXviewCmd procedure} {
1491     .t delete 1.0 end
1492     .t insert end xxxxxxxxx\n
1493     .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1494     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1495     .t xview moveto .3
1496     .t xview
1497 } {0.303571 0.660714}
1498 test textDisp-14.8 {TkTextXviewCmd procedure} {
1499     .t delete 1.0 end
1500     .t insert end xxxxxxxxx\n
1501     .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1502     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1503     .t xview moveto -.4
1504     .t xview
1505 } {0 0.357143}
1506 test textDisp-14.9 {TkTextXviewCmd procedure} {
1507     .t delete 1.0 end
1508     .t insert end xxxxxxxxx\n
1509     .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1510     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1511     .t xview m 1.4
1512     .t xview
1513 } {0.642857 1}
1514 test textDisp-14.10 {TkTextXviewCmd procedure} {
1515     list [catch {.t xview scroll a} msg] $msg
1516 } {1 {wrong # args: should be ".t xview scroll number units|pages"}}
1517 test textDisp-14.11 {TkTextXviewCmd procedure} {
1518     list [catch {.t xview scroll a b c} msg] $msg
1519 } {1 {wrong # args: should be ".t xview scroll number units|pages"}}
1520 test textDisp-14.12 {TkTextXviewCmd procedure} {
1521     list [catch {.t xview scroll gorp units} msg] $msg
1522 } {1 {expected integer but got "gorp"}}
1523 test textDisp-14.13 {TkTextXviewCmd procedure} {
1524     .t delete 1.0 end
1525     .t insert end xxxxxxxxx\n
1526     .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"
1527     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1528     .t xview moveto 0
1529     .t xview scroll 2 p
1530     set x [.t index @0,22]
1531     .t xview scroll -1 p
1532     lappend x [.t index @0,22]
1533     .t xview scroll -2 pages
1534     lappend x [.t index @0,22]
1535 } {2.36 2.18 2.0}
1536 test textDisp-14.14 {TkTextXviewCmd procedure} {
1537     .t delete 1.0 end
1538     .t insert end xxxxxxxxx\n
1539     .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"
1540     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1541     .t xview moveto 0
1542     .t xview scroll 21 u  
1543     set x [.t index @0,22]
1544     .t xview scroll -1 u
1545     lappend x [.t index @0,22]
1546     .t xview scroll 100 units
1547     lappend x [.t index @0,22]
1548     .t xview scroll -15 units
1549     lappend x [.t index @0,22]
1550 } {2.21 2.20 2.99 2.84}
1551 test textDisp-14.15 {TkTextXviewCmd procedure} {
1552     list [catch {.t xview scroll 14 globs} msg] $msg
1553 } {1 {bad argument "globs": must be units or pages}}
1554 test textDisp-14.16 {TkTextXviewCmd procedure} {
1555     list [catch {.t xview flounder} msg] $msg
1556 } {1 {unknown option "flounder": must be moveto or scroll}}
1557
1558 .t configure -wrap char
1559 .t delete 1.0 end
1560 for {set i 1} {$i < 99} {incr i} {
1561     .t insert end "Line $i\n"
1562 }
1563 .t insert end "Line 100"
1564 .t delete 50.0 51.0
1565 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
1566 test textDisp-15.1 {ScrollByLines procedure, scrolling backwards} {
1567     .t yview 45.0
1568     update
1569     .t yview scroll -3 units
1570     .t index @0,0
1571 } {42.0}
1572 test textDisp-15.2 {ScrollByLines procedure, scrolling backwards} {
1573     .t yview 51.0
1574     update
1575     .t yview scroll -2 units
1576     .t index @0,0
1577 } {50.20}
1578 test textDisp-15.3 {ScrollByLines procedure, scrolling backwards} {
1579     .t yview 51.0
1580     update
1581     .t yview scroll -4 units
1582     .t index @0,0
1583 } {49.0}
1584 test textDisp-15.4 {ScrollByLines procedure, scrolling backwards} {
1585     .t yview 50.20
1586     update
1587     .t yview scroll -2 units
1588     .t index @0,0
1589 } {49.0}
1590 test textDisp-15.5 {ScrollByLines procedure, scrolling backwards} {
1591     .t yview 50.40
1592     update
1593     .t yview scroll -2 units
1594     .t index @0,0
1595 } {50.0}
1596 test textDisp-15.6 {ScrollByLines procedure, scrolling backwards} {
1597     .t yview 3.2
1598     update
1599     .t yview scroll -5 units
1600     .t index @0,0
1601 } {1.0}
1602 test textDisp-15.7 {ScrollByLines procedure, scrolling forwards} {
1603     .t yview 48.0
1604     update
1605     .t yview scroll 4 units
1606     .t index @0,0
1607 } {50.40}
1608
1609 .t configure -wrap char
1610 .t delete 1.0 end
1611 .t insert insert "Line 1"
1612 for {set i 2} {$i <= 200} {incr i} {
1613     .t insert end "\nLine $i"
1614 }
1615 .t tag add big 100.0 105.0
1616 .t insert 151.end { has a lot of extra text, so that it wraps around on the screen several times over.}
1617 .t insert 153.end { also has enoug extra text to wrap.}
1618 update
1619 test textDisp-16.1 {TkTextYviewCmd procedure} {
1620     .t yview 21.0
1621     set x [.t yview]
1622     .t yview 1.0
1623     set x
1624 } {0.1 0.15}
1625 test textDisp-16.2 {TkTextYviewCmd procedure} {
1626     list [catch {.t yview 2 3} msg] $msg
1627 } {1 {unknown option "2": must be moveto or scroll}}
1628 test textDisp-16.3 {TkTextYviewCmd procedure} {
1629     list [catch {.t yview -pickplace} msg] $msg
1630 } {1 {wrong # args: should be ".t yview -pickplace lineNum|index"}}
1631 test textDisp-16.4 {TkTextYviewCmd procedure} {
1632     list [catch {.t yview -pickplace 2 3} msg] $msg
1633 } {1 {wrong # args: should be ".t yview -pickplace lineNum|index"}}
1634 test textDisp-16.5 {TkTextYviewCmd procedure} {
1635     list [catch {.t yview -bogus 2} msg] $msg
1636 } {1 {unknown option "-bogus": must be moveto or scroll}}
1637 test textDisp-16.6 {TkTextYviewCmd procedure, integer position} {
1638     .t yview 100.0
1639     update
1640     .t yview 98
1641     .t index @0,0
1642 } {99.0}
1643 test textDisp-16.7 {TkTextYviewCmd procedure} {
1644     .t yview 2.0
1645     .t yv -pickplace 13.0
1646     .t index @0,0
1647 } {4.0}
1648 test textDisp-16.8 {TkTextYviewCmd procedure} {
1649     list [catch {.t yview bad_mark_name} msg] $msg
1650 } {1 {bad text index "bad_mark_name"}}
1651 test textDisp-16.9 {TkTextYviewCmd procedure, "moveto" option} {
1652     list [catch {.t yview moveto a b} msg] $msg
1653 } {1 {wrong # args: should be ".t yview moveto fraction"}}
1654 test textDisp-16.10 {TkTextYviewCmd procedure, "moveto" option} {
1655     list [catch {.t yview moveto gorp} msg] $msg
1656 } {1 {expected floating-point number but got "gorp"}}
1657 test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} {
1658     .t yview moveto 0.5
1659     .t index @0,0
1660 } {101.0}
1661 test textDisp-16.12 {TkTextYviewCmd procedure, "moveto" option} {
1662     .t yview moveto -1
1663     .t index @0,0
1664 } {1.0}
1665 test textDisp-16.13 {TkTextYviewCmd procedure, "moveto" option} {
1666     .t yview moveto 1.1
1667     .t index @0,0
1668 } {191.0}
1669 test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} {
1670     .t yview moveto .75
1671     .t index @0,0
1672 } {151.0}
1673 test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} {
1674     .t yview moveto .752
1675     .t index @0,0
1676 } {151.20}
1677 test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} {
1678     .t yview moveto .754
1679     .t index @0,0
1680 } {151.60}
1681 test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} {
1682     .t yview moveto .755
1683     .t index @0,0
1684 } {152.0}
1685 test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {fonts} {
1686     catch {destroy .top1}
1687     toplevel .top1
1688     wm geometry .top1 +0+0
1689     text .top1.t -height 3 -width 4 -wrap none -setgrid 1 -padx 6 \
1690         -spacing3 6
1691     .top1.t insert end "1\n2\n3\n4\n5\n6"
1692     pack .top1.t
1693     update
1694     .top1.t yview moveto 0.3333
1695     set result [.top1.t yview]
1696     destroy .top1
1697     set result
1698 } {0.333333 0.833333}
1699 test textDisp-16.19 {TkTextYviewCmd procedure, "scroll" option} {
1700     list [catch {.t yview scroll a} msg] $msg
1701 } {1 {wrong # args: should be ".t yview scroll number units|pages"}}
1702 test textDisp-16.20 {TkTextYviewCmd procedure, "scroll" option} {
1703     list [catch {.t yview scroll a b c} msg] $msg
1704 } {1 {wrong # args: should be ".t yview scroll number units|pages"}}
1705 test textDisp-16.21 {TkTextYviewCmd procedure, "scroll" option} {
1706     list [catch {.t yview scroll badInt bogus} msg] $msg
1707 } {1 {expected integer but got "badInt"}}
1708 test textDisp-16.22 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1709     .t yview 50.0
1710     update
1711     .t yview scroll -1 pages
1712     .t index @0,0
1713 } {42.0}
1714 test textDisp-16.23 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1715     .t yview 50.0
1716     update
1717     .t yview scroll -3 p
1718     .t index @0,0
1719 } {26.0}
1720 test textDisp-16.24 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1721     .t yview 5.0
1722     update
1723     .t yview scroll -3 p
1724     .t index @0,0
1725 } {1.0}
1726 test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1727     .t configure -height 1
1728     update
1729     .t yview 50.0
1730     update
1731     .t yview scroll -1 pages
1732     set x [.t index @0,0]
1733     .t configure -height 10
1734     update
1735     set x
1736 } {49.0}
1737 test textDisp-16.26 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1738     .t yview 50.0
1739     update
1740     .t yview scroll 1 pages
1741     .t index @0,0
1742 } {58.0}
1743 test textDisp-16.27 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1744     .t yview 50.0
1745     update
1746     .t yview scroll 2 pages
1747     .t index @0,0
1748 } {66.0}
1749 test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {fonts} {
1750     .t yview 98.0
1751     update
1752     .t yview scroll 1 page
1753     .t index @0,0
1754 } {103.0}
1755 test textDisp-16.29 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1756     .t configure -height 1
1757     update
1758     .t yview 50.0
1759     update
1760     .t yview scroll 1 pages
1761     set x [.t index @0,0]
1762     .t configure -height 10
1763     update
1764     set x
1765 } {51.0}
1766 test textDisp-16.30 {TkTextYviewCmd procedure, "scroll units" option} {
1767     .t yview 45.0
1768     update
1769     .t yview scroll -3 units
1770     .t index @0,0
1771 } {42.0}
1772 test textDisp-16.31 {TkTextYviewCmd procedure, "scroll units" option} {
1773     .t yview 149.0
1774     update
1775     .t yview scroll 4 units
1776     .t index @0,0
1777 } {151.40}
1778 test textDisp-16.32 {TkTextYviewCmd procedure} {
1779     list [catch {.t yview scroll 12 bogoids} msg] $msg
1780 } {1 {bad argument "bogoids": must be units or pages}}
1781 test textDisp-16.33 {TkTextYviewCmd procedure} {
1782     list [catch {.t yview bad_arg 1 2} msg] $msg
1783 } {1 {unknown option "bad_arg": must be moveto or scroll}}
1784
1785 .t delete 1.0 end
1786 foreach 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} {
1787     .t insert end "\nLine $i 11111 $i 22222 $i 33333 $i 44444 $i 55555"
1788     .t insert end " $i 66666 $i 77777 $i 88888 $i"
1789 }
1790 .t configure -wrap none
1791 test textDisp-17.1 {TkTextScanCmd procedure} {
1792     list [catch {.t scan a b} msg] $msg
1793 } {1 {wrong # args: should be ".t scan mark x y" or ".t scan dragto x y ?gain?"}}
1794 test textDisp-17.2 {TkTextScanCmd procedure} {
1795     list [catch {.t scan a b c d} msg] $msg
1796 } {1 {expected integer but got "b"}}
1797 test textDisp-17.3 {TkTextScanCmd procedure} {
1798     list [catch {.t scan stupid b 20} msg] $msg
1799 } {1 {expected integer but got "b"}}
1800 test textDisp-17.4 {TkTextScanCmd procedure} {
1801     list [catch {.t scan stupid -2 bogus} msg] $msg
1802 } {1 {expected integer but got "bogus"}}
1803 test textDisp-17.5 {TkTextScanCmd procedure} {
1804     list [catch {.t scan stupid 123 456} msg] $msg
1805 } {1 {bad scan option "stupid": must be mark or dragto}}
1806 test textDisp-17.6 {TkTextScanCmd procedure} {fonts} {
1807     .t yview 1.0
1808     .t xview moveto 0
1809     .t scan mark 40 60
1810     .t scan dragto 35 55
1811     .t index @0,0
1812 } {4.7}
1813 test textDisp-17.7 {TkTextScanCmd procedure} {fonts} {
1814     .t yview 10.0
1815     .t xview moveto 0
1816     .t xview scroll 20 units
1817     .t scan mark -10 60
1818     .t scan dragto -5 65
1819     .t index @0,0
1820     set x [.t index @0,0]
1821     .t scan dragto 0 70
1822     list $x [.t index @0,0]
1823 } {7.13 3.6}
1824 test textDisp-17.8 {TkTextScanCmd procedure} {fonts} {
1825     .t yview 1.0
1826     .t xview moveto 0
1827     .t scan mark 0 60
1828     .t scan dragto 30 100
1829     .t scan dragto 25 95 
1830     .t index @0,0
1831 } {4.7}
1832 test textDisp-17.9 {TkTextScanCmd procedure} {fonts} {
1833     .t yview end
1834     .t xview moveto 0
1835     .t xview scroll 100 units
1836     .t scan mark 90 60
1837     .t scan dragto 10 0
1838     .t scan dragto 15 5
1839     .t index @0,0
1840 } {18.44}
1841 .t configure -wrap word
1842 test textDisp-17.10 {TkTextScanCmd procedure, word wrapping} {fonts} {
1843     .t yview 10.0
1844     .t scan mark -10 60
1845     .t scan dragto -5 65
1846     set x [.t index @0,0]
1847     .t scan dragto 0 70
1848     list $x [.t index @0,0]
1849 } {9.31 8.47}
1850
1851 .t configure -xscrollcommand scroll -yscrollcommand {}
1852 test textDisp-18.1 {GetXView procedure} {
1853     .t configure -wrap none
1854     .t delete 1.0 end
1855     .t insert end xxxxxxxxx\n
1856     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1857     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1858     update
1859     set scrollInfo
1860 } {0 0.363636}
1861 test textDisp-18.2 {GetXView procedure} {
1862     .t configure -wrap char
1863     .t delete 1.0 end
1864     .t insert end xxxxxxxxx\n
1865     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1866     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1867     update
1868     set scrollInfo
1869 } {0 1}
1870 test textDisp-18.3 {GetXView procedure} {
1871     .t configure -wrap none
1872     .t delete 1.0 end
1873     update
1874     set scrollInfo
1875 } {0 1}
1876 test textDisp-18.4 {GetXView procedure} {
1877     .t configure -wrap none
1878     .t delete 1.0 end
1879     .t insert end xxxxxxxxx\n
1880     .t insert end xxxxxx\n
1881     .t insert end xxxxxxxxxxxxxxxxx
1882     update
1883     set scrollInfo
1884 } {0 1}
1885 test textDisp-18.5 {GetXView procedure} {
1886     .t configure -wrap none
1887     .t delete 1.0 end
1888     .t insert end xxxxxxxxx\n
1889     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1890     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1891     .t xview scroll 31 units
1892     update
1893     set scrollInfo
1894 } {0.563636 0.927273}
1895 test textDisp-18.6 {GetXView procedure} {
1896     .t configure -wrap none
1897     .t delete 1.0 end
1898     .t insert end xxxxxxxxx\n
1899     .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1900     .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1901     .t xview moveto 0
1902     .t xview scroll 31 units
1903     update
1904     set x {}
1905     lappend x $scrollInfo
1906     .t configure -wrap char
1907     update
1908     lappend x $scrollInfo
1909     .t configure -wrap word
1910     update
1911     lappend x $scrollInfo
1912     .t configure -wrap none
1913     update
1914     lappend x $scrollInfo
1915 } {{0.553571 0.910714} {0 1} {0 1} {0 0.357143}}
1916 test textDisp-18.7 {GetXView procedure} {
1917     .t configure -wrap none
1918     .t delete 1.0 end
1919     update
1920     set scrollInfo unchanged
1921     .t insert end xxxxxx\n
1922     .t insert end xxx
1923     update
1924     set scrollInfo
1925 } {unchanged}
1926 test textDisp-18.8 {GetXView procedure} {
1927     proc bgerror msg {
1928         global x errorInfo
1929         set x [list $msg $errorInfo]
1930     }
1931     proc bogus args {
1932         error "bogus scroll proc"
1933     }
1934     .t configure -wrap none
1935     .t delete 1.0 end
1936     .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1937     update
1938     .t delete 1.0 end
1939     .t configure -xscrollcommand scrollError
1940     update
1941     set x
1942 } {{scrolling error} {scrolling error
1943     while executing
1944 "error "scrolling error""
1945     (procedure "scrollError" line 2)
1946     invoked from within
1947 "scrollError 0 1"
1948     (horizontal scrolling command executed by text)}}
1949 catch {rename bgerror {}}
1950 catch {rename bogus {}}
1951 .t configure -xscrollcommand {} -yscrollcommand scroll
1952
1953 .t configure -xscrollcommand {} -yscrollcommand scroll
1954 test textDisp-19.1 {GetYView procedure} {
1955     .t configure -wrap char
1956     .t delete 1.0 end
1957     update
1958     set scrollInfo
1959 } {0 1}
1960 test textDisp-19.2 {GetYView procedure} {
1961     .t configure -wrap char
1962     .t delete 1.0 end
1963     update
1964     set scrollInfo "unchanged"
1965     .t insert 1.0 "Line1\nLine2"
1966     update
1967     set scrollInfo
1968 } {unchanged}
1969 test textDisp-19.3 {GetYView procedure} {
1970     .t configure -wrap char
1971     .t delete 1.0 end
1972     update
1973     set scrollInfo "unchanged"
1974     .t insert 1.0 "Line 1\nLine 2 is so long that it wraps around\nLine 3"
1975     update
1976     set scrollInfo
1977 } {unchanged}
1978 test textDisp-19.4 {GetYView procedure} {
1979     .t configure -wrap char
1980     .t delete 1.0 end
1981     .t insert 1.0 "Line 1"
1982     update
1983     set scrollInfo "unchanged"
1984     foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
1985         .t insert end "\nLine $i"
1986     }
1987     update
1988     set scrollInfo
1989 } {0 0.769231}
1990 test textDisp-19.5 {GetYView procedure} {
1991     .t configure -wrap char
1992     .t delete 1.0 end
1993     .t insert 1.0 "Line 1"
1994     foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
1995         .t insert end "\nLine $i"
1996     }
1997     .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
1998     update
1999     set x $scrollInfo
2000 } {0 0.538462}
2001 test textDisp-19.6 {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     .t yview 4.0
2010     update
2011     set x $scrollInfo
2012 } {0.230769 1}
2013 test textDisp-19.7 {GetYView procedure} {
2014     .t configure -wrap char
2015     .t delete 1.0 end
2016     .t insert 1.0 "Line 1"
2017     foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2018         .t insert end "\nLine $i"
2019     }
2020     .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2021     .t yview 2.26
2022     update
2023     set x $scrollInfo
2024 } {0.097166 0.692308}
2025 test textDisp-19.8 {GetYView procedure} {
2026     .t configure -wrap char
2027     .t delete 1.0 end
2028     .t insert 1.0 "Line 1"
2029     foreach i {2 3 4 5 6 7 8 9 10 11 12 13} {
2030         .t insert end "\nLine $i"
2031     }
2032     .t insert 10.end " is really quite long; in fact it's so long that it wraps three times"
2033     .t yview 2.0
2034     update
2035     set x $scrollInfo
2036 } {0.0769231 0.732268}
2037 test textDisp-19.9 {GetYView procedure} {
2038     .t configure -wrap char
2039     .t delete 1.0 end
2040     .t insert 1.0 "Line 1"
2041     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2042         .t insert end "\nLine $i"
2043     }
2044     .t yview 3.0
2045     update
2046     set scrollInfo
2047 } {0.133333 0.8}
2048 test textDisp-19.10 {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 11.0
2056     update
2057     set scrollInfo
2058 } {0.333333 1}
2059 test textDisp-19.11 {GetYView procedure} {
2060     .t configure -wrap word
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 insert end "\nThis last line wraps around four "
2067     .t insert end "times with a bit left on the last line."
2068     .t yview insert
2069     update
2070     set scrollInfo
2071 } {0.625 1}
2072 test textDisp-19.12 {GetYView procedure, partially visible last line} {
2073     catch {destroy .top}
2074     toplevel .top
2075     wm geometry .top +0+0
2076     text .top.t -width 40 -height 5
2077     pack .top.t -expand yes -fill both
2078     .top.t insert end "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
2079     update
2080     scan [wm geom .top] %dx%d twidth theight
2081     wm geom .top ${twidth}x[expr $theight - 3]
2082     update
2083     .top.t yview
2084 } {0 0.8}
2085 test textDisp-19.13 {GetYView procedure, partially visible last line} {fonts} {
2086     catch {destroy .top}
2087     toplevel .top
2088     wm geometry .top +0+0
2089     text .top.t -width 40 -height 5
2090     pack .top.t -expand yes -fill both
2091     .top.t insert end "Line 1\nLine 2\nLine 3\nLine 4 has enough text to wrap around at least once"
2092     update
2093     scan [wm geom .top] %dx%d twidth theight
2094     wm geom .top ${twidth}x[expr $theight - 3]
2095     update
2096     .top.t yview
2097 } {0 0.942308}
2098 catch {destroy .top}
2099 test textDisp-19.14 {GetYView procedure} {
2100     .t configure -wrap word
2101     .t delete 1.0 end
2102     .t insert 1.0 "Line 1"
2103     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2104         .t insert end "\nLine $i"
2105     }
2106     .t insert end "\nThis last line wraps around four "
2107     .t insert end "times with a bit left on the last line."
2108     update
2109     set scrollInfo "unchanged"
2110     .t mark set insert 3.0
2111     .t tag configure x -background red
2112     .t tag add x 1.0 5.0
2113     update
2114     .t tag delete x
2115     set scrollInfo
2116 } {unchanged}
2117 test textDisp-19.15 {GetYView procedure} {
2118     .t configure -wrap word
2119     .t delete 1.0 end
2120     .t insert 1.0 "Line 1"
2121     foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
2122         .t insert end "\nLine $i"
2123     }
2124     .t insert end "\nThis last line wraps around four "
2125     .t insert end "times with a bit left on the last line."
2126     update
2127     .t configure -yscrollcommand scrollError
2128     proc bgerror args {
2129         global x errorInfo errorCode
2130         set x [list $args $errorInfo $errorCode]
2131     }
2132     .t delete 1.0 end
2133     update
2134     rename bgerror {}
2135     .t configure -yscrollcommand scroll
2136     set x
2137 } {{{scrolling error}} {scrolling error
2138     while executing
2139 "error "scrolling error""
2140     (procedure "scrollError" line 2)
2141     invoked from within
2142 "scrollError 0 1"
2143     (vertical scrolling command executed by text)} NONE}
2144
2145 .t delete 1.0 end
2146 .t insert end "Line 1"
2147 for {set i 2} {$i <= 200} {incr i} {
2148     .t insert end "\nLine $i"
2149 }
2150 .t configure -wrap word
2151 .t delete 50.0 51.0
2152 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2153 test textDisp-20.1 {FindDLine} {fonts} {
2154     .t yview 48.0
2155     list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \
2156             [.t dlineinfo 58.0]
2157 } {{} {} {3 16 49 13 10} {}}
2158 test textDisp-20.2 {FindDLine} {fonts} {
2159     .t yview 100.0
2160     .t yview -pickplace 53.0
2161     list [.t dlineinfo 50.0] [.t dlineinfo 50.14] [.t dlineinfo 50.15]
2162 } {{} {} {3 3 140 13 10}}
2163 test textDisp-20.3 {FindDLine} {fonts} {
2164     .t yview 100.0
2165     .t yview 49.0
2166     list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 57.0]
2167 } {{3 16 105 13 10} {3 29 140 13 10} {}}
2168 test textDisp-20.4 {FindDLine} {fonts} {
2169     .t yview 100.0
2170     .t yview 42.0
2171     list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
2172 } {{3 107 105 13 10} {3 120 140 13 10} {}}
2173 .t config -wrap none
2174 test textDisp-20.5 {FindDLine} {fonts} {
2175     .t yview 100.0
2176     .t yview 48.0
2177     list [.t dlineinfo 50.0] [.t dlineinfo 50.20] [.t dlineinfo 50.40]
2178 } {{3 29 371 13 10} {3 29 371 13 10} {3 29 371 13 10}}
2179
2180 .t config -wrap word
2181 test textDisp-21.1 {TkTextPixelIndex} {fonts} {
2182     .t yview 48.0
2183     list [.t index @-10,-10] [.t index @6,6] [.t index @22,6] \
2184             [.t index @102,6] [.t index @38,55] [.t index @44,67]
2185 } {48.0 48.0 48.2 48.7 50.40 50.40}
2186 .t insert end \n
2187 test textDisp-21.2 {TkTextPixelIndex} {fonts} {
2188     .t yview 195.0
2189     list [.t index @11,70] [.t index @11,84] [.t index @11,102] \
2190             [.t index @11,1002]
2191 } {197.1 198.1 199.1 201.0}
2192 test textDisp-21.3 {TkTextPixelIndex, horizontal scrolling} {fonts} {
2193     .t configure -wrap none
2194     .t delete 1.0 end
2195     .t insert end "12345\n"
2196     .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
2197     .t xview scroll 2 units
2198     list [.t index @-5,7] [.t index @5,7] [.t index @33,20]
2199 } {1.2 1.2 2.6}
2200
2201 .t delete 1.0 end
2202 .t insert end "Line 1"
2203 for {set i 2} {$i <= 200} {incr i} {
2204     .t insert end "\nLine $i"
2205 }
2206 .t configure -wrap word
2207 .t delete 50.0 51.0
2208 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2209 update
2210 .t tag add x 50.1
2211 test textDisp-22.1 {TkTextCharBbox} {fonts} {
2212     .t config -wrap word
2213     .t yview 48.0
2214     list [.t bbox 47.2] [.t bbox 48.0] [.t bbox 50.5] [.t bbox 50.40] \
2215             [.t bbox 58.0]
2216 } {{} {3 3 7 13} {38 29 7 13} {38 55 7 13} {}}
2217 test textDisp-22.2 {TkTextCharBbox} {fonts} {
2218     .t config -wrap none
2219     .t yview 48.0
2220     list [.t bbox 50.5] [.t bbox 50.40] [.t bbox 57.0]
2221 } {{38 29 7 13} {} {3 120 7 13}}
2222 test textDisp-22.3 {TkTextCharBbox, cut-off lines} {fonts} {
2223     .t config -wrap char
2224     .t yview 10.0
2225     wm geom . ${width}x[expr $height-1]
2226     update
2227     list [.t bbox 19.1] [.t bbox 20.1]
2228 } {{10 120 7 13} {10 133 7 3}}
2229 test textDisp-22.4 {TkTextCharBbox, cut-off lines} {fonts} {
2230     .t config -wrap char
2231     .t yview 10.0
2232     wm geom . ${width}x[expr $height+1]
2233     update
2234     list [.t bbox 19.1] [.t bbox 20.1]
2235 } {{10 120 7 13} {10 133 7 5}}
2236 test textDisp-22.5 {TkTextCharBbox, cut-off char} {fonts} {
2237     .t config -wrap none
2238     .t yview 10.0
2239     wm geom . [expr $width-95]x$height
2240     update
2241     .t bbox 15.6
2242 } {45 68 7 13}
2243 test textDisp-22.6 {TkTextCharBbox, line visible but not char} {fonts} {
2244     .t config -wrap char
2245     .t yview 10.0
2246     .t tag add big 20.2 20.5
2247     wm geom . ${width}x[expr $height+3]
2248     update
2249     list [.t bbox 19.1] [.t bbox 20.1] [.t bbox 20.2]
2250 } {{10 120 7 13} {} {17 133 14 7}}
2251 wm geom . {}
2252 update
2253 test textDisp-22.7 {TkTextCharBbox, different character sizes} {fonts} {
2254     .t config -wrap char
2255     .t yview 10.0
2256     .t tag add big 12.2 12.5
2257     update
2258     list [.t bbox 12.1] [.t bbox 12.2]
2259 } {{10 41 7 13} {17 29 14 27}}
2260 .t tag remove big 1.0 end
2261 test textDisp-22.8 {TkTextCharBbox, horizontal scrolling} {fonts} {
2262     .t configure -wrap none
2263     .t delete 1.0 end
2264     .t insert end "12345\n"
2265     .t insert end "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
2266     .t xview scroll 4 units
2267     list [.t bbox 1.3] [.t bbox 1.4] [.t bbox 2.3] [.t bbox 2.4] \
2268             [.t bbox 2.23] [.t bbox 2.24]
2269 } {{} {3 3 7 13} {} {3 16 7 13} {136 16 7 13} {}}
2270 test textDisp-22.9 {TkTextCharBbox, handling of spacing} {fonts} {
2271     .t configure -wrap char
2272     .t delete 1.0 end
2273     .t insert 1.0 "abcdefghijkl\nmnopqrstuvwzyz"
2274     .t tag configure spacing -spacing1 8 -spacing3 2
2275     .t tag add spacing 1.0 end
2276     frame .t.f1 -width 10 -height 4 -bg black
2277     frame .t.f2 -width 10 -height 4 -bg black
2278     frame .t.f3 -width 10 -height 4 -bg black
2279     frame .t.f4 -width 10 -height 4 -bg black
2280     .t window create 1.3 -window .t.f1 -align top
2281     .t window create 1.7 -window .t.f2 -align center
2282     .t window create 2.1 -window .t.f3 -align bottom
2283     .t window create 2.10 -window .t.f4 -align baseline
2284     update
2285     list [.t bbox .t.f1] [.t bbox .t.f2] [.t bbox .t.f3] [.t bbox .t.f4] \
2286             [.t bbox 1.1] [.t bbox 2.9]
2287 } {{24 11 10 4} {55 15 10 4} {10 43 10 4} {76 40 10 4} {10 11 7 13} {69 34 7 13}}
2288 .t tag delete spacing
2289
2290 .t delete 1.0 end
2291 .t insert end "Line 1"
2292 for {set i 2} {$i <= 200} {incr i} {
2293     .t insert end "\nLine $i"
2294 }
2295 .t configure -wrap word
2296 .t delete 50.0 51.0
2297 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2298 update
2299 test textDisp-23.1 {TkTextDLineInfo} {fonts} {
2300     .t config -wrap word
2301     .t yview 48.0
2302     list [.t dlineinfo 47.3] [.t dlineinfo 48.0] [.t dlineinfo 50.40] \
2303             [.t dlineinfo 56.0]
2304 } {{} {3 3 49 13 10} {3 55 126 13 10} {}}
2305 test textDisp-23.2 {TkTextDLineInfo} {fonts} {
2306     .t config -bd 4 -wrap word
2307     update
2308     .t yview 48.0
2309     .t dlineinfo 50.40
2310 } {7 59 126 13 10}
2311 .t config -bd 0
2312 test textDisp-23.3 {TkTextDLineInfo} {fonts} {
2313     .t config -wrap none
2314     update
2315     .t yview 48.0
2316     list [.t dlineinfo 50.40] [.t dlineinfo 57.3]
2317 } {{3 29 371 13 10} {3 120 49 13 10}}
2318 test textDisp-23.4 {TkTextDLineInfo, cut-off lines} {fonts} {
2319     .t config -wrap char
2320     .t yview 10.0
2321     wm geom . ${width}x[expr $height-1]
2322     update
2323     list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
2324 } {{3 120 49 13 10} {3 133 49 3 10}}
2325 test textDisp-23.5 {TkTextDLineInfo, cut-off lines} {fonts} {
2326     .t config -wrap char
2327     .t yview 10.0
2328     wm geom . ${width}x[expr $height+1]
2329     update
2330     list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
2331 } {{3 120 49 13 10} {3 133 49 5 10}}
2332 wm geom . {}
2333 update
2334 test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {fonts} {
2335     .t config -wrap none
2336     .t delete 1.0 end
2337     .t insert end "First line\n"
2338     .t insert end "Second line is a very long one that doesn't all fit.\n"
2339     .t insert end "Third"
2340     .t xview scroll 6 units
2341     update
2342     list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
2343 } {{-39 3 70 13 10} {-39 16 364 13 10} {-39 29 35 13 10}}
2344 .t xview moveto 0
2345 test textDisp-23.7 {TkTextDLineInfo, centering} {fonts} {
2346     .t config -wrap word
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 tag configure x -justify center
2352     .t tag configure y -justify right
2353     .t tag add x 1.0
2354     .t tag add y 3.0
2355     list [.t dlineinfo 1.0] [.t dlineinfo 2.0] [.t dlineinfo 3.0]
2356 } {{38 3 70 13 10} {3 16 119 13 10} {108 55 35 13 10}}
2357 .t tag delete x y
2358
2359 test textDisp-24.1 {TkTextCharLayoutProc} {fonts} {
2360     .t configure -wrap char
2361     .t delete 1.0 end
2362     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2363     list [.t bbox 1.19] [.t bbox 1.20]
2364 } {{136 3 7 13} {3 16 7 13}}
2365 test textDisp-24.2 {TkTextCharLayoutProc} {fonts} {
2366     .t configure -wrap char
2367     .t delete 1.0 end
2368     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2369     wm geom . [expr $width+1]x$height
2370     update
2371     list [.t bbox 1.19] [.t bbox 1.20]
2372 } {{136 3 12 13} {3 16 7 13}}
2373 test textDisp-24.3 {TkTextCharLayoutProc} {fonts} {
2374     .t configure -wrap char
2375     .t delete 1.0 end
2376     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2377     wm geom . [expr $width-1]x$height
2378     update
2379     list [.t bbox 1.19] [.t bbox 1.20]
2380 } {{136 3 10 13} {3 16 7 13}}
2381 test textDisp-24.4 {TkTextCharLayoutProc, newline not visible} {fonts} {
2382     .t configure -wrap char
2383     .t delete 1.0 end
2384     .t insert 1.0 01234567890123456789\n012345678901234567890
2385     wm geom . {}
2386     update
2387     list [.t bbox 1.19] [.t bbox 1.20] [.t bbox 2.20]
2388 } {{136 3 7 13} {143 3 0 13} {3 29 7 13}}
2389 test textDisp-24.5 {TkTextCharLayoutProc, char doesn't fit, newline not visible} {fonts} {
2390     .t configure -wrap char
2391     .t delete 1.0 end
2392     .t insert 1.0 0\n1\n
2393     wm geom . 110x$height
2394     update
2395     list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 2.0]
2396 } {{3 3 4 13} {7 3 0 13} {3 16 4 13}}
2397 test textDisp-24.6 {TkTextCharLayoutProc, line ends with space} {fonts} {
2398     .t configure -wrap char
2399     .t delete 1.0 end
2400     .t insert 1.0 "a b c d e f g h i j k l m n o p"
2401     wm geom . {}
2402     update
2403     list [.t bbox 1.19] [.t bbox 1.20]
2404 } {{136 3 7 13} {3 16 7 13}}
2405 test textDisp-24.7 {TkTextCharLayoutProc, line ends with space} {fonts} {
2406     .t configure -wrap char
2407     .t delete 1.0 end
2408     .t insert 1.0 "a b c d e f g h i j k l m n o p"
2409     wm geom . [expr $width+1]x$height
2410     update
2411     list [.t bbox 1.19] [.t bbox 1.20]
2412 } {{136 3 12 13} {3 16 7 13}}
2413 test textDisp-24.8 {TkTextCharLayoutProc, line ends with space} {fonts} {
2414     .t configure -wrap char
2415     .t delete 1.0 end
2416     .t insert 1.0 "a b c d e f g h i j k l m n o p"
2417     wm geom . [expr $width-1]x$height
2418     update
2419     list [.t bbox 1.19] [.t bbox 1.20]
2420 } {{136 3 10 13} {3 16 7 13}}
2421 test textDisp-24.9 {TkTextCharLayoutProc, line ends with space} {fonts} {
2422     .t configure -wrap char
2423     .t delete 1.0 end
2424     .t insert 1.0 "a b c d e f g h i j k l m n o p"
2425     wm geom . [expr $width-6]x$height
2426     update
2427     list [.t bbox 1.19] [.t bbox 1.20]
2428 } {{136 3 5 13} {3 16 7 13}}
2429 test textDisp-24.10 {TkTextCharLayoutProc, line ends with space} {fonts} {
2430     .t configure -wrap char
2431     .t delete 1.0 end
2432     .t insert 1.0 "a b c d e f g h i j k l m n o p"
2433     wm geom . [expr $width-7]x$height
2434     update
2435     list [.t bbox 1.19] [.t bbox 1.20]
2436 } {{136 3 4 13} {3 16 7 13}}
2437 test textDisp-24.11 {TkTextCharLayoutProc, line ends with space that doesn't quite fit} {fonts} {
2438     .t configure -wrap char
2439     .t delete 1.0 end
2440     .t insert 1.0 "01234567890123456789 \nabcdefg"
2441     wm geom . [expr $width-2]x$height
2442     update
2443     set result {}
2444     lappend result [.t bbox 1.21] [.t bbox 2.0]
2445     .t mark set insert 1.21
2446     lappend result [.t bbox 1.21] [.t bbox 2.0]
2447 } {{145 3 0 13} {3 16 7 13} {145 3 0 13} {3 16 7 13}}
2448 test textDisp-24.12 {TkTextCharLayoutProc, tab causes wrap} {fonts} {
2449     .t configure -wrap char
2450     .t delete 1.0 end
2451     .t insert 1.0 "abcdefghi"
2452     .t mark set insert 1.4
2453     .t insert insert \t\t\t
2454     list [.t bbox {insert -1c}] [.t bbox insert]
2455 } {{115 3 30 13} {3 16 7 13}}
2456 test textDisp-24.13 {TkTextCharLayoutProc, -wrap none} {fonts} {
2457     .t configure -wrap none
2458     .t delete 1.0 end
2459     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2460     wm geom . {}
2461     update
2462     list [.t bbox 1.19] [.t bbox 1.20]
2463 } {{136 3 7 13} {}}
2464 test textDisp-24.14 {TkTextCharLayoutProc, -wrap none} {fonts} {
2465     .t configure -wrap none
2466     .t delete 1.0 end
2467     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2468     wm geom . [expr $width+1]x$height
2469     update
2470     list [.t bbox 1.19] [.t bbox 1.20]
2471 } {{136 3 7 13} {143 3 5 13}}
2472 test textDisp-24.15 {TkTextCharLayoutProc, -wrap none} {fonts} {
2473     .t configure -wrap none
2474     .t delete 1.0 end
2475     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2476     wm geom . [expr $width-1]x$height
2477     update
2478     list [.t bbox 1.19] [.t bbox 1.20]
2479 } {{136 3 7 13} {143 3 3 13}}
2480 test textDisp-24.16 {TkTextCharLayoutProc, no chars fit} {fonts} {
2481     .t configure -wrap char
2482     .t delete 1.0 end
2483     .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2484     wm geom . 103x$height
2485     update
2486     list [.t bbox 1.0] [.t bbox 1.1] [.t bbox 1.2]
2487 } {{3 3 1 13} {3 16 1 13} {3 29 1 13}}
2488 test textDisp-24.17 {TkTextCharLayoutProc, -wrap word} {fonts} {
2489     .t configure -wrap word
2490     .t delete 1.0 end
2491     .t insert 1.0 "This is a line that wraps around"
2492     wm geom . {}
2493     update
2494     list [.t bbox 1.19] [.t bbox 1.20]
2495 } {{136 3 7 13} {3 16 7 13}}
2496 test textDisp-24.18 {TkTextCharLayoutProc, -wrap word} {fonts} {
2497     .t configure -wrap word
2498     .t delete 1.0 end
2499     .t insert 1.0 "xThis is a line that wraps around"
2500     wm geom . {}
2501     update
2502     list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
2503 } {{101 3 7 13} {108 3 35 13} {3 16 7 13}}
2504 test textDisp-24.19 {TkTextCharLayoutProc, -wrap word} {fonts} {
2505     .t configure -wrap word
2506     .t delete 1.0 end
2507     .t insert 1.0 "xxThis is a line that wraps around"
2508     wm geom . {}
2509     update
2510     list [.t bbox 1.14] [.t bbox 1.15] [.t bbox 1.16]
2511 } {{101 3 7 13} {108 3 7 13} {115 3 28 13}}
2512 test textDisp-24.20 {TkTextCharLayoutProc, vertical offset} {fonts} {
2513     .t configure -wrap none
2514     .t delete 1.0 end
2515     .t insert 1.0 "Line 1\nLine 2\nLine 3"
2516     set result {}
2517     lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2518     .t tag configure up -offset 6
2519     .t tag add up 2.1
2520     lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2521     .t tag configure  up -offset -2
2522     lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2523     .t tag delete up
2524     set result
2525 } {{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}}
2526 .t configure -width 30
2527 update
2528 test textDisp-24.21 {TkTextCharLayoutProc, word breaks} {fonts} {
2529     .t configure -wrap word
2530     .t delete 1.0 end
2531     .t insert 1.0 "Sample text xxxxxxx yyyyy zzzzzzz qqqqq rrrr ssss tt u vvvvv"
2532     frame .t.f -width 30 -height 20 -bg black
2533     .t window create 1.36 -window .t.f
2534     .t bbox 1.26
2535 } {3 19 7 13}
2536 test textDisp-24.22 {TkTextCharLayoutProc, word breaks} {fonts} {
2537     .t configure -wrap word
2538     .t delete 1.0 end
2539     frame .t.f -width 30 -height 20 -bg black
2540     .t insert 1.0 "Sample text xxxxxxx yyyyyyy"
2541     .t window create end -window .t.f
2542     .t insert end "zzzzzzz qqqqq rrrr ssss tt u vvvvv"
2543     .t bbox 1.28
2544 } {33 19 7 13}
2545 test textDisp-24.23 {TkTextCharLayoutProc, word breaks} {fonts} {
2546     .t configure -wrap word
2547     .t delete 1.0 end
2548     frame .t.f -width 30 -height 20 -bg black
2549     .t insert 1.0 "Sample text xxxxxxx yyyyyyy "
2550     .t insert end "zzzzzzz qqqqq rrrr ssss tt"
2551     .t window create end -window .t.f
2552     .t insert end "u vvvvv"
2553     .t bbox .t.f
2554 } {3 29 30 20}
2555 catch {destroy .t.f}
2556 .t configure -width 20
2557 update
2558 test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} {fonts} {
2559     .t delete 1.0 end
2560     .t tag configure x -justify center
2561     .t insert 1.0 aa\tbb\tcc\tdd\t
2562     .t tag add x 1.0 end
2563     list [.t bbox 1.0] [.t bbox 1.10]
2564 } {{45 3 7 13} {94 3 7 13}}
2565
2566 .t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
2567     -tabs 100
2568 update
2569 test textDisp-25.1 {CharBboxProc procedure, check tab width} {fonts} {
2570     .t delete 1.0 end
2571     .t insert 1.0 abc\td\tfgh
2572     list [.t bbox 1.3] [.t bbox 1.5] [.t bbox 1.6]
2573 } {{21 1 79 13} {107 1 93 13} {200 1 7 13}}
2574
2575 .t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
2576         -tabs {}
2577 update
2578 test textDisp-26.1 {AdjustForTab procedure, no tabs} {fonts} {
2579     .t delete 1.0 end
2580     .t insert 1.0 a\tbcdefghij\tc\td
2581     list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
2582             [lindex [.t bbox 1.14] 0]
2583 } {56 168 224}
2584 test textDisp-26.2 {AdjustForTab procedure, not enough tabs specified} {
2585     .t delete 1.0 end
2586     .t insert 1.0 a\tb\tc\td
2587     .t tag delete x
2588     .t tag configure x -tabs 40
2589     .t tag add x 1.0 end
2590     list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0] \
2591             [lindex [.t bbox 1.6] 0]
2592 } {40 80 120}
2593 test textDisp-26.3 {AdjustForTab procedure, not enough tabs specified} {
2594     .t delete 1.0 end
2595     .t insert 1.0 a\tb\tc\td\te
2596     .t tag delete x
2597     .t tag configure x -tabs {40 70 right}
2598     .t tag add x 1.0 end
2599     list [lindex [.t bbox 1.2] 0] \
2600             [expr [lindex [.t bbox 1.4] 0] + [lindex [.t bbox 1.4] 2]] \
2601             [expr [lindex [.t bbox 1.6] 0] + [lindex [.t bbox 1.6] 2]] \
2602             [expr [lindex [.t bbox 1.8] 0] + [lindex [.t bbox 1.8] 2]]
2603 } {40 70 100 130}
2604 test textDisp-26.4 {AdjustForTab procedure, different alignments} {
2605     .t delete 1.0 end
2606     .t insert 1.0 a\tbc\tde\tfg\thi
2607     .t tag delete x
2608     .t tag configure x -tabs {40 center 80 left 130 right}
2609     .t tag add x 1.0 end
2610     .t tag add y 1.2
2611     .t tag add y 1.5
2612     .t tag add y 1.8
2613     list [lindex [.t bbox 1.3] 0] [lindex [.t bbox 1.5] 0] \
2614             [lindex [.t bbox 1.10] 0]
2615 } {40 80 130}
2616 test textDisp-26.5 {AdjustForTab procedure, numeric alignment} {
2617     .t delete 1.0 end
2618     .t insert 1.0 a\t1.234
2619     .t tag delete x
2620     .t tag configure x -tabs {120 numeric}
2621     .t tag add x 1.0 end
2622     .t tag add y 1.2
2623     .t tag add y 1.5
2624     lindex [.t bbox 1.3] 0
2625 } {120}
2626 test textDisp-26.6 {AdjustForTab procedure, numeric alignment} {
2627     .t delete 1.0 end
2628     .t insert 1.0 a\t1,456.234
2629     .t tag delete x
2630     .t tag configure x -tabs {120 numeric}
2631     .t tag add x 1.0 end
2632     .t tag add y 1.2
2633     lindex [.t bbox 1.7] 0
2634 } {120}
2635 test textDisp-26.7 {AdjustForTab procedure, numeric alignment} {
2636     .t delete 1.0 end
2637     .t insert 1.0 a\t1.456.234,7
2638     .t tag delete x
2639     .t tag configure x -tabs {120 numeric}
2640     .t tag add x 1.0 end
2641     .t tag add y 1.2
2642     lindex [.t bbox 1.11] 0
2643 } {120}
2644 test textDisp-26.8 {AdjustForTab procedure, numeric alignment} {
2645     .t delete 1.0 end
2646     .t insert 1.0 a\ttest
2647     .t tag delete x
2648     .t tag configure x -tabs {120 numeric}
2649     .t tag add x 1.0 end
2650     .t tag add y 1.2
2651     lindex [.t bbox 1.6] 0
2652 } {120}
2653 test textDisp-26.9 {AdjustForTab procedure, numeric alignment} {
2654     .t delete 1.0 end
2655     .t insert 1.0 a\t1234
2656     .t tag delete x
2657     .t tag configure x -tabs {120 numeric}
2658     .t tag add x 1.0 end
2659     .t tag add y 1.2
2660     lindex [.t bbox 1.6] 0
2661 } {120}
2662 test textDisp-26.10 {AdjustForTab procedure, numeric alignment} {
2663     .t delete 1.0 end
2664     .t insert 1.0 a\t1.234567
2665     .t tag delete x
2666     .t tag configure x -tabs {120 numeric}
2667     .t tag add x 1.0 end
2668     .t tag add y 1.5
2669     lindex [.t bbox 1.3] 0
2670 } {120}
2671 test textDisp-26.11 {AdjustForTab procedure, numeric alignment} {
2672     .t delete 1.0 end
2673     .t insert 1.0 a\tx=1.234567
2674     .t tag delete x
2675     .t tag configure x -tabs {120 numeric}
2676     .t tag add x 1.0 end
2677     .t tag add y 1.7
2678     .t tag add y 1.9
2679     lindex [.t bbox 1.5] 0
2680 } {120}
2681 test textDisp-26.12 {AdjustForTab procedure, adjusting chunks} {
2682     .t delete 1.0 end
2683     .t insert 1.0 a\tx1.234567
2684     .t tag delete x
2685     .t tag configure x -tabs {120 numeric}
2686     .t tag add x 1.0 end
2687     .t tag add y 1.7
2688     .t tag add y 1.9
2689     button .b -text "="
2690     .t window create 1.3 -window .b
2691     update
2692     lindex [.t bbox 1.5] 0
2693 } {120}
2694 test textDisp-26.13 {AdjustForTab procedure, not enough space} {fonts} {
2695     .t delete 1.0 end
2696     .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
2697     .t tag delete x
2698     .t tag configure x -tabs {10 30 center 50 right 120}
2699     .t tag add x 1.0 end
2700     list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
2701             [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]
2702 } {28 56 84 120}
2703
2704 .t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
2705         -wrap char
2706 update
2707 test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {fonts} {
2708     .t delete 1.0 end
2709     .t insert 1.0 a\tbcdefghij\tc\td
2710     list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]
2711 } {{60 5 7 13} {116 5 7 13} {4 18 7 13}}
2712 test textDisp-27.2 {SizeOfTab procedure, choosing tabX and alignment} {fonts} {
2713     .t delete 1.0 end
2714     .t insert 1.0 a\tbcd
2715     .t tag delete x
2716     .t tag configure x -tabs 120
2717     .t tag add x 1.0 end
2718     list [.t bbox 1.3] [.t bbox 1.4]
2719 } {{131 5 13 13} {4 18 7 13}}
2720 test textDisp-27.3 {SizeOfTab procedure, choosing tabX and alignment} {fonts} {
2721     .t delete 1.0 end
2722     .t insert 1.0 a\t\t\tbcd
2723     .t tag delete x
2724     .t tag configure x -tabs 40
2725     .t tag add x 1.0 end
2726     list [.t bbox 1.5] [.t bbox 1.6]
2727 } {{131 5 13 13} {4 18 7 13}}
2728 test textDisp-27.4 {SizeOfTab procedure, choosing tabX and alignment} {fonts} {
2729     .t delete 1.0 end
2730     .t insert 1.0 a\t\t\tbcd
2731     .t tag delete x
2732     .t tag configure x -tabs {20 center 70 left}
2733     .t tag add x 1.0 end
2734     list [.t bbox 1.5] [.t bbox 1.6]
2735 } {{131 5 13 13} {4 18 7 13}}
2736 test textDisp-27.5 {SizeOfTab procedure, center alignment} {fonts} {
2737     .t delete 1.0 end
2738     .t insert 1.0 a\txyzzyabc
2739     .t tag delete x
2740     .t tag configure x -tabs {120 center}
2741     .t tag add x 1.0 end
2742     list [.t bbox 1.6] [.t bbox 1.7]
2743 } {{135 5 9 13} {4 18 7 13}}
2744 test textDisp-27.6 {SizeOfTab procedure, center alignment} {fonts} {
2745     .t delete 1.0 end
2746     .t insert 1.0 a\txyzzyabc
2747     .t tag delete x
2748     .t tag configure x -tabs {150 center}
2749     .t tag add x 1.0 end
2750     list [.t bbox 1.6] [.t bbox 1.7]
2751 } {{32 18 7 13} {39 18 7 13}}
2752 test textDisp-27.7 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {fonts} {
2753     .t delete 1.0 end
2754     .t configure -tabs {1c 2c center 3c 4c} -wrap none -width 40
2755     .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
2756     update
2757     .t bbox 2.24
2758 } {172 18 7 13}
2759 .t configure -wrap char -tabs {} -width 20
2760 update
2761 test textDisp-27.8 {SizeOfTab procedure, right alignment} {fonts} {
2762     .t delete 1.0 end
2763     .t insert 1.0 a\t\txyzzyabc
2764     .t tag delete x
2765     .t tag configure x -tabs {100 left 140 right}
2766     .t tag add x 1.0 end
2767     list [.t bbox 1.6] [.t bbox 1.7]
2768 } {{137 5 7 13} {4 18 7 13}}
2769 test textDisp-27.9 {SizeOfTab procedure, left alignment} {fonts} {
2770     .t delete 1.0 end
2771     .t insert 1.0 a\txyzzyabc
2772     .t tag delete x
2773     .t tag configure x -tabs {120}
2774     .t tag add x 1.0 end
2775     list [.t bbox 1.3] [.t bbox 1.4]
2776 } {{131 5 13 13} {4 18 7 13}}
2777 test textDisp-27.10 {SizeOfTab procedure, numeric alignment} {fonts} {
2778     .t delete 1.0 end
2779     .t insert 1.0 a\t123.4
2780     .t tag delete x
2781     .t tag configure x -tabs {120 numeric}
2782     .t tag add x 1.0 end
2783     list [.t bbox 1.3] [.t bbox 1.4]
2784 } {{117 5 27 13} {4 18 7 13}}
2785 test textDisp-27.11 {SizeOfTab procedure, making tabs at least as wide as a space} {fonts} {
2786     .t delete 1.0 end
2787     .t insert 1.0 abc\tdefghijklmnopqrst
2788     .t tag delete x
2789     .t tag configure x -tabs {120}
2790     .t tag add x 1.0 end
2791     list [.t bbox 1.5] [.t bbox 1.6]
2792 } {{131 5 13 13} {4 18 7 13}}
2793
2794 proc bizarre_scroll args {
2795     .t2.t delete 5.0 end
2796 }
2797 test textDisp-28.1 {"yview" option with bizarre scroll command} {
2798     catch {destroy .t2}
2799     toplevel .t2
2800     text .t2.t -width 40 -height 4
2801     .t2.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n"
2802     pack .t2.t
2803     wm geometry .t2 +0+0
2804     update
2805     .t2.t configure -yscrollcommand bizarre_scroll
2806     .t2.t yview 100.0
2807     set result [.t2.t index @0,0]
2808     update
2809     lappend result [.t2.t index @0,0]
2810 } {6.0 1.0}
2811
2812 test textDisp-29.1 {miscellaneous: lines wrap but are still too long} {fonts} {
2813     catch {destroy .t2}
2814     toplevel .t2
2815     wm geometry .t2 +0+0
2816     text .t2.t -width 20 -height 10 -font $fixedFont \
2817             -wrap char -xscrollcommand ".t2.s set"
2818     pack .t2.t -side top
2819     scrollbar .t2.s -orient horizontal -command ".t2.t xview"
2820     pack .t2.s -side bottom -fill x
2821     .t2.t insert end 123
2822     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
2823     .t2.t window create 1.1 -window .t2.t.f
2824     update
2825     list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
2826 } {{0 0.466667} 300x50+5+18 {12 68 7 13}}
2827 test textDisp-29.2 {miscellaneous: lines wrap but are still too long} {fonts} {
2828     catch {destroy .t2}
2829     toplevel .t2
2830     wm geometry .t2 +0+0
2831     text .t2.t -width 20 -height 10 -font $fixedFont \
2832             -wrap char -xscrollcommand ".t2.s set"
2833     pack .t2.t -side top
2834     scrollbar .t2.s -orient horizontal -command ".t2.t xview"
2835     pack .t2.s -side bottom -fill x
2836     .t2.t insert end 123
2837     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
2838     .t2.t window create 1.1 -window .t2.t.f
2839     .t2.t xview scroll 1 unit
2840     update
2841     list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
2842 } {{0.0233333 0.49} 300x50+-2+18 {5 68 7 13}}
2843 test textDisp-29.3 {miscellaneous: lines wrap but are still too long} {fonts} {
2844     catch {destroy .t2}
2845     toplevel .t2
2846     wm geometry .t2 +0+0
2847     text .t2.t -width 20 -height 10 -font $fixedFont \
2848             -wrap char -xscrollcommand ".t2.s set"
2849     pack .t2.t -side top
2850     scrollbar .t2.s -orient horizontal -command ".t2.t xview"
2851     pack .t2.s -side bottom -fill x
2852     .t2.t insert end 123
2853     frame .t2.t.f -width 300 -height 50 -bd 2 -relief raised
2854     .t2.t window create 1.1 -window .t2.t.f
2855     update
2856     .t2.t xview scroll 200 units
2857     update
2858     list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
2859 } {{0.536667 1} 300x50+-156+18 {}}
2860
2861 deleteWindows
2862 option clear
2863
2864 # cleanup
2865 ::tcltest::cleanupTests
2866 return