summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2005-10-10 10:36:34 (GMT)
committervincentdarley <vincentdarley>2005-10-10 10:36:34 (GMT)
commit465cf308ea2f63fa388ed9e0e055c82e8e9e3ca3 (patch)
treece21d5eee20f7e5c9a628e238ad0a87a0aaeebad /tests
parentebaf2538558086d8a3749809e5863e1b134f19ab (diff)
downloadtk-465cf308ea2f63fa388ed9e0e055c82e8e9e3ca3.zip
tk-465cf308ea2f63fa388ed9e0e055c82e8e9e3ca3.tar.gz
tk-465cf308ea2f63fa388ed9e0e055c82e8e9e3ca3.tar.bz2
tip256 implementation
Diffstat (limited to 'tests')
-rw-r--r--tests/text.test67
-rw-r--r--tests/textDisp.test148
2 files changed, 211 insertions, 4 deletions
diff --git a/tests/text.test b/tests/text.test
index e25e71b..17c9488 100644
--- a/tests/text.test
+++ b/tests/text.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: text.test,v 1.39 2005/08/23 23:04:42 dkf Exp $
+# RCS: @(#) $Id: text.test,v 1.40 2005/10/10 10:36:35 vincentdarley Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -86,6 +86,7 @@ foreach test {
{-spacing3 -10 0 bogus}
{-state d disabled foo}
{-tabs {1i 2i 3i 4i} {1i 2i 3i 4i} bad_tabs}
+ {-tabstyle wordprocessor wordprocessor garbage}
{-undo 1 1 eh}
{-width 73 73 2.4}
{-wrap w word bad_wrap}
@@ -115,7 +116,7 @@ test text-1.[incr i] {text options} {
lappend result [lindex $i 4]
}
set result
-} {1 blue {} {} 0 7 watch {} 0 {} fixed #012 5 #123 #234 0 #ffff01234567 green 45 100 47 2 5 3 82 raised #ffff01234567 21 yellow 0 0 0 0 {} disabled {1i 2i 3i 4i} {any old thing} 1 73 word {x scroll command} {test command}}
+} {1 blue {} {} 0 7 watch {} 0 {} fixed #012 5 #123 #234 0 #ffff01234567 green 45 100 47 2 5 3 82 raised #ffff01234567 21 yellow 0 0 0 0 {} disabled {1i 2i 3i 4i} wordprocessor {any old thing} 1 73 word {x scroll command} {test command}}
test text-2.1 {Tk_TextCmd procedure} {
list [catch {text} msg] $msg
@@ -1805,6 +1806,13 @@ test text-20.78.5 {TextSearchCmd, hidden text inside match must count in length}
list [.t2 search -strict -all -count foo foar 1.3] $foo
} {{2.0 3.0} {6 4}}
+test text-20.78.6 {TextSearchCmd, single line with -all} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert end " X\n X\n X\n X\n X\n X\n"
+ .t2 search -all -regexp { +| *\n} 1.0 end
+} {1.0 1.2 2.0 2.2 3.0 3.2 4.0 4.2 5.0 5.2 6.0 6.2 7.0}
+
test text-20.79 {TextSearchCmd, multiline matching} {
deleteWindows
pack [text .t2]
@@ -2828,6 +2836,61 @@ test text-20.185 {TextSearchCmd, elide up to match} {
lappend res [.t2 search -regexp c 1.0]
} {{} {} 1.0 2.1 2.0 3.1 2.0 3.0}
+test text-20.186 {TextSearchCmd, strict limits} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -strictlimits -- "world" 1.3 1.8
+} {}
+
+test text-20.187 {TextSearchCmd, strict limits} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -strictlimits -- "world" 1.3 1.10
+} {}
+
+test text-20.188 {TextSearchCmd, strict limits} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -strictlimits -- "world" 1.3 1.11
+} {1.6}
+
+test text-20.1189 {TextSearchCmd, strict limits backwards} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -strictlimits -backward -- "world" 2.3 1.8
+} {}
+
+test text-20.190 {TextSearchCmd, strict limits backwards} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -strictlimits -backward -- "world" 2.3 1.6
+} {1.6}
+
+test text-20.191 {TextSearchCmd, strict limits backwards} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -strictlimits -backward -- "world" 2.3 1.7
+} {}
+
+test text-20.188 {TextSearchCmd, strict limits} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -regexp -strictlimits -- "world" 1.3 1.8
+} {}
+
+test text-20.189 {TextSearchCmd, strict limits} {
+ deleteWindows
+ pack [text .t2]
+ .t2 insert 1.0 "Hello world!\nThis is a test\n"
+ .t2 search -regexp -strictlimits -backward -- "world" 2.3 1.8
+} {}
deleteWindows
text .t2 -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 365dd8d..cd52fe0 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: textDisp.test,v 1.37 2005/05/10 22:26:16 dgp Exp $
+# RCS: @(#) $Id: textDisp.test,v 1.38 2005/10/10 10:36:35 vincentdarley Exp $
package require tcltest 2.1
eval tcltest::configure $argv
@@ -2992,6 +2992,15 @@ test textDisp-26.1 {AdjustForTab procedure, no tabs} {textfonts} {
.t insert 1.0 a\tbcdefghij\tc\td
list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
[lindex [.t bbox 1.14] 0]
+} [list 56 126 168]
+test textDisp-26.1.2 {AdjustForTab procedure, no tabs} {textfonts} {
+ .t delete 1.0 end
+ .t insert 1.0 a\tbcdefghij\tc\td
+ .t configure -tabstyle wordprocessor
+ set res [list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
+ [lindex [.t bbox 1.14] 0]]
+ .t configure -tabstyle tabular
+ set res
} [list 56 168 224]
test textDisp-26.2 {AdjustForTab procedure, not enough tabs specified} {
.t delete 1.0 end
@@ -3111,6 +3120,17 @@ test textDisp-26.13 {AdjustForTab procedure, not enough space} {textfonts} {
.t tag add x 1.0 end
list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
[lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]
+} [list 28 56 84 120]
+test textDisp-26.13.2 {AdjustForTab procedure, not enough space} {textfonts} {
+ .t delete 1.0 end
+ .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
+ .t tag delete x
+ .t tag configure x -tabs {10 30 center 50 right 120} -tabstyle wordprocessor
+ .t tag add x 1.0 end
+ set res [list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
+ [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]]
+ .t tag configure x -tabstyle tabular
+ set res
} [list 28 56 120 190]
test textDisp-26.14 {AdjustForTab procedure, not enough space} {textfonts} {
.t delete 1.0 end
@@ -3120,6 +3140,18 @@ test textDisp-26.14 {AdjustForTab procedure, not enough space} {textfonts} {
.t insert end "Watch the \tX and the \t\t\tY\n" moop
list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
[lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]
+} [list 77 224 77 224]
+test textDisp-26.14.2 {AdjustForTab procedure, not enough space} {textfonts} {
+ .t delete 1.0 end
+ .t configure -tabstyle wordprocessor
+ .t insert end "a \tb \tc \td \te \tf \tg\n"
+ .t insert end "Watch the \tX and the \t\t\tY\n"
+ .t tag configure moop -tabs [expr {8*$fixedWidth}]
+ .t insert end "Watch the \tX and the \t\t\tY\n" moop
+ set res [list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
+ [lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]]
+ .t configure -tabstyle tabular
+ set res
} [list 112 56 112 56]
.t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
@@ -3129,6 +3161,14 @@ test textDisp-27.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
.t delete 1.0 end
.t insert 1.0 a\tbcdefghij\tc\td
list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]
+} [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 130 5 7 $fixedHeight]]
+test textDisp-27.1.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
+ .t delete 1.0 end
+ .t insert 1.0 a\tbcdefghij\tc\td
+ .t configure -tabstyle wordprocessor
+ set res [list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]]
+ .t configure -tabstyle tabular
+ set res
} [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
test textDisp-27.2 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
.t delete 1.0 end
@@ -3189,8 +3229,30 @@ test textDisp-27.7 {SizeOfTab procedure, center alignment, wrap -none (potential
set res [.t bbox 2.23]
lset res 0 [expr {[lindex $res 0] - $tab}]
set res
+} [list -28 [expr {$fixedDiff + 18}] 7 $fixedHeight]
+test textDisp-27.7.1 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {textfonts} {
+ .t delete 1.0 end
+ .t configure -tabstyle wordprocessor
+ set cm [winfo fpixels .t 1c]
+ .t configure -tabs {1c 2c center 3c 4c 5c 6c 7c 8c} -wrap none -width 40
+ .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
+ set width [expr {$fixedWidth * 19}]
+ set tab $cm
+ while {$tab < $width} {
+ set tab [expr {$tab + $cm}]
+ }
+ # Now we've calculated to the end of the tab after 'a', add one
+ # more for 'bb\t' and we're there, with 4 for the border. Since
+ # Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
+ # so must we.
+ set tab [expr {4 + int(0.5 + $tab + $cm)}]
+ update
+ set res [.t bbox 2.23]
+ .t configure -tabstyle tabular
+ lset res 0 [expr {[lindex $res 0] - $tab}]
+ set res
} [list 0 [expr {$fixedDiff + 18}] 7 $fixedHeight]
-test textDisp-27.7.1 {SizeOfTab procedure, fractional tab interpolation problem} {
+test textDisp-27.7.2 {SizeOfTab procedure, fractional tab interpolation problem} {
.t delete 1.0 end
set interpolatetab {1c 2c}
set precisetab {}
@@ -3571,6 +3633,88 @@ test textDisp-32.1 {everything elided} {
destroy .tt
} {}
+test textDisp-32.2 {elide and tags} {
+ pack [text .tt -height 30 -width 100 -bd 0 \
+ -highlightthickness 0 -padx 0]
+ .tt insert end \
+ {test text using tags 1 and 3 } \
+ {testtag1 testtag3} \
+ {[this bit here uses tags 2 and 3]} \
+ {testtag2 testtag3}
+ update
+ # indent left margin of tag 1 by 20 pixels
+ # text should be indented
+ .tt tag configure testtag1 -lmargin1 20 ; update
+ #1
+ set res {}
+ lappend res [list [.tt index "1.0 + 0 displaychars"] \
+ [lindex [.tt bbox 1.0] 0] \
+ [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
+
+ # hide tag 1, remaining text should not be indented, since
+ # the indented tag and character is hidden.
+ .tt tag configure testtag1 -elide 1 ; update
+ #2
+ lappend res [list [.tt index "1.0 + 0 displaychars"] \
+ [lindex [.tt bbox 1.0] 0] \
+ [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
+
+ # reset
+ .tt tag configure testtag1 -lmargin1 0
+ .tt tag configure testtag1 -elide 0
+
+ # indent left margin of tag 2 by 20 pixels
+ # text should not be indented, since tag1 has lmargin1 of 0.
+ .tt tag configure testtag2 -lmargin1 20 ; update
+ #3
+ lappend res [list [.tt index "1.0 + 0 displaychars"] \
+ [lindex [.tt bbox 1.0] 0] \
+ [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
+
+ # hide tag 1, remaining text should now be indented, but
+ # the bbox of 1.0 should have zero width and zero indent,
+ # since it is elided at that position.
+ .tt tag configure testtag1 -elide 1 ; update
+ #4
+ lappend res [list [.tt index "1.0 + 0 displaychars"] \
+ [lindex [.tt bbox 1.0] 0] \
+ [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
+
+ # reset
+ .tt tag configure testtag2 -lmargin1 {}
+ .tt tag configure testtag1 -elide 0
+
+ # indent left margin of tag 3 by 20 pixels
+ # text should be indented, since this tag takes
+ # precedence over testtag1, and is applied to the
+ # start of the text.
+ .tt tag configure testtag3 -lmargin1 20 ; update
+ #5
+ lappend res [list [.tt index "1.0 + 0 displaychars"] \
+ [lindex [.tt bbox 1.0] 0] \
+ [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
+
+ # hide tag 1, remaining text should still be indented,
+ # since it still has testtag3 on it. Again the
+ # bbox of 1.0 should have 0.
+ .tt tag configure testtag1 -elide 1 ; update
+ #6
+ lappend res [list [.tt index "1.0 + 0 displaychars"] \
+ [lindex [.tt bbox 1.0] 0] \
+ [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
+
+ .tt tag configure testtag3 -lmargin1 {} -elide 0
+ .tt tag configure testtag1 -elide 1 -lmargin1 20
+ #7
+ lappend res [list [.tt index "1.0 + 0 displaychars"] \
+ [lindex [.tt bbox 1.0] 0] \
+ [lindex [.tt bbox "1.0 + 0 displaychars"] 0]]
+
+ destroy .tt
+ set res
+} {{1.0 20 20} {1.29 0 0} {1.0 0 0} {1.29 0 20}\
+ {1.0 20 20} {1.29 0 20} {1.0 20 20}}
+
test textDisp-33.0 {one line longer than fits in the widget} {
pack [text .tt -wrap char]
.tt insert 1.0 [string repeat "more wrap + " 300]