summaryrefslogtreecommitdiffstats
path: root/tests/textDisp.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/textDisp.test')
-rw-r--r--tests/textDisp.test486
1 files changed, 424 insertions, 62 deletions
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 79310b0..da8659b 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -6,11 +6,12 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: textDisp.test,v 1.9 2003/04/01 21:06:53 dgp Exp $
+# RCS: @(#) $Id: textDisp.test,v 1.10 2003/10/31 09:02:16 vincentdarley Exp $
package require tcltest 2.1
eval tcltest::configure $argv
tcltest::loadTestedCommands
+namespace import -force tcltest::test
# The procedure below is used as the scrolling command for the text;
# it just saves the scrolling information in a variable "scrollInfo".
@@ -37,6 +38,7 @@ option add *Text.highlightThickness 2
# because some window managers don't allow the overall width of a window
# to get very narrow.
+catch {destroy .f .t}
frame .f -width 100 -height 20
pack append . .f left
@@ -547,7 +549,7 @@ test textDisp-4.11 {UpdateDisplayInfo, filling in extra vertical space} {
} {6.40 {13.0 7.0 6.80 6.60 6.40} {6.40 6.60 6.80 7.0 13.0}}
test textDisp-4.12 {UpdateDisplayInfo, filling in extra vertical space} {
.t delete 1.0 end
- .t insert end "1\n2\n3\n4\n5\n7\n8\n9\n10\n11\n12\n13"
+ .t insert end "1\n2\n3\n4\n5\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16"
button .b -text "Test" -bd 2 -highlightthickness 2
.t window create 3.end -window .b
.t yview moveto 1
@@ -793,7 +795,7 @@ test textDisp-6.7 {DisplayText, vertical scrollbar updates} {
.t delete 1.0 end
update
set scrollInfo
-} {0 1}
+} {0.0 1.0}
test textDisp-6.8 {DisplayText, vertical scrollbar updates} {
.t configure -wrap char
.t delete 1.0 end
@@ -805,7 +807,7 @@ test textDisp-6.8 {DisplayText, vertical scrollbar updates} {
}
update
set scrollInfo
-} {0 0.769231}
+} {0.0 0.769230769231}
.t configure -yscrollcommand {} -xscrollcommand scroll
test textDisp-6.9 {DisplayText, horizontal scrollbar updates} {
.t configure -wrap none
@@ -817,7 +819,7 @@ test textDisp-6.9 {DisplayText, horizontal scrollbar updates} {
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
update
set scrollInfo
-} {0 0.363636}
+} {0.0 0.363636363636}
# The following group of tests is marked non-portable because
# they result in a lot of extra redisplay under Ultrix. I don't
@@ -1020,10 +1022,12 @@ test textDisp-8.11 {TkTextChanged, scrollbar notification when changes are off-s
update
set scrollInfo ""
.t insert end "a\nb\nc\n"
- update
+ # We need to wait for our asychronous callbacks to update the
+ # scrollbar
+ update ; after 50; update
.t configure -yscrollcommand ""
set scrollInfo
-} {0 0.625}
+} {0.0 0.625}
test textDisp-9.1 {TkTextRedrawTag} {
.t configure -wrap char
@@ -1209,12 +1213,12 @@ test textDisp-11.6 {TkTextSetYView} {
} {28.0 {28.0 29.0}}
test textDisp-11.7 {TkTextSetYView} {
.t yview 30.0
- update
+ update ; update
set tk_textRedraw {}
.t yview -pickplace 26.0
update
list [.t index @0,0] $tk_textRedraw
-} {22.0 {22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0}}
+} {21.0 {21.0 22.0 23.0 24.0 25.0 26.0 27.0 28.0 29.0}}
test textDisp-11.8 {TkTextSetYView} {
.t yview 30.0
update
@@ -1230,7 +1234,7 @@ test textDisp-11.9 {TkTextSetYView} {
.t yview -pickplace 43.0
update
list [.t index @0,0] $tk_textRedraw
-} {39.0 {40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0}}
+} {38.0 {40.0 41.0 42.0 43.0 44.0 45.0 46.0 47.0 48.0}}
test textDisp-11.10 {TkTextSetYView} {
.t yview 30.0
update
@@ -1257,7 +1261,7 @@ test textDisp-11.12 {TkTextSetYView, wrapped line is off-screen} {
list [.t index @0,0] $tk_textRedraw
} {2.0 10.20}
.t delete 10.0 11.0
-test textDisp-11.13 {TkTestSetYView, partially-visible last line} {
+test textDisp-11.13 {TkTestSetYView, partially visible last line} {
catch {destroy .top}
toplevel .top
wm geometry .top +0+0
@@ -1276,8 +1280,10 @@ test textDisp-11.13 {TkTestSetYView, partially-visible last line} {
set tk_textRedraw {}
.top.t see 5.0
update
+ # Note, with smooth scrolling, the results of this test
+ # have changed, and the old '2.0 {5.0 6.0}' is quite wrong.
list [.top.t index @0,0] $tk_textRedraw
-} {2.0 {5.0 6.0}}
+} {1.0 5.0}
catch {destroy .top}
toplevel .top
wm geometry .top +0+0
@@ -1299,7 +1305,8 @@ test textDisp-11.15 {TkTextSetYView, only a few lines visible} {
update
.top.t see 11.0
.top.t index @0,0
-} {10.0}
+ # Thie index 9.0 should be just visible by a couple of pixels
+} {9.0}
test textDisp-11.16 {TkTextSetYView, only a few lines visible} {
.top.t yview 8.0
update
@@ -1311,7 +1318,8 @@ test textDisp-11.17 {TkTextSetYView, only a few lines visible} {
update
.top.t see 4.0
.top.t index @0,0
-} {3.0}
+ # Thie index 2.0 should be just visible by a couple of pixels
+} {2.0}
destroy .top
.t configure -wrap word
@@ -1323,21 +1331,21 @@ test textDisp-12.1 {MeasureUp} {
.t yview -pickplace 52.0
update
.t index @0,0
-} {50.0}
+} {49.0}
test textDisp-12.2 {MeasureUp} {
.t yview 100.0
update
.t yview -pickplace 53.0
update
.t index @0,0
-} {50.15}
+} {50.0}
test textDisp-12.3 {MeasureUp} {
.t yview 100.0
update
.t yview -pickplace 50.10
update
.t index @0,0
-} {46.0}
+} {45.0}
.t configure -wrap none
test textDisp-12.4 {MeasureUp} {
.t yview 100.0
@@ -1345,14 +1353,14 @@ test textDisp-12.4 {MeasureUp} {
.t yview -pickplace 53.0
update
.t index @0,0
-} {49.0}
+} {48.0}
test textDisp-12.5 {MeasureUp} {
.t yview 100.0
update
.t yview -pickplace 50.10
update
.t index @0,0
-} {46.0}
+} {45.0}
.t configure -wrap none
.t delete 1.0 end
@@ -1394,7 +1402,7 @@ test textDisp-13.6 {TkTextSeeCmd procedure} {
set x [.t index @0,0]
.t configure -wrap none
set x
-} {28.0}
+} {27.0}
test textDisp-13.7 {TkTextSeeCmd procedure} {fonts} {
.t xview moveto 0
.t yview moveto 0
@@ -1463,7 +1471,7 @@ test textDisp-14.1 {TkTextXviewCmd procedure} {
.t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
.t xview moveto .5
.t xview
-} {0.5 0.857143}
+} {0.5 0.857142857143}
.t configure -wrap char
test textDisp-14.2 {TkTextXviewCmd procedure} {
.t delete 1.0 end
@@ -1472,7 +1480,7 @@ test textDisp-14.2 {TkTextXviewCmd procedure} {
.t insert end "xxxxx\n"
.t insert end "xxxx"
.t xview
-} {0 1}
+} {0.0 1.0}
.t configure -wrap none
test textDisp-14.3 {TkTextXviewCmd procedure} {
.t delete 1.0 end
@@ -1481,7 +1489,7 @@ test textDisp-14.3 {TkTextXviewCmd procedure} {
.t insert end "xxxxx\n"
.t insert end "xxxx"
.t xview
-} {0 1}
+} {0.0 1.0}
test textDisp-14.4 {TkTextXviewCmd procedure} {
list [catch {.t xview moveto} msg] $msg
} {1 {wrong # args: should be ".t xview moveto fraction"}}
@@ -1498,7 +1506,7 @@ test textDisp-14.7 {TkTextXviewCmd procedure} {
.t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
.t xview moveto .3
.t xview
-} {0.303571 0.660714}
+} {0.303571428571 0.660714285714}
test textDisp-14.8 {TkTextXviewCmd procedure} {
.t delete 1.0 end
.t insert end xxxxxxxxx\n
@@ -1506,7 +1514,7 @@ test textDisp-14.8 {TkTextXviewCmd procedure} {
.t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
.t xview moveto -.4
.t xview
-} {0 0.357143}
+} {0.0 0.357142857143}
test textDisp-14.9 {TkTextXviewCmd procedure} {
.t delete 1.0 end
.t insert end xxxxxxxxx\n
@@ -1514,7 +1522,7 @@ test textDisp-14.9 {TkTextXviewCmd procedure} {
.t insert end "xxxx xxxxxxxxx xxxxxxxxxxxxx"
.t xview m 1.4
.t xview
-} {0.642857 1}
+} {0.642857142857 1.0}
test textDisp-14.10 {TkTextXviewCmd procedure} {
list [catch {.t xview scroll a} msg] $msg
} {1 {wrong # args: should be ".t xview scroll number units|pages"}}
@@ -1619,13 +1627,13 @@ for {set i 2} {$i <= 200} {incr i} {
.t tag add big 100.0 105.0
.t insert 151.end { has a lot of extra text, so that it wraps around on the screen several times over.}
.t insert 153.end { also has enoug extra text to wrap.}
-update
+update ; .t count -update -ypixels 1.0 end
test textDisp-16.1 {TkTextYviewCmd procedure} {
.t yview 21.0
set x [.t yview]
.t yview 1.0
- set x
-} {0.1 0.15}
+ list [expr {int([lindex $x 0]*100)}] [expr {int ([lindex $x 1] * 100)}]
+} {9 14}
test textDisp-16.2 {TkTextYviewCmd procedure} {
list [catch {.t yview 2 3} msg] $msg
} {1 {unknown option "2": must be moveto or scroll}}
@@ -1661,7 +1669,7 @@ test textDisp-16.10 {TkTextYviewCmd procedure, "moveto" option} {
test textDisp-16.11 {TkTextYviewCmd procedure, "moveto" option} {
.t yview moveto 0.5
.t index @0,0
-} {101.0}
+} {103.0}
test textDisp-16.12 {TkTextYviewCmd procedure, "moveto" option} {
.t yview moveto -1
.t index @0,0
@@ -1673,19 +1681,19 @@ test textDisp-16.13 {TkTextYviewCmd procedure, "moveto" option} {
test textDisp-16.14 {TkTextYviewCmd procedure, "moveto" option} {
.t yview moveto .75
.t index @0,0
-} {151.0}
+} {151.60}
test textDisp-16.15 {TkTextYviewCmd procedure, "moveto" option} {
.t yview moveto .752
.t index @0,0
-} {151.20}
+} {151.60}
test textDisp-16.16 {TkTextYviewCmd procedure, "moveto" option} {
.t yview moveto .754
.t index @0,0
-} {151.60}
+} {151.80}
test textDisp-16.17 {TkTextYviewCmd procedure, "moveto" option} {
.t yview moveto .755
.t index @0,0
-} {152.0}
+} {151.80}
test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {fonts} {
catch {destroy .top1}
toplevel .top1
@@ -1702,12 +1710,15 @@ test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {fonts} {
} {0.333333 0.833333}
test textDisp-16.19 {TkTextYviewCmd procedure, "scroll" option} {
list [catch {.t yview scroll a} msg] $msg
-} {1 {wrong # args: should be ".t yview scroll number units|pages"}}
+} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}}
test textDisp-16.20 {TkTextYviewCmd procedure, "scroll" option} {
list [catch {.t yview scroll a b c} msg] $msg
-} {1 {wrong # args: should be ".t yview scroll number units|pages"}}
+} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}}
test textDisp-16.21 {TkTextYviewCmd procedure, "scroll" option} {
list [catch {.t yview scroll badInt bogus} msg] $msg
+} {1 {bad argument "bogus": must be units, pages or pixels}}
+test textDisp-16.21.2 {TkTextYviewCmd procedure, "scroll" option} {
+ list [catch {.t yview scroll badInt units} msg] $msg
} {1 {expected integer but got "badInt"}}
test textDisp-16.22 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t yview 50.0
@@ -1715,16 +1726,19 @@ test textDisp-16.22 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t yview scroll -1 pages
.t index @0,0
} {42.0}
+test textDisp-16.22.1 {TkTextYviewCmd procedure, "scroll" option, back pages} {
+ list [catch {.t yview scroll -3 p} res] $res
+} {1 {ambiguous argument "p": must be units, pages or pixels}}
test textDisp-16.23 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t yview 50.0
update
- .t yview scroll -3 p
+ .t yview scroll -3 pa
.t index @0,0
} {26.0}
test textDisp-16.24 {TkTextYviewCmd procedure, "scroll" option, back pages} {
.t yview 5.0
update
- .t yview scroll -3 p
+ .t yview scroll -3 pa
.t index @0,0
} {1.0}
test textDisp-16.25 {TkTextYviewCmd procedure, "scroll" option, back pages} {
@@ -1781,10 +1795,65 @@ test textDisp-16.31 {TkTextYviewCmd procedure, "scroll units" option} {
} {151.40}
test textDisp-16.32 {TkTextYviewCmd procedure} {
list [catch {.t yview scroll 12 bogoids} msg] $msg
-} {1 {bad argument "bogoids": must be units or pages}}
+} {1 {bad argument "bogoids": must be units, pages or pixels}}
test textDisp-16.33 {TkTextYviewCmd procedure} {
list [catch {.t yview bad_arg 1 2} msg] $msg
} {1 {unknown option "bad_arg": must be moveto or scroll}}
+test textDisp-16.34 {TkTextYviewCmd procedure} {
+ set res {}
+ .t yview 1.0
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll 1 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll 1 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll 1 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll 1 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll 1 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+} {0.0 1.0 2.0 3.0 4.0 5.0}
+test textDisp-16.35 {TkTextYviewCmd procedure} {
+ set res {}
+ .t yview 1.0
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll 13 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll -4 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll -9 pixels
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+} {0.0 13.0 9.0 0.0}
+test textDisp-16.36 {TkTextYviewCmd procedure} {
+ set res {}
+ .t yview 1.0
+ .t yview scroll 5 pixels
+ .t yview scroll -1 pages
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+ .t yview scroll 5 pixels
+ .t yview scroll -1 units
+ lappend res [expr {[lindex [.t yview] 0] * [.t count -ypixels 1.0 end]}]
+} {0.0 0.0}
+test textDisp-16.37 {TkTextYviewCmd procedure} {
+ list [catch {.t yview scroll 1.3 pixels} msg] $msg
+} {0 {}}
+test textDisp-16.38 {TkTextYviewCmd procedure} {
+ list [catch {.t yview scroll 1.3blah pixels} msg] $msg
+} {1 {bad screen distance "1.3blah"}}
+test textDisp-16.39 {TkTextYviewCmd procedure} {
+ list [catch {.t yview scroll 1.3i pixels} msg] $msg
+} {0 {}}
+test textDisp-16.40 {text count -xpixels} {
+ set res {}
+ lappend res [.t count -xpixels 1.0 1.5] \
+ [.t count -xpixels 1.5 1.0] \
+ [.t count -xpixels 1.0 13.0] \
+ [.t count -xpixels 1.0 "1.0 displaylineend"] \
+ [.t count -xpixels 1.0 "1.0 lineend"] \
+ [.t count -xpixels 1.0 "1.0 displaylineend"] \
+ [.t count -xpixels 1.0 end]
+} {35 -35 0 42 42 42 0}
.t delete 1.0 end
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} {
@@ -1861,7 +1930,7 @@ test textDisp-18.1 {GetXView procedure} {
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
update
set scrollInfo
-} {0 0.363636}
+} {0.0 0.363636363636}
test textDisp-18.2 {GetXView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -1870,13 +1939,13 @@ test textDisp-18.2 {GetXView procedure} {
.t insert end xxxxxxxxxxxxxxxxxxxxxxxxxx
update
set scrollInfo
-} {0 1}
+} {0.0 1.0}
test textDisp-18.3 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
update
set scrollInfo
-} {0 1}
+} {0.0 1.0}
test textDisp-18.4 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
@@ -1885,7 +1954,7 @@ test textDisp-18.4 {GetXView procedure} {
.t insert end xxxxxxxxxxxxxxxxx
update
set scrollInfo
-} {0 1}
+} {0.0 1.0}
test textDisp-18.5 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
@@ -1895,7 +1964,7 @@ test textDisp-18.5 {GetXView procedure} {
.t xview scroll 31 units
update
set scrollInfo
-} {0.563636 0.927273}
+} {0.563636363636 0.927272727273}
test textDisp-18.6 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
@@ -1916,7 +1985,7 @@ test textDisp-18.6 {GetXView procedure} {
.t configure -wrap none
update
lappend x $scrollInfo
-} {{0.553571 0.910714} {0 1} {0 1} {0 0.357143}}
+} {{0.553571428571 0.910714285714} {0.0 1.0} {0.0 1.0} {0.0 0.357142857143}}
test textDisp-18.7 {GetXView procedure} {
.t configure -wrap none
.t delete 1.0 end
@@ -1948,7 +2017,7 @@ test textDisp-18.8 {GetXView procedure} {
"error "scrolling error""
(procedure "scrollError" line 2)
invoked from within
-"scrollError 0 1"
+"scrollError 0.0 1.0"
(horizontal scrolling command executed by text)}}
catch {rename bgerror {}}
catch {rename bogus {}}
@@ -1960,7 +2029,7 @@ test textDisp-19.1 {GetYView procedure} {
.t delete 1.0 end
update
set scrollInfo
-} {0 1}
+} {0.0 1.0}
test textDisp-19.2 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -1973,7 +2042,7 @@ test textDisp-19.2 {GetYView procedure} {
test textDisp-19.3 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
- update
+ update; after 10 ; update
set scrollInfo "unchanged"
.t insert 1.0 "Line 1\nLine 2 is so long that it wraps around\nLine 3"
update
@@ -1990,7 +2059,7 @@ test textDisp-19.4 {GetYView procedure} {
}
update
set scrollInfo
-} {0 0.769231}
+} {0.0 0.769230769231}
test textDisp-19.5 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -1999,9 +2068,9 @@ test textDisp-19.5 {GetYView procedure} {
.t insert end "\nLine $i"
}
.t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
- update
+ update ; after 100
set x $scrollInfo
-} {0 0.538462}
+} {0.0 0.625}
test textDisp-19.6 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -2013,7 +2082,7 @@ test textDisp-19.6 {GetYView procedure} {
.t yview 4.0
update
set x $scrollInfo
-} {0.230769 1}
+} {0.375 1.0}
test textDisp-19.7 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -2023,9 +2092,9 @@ test textDisp-19.7 {GetYView procedure} {
}
.t insert 2.end " is really quite long; in fact it's so long that it wraps three times"
.t yview 2.26
- update
+ update; after 1; update
set x $scrollInfo
-} {0.097166 0.692308}
+} {0.125 0.75}
test textDisp-19.8 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -2036,8 +2105,9 @@ test textDisp-19.8 {GetYView procedure} {
.t insert 10.end " is really quite long; in fact it's so long that it wraps three times"
.t yview 2.0
update
+ .t count -update -ypixels 1.0 end
set x $scrollInfo
-} {0.0769231 0.732268}
+} {0.0625 0.6875}
test textDisp-19.9 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -2048,7 +2118,7 @@ test textDisp-19.9 {GetYView procedure} {
.t yview 3.0
update
set scrollInfo
-} {0.133333 0.8}
+} {0.133333333333 0.8}
test textDisp-19.10 {GetYView procedure} {
.t configure -wrap char
.t delete 1.0 end
@@ -2059,7 +2129,29 @@ test textDisp-19.10 {GetYView procedure} {
.t yview 11.0
update
set scrollInfo
-} {0.333333 1}
+} {0.333333333333 1.0}
+test textDisp-19.10.1 {Widget manipulation causes height miscount} {
+ .t configure -wrap char
+ .t delete 1.0 end
+ .t insert 1.0 "Line 1"
+ foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
+ .t insert end "\nLine $i"
+ }
+ .t yview 11.0
+ update
+ .t configure -wrap word
+ .t delete 1.0 end
+ .t insert 1.0 "Line 1"
+ foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
+ .t insert end "\nLine $i"
+ }
+ .t insert end "\nThis last line wraps around four "
+ .t insert end "times with a bit left on the last line."
+ .t yview insert
+ update
+ .t count -update -ypixels 1.0 end
+ set scrollInfo
+} {0.5 1.0}
test textDisp-19.11 {GetYView procedure} {
.t configure -wrap word
.t delete 1.0 end
@@ -2071,8 +2163,134 @@ test textDisp-19.11 {GetYView procedure} {
.t insert end "times with a bit left on the last line."
.t yview insert
update
+ .t count -update -ypixels 1.0 end
set scrollInfo
-} {0.625 1}
+} {0.5 1.0}
+test textDisp-19.11.2 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 1.0 end
+} {20}
+test textDisp-19.11.3 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines end 1.0
+} {-20}
+test textDisp-19.11.4 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 1.1 1.3
+} {0}
+test textDisp-19.11.5 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 16.0 16.1
+} {0}
+test textDisp-19.11.5.1 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 16.0 16.5
+} {0}
+test textDisp-19.11.6 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 16.0 16.20
+} {1}
+test textDisp-19.11.7 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 16.0 16.40
+} {2}
+test textDisp-19.11.8 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines "16.0 displaylineend +1c" "16.0 lineend"
+} {3}
+test textDisp-19.11.9 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 16.0 "16.0 lineend"
+} {4}
+test textDisp-19.11.10 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 16.0 "16.0 +4displaylines"
+} {4}
+test textDisp-19.11.11 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines 16.0 "16.0 +2displaylines"
+} {2}
+test textDisp-19.11.12 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t count -displaylines "16.0 +1displayline" "16.0 +2displaylines -1c"
+} {0}
+.t tag configure elide -elide 1
+test textDisp-19.11.13 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "16.0 +1displaylines" "16.0 +1displaylines +6c"
+ .t count -displaylines 16.0 "16.0 +4displaylines"
+} {4}
+test textDisp-19.11.14 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "16.0 +1displaylines" "16.0 +1displaylines displaylineend"
+ .t count -displaylines 16.0 "16.0 +4displaylines"
+} {4}
+test textDisp-19.11.15 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "16.0 +1displaylines" "16.0 +2displaylines"
+ .t count -displaylines 16.0 "16.0 +4displaylines -1c"
+} {3}
+test textDisp-19.11.15 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "16.0 +1displaylines" "16.0 +2displaylines"
+ .t count -displaylines 16.0 "16.0 +4displaylines"
+} {4}
+test textDisp-19.11.16 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "12.0" "14.0"
+ .t count -displaylines 12.0 16.0
+} {2}
+test textDisp-19.11.17 {TextWidgetCmd procedure, "index +displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "12.0" "14.0"
+ list [.t index "11.5 +2d lines"] \
+ [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \
+ [.t index "13.0 +2d lines"] [.t index "13.1 +3d lines"] \
+ [.t index "13.0 +4d lines"]
+} {15.5 16.0 15.0 16.0 16.15 16.33}
+test textDisp-19.11.18 {TextWidgetCmd procedure, "index +displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "12.0" "14.0"
+ list [.t index "15.5 -2d lines"] \
+ [.t index "16.0 -2d lines"] [.t index "15.0 -2d lines"] \
+ [.t index "16.0 -3d lines"] [.t index "16.17 -4d lines"] \
+ [.t index "16.36 -5d lines"]
+} {11.5 14.0 11.0 11.0 11.2 11.3}
+test textDisp-19.11.19 {TextWidgetCmd procedure, "count -displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "12.0" "16.0 +1displaylines"
+ .t count -displaylines 12.0 17.0
+} {4}
+test textDisp-19.11.20 {TextWidgetCmd procedure, "index +displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "12.0" "16.0 +1displaylines"
+ list [.t index "11.5 +2d lines"] \
+ [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \
+ [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \
+ [.t index "13.0 +4d lines"]
+} {16.38 16.50 16.33 16.50 16.67 17.0}
+test textDisp-19.11.21 {TextWidgetCmd procedure, "index +displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "12.0" "16.0 +1displaylines"
+ list [.t index "16.38 -2d lines"] \
+ [.t index "16.50 -3d lines"] [.t index "16.33 -2d lines"] \
+ [.t index "16.53 -4d lines"] [.t index "16.69 -4d lines"] \
+ [.t index "17.1 -5d lines"]
+} {11.5 11.0 11.0 10.3 11.2 11.0}
+test textDisp-19.11.22 {TextWidgetCmd procedure, "index +displaylines"} {
+ .t tag remove elide 1.0 end
+ list [.t index "end +5d lines"] \
+ [.t index "end -3d lines"] [.t index "1.0 -2d lines"] \
+ [.t index "1.0 +4d lines"] [.t index "1.0 +50d lines"] \
+ [.t index "end -50d lines"]
+} {17.0 16.33 1.0 5.0 17.0 1.0}
+test textDisp-19.11.23 {TextWidgetCmd procedure, "index +displaylines"} {
+ .t tag remove elide 1.0 end
+ .t tag add elide "12.3" "16.0 +1displaylines"
+ list [.t index "11.5 +2d lines"] \
+ [.t index "12.0 +2d lines"] [.t index "11.0 +2d lines"] \
+ [.t index "13.0 +2d lines"] [.t index "13.0 +3d lines"] \
+ [.t index "13.0 +4d lines"]
+} {16.21 16.33 16.16 16.50 16.67 17.0}
+.t tag remove elide 1.0 end
+test textDisp-19.11.24 {TextWidgetCmd procedure, "index +/-displaylines"} {
+ list [.t index "11.5 + -1 display lines"] \
+ [.t index "11.5 + +1 disp lines"] \
+ [.t index "11.5 - -1 disp lines"] \
+ [.t index "11.5 - +1 disp lines"] \
+ [.t index "11.5 -1 disp lines"] \
+ [.t index "11.5 +1 disp lines"] \
+ [.t index "11.5 +0 disp lines"]
+} {10.5 12.5 12.5 10.5 10.5 12.5 11.5}
+.t tag remove elide 1.0 end
test textDisp-19.12 {GetYView procedure, partially visible last line} {
catch {destroy .top}
toplevel .top
@@ -2080,12 +2298,13 @@ test textDisp-19.12 {GetYView procedure, partially visible last line} {
text .top.t -width 40 -height 5
pack .top.t -expand yes -fill both
.top.t insert end "Line 1\nLine 2\nLine 3\nLine 4\nLine 5"
- update
+ # Need to wait for asychronous calculations to complete.
+ update ; after 10
scan [wm geom .top] %dx%d twidth theight
wm geom .top ${twidth}x[expr $theight - 3]
update
.top.t yview
-} {0 0.8}
+} {0.0 0.9625}
test textDisp-19.13 {GetYView procedure, partially visible last line} {fonts} {
catch {destroy .top}
toplevel .top
@@ -2109,7 +2328,8 @@ test textDisp-19.14 {GetYView procedure} {
}
.t insert end "\nThis last line wraps around four "
.t insert end "times with a bit left on the last line."
- update
+ # Need to update so everything is calculated.
+ update ; .t count -update -ypixels 1.0 end
set scrollInfo "unchanged"
.t mark set insert 3.0
.t tag configure x -background red
@@ -2143,9 +2363,30 @@ test textDisp-19.15 {GetYView procedure} {
"error "scrolling error""
(procedure "scrollError" line 2)
invoked from within
-"scrollError 0 1"
+"scrollError 0.0 1.0"
(vertical scrolling command executed by text)} NONE}
+test textDisp-19.16 {count -ypixels} {
+ .t configure -wrap word
+ .t delete 1.0 end
+ .t insert 1.0 "Line 1"
+ foreach i {2 3 4 5 6 7 8 9 10 11 12 13 14 15} {
+ .t insert end "\nLine $i"
+ }
+ .t insert end "\nThis last line wraps around four "
+ .t insert end "times with a bit left on the last line."
+ # Need to update so everything is calculated.
+ update
+ set res {}
+ lappend res \
+ [.t count -ypixels 1.0 end] \
+ [.t count -update -ypixels 1.0 end] \
+ [.t count -ypixels 15.0 16.0] \
+ [.t count -ypixels 15.0 "16.0 displaylineend +1c"] \
+ [.t count -ypixels 16.0 "16.0 displaylineend +1c"] \
+ [.t count -ypixels "16.0 +1 displaylines" "16.0 +4 displaylines +3c"]
+} {300 300 15 30 15 45}
+
.t delete 1.0 end
.t insert end "Line 1"
for {set i 2} {$i <= 200} {incr i} {
@@ -2862,6 +3103,127 @@ test textDisp-29.3 {miscellaneous: lines wrap but are still too long} {fonts} {
list [.t2.t xview] [winfo geom .t2.t.f] [.t2.t bbox 1.3]
} {{0.536667 1} 300x50+-156+18 {}}
+test textDisp-30.1 {elidden text complications} {knownBug} {
+ .t2.t delete 1.0 end
+ .t2.t insert 1.0 "1111\n2222\n3333"
+ .t2.t tag configure elidden -elide 1 -background red
+ .t2.t tag add elidden 1.2 3.2
+ # Known Bug: the newline at 1.4 will not be elidden.
+ # Each logical line must have its own DLines
+ .t2.t count -displaylines 1.0 end
+} {1}
+
+.t configure -height 1
+update
+
+test textDisp-31.1 {line embedded window height update} {
+ set res {}
+ .t delete 1.0 end
+ .t insert end "abcd\nefgh\nijkl\nmnop\nqrst\nuvwx\nyx"
+ frame .t.f -background red -width 100 -height 100
+ .t window create 3.0 -window .t.f
+ lappend res [.t count -update -ypixels 1.0 end]
+ .t.f configure -height 10
+ lappend res [.t count -ypixels 1.0 end]
+ lappend res [.t count -update -ypixels 1.0 end]
+ set res
+} {190 190 105}
+
+test textDisp-31.2 {line update index shifting} {
+ set res {}
+ .t.f configure -height 100
+ update
+ lappend res [.t count -update -ypixels 1.0 end]
+ .t.f configure -height 10
+ .t insert 1.0 "abc\n"
+ .t insert 1.0 "abc\n"
+ lappend res [.t count -ypixels 1.0 end]
+ lappend res [.t count -update -ypixels 1.0 end]
+ .t.f configure -height 100
+ .t delete 1.0 3.0
+ lappend res [.t count -ypixels 1.0 end]
+ lappend res [.t count -update -ypixels 1.0 end]
+ set res
+} {190 220 135 105 190}
+
+test textDisp-31.3 {line update index shifting} {
+ # Should do exactly the same as the above, as long
+ # as we are correctly tagging the correct lines for
+ # recalculation. The 'update' and 'delay' must be
+ # long enough to ensure all asynchronous updates
+ # have been performed.
+ set res {}
+ .t.f configure -height 100
+ update
+ lappend res [.t count -update -ypixels 1.0 end]
+ .t.f configure -height 10
+ .t insert 1.0 "abc\n"
+ .t insert 1.0 "abc\n"
+ lappend res [.t count -ypixels 1.0 end]
+ update ; after 1000 ; update
+ lappend res [.t count -ypixels 1.0 end]
+ .t.f configure -height 100
+ .t delete 1.0 3.0
+ lappend res [.t count -ypixels 1.0 end]
+ update ; after 1000 ; update
+ lappend res [.t count -ypixels 1.0 end]
+ set res
+} {190 220 135 105 190}
+
+test textDisp-31.4 {line embedded image height update} {
+ set res {}
+ image create photo textest -height 100 -width 10
+ .t delete 3.0
+ .t image create 3.0 -image textest
+ update
+ lappend res [.t count -update -ypixels 1.0 end]
+ textest configure -height 10
+ lappend res [.t count -ypixels 1.0 end]
+ lappend res [.t count -update -ypixels 1.0 end]
+ set res
+} {190 190 105}
+
+test textDisp-31.5 {line update index shifting} {
+ set res {}
+ textest configure -height 100
+ update ; after 1000 ; update
+ lappend res [.t count -update -ypixels 1.0 end]
+ textest configure -height 10
+ .t insert 1.0 "abc\n"
+ .t insert 1.0 "abc\n"
+ lappend res [.t count -ypixels 1.0 end]
+ lappend res [.t count -update -ypixels 1.0 end]
+ textest configure -height 100
+ .t delete 1.0 3.0
+ lappend res [.t count -ypixels 1.0 end]
+ lappend res [.t count -update -ypixels 1.0 end]
+ set res
+} {190 220 135 105 190}
+
+test textDisp-31.6 {line update index shifting} {
+ # Should do exactly the same as the above, as long
+ # as we are correctly tagging the correct lines for
+ # recalculation. The 'update' and 'delay' must be
+ # long enough to ensure all asynchronous updates
+ # have been performed.
+ set res {}
+ textest configure -height 100
+ update ; after 1000 ; update
+ lappend res [.t count -update -ypixels 1.0 end]
+ textest configure -height 10
+ .t insert 1.0 "abc\n"
+ .t insert 1.0 "abc\n"
+ lappend res [.t count -ypixels 1.0 end]
+ update ; after 1000 ; update
+ lappend res [.t count -ypixels 1.0 end]
+ textest configure -height 100
+ .t delete 1.0 3.0
+ lappend res [.t count -ypixels 1.0 end]
+ update ; after 1000 ; update
+ lappend res [.t count -ypixels 1.0 end]
+ set res
+} {190 220 135 105 190}
+
deleteWindows
option clear