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.
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.
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
18 namespace import -force tcltest::interpreter
19 namespace import -force tcltest::makeFile
20 namespace import -force tcltest::removeFile
22 # The procedure below is used as the scrolling command for the text;
23 # it just saves the scrolling information in a variable "scrollInfo".
30 # The procedure below is used to generate errors during scrolling commands.
32 proc scrollError args {
33 error "scrolling error"
36 # Create entries in the option database to be sure that geometry options
37 # like border width have predictable values.
39 option add *Text.borderWidth 2
40 option add *Text.highlightThickness 2
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
47 frame .f -width 100 -height 20
50 set fixedFont {Courier -12}
51 set fixedHeight [font metrics $fixedFont -linespace]
52 set fixedWidth [font measure $fixedFont m]
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
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.
67 wm positionfrom . user
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.
78 if {([winfo rooty .] < 50) || ([winfo rootx .] < 50)} {
81 test textDisp-1.1 {GetStyle procedure, priorities and tab stops} {
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
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}
98 lappend x [lindex [.t bbox 1.2] 0]
101 test textDisp-1.2 {GetStyle procedure, wrapmode} {fonts} {
102 .t configure -wrap char
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
109 set result [list [.t bbox 2.20]]
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} {}}
117 test textDisp-2.1 {LayoutDLine, basics} {
118 .t configure -wrap char
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
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
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
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
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
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
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}
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
168 .t configure -wrap char
170 .t insert 1.0 "This isxx some sample text for testing."
172 list [.t bbox 1.19] [.t bbox 1.20]
173 } {{138 5 8 13} {5 18 7 13}}
176 test textDisp-2.9 {LayoutDLine, marks and tags} {fonts} {
177 .t configure -wrap word
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
185 .t insert 1.0 "This is a very_very_long_word_that_wraps."
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
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
201 .t insert 1.0 "\na\nbb\nccc\ndddd"
202 .t tag configure x -justify center
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
210 .t insert 1.0 "\na\nbb\nccc\ndddd"
211 .t tag configure x -justify right
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
219 .t insert 1.0 "\na\nbb\nccc\ndddd"
220 .t tag configure x -justify center
222 .t tag configure y -justify right
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
230 .t insert 1.0 "\na\nbb\nccc\ndddd"
231 .t tag configure x -justify center
233 .t tag configure y -justify right
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
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
250 .t insert 1.0 "Lots of long words, enough to force word wrap\nThen\nmore lines"
251 .t tag configure x -justify center
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
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
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}}
269 test textDisp-2.19 {LayoutDLine, margins} {fonts} {
270 .t configure -wrap word
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
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
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
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
291 .t insert 1.0 "Sample text"
292 .t tag configure x -lmargin1 80 -lmargin2 80 -rmargin 100
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}}
298 test textDisp-2.22 {LayoutDLine, spacing options} {fonts} {
299 .t configure -wrap word
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]
324 .t configure -spacing1 0 -spacing2 0 -spacing3 0
325 test textDisp-2.23 {LayoutDLine, spacing options} {fonts} {
326 .t configure -wrap word
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
343 .t tag configure y -spacing1 0 -spacing2 3
344 .t tag add y 2.19 end
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]
356 .t configure -spacing1 0 -spacing2 0 -spacing3 0
357 test textDisp-2.24 {LayoutDLine, tabs, saving from first chunk} {fonts} {
360 .t tag configure x -tabs 70
361 .t tag configure y -tabs 80
362 .t insert 1.0 "ab\tcde"
365 lindex [.t bbox 1.3] 0
367 test textDisp-2.25 {LayoutDLine, tabs, breaking chunks at tabs} {fonts} {
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
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]
378 test textDisp-2.26 {LayoutDLine, tabs, breaking chunks at tabs} {fonts} {
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
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]
389 test textDisp-2.27 {LayoutDLine, tabs, calling AdjustForTab} {fonts} {
392 .t tag configure x -tabs {30 60}
393 .t insert 1.0 "a\tb\tcd"
395 list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.4] 0]
397 test textDisp-2.28 {LayoutDLine, tabs, running out of space in dline} {fonts} {
399 .t insert 1.0 "a\tb\tc\td"
402 test textDisp-2.29 {LayoutDLine, tabs, running out of space in dline} {fonts} {
404 .t insert 1.0 "a\tx\tabcd"
407 test textDisp-2.30 {LayoutDLine, tabs, running out of space in dline} {fonts} {
409 .t insert 1.0 "a\tx\tabc"
413 test textDisp-3.1 {different character sizes} {fonts} {
414 .t configure -wrap word
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}}
424 .t configure -wrap char
425 test textDisp-4.1 {UpdateDisplayInfo, basic} {fonts} {
427 .t insert end "Line 1\nLine 2\nLine 3\n"
430 .t insert 2.0 "New Line 2"
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} {
436 .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
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} {
446 .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
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}}
454 test textDisp-4.4 {UpdateDisplayInfo, wrap-mode "none"} {fonts} {
455 .t configure -wrap none
457 .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
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
464 .t configure -wrap none
466 .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
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.
478 if {$tcl_platform(platform) == "windows"} {
479 wm overrideredirect . 1
481 frame .f2 -width 20 -height 100
482 pack before .f .f2 top
485 .t configure -wrap none -borderwidth 2
487 .t insert end "Line 1\nLine 2 is so long that it wraps around\nLine 3"
489 set x [list [.t bbox 1.0] [.t bbox 2.0] $tk_textRelayout]
490 wm overrideredirect . 0
495 .t configure -borderwidth 0 -wrap char
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.
506 if {$tcl_platform(platform) == "windows"} {
507 wm overrideredirect . 1
510 .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
515 set x [list [.t index @0,0] $tk_textRelayout $tk_textRedraw]
516 wm overrideredirect . 0
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} {
522 .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
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} {
531 .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17"
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} {
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"
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} {
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"
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} {
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
568 .t configure -wrap word
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"
574 .t tag configure x -relief raised -borderwidth 2 -background white
575 test textDisp-4.13 {UpdateDisplayInfo, special handling for top/bottom lines} {
579 .t yview scroll 3 units
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
587 .t yview scroll 3 units
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} {
595 .t yview scroll -2 units
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
603 .t yview scroll -2 units
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
610 .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
611 .t insert end "\nLine 3\nLine 4"
613 .t xview scroll 3 units
615 list $tk_textRelayout $tk_textRedraw [.t bbox 2.0] [.t bbox 2.5] \
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
621 .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
622 .t insert end "\nLine 3\nLine 4"
624 .t xview scroll 100 units
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
631 .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
632 .t insert end "\nLine 3\nLine 4"
635 .t xview scroll -10 units
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
642 .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
643 .t insert end "\nLine 3\nLine 4"
645 .t xview scroll 100 units
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
654 .t insert end "Short line 1\nLine 2 is long enough to scroll horizontally"
655 .t insert end "\nLine 3\nLine 4"
660 list $tk_textRelayout $tk_textRedraw
662 test textDisp-4.22 {UpdateDisplayInfo, no horizontal scrolling except for -wrap none} {fonts} {
663 .t configure -wrap none
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
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
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
679 .t configure -wrap char
680 list [.t bbox 2.0] [.t bbox 2.16]
681 } {{3 16 7 13} {115 16 7 13}}
683 test textDisp-5.1 {DisplayDLine, handling of spacing} {fonts} {
684 .t configure -wrap char
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
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
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.
707 test textDisp-5.2 {DisplayDLine, line resizes during display} {
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
713 list [winfo width .t.f] [winfo height .t.f]
716 .t configure -wrap char
717 test textDisp-6.1 {scrolling in DisplayText, scroll up} {
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"
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} {
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"
735 .t insert 2.0 "New Line 2\n"
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
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"
747 .t insert 2.end "is so long that it wraps"
748 .t insert 4.end "is so long that it wraps"
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
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"
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"
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
768 place .f2 -in .t -relx 0.5 -rely 0.5 -relwidth 0.5 -relheight 0.5
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"
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
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"
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}}
798 test textDisp-6.7 {DisplayText, vertical scrollbar updates} {
799 .t configure -wrap char
804 test textDisp-6.8 {DisplayText, vertical scrollbar updates} {
805 .t configure -wrap char
807 .t insert 1.0 "Line 1"
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"
816 .t configure -yscrollcommand {} -xscrollcommand scroll
817 test textDisp-6.9 {DisplayText, horizontal scrollbar updates} {
818 .t configure -wrap none
821 set scrollInfo unchanged
822 .t insert end xxxxxxxxx\n
823 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
824 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
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.
833 .t configure -bd 2 -relief raised -wrap char
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"
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
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
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
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 \
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
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
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
897 list $tk_textRelayout $tk_textRedraw
898 } {{} {borders 3.0 4.0 5.0}}
899 test textDisp-7.8 {TkTextRedrawRegion} {nonPortable} {
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
908 list $tk_textRelayout $tk_textRedraw
909 } {{} {borders 4.0 5.0 6.0 7.0 eof}}
912 test textDisp-8.1 {TkTextChanged: redisplay whole lines} {fonts} {
913 .t configure -wrap word
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"
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} {
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"
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} {
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"
945 list $tk_textRelayout $tk_textRedraw
947 test textDisp-8.4 {TkTextChanged} {
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"
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} {
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"
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} {
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"
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} {
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"
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} {
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"
1000 list $tk_textRelayout $tk_textRedraw
1002 test textDisp-8.9 {TkTextChanged} {
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"
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
1016 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1023 test textDisp-8.11 {TkTextChanged, scrollbar notification when changes are off-screen} {
1025 .t insert end "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n"
1026 .t configure -yscrollcommand scroll
1029 .t insert end "a\nb\nc\n"
1031 .t configure -yscrollcommand ""
1035 test textDisp-9.1 {TkTextRedrawTag} {
1036 .t configure -wrap char
1038 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1040 .t tag add big 2.2 2.4
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
1047 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1049 .t tag add big 1.2 2.4
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
1056 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1058 .t tag add big 2.2 2.4
1059 .t tag remove big 1.0 end
1061 list $tk_textRelayout $tk_textRedraw
1063 test textDisp-9.4 {TkTextRedrawTag} {
1064 .t configure -wrap char
1066 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1068 .t tag add big 2.2 2.20
1069 .t tag remove big 1.0 end
1071 list $tk_textRelayout $tk_textRedraw
1073 test textDisp-9.5 {TkTextRedrawTag} {
1074 .t configure -wrap char
1076 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap around\nLine 3\nLine 4"
1078 .t tag add big 2.2 2.end
1079 .t tag remove big 1.0 end
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
1086 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1088 .t tag add big 2.2 3.5
1089 .t tag remove big 1.0 end
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
1096 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1099 .t tag remove big 2.19
1103 test textDisp-9.8 {TkTextRedrawTag} {fonts} {
1104 .t configure -wrap char
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
1109 .t tag add big 2.0 2.5
1113 test textDisp-9.9 {TkTextRedrawTag} {fonts} {
1114 .t configure -wrap char
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
1119 .t tag add big 1.5 2.5
1123 test textDisp-9.10 {TkTextRedrawTag} {
1124 .t configure -wrap char
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
1129 set tk_textRedraw {none}
1130 .t tag add big 1.3 1.5
1134 test textDisp-9.11 {TkTextRedrawTag} {
1135 .t configure -wrap char
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
1140 .t tag add big 1.0 2.0
1145 test textDisp-10.1 {TkTextRelayoutWindow} {
1146 .t configure -wrap char
1148 .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4"
1150 .t configure -bg black
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"
1162 tkwait visibility .top.t
1163 place .top.t -width 150 -height 100
1167 catch {destroy .top}
1170 .t insert end "Line 1"
1171 for {set i 2} {$i <= 200} {incr i} {
1172 .t insert end "\nLine $i"
1175 test textDisp-11.1 {TkTextSetYView} {
1180 test textDisp-11.2 {TkTextSetYView} {
1185 list [.t index @0,0] $tk_textRedraw
1186 } {32.0 {40.0 41.0}}
1187 test textDisp-11.3 {TkTextSetYView} {
1192 list [.t index @0,0] $tk_textRedraw
1193 } {28.0 {28.0 29.0}}
1194 test textDisp-11.4 {TkTextSetYView} {
1199 list [.t index @0,0] $tk_textRedraw
1201 test textDisp-11.5 {TkTextSetYView} {
1204 set tk_textRedraw {}
1205 .t yview -pickplace 31.0
1207 list [.t index @0,0] $tk_textRedraw
1209 test textDisp-11.6 {TkTextSetYView} {
1212 set tk_textRedraw {}
1213 .t yview -pickplace 28.0
1215 list [.t index @0,0] $tk_textRedraw
1216 } {28.0 {28.0 29.0}}
1217 test textDisp-11.7 {TkTextSetYView} {
1220 set tk_textRedraw {}
1221 .t yview -pickplace 26.0
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} {
1228 set tk_textRedraw {}
1229 .t yview -pickplace 41.0
1231 list [.t index @0,0] $tk_textRedraw
1232 } {32.0 {40.0 41.0}}
1233 test textDisp-11.9 {TkTextSetYView} {
1236 set tk_textRedraw {}
1237 .t yview -pickplace 43.0
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} {
1244 set tk_textRedraw {}
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} {
1252 set tk_textRedraw {}
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"
1261 set tk_textRedraw {}
1264 list [.t index @0,0] $tk_textRedraw
1267 test textDisp-11.13 {TkTestSetYView, partially-visible last line} {
1268 catch {destroy .top}
1270 wm geometry .top +0+0
1271 text .top.t -width 20 -height 5
1273 .top.t insert end "Line 1"
1274 for {set i 2} {$i <= 100} {incr i} {
1275 .top.t insert end "\nLine $i"
1278 scan [wm geometry .top] "%dx%d" w2 h2
1279 wm geometry .top ${w2}x[expr $h2-2]
1283 set tk_textRedraw {}
1286 list [.top.t index @0,0] $tk_textRedraw
1288 catch {destroy .top}
1290 wm geometry .top +0+0
1291 text .top.t -width 30 -height 3
1293 .top.t insert end "Line 1"
1294 for {set i 2} {$i <= 20} {incr i} {
1295 .top.t insert end "\nLine $i"
1298 test textDisp-11.14 {TkTextSetYView, only a few lines visible} {
1304 test textDisp-11.15 {TkTextSetYView, only a few lines visible} {
1310 test textDisp-11.16 {TkTextSetYView, only a few lines visible} {
1316 test textDisp-11.17 {TkTextSetYView, only a few lines visible} {
1324 .t configure -wrap word
1326 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
1327 test textDisp-12.1 {MeasureUp} {
1330 .t yview -pickplace 52.0
1334 test textDisp-12.2 {MeasureUp} {
1337 .t yview -pickplace 53.0
1341 test textDisp-12.3 {MeasureUp} {
1344 .t yview -pickplace 50.10
1348 .t configure -wrap none
1349 test textDisp-12.4 {MeasureUp} {
1352 .t yview -pickplace 53.0
1356 test textDisp-12.5 {MeasureUp} {
1359 .t yview -pickplace 50.10
1364 .t configure -wrap none
1366 for {set i 1} {$i < 99} {incr i} {
1367 .t insert end "Line $i\n"
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} {
1387 test textDisp-13.5 {TkTextSeeCmd procedure} {
1388 .t configure -wrap char
1395 test textDisp-13.6 {TkTextSeeCmd procedure} {
1396 .t configure -wrap char
1401 set x [.t index @0,0]
1402 .t configure -wrap none
1405 test textDisp-13.7 {TkTextSeeCmd procedure} {fonts} {
1408 .t tag add sel 30.20
1409 .t tag add sel 30.40
1412 set x [list [.t bbox 30.50]]
1414 lappend x [.t bbox 30.39]
1416 lappend x [.t bbox 30.38]
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} {
1423 .t tag add sel 30.20
1424 .t tag add sel 30.50
1427 set x [list [.t bbox 30.50]]
1429 lappend x [.t bbox 30.60]
1431 lappend x [.t bbox 30.65]
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
1439 .t tag add sel 30.20
1440 .t tag add sel 30.50
1443 set x [list [.t bbox 30.50]]
1445 lappend x [.t bbox 30.60]
1447 lappend x [.t bbox 30.65]
1449 lappend x [.t bbox 30.90]
1450 } {{80 55 7 13} {136 55 7 13} {136 55 7 13} {80 55 7 13}}
1453 .t configure -wrap none
1454 test textDisp-14.1 {TkTextXviewCmd procedure} {
1457 .t insert end xxxxxxxxx\n
1458 .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1459 .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1463 .t configure -wrap char
1464 test textDisp-14.2 {TkTextXviewCmd procedure} {
1467 .t insert end xxxxxxxxx\n
1468 .t insert end "xxxxx\n"
1469 .t insert end "xxxx"
1472 .t configure -wrap none
1473 test textDisp-14.3 {TkTextXviewCmd procedure} {
1476 .t insert end xxxxxxxxx\n
1477 .t insert end "xxxxx\n"
1478 .t insert end "xxxx"
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} {
1492 .t insert end xxxxxxxxx\n
1493 .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1494 .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1497 } {0.303571 0.660714}
1498 test textDisp-14.8 {TkTextXviewCmd procedure} {
1500 .t insert end xxxxxxxxx\n
1501 .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1502 .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1506 test textDisp-14.9 {TkTextXviewCmd procedure} {
1508 .t insert end xxxxxxxxx\n
1509 .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1510 .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
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} {
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"
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]
1536 test textDisp-14.14 {TkTextXviewCmd procedure} {
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"
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}}
1558 .t configure -wrap char
1560 for {set i 1} {$i < 99} {incr i} {
1561 .t insert end "Line $i\n"
1563 .t insert end "Line 100"
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} {
1569 .t yview scroll -3 units
1572 test textDisp-15.2 {ScrollByLines procedure, scrolling backwards} {
1575 .t yview scroll -2 units
1578 test textDisp-15.3 {ScrollByLines procedure, scrolling backwards} {
1581 .t yview scroll -4 units
1584 test textDisp-15.4 {ScrollByLines procedure, scrolling backwards} {
1587 .t yview scroll -2 units
1590 test textDisp-15.5 {ScrollByLines procedure, scrolling backwards} {
1593 .t yview scroll -2 units
1596 test textDisp-15.6 {ScrollByLines procedure, scrolling backwards} {
1599 .t yview scroll -5 units
1602 test textDisp-15.7 {ScrollByLines procedure, scrolling forwards} {
1605 .t yview scroll 4 units
1609 .t configure -wrap char
1611 .t insert insert "Line 1"
1612 for {set i 2} {$i <= 200} {incr i} {
1613 .t insert end "\nLine $i"
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.}
1619 test textDisp-16.1 {TkTextYviewCmd procedure} {
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} {
1643 test textDisp-16.7 {TkTextYviewCmd procedure} {
1645 .t yv -pickplace 13.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} {
1661 test textDisp-16.12 {TkTextYviewCmd procedure, "moveto" option} {
1665 test textDisp-16.13 {TkTextYviewCmd procedure, "moveto" option} {
1669 test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} {
1673 test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} {
1674 .t yview moveto .752
1677 test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} {
1678 .t yview moveto .754
1681 test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} {
1682 .t yview moveto .755
1685 test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {fonts} {
1686 catch {destroy .top1}
1688 wm geometry .top1 +0+0
1689 text .top1.t -height 3 -width 4 -wrap none -setgrid 1 -padx 6 \
1691 .top1.t insert end "1\n2\n3\n4\n5\n6"
1694 .top1.t yview moveto 0.3333
1695 set result [.top1.t yview]
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} {
1711 .t yview scroll -1 pages
1714 test textDisp-16.23 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1717 .t yview scroll -3 p
1720 test textDisp-16.24 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1723 .t yview scroll -3 p
1726 test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} {
1727 .t configure -height 1
1731 .t yview scroll -1 pages
1732 set x [.t index @0,0]
1733 .t configure -height 10
1737 test textDisp-16.26 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1740 .t yview scroll 1 pages
1743 test textDisp-16.27 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1746 .t yview scroll 2 pages
1749 test textDisp-16.28 {TkTextYviewCmd procedure, "scroll" option, forward pages} {fonts} {
1752 .t yview scroll 1 page
1755 test textDisp-16.29 {TkTextYviewCmd procedure, "scroll" option, forward pages} {
1756 .t configure -height 1
1760 .t yview scroll 1 pages
1761 set x [.t index @0,0]
1762 .t configure -height 10
1766 test textDisp-16.30 {TkTextYviewCmd procedure, "scroll units" option} {
1769 .t yview scroll -3 units
1772 test textDisp-16.31 {TkTextYviewCmd procedure, "scroll units" option} {
1775 .t yview scroll 4 units
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}}
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"
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} {
1810 .t scan dragto 35 55
1813 test textDisp-17.7 {TkTextScanCmd procedure} {fonts} {
1816 .t xview scroll 20 units
1818 .t scan dragto -5 65
1820 set x [.t index @0,0]
1822 list $x [.t index @0,0]
1824 test textDisp-17.8 {TkTextScanCmd procedure} {fonts} {
1828 .t scan dragto 30 100
1829 .t scan dragto 25 95
1832 test textDisp-17.9 {TkTextScanCmd procedure} {fonts} {
1835 .t xview scroll 100 units
1841 .t configure -wrap word
1842 test textDisp-17.10 {TkTextScanCmd procedure, word wrapping} {fonts} {
1845 .t scan dragto -5 65
1846 set x [.t index @0,0]
1848 list $x [.t index @0,0]
1851 .t configure -xscrollcommand scroll -yscrollcommand {}
1852 test textDisp-18.1 {GetXView procedure} {
1853 .t configure -wrap none
1855 .t insert end xxxxxxxxx\n
1856 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1857 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1861 test textDisp-18.2 {GetXView procedure} {
1862 .t configure -wrap char
1864 .t insert end xxxxxxxxx\n
1865 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1866 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1870 test textDisp-18.3 {GetXView procedure} {
1871 .t configure -wrap none
1876 test textDisp-18.4 {GetXView procedure} {
1877 .t configure -wrap none
1879 .t insert end xxxxxxxxx\n
1880 .t insert end xxxxxx\n
1881 .t insert end xxxxxxxxxxxxxxxxx
1885 test textDisp-18.5 {GetXView procedure} {
1886 .t configure -wrap none
1888 .t insert end xxxxxxxxx\n
1889 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1890 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
1891 .t xview scroll 31 units
1894 } {0.563636 0.927273}
1895 test textDisp-18.6 {GetXView procedure} {
1896 .t configure -wrap none
1898 .t insert end xxxxxxxxx\n
1899 .t insert end "xxxxx xxxxxxxxxxx xxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx\n"
1900 .t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
1902 .t xview scroll 31 units
1905 lappend x $scrollInfo
1906 .t configure -wrap char
1908 lappend x $scrollInfo
1909 .t configure -wrap word
1911 lappend x $scrollInfo
1912 .t configure -wrap none
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
1920 set scrollInfo unchanged
1921 .t insert end xxxxxx\n
1926 test textDisp-18.8 {GetXView procedure} {
1929 set x [list $msg $errorInfo]
1932 error "bogus scroll proc"
1934 .t configure -wrap none
1936 .t insert end xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n
1939 .t configure -xscrollcommand scrollError
1942 } {{scrolling error} {scrolling error
1944 "error "scrolling error""
1945 (procedure "scrollError" line 2)
1948 (horizontal scrolling command executed by text)}}
1949 catch {rename bgerror {}}
1950 catch {rename bogus {}}
1951 .t configure -xscrollcommand {} -yscrollcommand scroll
1953 .t configure -xscrollcommand {} -yscrollcommand scroll
1954 test textDisp-19.1 {GetYView procedure} {
1955 .t configure -wrap char
1960 test textDisp-19.2 {GetYView procedure} {
1961 .t configure -wrap char
1964 set scrollInfo "unchanged"
1965 .t insert 1.0 "Line1\nLine2"
1969 test textDisp-19.3 {GetYView procedure} {
1970 .t configure -wrap char
1973 set scrollInfo "unchanged"
1974 .t insert 1.0 "Line 1\nLine 2 is so long that it wraps around\nLine 3"
1978 test textDisp-19.4 {GetYView procedure} {
1979 .t configure -wrap char
1981 .t insert 1.0 "Line 1"
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"
1990 test textDisp-19.5 {GetYView procedure} {
1991 .t configure -wrap char
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"
1997 .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2001 test textDisp-19.6 {GetYView procedure} {
2002 .t configure -wrap char
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"
2008 .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2013 test textDisp-19.7 {GetYView procedure} {
2014 .t configure -wrap char
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"
2020 .t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
2024 } {0.097166 0.692308}
2025 test textDisp-19.8 {GetYView procedure} {
2026 .t configure -wrap char
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"
2032 .t insert 10.end " is really quite long; in fact it's so long that it wraps three times"
2036 } {0.0769231 0.732268}
2037 test textDisp-19.9 {GetYView procedure} {
2038 .t configure -wrap char
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"
2048 test textDisp-19.10 {GetYView procedure} {
2049 .t configure -wrap char
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"
2059 test textDisp-19.11 {GetYView procedure} {
2060 .t configure -wrap word
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"
2066 .t insert end "\nThis last line wraps around four "
2067 .t insert end "times with a bit left on the last line."
2072 test textDisp-19.12 {GetYView procedure, partially visible last line} {
2073 catch {destroy .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"
2080 scan [wm geom .top] %dx%d twidth theight
2081 wm geom .top ${twidth}x[expr $theight - 3]
2085 test textDisp-19.13 {GetYView procedure, partially visible last line} {fonts} {
2086 catch {destroy .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"
2093 scan [wm geom .top] %dx%d twidth theight
2094 wm geom .top ${twidth}x[expr $theight - 3]
2098 catch {destroy .top}
2099 test textDisp-19.14 {GetYView procedure} {
2100 .t configure -wrap word
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"
2106 .t insert end "\nThis last line wraps around four "
2107 .t insert end "times with a bit left on the last line."
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
2117 test textDisp-19.15 {GetYView procedure} {
2118 .t configure -wrap word
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"
2124 .t insert end "\nThis last line wraps around four "
2125 .t insert end "times with a bit left on the last line."
2127 .t configure -yscrollcommand scrollError
2129 global x errorInfo errorCode
2130 set x [list $args $errorInfo $errorCode]
2135 .t configure -yscrollcommand scroll
2137 } {{{scrolling error}} {scrolling error
2139 "error "scrolling error""
2140 (procedure "scrollError" line 2)
2143 (vertical scrolling command executed by text)} NONE}
2146 .t insert end "Line 1"
2147 for {set i 2} {$i <= 200} {incr i} {
2148 .t insert end "\nLine $i"
2150 .t configure -wrap word
2152 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2153 test textDisp-20.1 {FindDLine} {fonts} {
2155 list [.t dlineinfo 46.0] [.t dlineinfo 47.0] [.t dlineinfo 49.0] \
2157 } {{} {} {3 16 49 13 10} {}}
2158 test textDisp-20.2 {FindDLine} {fonts} {
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} {
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} {
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} {
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}}
2180 .t config -wrap word
2181 test textDisp-21.1 {TkTextPixelIndex} {fonts} {
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}
2187 test textDisp-21.2 {TkTextPixelIndex} {fonts} {
2189 list [.t index @11,70] [.t index @11,84] [.t index @11,102] \
2191 } {197.1 198.1 199.1 201.0}
2192 test textDisp-21.3 {TkTextPixelIndex, horizontal scrolling} {fonts} {
2193 .t configure -wrap none
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]
2202 .t insert end "Line 1"
2203 for {set i 2} {$i <= 200} {incr i} {
2204 .t insert end "\nLine $i"
2206 .t configure -wrap word
2208 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2211 test textDisp-22.1 {TkTextCharBbox} {fonts} {
2212 .t config -wrap word
2214 list [.t bbox 47.2] [.t bbox 48.0] [.t bbox 50.5] [.t bbox 50.40] \
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
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
2225 wm geom . ${width}x[expr $height-1]
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
2232 wm geom . ${width}x[expr $height+1]
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
2239 wm geom . [expr $width-95]x$height
2243 test textDisp-22.6 {TkTextCharBbox, line visible but not char} {fonts} {
2244 .t config -wrap char
2246 .t tag add big 20.2 20.5
2247 wm geom . ${width}x[expr $height+3]
2249 list [.t bbox 19.1] [.t bbox 20.1] [.t bbox 20.2]
2250 } {{10 120 7 13} {} {17 133 14 7}}
2253 test textDisp-22.7 {TkTextCharBbox, different character sizes} {fonts} {
2254 .t config -wrap char
2256 .t tag add big 12.2 12.5
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
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
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
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
2291 .t insert end "Line 1"
2292 for {set i 2} {$i <= 200} {incr i} {
2293 .t insert end "\nLine $i"
2295 .t configure -wrap word
2297 .t insert 50.0 "This is a long line, one that will wrap around twice.\n"
2299 test textDisp-23.1 {TkTextDLineInfo} {fonts} {
2300 .t config -wrap word
2302 list [.t dlineinfo 47.3] [.t dlineinfo 48.0] [.t dlineinfo 50.40] \
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
2312 test textDisp-23.3 {TkTextDLineInfo} {fonts} {
2313 .t config -wrap none
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
2321 wm geom . ${width}x[expr $height-1]
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
2328 wm geom . ${width}x[expr $height+1]
2330 list [.t dlineinfo 19.0] [.t dlineinfo 20.0]
2331 } {{3 120 49 13 10} {3 133 49 5 10}}
2334 test textDisp-23.6 {TkTextDLineInfo, horizontal scrolling} {fonts} {
2335 .t config -wrap none
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
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}}
2345 test textDisp-23.7 {TkTextDLineInfo, centering} {fonts} {
2346 .t config -wrap word
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
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}}
2359 test textDisp-24.1 {TkTextCharLayoutProc} {fonts} {
2360 .t configure -wrap char
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
2368 .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2369 wm geom . [expr $width+1]x$height
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
2376 .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2377 wm geom . [expr $width-1]x$height
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
2384 .t insert 1.0 01234567890123456789\n012345678901234567890
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
2392 .t insert 1.0 0\n1\n
2393 wm geom . 110x$height
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
2400 .t insert 1.0 "a b c d e f g h i j k l m n o p"
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
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
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
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
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
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
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
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
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
2440 .t insert 1.0 "01234567890123456789 \nabcdefg"
2441 wm geom . [expr $width-2]x$height
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
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
2459 .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2462 list [.t bbox 1.19] [.t bbox 1.20]
2464 test textDisp-24.14 {TkTextCharLayoutProc, -wrap none} {fonts} {
2465 .t configure -wrap none
2467 .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2468 wm geom . [expr $width+1]x$height
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
2475 .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2476 wm geom . [expr $width-1]x$height
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
2483 .t insert 1.0 "abcdefghijklmnopqrstuvwxyz"
2484 wm geom . 103x$height
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
2491 .t insert 1.0 "This is a line that wraps around"
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
2499 .t insert 1.0 "xThis is a line that wraps around"
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
2507 .t insert 1.0 "xxThis is a line that wraps around"
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
2515 .t insert 1.0 "Line 1\nLine 2\nLine 3"
2517 lappend result [.t bbox 2.1] [.t dlineinfo 2.1]
2518 .t tag configure up -offset 6
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]
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
2528 test textDisp-24.21 {TkTextCharLayoutProc, word breaks} {fonts} {
2529 .t configure -wrap word
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
2536 test textDisp-24.22 {TkTextCharLayoutProc, word breaks} {fonts} {
2537 .t configure -wrap word
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"
2545 test textDisp-24.23 {TkTextCharLayoutProc, word breaks} {fonts} {
2546 .t configure -wrap word
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"
2555 catch {destroy .t.f}
2556 .t configure -width 20
2558 test textDisp-24.24 {TkTextCharLayoutProc, justification and tabs} {fonts} {
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}}
2566 .t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
2569 test textDisp-25.1 {CharBboxProc procedure, check tab width} {fonts} {
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}}
2575 .t configure -width 40 -bd 0 -relief flat -highlightthickness 0 -padx 0 \
2578 test textDisp-26.1 {AdjustForTab procedure, no tabs} {fonts} {
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]
2584 test textDisp-26.2 {AdjustForTab procedure, not enough tabs specified} {
2586 .t insert 1.0 a\tb\tc\td
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]
2593 test textDisp-26.3 {AdjustForTab procedure, not enough tabs specified} {
2595 .t insert 1.0 a\tb\tc\td\te
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]]
2604 test textDisp-26.4 {AdjustForTab procedure, different alignments} {
2606 .t insert 1.0 a\tbc\tde\tfg\thi
2608 .t tag configure x -tabs {40 center 80 left 130 right}
2609 .t tag add x 1.0 end
2613 list [lindex [.t bbox 1.3] 0] [lindex [.t bbox 1.5] 0] \
2614 [lindex [.t bbox 1.10] 0]
2616 test textDisp-26.5 {AdjustForTab procedure, numeric alignment} {
2618 .t insert 1.0 a\t1.234
2620 .t tag configure x -tabs {120 numeric}
2621 .t tag add x 1.0 end
2624 lindex [.t bbox 1.3] 0
2626 test textDisp-26.6 {AdjustForTab procedure, numeric alignment} {
2628 .t insert 1.0 a\t1,456.234
2630 .t tag configure x -tabs {120 numeric}
2631 .t tag add x 1.0 end
2633 lindex [.t bbox 1.7] 0
2635 test textDisp-26.7 {AdjustForTab procedure, numeric alignment} {
2637 .t insert 1.0 a\t1.456.234,7
2639 .t tag configure x -tabs {120 numeric}
2640 .t tag add x 1.0 end
2642 lindex [.t bbox 1.11] 0
2644 test textDisp-26.8 {AdjustForTab procedure, numeric alignment} {
2646 .t insert 1.0 a\ttest
2648 .t tag configure x -tabs {120 numeric}
2649 .t tag add x 1.0 end
2651 lindex [.t bbox 1.6] 0
2653 test textDisp-26.9 {AdjustForTab procedure, numeric alignment} {
2655 .t insert 1.0 a\t1234
2657 .t tag configure x -tabs {120 numeric}
2658 .t tag add x 1.0 end
2660 lindex [.t bbox 1.6] 0
2662 test textDisp-26.10 {AdjustForTab procedure, numeric alignment} {
2664 .t insert 1.0 a\t1.234567
2666 .t tag configure x -tabs {120 numeric}
2667 .t tag add x 1.0 end
2669 lindex [.t bbox 1.3] 0
2671 test textDisp-26.11 {AdjustForTab procedure, numeric alignment} {
2673 .t insert 1.0 a\tx=1.234567
2675 .t tag configure x -tabs {120 numeric}
2676 .t tag add x 1.0 end
2679 lindex [.t bbox 1.5] 0
2681 test textDisp-26.12 {AdjustForTab procedure, adjusting chunks} {
2683 .t insert 1.0 a\tx1.234567
2685 .t tag configure x -tabs {120 numeric}
2686 .t tag add x 1.0 end
2690 .t window create 1.3 -window .b
2692 lindex [.t bbox 1.5] 0
2694 test textDisp-26.13 {AdjustForTab procedure, not enough space} {fonts} {
2696 .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
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]
2704 .t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
2707 test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {fonts} {
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} {
2714 .t insert 1.0 a\tbcd
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} {
2722 .t insert 1.0 a\t\t\tbcd
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} {
2730 .t insert 1.0 a\t\t\tbcd
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} {
2738 .t insert 1.0 a\txyzzyabc
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} {
2746 .t insert 1.0 a\txyzzyabc
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} {
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
2759 .t configure -wrap char -tabs {} -width 20
2761 test textDisp-27.8 {SizeOfTab procedure, right alignment} {fonts} {
2763 .t insert 1.0 a\t\txyzzyabc
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} {
2771 .t insert 1.0 a\txyzzyabc
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} {
2779 .t insert 1.0 a\t123.4
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} {
2787 .t insert 1.0 abc\tdefghijklmnopqrst
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}}
2794 proc bizarre_scroll args {
2795 .t2.t delete 5.0 end
2797 test textDisp-28.1 {"yview" option with bizarre scroll command} {
2800 text .t2.t -width 40 -height 4
2801 .t2.t insert end "1\n2\n3\n4\n5\n6\n7\n8\n"
2803 wm geometry .t2 +0+0
2805 .t2.t configure -yscrollcommand bizarre_scroll
2807 set result [.t2.t index @0,0]
2809 lappend result [.t2.t index @0,0]
2812 test textDisp-29.1 {miscellaneous: lines wrap but are still too long} {fonts} {
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
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} {
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
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} {
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
2856 .t2.t xview scroll 200 units
2858 list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
2859 } {{0.536667 1} 300x50+-156+18 {}}
2865 ::tcltest::cleanupTests