1 |
578 |
markom |
# This file is a Tcl script to test entry widgets in Tk. It is
|
2 |
|
|
# organized in the standard fashion for Tcl tests.
|
3 |
|
|
#
|
4 |
|
|
# Copyright (c) 1994 The Regents of the University of California.
|
5 |
|
|
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
|
6 |
|
|
#
|
7 |
|
|
# See the file "license.terms" for information on usage and redistribution
|
8 |
|
|
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
9 |
|
|
#
|
10 |
|
|
# RCS: @(#) $Id: entry.test,v 1.1.1.1 2002-01-16 10:25:58 markom Exp $
|
11 |
|
|
|
12 |
|
|
if {[lsearch [image types] test] < 0} {
|
13 |
|
|
puts "This application hasn't been compiled with the \"test\""
|
14 |
|
|
puts "image, so I can't run this test. Are you sure you're using"
|
15 |
|
|
puts "tktest instead of wish?"
|
16 |
|
|
return
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
if {[info procs test] != "test"} {
|
20 |
|
|
source defs
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
foreach i [winfo children .] {
|
24 |
|
|
destroy $i
|
25 |
|
|
}
|
26 |
|
|
wm geometry . {}
|
27 |
|
|
raise .
|
28 |
|
|
|
29 |
|
|
proc scroll args {
|
30 |
|
|
global scrollInfo
|
31 |
|
|
set scrollInfo $args
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
# Create additional widget that's used to hold the selection at times.
|
35 |
|
|
|
36 |
|
|
entry .sel
|
37 |
|
|
.sel insert end "This is some sample text"
|
38 |
|
|
|
39 |
|
|
# Font names
|
40 |
|
|
|
41 |
|
|
set big -adobe-helvetica-medium-r-normal--24-240-75-75-p-*-iso8859-1
|
42 |
|
|
set fixed -adobe-courier-medium-r-normal--12-120-75-75-m-*-iso8859-1
|
43 |
|
|
|
44 |
|
|
# Create entries in the option database to be sure that geometry options
|
45 |
|
|
# like border width have predictable values.
|
46 |
|
|
|
47 |
|
|
option add *Entry.borderWidth 2
|
48 |
|
|
option add *Entry.highlightThickness 2
|
49 |
|
|
option add *Entry.font {Helvetica -12}
|
50 |
|
|
|
51 |
|
|
entry .e -bd 2 -relief sunken
|
52 |
|
|
pack .e
|
53 |
|
|
update
|
54 |
|
|
set i 1
|
55 |
|
|
foreach test {
|
56 |
|
|
{-background #ff0000 #ff0000 non-existent
|
57 |
|
|
{unknown color name "non-existent"}}
|
58 |
|
|
{-bd 4 4 badValue {bad screen distance "badValue"}}
|
59 |
|
|
{-bg #ff0000 #ff0000 non-existent {unknown color name "non-existent"}}
|
60 |
|
|
{-borderwidth 1.3 1 badValue {bad screen distance "badValue"}}
|
61 |
|
|
{-cursor arrow arrow badValue {bad cursor spec "badValue"}}
|
62 |
|
|
{-exportselection yes 1 xyzzy {expected boolean value but got "xyzzy"}}
|
63 |
|
|
{-fg #110022 #110022 bogus {unknown color name "bogus"}}
|
64 |
|
|
{-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*
|
65 |
|
|
-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* {}
|
66 |
|
|
{font "" doesn't exist}}
|
67 |
|
|
{-foreground #110022 #110022 bogus {unknown color name "bogus"}}
|
68 |
|
|
{-highlightbackground #123456 #123456 ugly {unknown color name "ugly"}}
|
69 |
|
|
{-highlightcolor #123456 #123456 bogus {unknown color name "bogus"}}
|
70 |
|
|
{-highlightthickness 6 6 bogus {bad screen distance "bogus"}}
|
71 |
|
|
{-highlightthickness -2 0 {} {}}
|
72 |
|
|
{-insertbackground #110022 #110022 bogus {unknown color name "bogus"}}
|
73 |
|
|
{-insertborderwidth 1.3 1 2.6x {bad screen distance "2.6x"}}
|
74 |
|
|
{-insertofftime 100 100 3.2 {expected integer but got "3.2"}}
|
75 |
|
|
{-insertontime 100 100 3.2 {expected integer but got "3.2"}}
|
76 |
|
|
{-justify right right bogus {bad justification "bogus": must be left, right, or center}}
|
77 |
|
|
{-relief groove groove 1.5 {bad relief type "1.5": must be flat, groove, raised, ridge, solid, or sunken}}
|
78 |
|
|
{-selectbackground #110022 #110022 bogus {unknown color name "bogus"}}
|
79 |
|
|
{-selectborderwidth 1.3 1 badValue {bad screen distance "badValue"}}
|
80 |
|
|
{-selectforeground #654321 #654321 bogus {unknown color name "bogus"}}
|
81 |
|
|
{-show * * {} {}}
|
82 |
|
|
{-state normal normal bogus {bad state value "bogus": must be normal or disabled}}
|
83 |
|
|
{-takefocus "any string" "any string" {} {}}
|
84 |
|
|
{-textvariable i i {} {}}
|
85 |
|
|
{-width 402 402 3p {expected integer but got "3p"}}
|
86 |
|
|
{-xscrollcommand {Some command} {Some command} {} {}}
|
87 |
|
|
} {
|
88 |
|
|
set name [lindex $test 0]
|
89 |
|
|
test entry-1.1 {configuration options} {
|
90 |
|
|
.e configure $name [lindex $test 1]
|
91 |
|
|
list [lindex [.e configure $name] 4] [.e cget $name]
|
92 |
|
|
} [list [lindex $test 2] [lindex $test 2]]
|
93 |
|
|
incr i
|
94 |
|
|
if {[lindex $test 3] != ""} {
|
95 |
|
|
test entry-1.2 {configuration options} {
|
96 |
|
|
list [catch {.e configure $name [lindex $test 3]} msg] $msg
|
97 |
|
|
} [list 1 [lindex $test 4]]
|
98 |
|
|
}
|
99 |
|
|
.e configure $name [lindex [.e configure $name] 3]
|
100 |
|
|
incr i
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
test entry-2.1 {Tk_EntryCmd procedure} {
|
104 |
|
|
list [catch {entry} msg] $msg
|
105 |
|
|
} {1 {wrong # args: should be "entry pathName ?options?"}}
|
106 |
|
|
test entry-2.2 {Tk_EntryCmd procedure} {
|
107 |
|
|
list [catch {entry gorp} msg] $msg
|
108 |
|
|
} {1 {bad window path name "gorp"}}
|
109 |
|
|
test entry-2.3 {Tk_EntryCmd procedure} {
|
110 |
|
|
catch {destroy .e}
|
111 |
|
|
entry .e
|
112 |
|
|
list [winfo exists .e] [winfo class .e] [info commands .e]
|
113 |
|
|
} {1 Entry .e}
|
114 |
|
|
test entry-2.4 {Tk_EntryCmd procedure} {
|
115 |
|
|
catch {destroy .e}
|
116 |
|
|
list [catch {entry .e -gorp foo} msg] $msg [winfo exists .e] \
|
117 |
|
|
[info commands .e]
|
118 |
|
|
} {1 {unknown option "-gorp"} 0 {}}
|
119 |
|
|
test entry-2.5 {Tk_EntryCmd procedure} {
|
120 |
|
|
catch {destroy .e}
|
121 |
|
|
entry .e
|
122 |
|
|
} {.e}
|
123 |
|
|
|
124 |
|
|
catch {destroy .e}
|
125 |
|
|
entry .e -font $fixed
|
126 |
|
|
pack .e
|
127 |
|
|
update
|
128 |
|
|
|
129 |
|
|
set cx [font measure $fixed a]
|
130 |
|
|
set cy [font metrics $fixed -linespace]
|
131 |
|
|
|
132 |
|
|
test entry-3.1 {EntryWidgetCmd procedure} {
|
133 |
|
|
list [catch {.e} msg] $msg
|
134 |
|
|
} {1 {wrong # args: should be ".e option ?arg arg ...?"}}
|
135 |
|
|
test entry-3.2 {EntryWidgetCmd procedure, "bbox" widget command} {
|
136 |
|
|
list [catch {.e bbox} msg] $msg
|
137 |
|
|
} {1 {wrong # args: should be ".e bbox index"}}
|
138 |
|
|
test entry-3.3 {EntryWidgetCmd procedure, "bbox" widget command} {
|
139 |
|
|
list [catch {.e bbox a b} msg] $msg
|
140 |
|
|
} {1 {wrong # args: should be ".e bbox index"}}
|
141 |
|
|
test entry-3.4 {EntryWidgetCmd procedure, "bbox" widget command} {
|
142 |
|
|
list [catch {.e bbox bogus} msg] $msg
|
143 |
|
|
} {1 {bad entry index "bogus"}}
|
144 |
|
|
test entry-3.5 {EntryWidgetCmd procedure, "bbox" widget command} {
|
145 |
|
|
.e delete 0 end
|
146 |
|
|
.e bbox 0
|
147 |
|
|
} [list 5 5 0 $cy]
|
148 |
|
|
test entry-3.6 {EntryWidgetCmd procedure, "bbox" widget command} {fonts} {
|
149 |
|
|
.e delete 0 end
|
150 |
|
|
.e insert 0 "abcdefghijklmnop"
|
151 |
|
|
list [.e bbox 0] [.e bbox 1] [.e bbox end]
|
152 |
|
|
} [list "5 5 $cx $cy" "[expr 5+$cx] 5 $cx $cy" "[expr 5+15*$cx] 5 $cx $cy"]
|
153 |
|
|
test entry-3.7 {EntryWidgetCmd procedure, "cget" widget command} {
|
154 |
|
|
list [catch {.e cget} msg] $msg
|
155 |
|
|
} {1 {wrong # args: should be ".e cget option"}}
|
156 |
|
|
test entry-3.8 {EntryWidgetCmd procedure, "cget" widget command} {
|
157 |
|
|
list [catch {.e cget a b} msg] $msg
|
158 |
|
|
} {1 {wrong # args: should be ".e cget option"}}
|
159 |
|
|
test entry-3.9 {EntryWidgetCmd procedure, "cget" widget command} {
|
160 |
|
|
list [catch {.e cget -gorp} msg] $msg
|
161 |
|
|
} {1 {unknown option "-gorp"}}
|
162 |
|
|
test entry-3.10 {EntryWidgetCmd procedure, "cget" widget command} {
|
163 |
|
|
.e configure -bd 4
|
164 |
|
|
.e cget -bd
|
165 |
|
|
} {4}
|
166 |
|
|
test entry-3.11 {EntryWidgetCmd procedure, "configure" widget command} {
|
167 |
|
|
llength [.e configure]
|
168 |
|
|
} {28}
|
169 |
|
|
test entry-3.12 {EntryWidgetCmd procedure, "configure" widget command} {
|
170 |
|
|
list [catch {.e configure -foo} msg] $msg
|
171 |
|
|
} {1 {unknown option "-foo"}}
|
172 |
|
|
test entry-3.13 {EntryWidgetCmd procedure, "configure" widget command} {
|
173 |
|
|
.e configure -bd 4
|
174 |
|
|
.e configure -bg #ffffff
|
175 |
|
|
lindex [.e configure -bd] 4
|
176 |
|
|
} {4}
|
177 |
|
|
test entry-3.14 {EntryWidgetCmd procedure, "delete" widget command} {
|
178 |
|
|
list [catch {.e delete} msg] $msg
|
179 |
|
|
} {1 {wrong # args: should be ".e delete firstIndex ?lastIndex?"}}
|
180 |
|
|
test entry-3.15 {EntryWidgetCmd procedure, "delete" widget command} {
|
181 |
|
|
list [catch {.e delete a b c} msg] $msg
|
182 |
|
|
} {1 {wrong # args: should be ".e delete firstIndex ?lastIndex?"}}
|
183 |
|
|
test entry-3.16 {EntryWidgetCmd procedure, "delete" widget command} {
|
184 |
|
|
list [catch {.e delete foo} msg] $msg
|
185 |
|
|
} {1 {bad entry index "foo"}}
|
186 |
|
|
test entry-3.17 {EntryWidgetCmd procedure, "delete" widget command} {
|
187 |
|
|
list [catch {.e delete 0 bar} msg] $msg
|
188 |
|
|
} {1 {bad entry index "bar"}}
|
189 |
|
|
test entry-3.18 {EntryWidgetCmd procedure, "delete" widget command} {
|
190 |
|
|
.e delete 0 end
|
191 |
|
|
.e insert end "01234567890"
|
192 |
|
|
.e delete 2 4
|
193 |
|
|
.e get
|
194 |
|
|
} {014567890}
|
195 |
|
|
test entry-3.19 {EntryWidgetCmd procedure, "delete" widget command} {
|
196 |
|
|
.e delete 0 end
|
197 |
|
|
.e insert end "01234567890"
|
198 |
|
|
.e delete 6
|
199 |
|
|
.e get
|
200 |
|
|
} {0123457890}
|
201 |
|
|
test entry-3.20 {EntryWidgetCmd procedure, "delete" widget command} {
|
202 |
|
|
.e delete 0 end
|
203 |
|
|
.e insert end "01234567890"
|
204 |
|
|
.e delete 6 5
|
205 |
|
|
.e get
|
206 |
|
|
} {01234567890}
|
207 |
|
|
test entry-3.21 {EntryWidgetCmd procedure, "delete" widget command} {
|
208 |
|
|
.e delete 0 end
|
209 |
|
|
.e insert end "01234567890"
|
210 |
|
|
.e configure -state disabled
|
211 |
|
|
.e delete 2 8
|
212 |
|
|
.e configure -state normal
|
213 |
|
|
.e get
|
214 |
|
|
} {01234567890}
|
215 |
|
|
test entry-3.22 {EntryWidgetCmd procedure, "get" widget command} {
|
216 |
|
|
list [catch {.e get foo} msg] $msg
|
217 |
|
|
} {1 {wrong # args: should be ".e get"}}
|
218 |
|
|
test entry-3.23 {EntryWidgetCmd procedure, "icursor" widget command} {
|
219 |
|
|
list [catch {.e icursor} msg] $msg
|
220 |
|
|
} {1 {wrong # args: should be ".e icursor pos"}}
|
221 |
|
|
test entry-3.24 {EntryWidgetCmd procedure, "icursor" widget command} {
|
222 |
|
|
list [catch {.e icursor foo} msg] $msg
|
223 |
|
|
} {1 {bad entry index "foo"}}
|
224 |
|
|
test entry-3.25 {EntryWidgetCmd procedure, "icursor" widget command} {
|
225 |
|
|
.e delete 0 end
|
226 |
|
|
.e insert end "01234567890"
|
227 |
|
|
.e icursor 4
|
228 |
|
|
.e index insert
|
229 |
|
|
} {4}
|
230 |
|
|
test entry-3.26 {EntryWidgetCmd procedure, "index" widget command} {
|
231 |
|
|
list [catch {.e in} msg] $msg
|
232 |
|
|
} {1 {bad option "in": must be bbox, cget, configure, delete, get, icursor, index, insert, scan, selection, or xview}}
|
233 |
|
|
test entry-3.27 {EntryWidgetCmd procedure, "index" widget command} {
|
234 |
|
|
list [catch {.e index} msg] $msg
|
235 |
|
|
} {1 {wrong # args: should be ".e index string"}}
|
236 |
|
|
test entry-3.28 {EntryWidgetCmd procedure, "index" widget command} {
|
237 |
|
|
list [catch {.e index foo} msg] $msg
|
238 |
|
|
} {1 {bad entry index "foo"}}
|
239 |
|
|
test entry-3.29 {EntryWidgetCmd procedure, "index" widget command} {
|
240 |
|
|
list [catch {.e index 0} msg] $msg
|
241 |
|
|
} {0 0}
|
242 |
|
|
test entry-3.30 {EntryWidgetCmd procedure, "insert" widget command} {
|
243 |
|
|
list [catch {.e insert a} msg] $msg
|
244 |
|
|
} {1 {wrong # args: should be ".e insert index text"}}
|
245 |
|
|
test entry-3.31 {EntryWidgetCmd procedure, "insert" widget command} {
|
246 |
|
|
list [catch {.e insert a b c} msg] $msg
|
247 |
|
|
} {1 {wrong # args: should be ".e insert index text"}}
|
248 |
|
|
test entry-3.32 {EntryWidgetCmd procedure, "insert" widget command} {
|
249 |
|
|
list [catch {.e insert foo Text} msg] $msg
|
250 |
|
|
} {1 {bad entry index "foo"}}
|
251 |
|
|
test entry-3.33 {EntryWidgetCmd procedure, "insert" widget command} {
|
252 |
|
|
.e delete 0 end
|
253 |
|
|
.e insert end "01234567890"
|
254 |
|
|
.e insert 3 xxx
|
255 |
|
|
.e get
|
256 |
|
|
} {012xxx34567890}
|
257 |
|
|
test entry-3.34 {EntryWidgetCmd procedure, "insert" widget command} {
|
258 |
|
|
.e delete 0 end
|
259 |
|
|
.e insert end "01234567890"
|
260 |
|
|
.e configure -state disabled
|
261 |
|
|
.e insert 3 xxx
|
262 |
|
|
.e configure -state normal
|
263 |
|
|
.e get
|
264 |
|
|
} {01234567890}
|
265 |
|
|
test entry-3.35 {EntryWidgetCmd procedure, "insert" widget command} {
|
266 |
|
|
list [catch {.e insert a b c} msg] $msg
|
267 |
|
|
} {1 {wrong # args: should be ".e insert index text"}}
|
268 |
|
|
test entry-3.36 {EntryWidgetCmd procedure, "scan" widget command} {
|
269 |
|
|
list [catch {.e scan a} msg] $msg
|
270 |
|
|
} {1 {wrong # args: should be ".e scan mark|dragto x"}}
|
271 |
|
|
test entry-3.37 {EntryWidgetCmd procedure, "scan" widget command} {
|
272 |
|
|
list [catch {.e scan a b c} msg] $msg
|
273 |
|
|
} {1 {wrong # args: should be ".e scan mark|dragto x"}}
|
274 |
|
|
test entry-3.38 {EntryWidgetCmd procedure, "scan" widget command} {
|
275 |
|
|
list [catch {.e scan foobar 20} msg] $msg
|
276 |
|
|
} {1 {bad scan option "foobar": must be mark or dragto}}
|
277 |
|
|
test entry-3.39 {EntryWidgetCmd procedure, "scan" widget command} {
|
278 |
|
|
list [catch {.e scan mark 20.1} msg] $msg
|
279 |
|
|
} {1 {expected integer but got "20.1"}}
|
280 |
|
|
# This test is non-portable because character sizes vary.
|
281 |
|
|
|
282 |
|
|
test entry-3.40 {EntryWidgetCmd procedure, "scan" widget command} {fonts} {
|
283 |
|
|
.e delete 0 end
|
284 |
|
|
update
|
285 |
|
|
.e insert end "This is quite a long string, in fact a "
|
286 |
|
|
.e insert end "very very long string"
|
287 |
|
|
.e scan mark 30
|
288 |
|
|
.e scan dragto 28
|
289 |
|
|
.e index @0
|
290 |
|
|
} {2}
|
291 |
|
|
test entry-3.41 {EntryWidgetCmd procedure, "select" widget command} {
|
292 |
|
|
list [catch {.e select} msg] $msg
|
293 |
|
|
} {1 {wrong # args: should be ".e select option ?index?"}}
|
294 |
|
|
test entry-3.42 {EntryWidgetCmd procedure, "select" widget command} {
|
295 |
|
|
list [catch {.e select foo} msg] $msg
|
296 |
|
|
} {1 {bad selection option "foo": must be adjust, clear, from, present, range, or to}}
|
297 |
|
|
test entry-3.43 {EntryWidgetCmd procedure, "select clear" widget command} {
|
298 |
|
|
list [catch {.e select clear gorp} msg] $msg
|
299 |
|
|
} {1 {wrong # args: should be ".e selection clear"}}
|
300 |
|
|
test entry-3.44 {EntryWidgetCmd procedure, "select clear" widget command} {
|
301 |
|
|
.e delete 0 end
|
302 |
|
|
.e insert end "0123456789"
|
303 |
|
|
.e select from 1
|
304 |
|
|
.e select to 4
|
305 |
|
|
update
|
306 |
|
|
.e select clear
|
307 |
|
|
list [catch {selection get} msg] $msg [selection own]
|
308 |
|
|
} {1 {PRIMARY selection doesn't exist or form "STRING" not defined} .e}
|
309 |
|
|
test entry-3.45 {EntryWidgetCmd procedure, "selection present" widget command} {
|
310 |
|
|
list [catch {.e selection present foo} msg] $msg
|
311 |
|
|
} {1 {wrong # args: should be ".e selection present"}}
|
312 |
|
|
test entry-3.46 {EntryWidgetCmd procedure, "selection present" widget command} {
|
313 |
|
|
.e delete 0 end
|
314 |
|
|
.e insert end 0123456789
|
315 |
|
|
.e select from 3
|
316 |
|
|
.e select to 6
|
317 |
|
|
.e selection present
|
318 |
|
|
} {1}
|
319 |
|
|
test entry-3.47 {EntryWidgetCmd procedure, "selection present" widget command} {
|
320 |
|
|
.e delete 0 end
|
321 |
|
|
.e insert end 0123456789
|
322 |
|
|
.e select from 3
|
323 |
|
|
.e select to 6
|
324 |
|
|
.e configure -exportselection false
|
325 |
|
|
.e selection present
|
326 |
|
|
} {1}
|
327 |
|
|
.e configure -exportselection true
|
328 |
|
|
test entry-3.48 {EntryWidgetCmd procedure, "selection present" widget command} {
|
329 |
|
|
.e delete 0 end
|
330 |
|
|
.e insert end 0123456789
|
331 |
|
|
.e select from 3
|
332 |
|
|
.e select to 6
|
333 |
|
|
.e delete 0 end
|
334 |
|
|
.e selection present
|
335 |
|
|
} {0}
|
336 |
|
|
test entry-3.49 {EntryWidgetCmd procedure, "selection adjust" widget command} {
|
337 |
|
|
list [catch {.e select adjust x} msg] $msg
|
338 |
|
|
} {1 {bad entry index "x"}}
|
339 |
|
|
test entry-3.50 {EntryWidgetCmd procedure, "selection adjust" widget command} {
|
340 |
|
|
list [catch {.e select adjust 2 3} msg] $msg
|
341 |
|
|
} {1 {wrong # args: should be ".e selection adjust index"}}
|
342 |
|
|
test entry-3.51 {EntryWidgetCmd procedure, "selection adjust" widget command} {
|
343 |
|
|
.e delete 0 end
|
344 |
|
|
.e insert end "0123456789"
|
345 |
|
|
.e select from 1
|
346 |
|
|
.e select to 5
|
347 |
|
|
update
|
348 |
|
|
.e select adjust 4
|
349 |
|
|
selection get
|
350 |
|
|
} {123}
|
351 |
|
|
test entry-3.52 {EntryWidgetCmd procedure, "selection adjust" widget command} {
|
352 |
|
|
.e delete 0 end
|
353 |
|
|
.e insert end "0123456789"
|
354 |
|
|
.e select from 1
|
355 |
|
|
.e select to 5
|
356 |
|
|
update
|
357 |
|
|
.e select adjust 2
|
358 |
|
|
selection get
|
359 |
|
|
} {234}
|
360 |
|
|
test entry-3.53 {EntryWidgetCmd procedure, "selection from" widget command} {
|
361 |
|
|
list [catch {.e select from 2 3} msg] $msg
|
362 |
|
|
} {1 {wrong # args: should be ".e selection from index"}}
|
363 |
|
|
test entry-3.54 {EntryWidgetCmd procedure, "selection range" widget command} {
|
364 |
|
|
list [catch {.e select range 2} msg] $msg
|
365 |
|
|
} {1 {wrong # args: should be ".e selection range start end"}}
|
366 |
|
|
test entry-3.55 {EntryWidgetCmd procedure, "selection range" widget command} {
|
367 |
|
|
list [catch {.e selection range 2 3 4} msg] $msg
|
368 |
|
|
} {1 {wrong # args: should be ".e selection range start end"}}
|
369 |
|
|
test entry-3.56 {EntryWidgetCmd procedure, "selection range" widget command} {
|
370 |
|
|
.e delete 0 end
|
371 |
|
|
.e insert end 0123456789
|
372 |
|
|
.e select from 1
|
373 |
|
|
.e select to 5
|
374 |
|
|
.e select range 4 4
|
375 |
|
|
list [catch {.e index sel.first} msg] $msg
|
376 |
|
|
} {1 {selection isn't in entry}}
|
377 |
|
|
test entry-3.57 {EntryWidgetCmd procedure, "selection range" widget command} {
|
378 |
|
|
.e delete 0 end
|
379 |
|
|
.e insert end 0123456789
|
380 |
|
|
.e select from 3
|
381 |
|
|
.e select to 7
|
382 |
|
|
.e select range 2 9
|
383 |
|
|
list [.e index sel.first] [.e index sel.last] [.e index anchor]
|
384 |
|
|
} {2 9 3}
|
385 |
|
|
.e delete 0 end
|
386 |
|
|
.e insert end "This is quite a long text string, so long that it "
|
387 |
|
|
.e insert end "runs off the end of the window quite a bit."
|
388 |
|
|
test entry-3.58 {EntryWidgetCmd procedure, "selection to" widget command} {
|
389 |
|
|
list [catch {.e select to 2 3} msg] $msg
|
390 |
|
|
} {1 {wrong # args: should be ".e selection to index"}}
|
391 |
|
|
test entry-3.59 {EntryWidgetCmd procedure, "xview" widget command} {
|
392 |
|
|
.e xview 5
|
393 |
|
|
.e xview
|
394 |
|
|
} {0.0537634 0.268817}
|
395 |
|
|
test entry-3.60 {EntryWidgetCmd procedure, "xview" widget command} {
|
396 |
|
|
list [catch {.e xview gorp} msg] $msg
|
397 |
|
|
} {1 {bad entry index "gorp"}}
|
398 |
|
|
test entry-3.61 {EntryWidgetCmd procedure, "xview" widget command} {
|
399 |
|
|
.e xview 0
|
400 |
|
|
.e icursor 10
|
401 |
|
|
.e xview insert
|
402 |
|
|
.e xview
|
403 |
|
|
} {0.107527 0.322581}
|
404 |
|
|
test entry-3.62 {EntryWidgetCmd procedure, "xview" widget command} {
|
405 |
|
|
list [catch {.e xview moveto foo bar} msg] $msg
|
406 |
|
|
} {1 {wrong # args: should be ".e xview moveto fraction"}}
|
407 |
|
|
test entry-3.63 {EntryWidgetCmd procedure, "xview" widget command} {
|
408 |
|
|
list [catch {.e xview moveto foo} msg] $msg
|
409 |
|
|
} {1 {expected floating-point number but got "foo"}}
|
410 |
|
|
test entry-3.64 {EntryWidgetCmd procedure, "xview" widget command} {
|
411 |
|
|
.e xview moveto 0.5
|
412 |
|
|
.e xview
|
413 |
|
|
} {0.505376 0.72043}
|
414 |
|
|
test entry-3.65 {EntryWidgetCmd procedure, "xview" widget command} {
|
415 |
|
|
list [catch {.e xview scroll 24} msg] $msg
|
416 |
|
|
} {1 {wrong # args: should be ".e xview scroll number units|pages"}}
|
417 |
|
|
test entry-3.66 {EntryWidgetCmd procedure, "xview" widget command} {
|
418 |
|
|
list [catch {.e xview scroll gorp units} msg] $msg
|
419 |
|
|
} {1 {expected integer but got "gorp"}}
|
420 |
|
|
test entry-3.67 {EntryWidgetCmd procedure, "xview" widget command} {
|
421 |
|
|
.e xview moveto 0
|
422 |
|
|
.e xview scroll 1 pages
|
423 |
|
|
.e xview
|
424 |
|
|
} {0.193548 0.408602}
|
425 |
|
|
test entry-3.68 {EntryWidgetCmd procedure, "xview" widget command} {
|
426 |
|
|
.e xview moveto .9
|
427 |
|
|
update
|
428 |
|
|
.e xview scroll -2 p
|
429 |
|
|
.e xview
|
430 |
|
|
} {0.397849 0.612903}
|
431 |
|
|
test entry-3.69 {EntryWidgetCmd procedure, "xview" widget command} {
|
432 |
|
|
.e xview 30
|
433 |
|
|
update
|
434 |
|
|
.e xview scroll 2 units
|
435 |
|
|
.e index @0
|
436 |
|
|
} {32}
|
437 |
|
|
test entry-3.70 {EntryWidgetCmd procedure, "xview" widget command} {
|
438 |
|
|
.e xview 30
|
439 |
|
|
update
|
440 |
|
|
.e xview scroll -1 units
|
441 |
|
|
.e index @0
|
442 |
|
|
} {29}
|
443 |
|
|
test entry-3.71 {EntryWidgetCmd procedure, "xview" widget command} {
|
444 |
|
|
list [catch {.e xview scroll 23 foobars} msg] $msg
|
445 |
|
|
} {1 {bad argument "foobars": must be units or pages}}
|
446 |
|
|
test entry-3.72 {EntryWidgetCmd procedure, "xview" widget command} {
|
447 |
|
|
list [catch {.e xview eat 23 hamburgers} msg] $msg
|
448 |
|
|
} {1 {unknown option "eat": must be moveto or scroll}}
|
449 |
|
|
test entry-3.73 {EntryWidgetCmd procedure, "xview" widget command} {
|
450 |
|
|
.e xview 0
|
451 |
|
|
update
|
452 |
|
|
.e xview -4
|
453 |
|
|
.e index @0
|
454 |
|
|
} {0}
|
455 |
|
|
test entry-3.74 {EntryWidgetCmd procedure, "xview" widget command} {
|
456 |
|
|
.e xview 300
|
457 |
|
|
.e index @0
|
458 |
|
|
} {73}
|
459 |
|
|
test entry-3.75 {EntryWidgetCmd procedure} {
|
460 |
|
|
list [catch {.e gorp} msg] $msg
|
461 |
|
|
} {1 {bad option "gorp": must be bbox, cget, configure, delete, get, icursor, index, insert, scan, selection, or xview}}
|
462 |
|
|
|
463 |
|
|
# The test below doesn't actually check anything directly, but if run
|
464 |
|
|
# with Purify or some other memory-allocation-checking program it will
|
465 |
|
|
# ensure that resources get properly freed.
|
466 |
|
|
|
467 |
|
|
test entry-4.1 {DestroyEntry procedure} {
|
468 |
|
|
catch {destroy .e}
|
469 |
|
|
entry .e -textvariable x -show *
|
470 |
|
|
pack .e
|
471 |
|
|
.e insert end "Sample text"
|
472 |
|
|
update
|
473 |
|
|
destroy .e
|
474 |
|
|
} {}
|
475 |
|
|
|
476 |
|
|
frame .f -width 200 -height 50 -relief raised -bd 2
|
477 |
|
|
pack .f -side right
|
478 |
|
|
test entry-5.1 {ConfigureEntry procedure, -textvariable} {
|
479 |
|
|
catch {destroy .e}
|
480 |
|
|
set x 12345
|
481 |
|
|
entry .e -textvariable x
|
482 |
|
|
.e get
|
483 |
|
|
} {12345}
|
484 |
|
|
test entry-5.2 {ConfigureEntry procedure, -textvariable} {
|
485 |
|
|
catch {destroy .e}
|
486 |
|
|
set x 12345
|
487 |
|
|
entry .e -textvariable x
|
488 |
|
|
set y abcde
|
489 |
|
|
.e configure -textvariable y
|
490 |
|
|
set x 54321
|
491 |
|
|
.e get
|
492 |
|
|
} {abcde}
|
493 |
|
|
test entry-5.3 {ConfigureEntry procedure, -textvariable} {
|
494 |
|
|
catch {destroy .e}
|
495 |
|
|
catch {unset x}
|
496 |
|
|
entry .e
|
497 |
|
|
.e insert 0 "Some text"
|
498 |
|
|
.e configure -textvariable x
|
499 |
|
|
set x
|
500 |
|
|
} {Some text}
|
501 |
|
|
test entry-5.4 {ConfigureEntry procedure, -textvariable} {
|
502 |
|
|
proc override args {
|
503 |
|
|
global x
|
504 |
|
|
set x 12345
|
505 |
|
|
}
|
506 |
|
|
catch {destroy .e}
|
507 |
|
|
catch {unset x}
|
508 |
|
|
trace variable x w override
|
509 |
|
|
entry .e
|
510 |
|
|
.e insert 0 "Some text"
|
511 |
|
|
.e configure -textvariable x
|
512 |
|
|
set result [list $x [.e get]]
|
513 |
|
|
unset x; rename override {}
|
514 |
|
|
set result
|
515 |
|
|
} {12345 12345}
|
516 |
|
|
test entry-5.5 {ConfigureEntry procedure} {
|
517 |
|
|
catch {destroy .e}
|
518 |
|
|
entry .e -exportselection false
|
519 |
|
|
pack .e
|
520 |
|
|
.e insert end "0123456789"
|
521 |
|
|
.sel select from 0
|
522 |
|
|
.sel select to 10
|
523 |
|
|
set x {}
|
524 |
|
|
lappend x [selection get]
|
525 |
|
|
.e select from 1
|
526 |
|
|
.e select to 5
|
527 |
|
|
lappend x [selection get]
|
528 |
|
|
.e configure -exportselection 1
|
529 |
|
|
lappend x [selection get]
|
530 |
|
|
set x
|
531 |
|
|
} {{This is so} {This is so} 1234}
|
532 |
|
|
test entry-5.6 {ConfigureEntry procedure} {
|
533 |
|
|
catch {destroy .e}
|
534 |
|
|
entry .e
|
535 |
|
|
pack .e
|
536 |
|
|
.e insert end "0123456789"
|
537 |
|
|
.e select from 1
|
538 |
|
|
.e select to 5
|
539 |
|
|
.e configure -exportselection 0
|
540 |
|
|
list [catch {selection get} msg] $msg [.e index sel.first] \
|
541 |
|
|
[.e index sel.last]
|
542 |
|
|
} {1 {PRIMARY selection doesn't exist or form "STRING" not defined} 1 5}
|
543 |
|
|
test entry-5.7 {ConfigureEntry procedure} {
|
544 |
|
|
catch {destroy .e}
|
545 |
|
|
entry .e -font $fixed -width 4 -xscrollcommand scroll
|
546 |
|
|
pack .e
|
547 |
|
|
.e insert end "01234567890"
|
548 |
|
|
update
|
549 |
|
|
.e configure -width 5
|
550 |
|
|
set scrollInfo
|
551 |
|
|
} {0 0.363636}
|
552 |
|
|
test entry-5.8 {ConfigureEntry procedure} {fonts} {
|
553 |
|
|
catch {destroy .e}
|
554 |
|
|
entry .e -width 0
|
555 |
|
|
pack .e
|
556 |
|
|
.e insert end "0123"
|
557 |
|
|
update
|
558 |
|
|
.e configure -font $big
|
559 |
|
|
update
|
560 |
|
|
winfo geom .e
|
561 |
|
|
} {62x37+0+0}
|
562 |
|
|
test entry-5.9 {ConfigureEntry procedure} {fonts} {
|
563 |
|
|
catch {destroy .e}
|
564 |
|
|
entry .e -font $fixed -bd 2 -relief raised
|
565 |
|
|
pack .e
|
566 |
|
|
.e insert end "0123"
|
567 |
|
|
update
|
568 |
|
|
list [.e index @10] [.e index @11] [.e index @12] [.e index @13]
|
569 |
|
|
} {0 0 1 1}
|
570 |
|
|
test entry-5.10 {ConfigureEntry procedure} {fonts} {
|
571 |
|
|
catch {destroy .e}
|
572 |
|
|
entry .e -font $fixed -bd 2 -relief flat
|
573 |
|
|
pack .e
|
574 |
|
|
.e insert end "0123"
|
575 |
|
|
update
|
576 |
|
|
list [.e index @10] [.e index @11] [.e index @12] [.e index @13]
|
577 |
|
|
} {0 0 1 1}
|
578 |
|
|
test entry-5.11 {ConfigureEntry procedure} {
|
579 |
|
|
# If "0" in selected font had 0 width, caused divide-by-zero error.
|
580 |
|
|
|
581 |
|
|
catch {destroy .e}
|
582 |
|
|
pack [entry .e -font {{open look glyph}}]
|
583 |
|
|
.e scan dragto 30
|
584 |
|
|
update
|
585 |
|
|
} {}
|
586 |
|
|
|
587 |
|
|
# No tests for DisplayEntry.
|
588 |
|
|
|
589 |
|
|
test entry-6.1 {EntryComputeGeometry procedure} {fonts} {
|
590 |
|
|
catch {destroy .e}
|
591 |
|
|
entry .e -font $fixed -bd 2 -relief raised -width 20 -highlightthickness 3
|
592 |
|
|
pack .e
|
593 |
|
|
.e insert end 012\t45
|
594 |
|
|
update
|
595 |
|
|
list [.e index @61] [.e index @62]
|
596 |
|
|
} {3 4}
|
597 |
|
|
test entry-6.2 {EntryComputeGeometry procedure} {fonts} {
|
598 |
|
|
catch {destroy .e}
|
599 |
|
|
entry .e -font $fixed -bd 2 -relief raised -width 20 -justify center \
|
600 |
|
|
-highlightthickness 3
|
601 |
|
|
pack .e
|
602 |
|
|
.e insert end 012\t45
|
603 |
|
|
update
|
604 |
|
|
list [.e index @96] [.e index @97]
|
605 |
|
|
} {3 4}
|
606 |
|
|
test entry-6.3 {EntryComputeGeometry procedure} {fonts} {
|
607 |
|
|
catch {destroy .e}
|
608 |
|
|
entry .e -font $fixed -bd 2 -relief raised -width 20 -justify right \
|
609 |
|
|
-highlightthickness 3
|
610 |
|
|
pack .e
|
611 |
|
|
.e insert end 012\t45
|
612 |
|
|
update
|
613 |
|
|
list [.e index @131] [.e index @132]
|
614 |
|
|
} {3 4}
|
615 |
|
|
test entry-6.4 {EntryComputeGeometry procedure} {
|
616 |
|
|
catch {destroy .e}
|
617 |
|
|
entry .e -font $fixed -bd 2 -relief raised -width 5
|
618 |
|
|
pack .e
|
619 |
|
|
.e insert end "01234567890"
|
620 |
|
|
update
|
621 |
|
|
.e xview 6
|
622 |
|
|
.e index @0
|
623 |
|
|
} {6}
|
624 |
|
|
test entry-6.5 {EntryComputeGeometry procedure} {
|
625 |
|
|
catch {destroy .e}
|
626 |
|
|
entry .e -font $fixed -bd 2 -relief raised -width 5
|
627 |
|
|
pack .e
|
628 |
|
|
.e insert end "01234567890"
|
629 |
|
|
update
|
630 |
|
|
.e xview 7
|
631 |
|
|
.e index @0
|
632 |
|
|
} {6}
|
633 |
|
|
test entry-6.6 {EntryComputeGeometry procedure} {fonts} {
|
634 |
|
|
catch {destroy .e}
|
635 |
|
|
entry .e -font $fixed -bd 2 -relief raised -width 10
|
636 |
|
|
pack .e
|
637 |
|
|
.e insert end "01234\t67890"
|
638 |
|
|
update
|
639 |
|
|
.e xview 3
|
640 |
|
|
list [.e index @39] [.e index @40]
|
641 |
|
|
} {5 6}
|
642 |
|
|
test entry-6.7 {EntryComputeGeometry procedure} {fonts} {
|
643 |
|
|
catch {destroy .e}
|
644 |
|
|
entry .e -font $big -bd 3 -relief raised -width 5
|
645 |
|
|
pack .e
|
646 |
|
|
.e insert end "01234567"
|
647 |
|
|
update
|
648 |
|
|
list [winfo reqwidth .e] [winfo reqheight .e]
|
649 |
|
|
} {77 39}
|
650 |
|
|
test entry-6.8 {EntryComputeGeometry procedure} {fonts} {
|
651 |
|
|
catch {destroy .e}
|
652 |
|
|
entry .e -font $big -bd 3 -relief raised -width 0
|
653 |
|
|
pack .e
|
654 |
|
|
.e insert end "01234567"
|
655 |
|
|
update
|
656 |
|
|
list [winfo reqwidth .e] [winfo reqheight .e]
|
657 |
|
|
} {116 39}
|
658 |
|
|
test entry-6.9 {EntryComputeGeometry procedure} {fonts} {
|
659 |
|
|
catch {destroy .e}
|
660 |
|
|
entry .e -font $big -bd 3 -relief raised -width 0 -highlightthickness 2
|
661 |
|
|
pack .e
|
662 |
|
|
update
|
663 |
|
|
list [winfo reqwidth .e] [winfo reqheight .e]
|
664 |
|
|
} {25 39}
|
665 |
|
|
test entry-6.10 {EntryComputeGeometry procedure} {fonts} {
|
666 |
|
|
catch {destroy .e}
|
667 |
|
|
entry .e -bd 1 -relief raised -width 0 -show .
|
668 |
|
|
.e insert 0 12345
|
669 |
|
|
pack .e
|
670 |
|
|
update
|
671 |
|
|
set x [winfo reqwidth .e]
|
672 |
|
|
.e configure -show X
|
673 |
|
|
lappend x [winfo reqwidth .e]
|
674 |
|
|
.e configure -show ""
|
675 |
|
|
lappend x [winfo reqwidth .e]
|
676 |
|
|
} {23 53 43}
|
677 |
|
|
|
678 |
|
|
catch {destroy .e}
|
679 |
|
|
entry .e -width 10 -font $fixed -textvariable contents -xscrollcommand scroll
|
680 |
|
|
pack .e
|
681 |
|
|
focus .e
|
682 |
|
|
test entry-7.1 {InsertChars procedure} {
|
683 |
|
|
.e delete 0 end
|
684 |
|
|
.e insert 0 abcde
|
685 |
|
|
.e insert 2 XXX
|
686 |
|
|
update
|
687 |
|
|
list [.e get] $contents $scrollInfo
|
688 |
|
|
} {abXXXcde abXXXcde {0 1}}
|
689 |
|
|
test entry-7.2 {InsertChars procedure} {
|
690 |
|
|
.e delete 0 end
|
691 |
|
|
.e insert 0 abcde
|
692 |
|
|
.e insert 500 XXX
|
693 |
|
|
update
|
694 |
|
|
list [.e get] $contents $scrollInfo
|
695 |
|
|
} {abcdeXXX abcdeXXX {0 1}}
|
696 |
|
|
test entry-7.3 {InsertChars procedure} {
|
697 |
|
|
.e delete 0 end
|
698 |
|
|
.e insert 0 0123456789
|
699 |
|
|
.e select from 2
|
700 |
|
|
.e select to 6
|
701 |
|
|
.e insert 2 XXX
|
702 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
703 |
|
|
.e select to 8
|
704 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
705 |
|
|
} {5 9 5 8}
|
706 |
|
|
test entry-7.4 {InsertChars procedure} {
|
707 |
|
|
.e delete 0 end
|
708 |
|
|
.e insert 0 0123456789
|
709 |
|
|
.e select from 2
|
710 |
|
|
.e select to 6
|
711 |
|
|
.e insert 3 XXX
|
712 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
713 |
|
|
.e select to 8
|
714 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
715 |
|
|
} {2 9 2 8}
|
716 |
|
|
test entry-7.5 {InsertChars procedure} {
|
717 |
|
|
.e delete 0 end
|
718 |
|
|
.e insert 0 0123456789
|
719 |
|
|
.e select from 2
|
720 |
|
|
.e select to 6
|
721 |
|
|
.e insert 5 XXX
|
722 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
723 |
|
|
.e select to 8
|
724 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
725 |
|
|
} {2 9 2 8}
|
726 |
|
|
test entry-7.6 {InsertChars procedure} {
|
727 |
|
|
.e delete 0 end
|
728 |
|
|
.e insert 0 0123456789
|
729 |
|
|
.e select from 2
|
730 |
|
|
.e select to 6
|
731 |
|
|
.e insert 6 XXX
|
732 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
733 |
|
|
.e select to 5
|
734 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
735 |
|
|
} {2 6 2 5}
|
736 |
|
|
test entry-7.7 {InsertChars procedure} {
|
737 |
|
|
.e delete 0 end
|
738 |
|
|
.e insert 0 0123456789
|
739 |
|
|
.e icursor 4
|
740 |
|
|
.e insert 4 XXX
|
741 |
|
|
.e index insert
|
742 |
|
|
} {7}
|
743 |
|
|
test entry-7.8 {InsertChars procedure} {
|
744 |
|
|
.e delete 0 end
|
745 |
|
|
.e insert 0 0123456789
|
746 |
|
|
.e icursor 4
|
747 |
|
|
.e insert 5 XXX
|
748 |
|
|
.e index insert
|
749 |
|
|
} {4}
|
750 |
|
|
test entry-7.9 {InsertChars procedure} {
|
751 |
|
|
.e delete 0 end
|
752 |
|
|
.e insert 0 "This is a very long string"
|
753 |
|
|
update
|
754 |
|
|
.e xview 4
|
755 |
|
|
.e insert 3 XXX
|
756 |
|
|
.e index @0
|
757 |
|
|
} {7}
|
758 |
|
|
test entry-7.10 {InsertChars procedure} {
|
759 |
|
|
.e delete 0 end
|
760 |
|
|
.e insert 0 "This is a very long string"
|
761 |
|
|
update
|
762 |
|
|
.e xview 4
|
763 |
|
|
.e insert 4 XXX
|
764 |
|
|
.e index @0
|
765 |
|
|
} {4}
|
766 |
|
|
.e configure -width 0
|
767 |
|
|
test entry-7.11 {InsertChars procedure} {fonts} {
|
768 |
|
|
.e delete 0 end
|
769 |
|
|
.e insert 0 "xyzzy"
|
770 |
|
|
update
|
771 |
|
|
.e insert 2 00
|
772 |
|
|
winfo reqwidth .e
|
773 |
|
|
} {59}
|
774 |
|
|
|
775 |
|
|
.e configure -width 10
|
776 |
|
|
test entry-8.1 {DeleteChars procedure} {
|
777 |
|
|
.e delete 0 end
|
778 |
|
|
.e insert 0 abcde
|
779 |
|
|
.e delete 2 4
|
780 |
|
|
update
|
781 |
|
|
list [.e get] $contents $scrollInfo
|
782 |
|
|
} {abe abe {0 1}}
|
783 |
|
|
test entry-8.2 {DeleteChars procedure} {
|
784 |
|
|
.e delete 0 end
|
785 |
|
|
.e insert 0 abcde
|
786 |
|
|
.e delete -2 2
|
787 |
|
|
update
|
788 |
|
|
list [.e get] $contents $scrollInfo
|
789 |
|
|
} {cde cde {0 1}}
|
790 |
|
|
test entry-8.3 {DeleteChars procedure} {
|
791 |
|
|
.e delete 0 end
|
792 |
|
|
.e insert 0 abcde
|
793 |
|
|
.e delete 3 1000
|
794 |
|
|
update
|
795 |
|
|
list [.e get] $contents $scrollInfo
|
796 |
|
|
} {abc abc {0 1}}
|
797 |
|
|
test entry-8.4 {DeleteChars procedure} {
|
798 |
|
|
.e delete 0 end
|
799 |
|
|
.e insert 0 0123456789abcde
|
800 |
|
|
.e select from 3
|
801 |
|
|
.e select to 8
|
802 |
|
|
.e delete 1 3
|
803 |
|
|
update
|
804 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
805 |
|
|
.e select to 5
|
806 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
807 |
|
|
} {1 6 1 5}
|
808 |
|
|
test entry-8.5 {DeleteChars procedure} {
|
809 |
|
|
.e delete 0 end
|
810 |
|
|
.e insert 0 0123456789abcde
|
811 |
|
|
.e select from 3
|
812 |
|
|
.e select to 8
|
813 |
|
|
.e delete 1 4
|
814 |
|
|
update
|
815 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
816 |
|
|
.e select to 4
|
817 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
818 |
|
|
} {1 5 1 4}
|
819 |
|
|
test entry-8.6 {DeleteChars procedure} {
|
820 |
|
|
.e delete 0 end
|
821 |
|
|
.e insert 0 0123456789abcde
|
822 |
|
|
.e select from 3
|
823 |
|
|
.e select to 8
|
824 |
|
|
.e delete 1 7
|
825 |
|
|
update
|
826 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
827 |
|
|
.e select to 5
|
828 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
829 |
|
|
} {1 2 1 5}
|
830 |
|
|
test entry-8.7 {DeleteChars procedure} {
|
831 |
|
|
.e delete 0 end
|
832 |
|
|
.e insert 0 0123456789abcde
|
833 |
|
|
.e select from 3
|
834 |
|
|
.e select to 8
|
835 |
|
|
.e delete 1 8
|
836 |
|
|
list [catch {.e index sel.first} msg] $msg
|
837 |
|
|
} {1 {selection isn't in entry}}
|
838 |
|
|
test entry-8.8 {DeleteChars procedure} {
|
839 |
|
|
.e delete 0 end
|
840 |
|
|
.e insert 0 0123456789abcde
|
841 |
|
|
.e select from 3
|
842 |
|
|
.e select to 8
|
843 |
|
|
.e delete 3 7
|
844 |
|
|
update
|
845 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
846 |
|
|
.e select to 8
|
847 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
848 |
|
|
} {3 4 3 8}
|
849 |
|
|
test entry-8.9 {DeleteChars procedure} {
|
850 |
|
|
.e delete 0 end
|
851 |
|
|
.e insert 0 0123456789abcde
|
852 |
|
|
.e select from 3
|
853 |
|
|
.e select to 8
|
854 |
|
|
.e delete 3 8
|
855 |
|
|
list [catch {.e index sel.first} msg] $msg
|
856 |
|
|
} {1 {selection isn't in entry}}
|
857 |
|
|
test entry-8.10 {DeleteChars procedure} {
|
858 |
|
|
.e delete 0 end
|
859 |
|
|
.e insert 0 0123456789abcde
|
860 |
|
|
.e select from 8
|
861 |
|
|
.e select to 3
|
862 |
|
|
.e delete 5 8
|
863 |
|
|
update
|
864 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
865 |
|
|
.e select to 8
|
866 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
867 |
|
|
} {3 5 5 8}
|
868 |
|
|
test entry-8.11 {DeleteChars procedure} {
|
869 |
|
|
.e delete 0 end
|
870 |
|
|
.e insert 0 0123456789abcde
|
871 |
|
|
.e select from 8
|
872 |
|
|
.e select to 3
|
873 |
|
|
.e delete 8 10
|
874 |
|
|
update
|
875 |
|
|
set x "[.e index sel.first] [.e index sel.last]"
|
876 |
|
|
.e select to 4
|
877 |
|
|
lappend x [.e index sel.first] [.e index sel.last]
|
878 |
|
|
} {3 8 4 8}
|
879 |
|
|
test entry-8.12 {DeleteChars procedure} {
|
880 |
|
|
.e delete 0 end
|
881 |
|
|
.e insert 0 0123456789abcde
|
882 |
|
|
.e icursor 4
|
883 |
|
|
.e delete 1 4
|
884 |
|
|
.e index insert
|
885 |
|
|
} {1}
|
886 |
|
|
test entry-8.13 {DeleteChars procedure} {
|
887 |
|
|
.e delete 0 end
|
888 |
|
|
.e insert 0 0123456789abcde
|
889 |
|
|
.e icursor 4
|
890 |
|
|
.e delete 1 5
|
891 |
|
|
.e index insert
|
892 |
|
|
} {1}
|
893 |
|
|
test entry-8.14 {DeleteChars procedure} {
|
894 |
|
|
.e delete 0 end
|
895 |
|
|
.e insert 0 0123456789abcde
|
896 |
|
|
.e icursor 4
|
897 |
|
|
.e delete 4 6
|
898 |
|
|
.e index insert
|
899 |
|
|
} {4}
|
900 |
|
|
test entry-8.15 {DeleteChars procedure} {
|
901 |
|
|
.e delete 0 end
|
902 |
|
|
.e insert 0 "This is a very long string"
|
903 |
|
|
.e xview 4
|
904 |
|
|
.e delete 1 4
|
905 |
|
|
.e index @0
|
906 |
|
|
} {1}
|
907 |
|
|
test entry-8.16 {DeleteChars procedure} {
|
908 |
|
|
.e delete 0 end
|
909 |
|
|
.e insert 0 "This is a very long string"
|
910 |
|
|
.e xview 4
|
911 |
|
|
.e delete 1 5
|
912 |
|
|
.e index @0
|
913 |
|
|
} {1}
|
914 |
|
|
test entry-8.17 {DeleteChars procedure} {
|
915 |
|
|
.e delete 0 end
|
916 |
|
|
.e insert 0 "This is a very long string"
|
917 |
|
|
.e xview 4
|
918 |
|
|
.e delete 4 6
|
919 |
|
|
.e index @0
|
920 |
|
|
} {4}
|
921 |
|
|
.e configure -width 0
|
922 |
|
|
test entry-8.18 {DeleteChars procedure} {fonts} {
|
923 |
|
|
.e delete 0 end
|
924 |
|
|
.e insert 0 "xyzzy"
|
925 |
|
|
update
|
926 |
|
|
.e delete 2 4
|
927 |
|
|
winfo reqwidth .e
|
928 |
|
|
} {31}
|
929 |
|
|
|
930 |
|
|
test entry-9.1 {EntryValueChanged procedure} {
|
931 |
|
|
catch {destroy .e}
|
932 |
|
|
proc override args {
|
933 |
|
|
global x
|
934 |
|
|
set x 12345
|
935 |
|
|
}
|
936 |
|
|
catch {unset x}
|
937 |
|
|
trace variable x w override
|
938 |
|
|
entry .e -textvariable x
|
939 |
|
|
.e insert 0 foo
|
940 |
|
|
set result [list $x [.e get]]
|
941 |
|
|
unset x; rename override {}
|
942 |
|
|
set result
|
943 |
|
|
} {12345 12345}
|
944 |
|
|
|
945 |
|
|
catch {destroy .e}
|
946 |
|
|
entry .e
|
947 |
|
|
pack .e
|
948 |
|
|
.e configure -width 0
|
949 |
|
|
test entry-10.1 {EntrySetValue procedure} {fonts} {
|
950 |
|
|
set x abcde
|
951 |
|
|
set y ab
|
952 |
|
|
.e configure -textvariable x
|
953 |
|
|
update
|
954 |
|
|
.e configure -textvariable y
|
955 |
|
|
update
|
956 |
|
|
list [.e get] [winfo reqwidth .e]
|
957 |
|
|
} {ab 24}
|
958 |
|
|
test entry-10.2 {EntrySetValue procedure, updating selection} {
|
959 |
|
|
catch {destroy .e}
|
960 |
|
|
entry .e -textvariable x
|
961 |
|
|
.e insert 0 "abcdefghjklmnopqrstu"
|
962 |
|
|
.e selection range 4 10
|
963 |
|
|
set x "a"
|
964 |
|
|
list [catch {.e index sel.first} msg] $msg
|
965 |
|
|
} {1 {selection isn't in entry}}
|
966 |
|
|
test entry-10.3 {EntrySetValue procedure, updating selection} {
|
967 |
|
|
catch {destroy .e}
|
968 |
|
|
entry .e -textvariable x
|
969 |
|
|
.e insert 0 "abcdefghjklmnopqrstu"
|
970 |
|
|
.e selection range 4 10
|
971 |
|
|
set x "abcdefg"
|
972 |
|
|
list [.e index sel.first] [.e index sel.last]
|
973 |
|
|
} {4 7}
|
974 |
|
|
test entry-10.4 {EntrySetValue procedure, updating selection} {
|
975 |
|
|
catch {destroy .e}
|
976 |
|
|
entry .e -textvariable x
|
977 |
|
|
.e insert 0 "abcdefghjklmnopqrstu"
|
978 |
|
|
.e selection range 4 10
|
979 |
|
|
set x "abcdefghijklmn"
|
980 |
|
|
list [.e index sel.first] [.e index sel.last]
|
981 |
|
|
} {4 10}
|
982 |
|
|
test entry-10.5 {EntrySetValue procedure, updating display position} {
|
983 |
|
|
catch {destroy .e}
|
984 |
|
|
entry .e -width 10 -font $fixed -textvariable x
|
985 |
|
|
pack .e
|
986 |
|
|
.e insert 0 "abcdefghjklmnopqrstuvwxyz"
|
987 |
|
|
.e xview 10
|
988 |
|
|
update
|
989 |
|
|
set x "abcdefg"
|
990 |
|
|
update
|
991 |
|
|
.e index @0
|
992 |
|
|
} {0}
|
993 |
|
|
test entry-10.6 {EntrySetValue procedure, updating display position} {
|
994 |
|
|
catch {destroy .e}
|
995 |
|
|
entry .e -width 10 -font $fixed -textvariable x
|
996 |
|
|
pack .e
|
997 |
|
|
.e insert 0 "abcdefghjklmnopqrstuvwxyz"
|
998 |
|
|
.e xview 10
|
999 |
|
|
update
|
1000 |
|
|
set x "1234567890123456789012"
|
1001 |
|
|
update
|
1002 |
|
|
.e index @0
|
1003 |
|
|
} {10}
|
1004 |
|
|
test entry-10.7 {EntrySetValue procedure, updating insertion cursor} {
|
1005 |
|
|
catch {destroy .e}
|
1006 |
|
|
entry .e -width 10 -font $fixed -textvariable x
|
1007 |
|
|
pack .e
|
1008 |
|
|
.e insert 0 "abcdefghjklmnopqrstuvwxyz"
|
1009 |
|
|
.e icursor 5
|
1010 |
|
|
set x "123"
|
1011 |
|
|
.e index insert
|
1012 |
|
|
} {3}
|
1013 |
|
|
test entry-10.8 {EntrySetValue procedure, updating insertion cursor} {
|
1014 |
|
|
catch {destroy .e}
|
1015 |
|
|
entry .e -width 10 -font $fixed -textvariable x
|
1016 |
|
|
pack .e
|
1017 |
|
|
.e insert 0 "abcdefghjklmnopqrstuvwxyz"
|
1018 |
|
|
.e icursor 5
|
1019 |
|
|
set x "123456"
|
1020 |
|
|
.e index insert
|
1021 |
|
|
} {5}
|
1022 |
|
|
|
1023 |
|
|
test entry-11.1 {EntryEventProc procedure} {
|
1024 |
|
|
catch {destroy .e}
|
1025 |
|
|
entry .e
|
1026 |
|
|
.e insert 0 abcdefg
|
1027 |
|
|
destroy .e
|
1028 |
|
|
update
|
1029 |
|
|
} {}
|
1030 |
|
|
test entry-11.2 {EntryEventProc procedure} {
|
1031 |
|
|
eval destroy [winfo children .]
|
1032 |
|
|
entry .e1 -fg #112233
|
1033 |
|
|
rename .e1 .e2
|
1034 |
|
|
set x {}
|
1035 |
|
|
lappend x [winfo children .]
|
1036 |
|
|
lappend x [.e2 cget -fg]
|
1037 |
|
|
destroy .e1
|
1038 |
|
|
lappend x [info command .e*] [winfo children .]
|
1039 |
|
|
} {.e1 #112233 {} {}}
|
1040 |
|
|
|
1041 |
|
|
test entry-12.1 {EntryCmdDeletedProc procedure} {
|
1042 |
|
|
eval destroy [winfo children .]
|
1043 |
|
|
button .e1 -text "xyz_123"
|
1044 |
|
|
rename .e1 {}
|
1045 |
|
|
list [info command .e*] [winfo children .]
|
1046 |
|
|
} {{} {}}
|
1047 |
|
|
|
1048 |
|
|
catch {destroy .e}
|
1049 |
|
|
entry .e -font $fixed -width 5 -bd 2 -relief sunken
|
1050 |
|
|
pack .e
|
1051 |
|
|
.e insert 0 012345678901234567890
|
1052 |
|
|
.e xview 4
|
1053 |
|
|
update
|
1054 |
|
|
test entry-13.1 {GetEntryIndex procedure} {
|
1055 |
|
|
.e index end
|
1056 |
|
|
} {21}
|
1057 |
|
|
test entry-13.2 {GetEntryIndex procedure} {
|
1058 |
|
|
list [catch {.e index abogus} msg] $msg
|
1059 |
|
|
} {1 {bad entry index "abogus"}}
|
1060 |
|
|
test entry-13.3 {GetEntryIndex procedure} {
|
1061 |
|
|
.e select from 1
|
1062 |
|
|
.e select to 6
|
1063 |
|
|
.e index anchor
|
1064 |
|
|
} {1}
|
1065 |
|
|
test entry-13.4 {GetEntryIndex procedure} {
|
1066 |
|
|
.e select from 4
|
1067 |
|
|
.e select to 1
|
1068 |
|
|
.e index anchor
|
1069 |
|
|
} {4}
|
1070 |
|
|
test entry-13.5 {GetEntryIndex procedure} {
|
1071 |
|
|
.e select from 3
|
1072 |
|
|
.e select to 15
|
1073 |
|
|
.e select adjust 4
|
1074 |
|
|
.e index anchor
|
1075 |
|
|
} {15}
|
1076 |
|
|
test entry-13.6 {GetEntryIndex procedure} {
|
1077 |
|
|
list [catch {.e index ebogus} msg] $msg
|
1078 |
|
|
} {1 {bad entry index "ebogus"}}
|
1079 |
|
|
test entry-13.7 {GetEntryIndex procedure} {
|
1080 |
|
|
.e icursor 2
|
1081 |
|
|
.e index insert
|
1082 |
|
|
} {2}
|
1083 |
|
|
test entry-13.8 {GetEntryIndex procedure} {
|
1084 |
|
|
list [catch {.e index ibogus} msg] $msg
|
1085 |
|
|
} {1 {bad entry index "ibogus"}}
|
1086 |
|
|
test entry-13.9 {GetEntryIndex procedure} {
|
1087 |
|
|
.e select from 1
|
1088 |
|
|
.e select to 6
|
1089 |
|
|
list [.e index sel.first] [.e index sel.last]
|
1090 |
|
|
} {1 6}
|
1091 |
|
|
selection clear .e
|
1092 |
|
|
test entry-13.10 {GetEntryIndex procedure} {pc} {
|
1093 |
|
|
.e index sel.first
|
1094 |
|
|
} {1}
|
1095 |
|
|
test entry-13.11 {GetEntryIndex procedure} {!pc} {
|
1096 |
|
|
list [catch {.e index sel.first} msg] $msg
|
1097 |
|
|
} {1 {selection isn't in entry}}
|
1098 |
|
|
test entry-13.12 {GetEntryIndex procedure} {pc} {
|
1099 |
|
|
list [catch {.e index sbogus} msg] $msg
|
1100 |
|
|
} {1 {bad entry index "sbogus"}}
|
1101 |
|
|
test entry-13.13 {GetEntryIndex procedure} {!pc} {
|
1102 |
|
|
list [catch {.e index sbogus} msg] $msg
|
1103 |
|
|
} {1 {selection isn't in entry}}
|
1104 |
|
|
test entry-13.14 {GetEntryIndex procedure} {
|
1105 |
|
|
list [catch {.e index @xyz} msg] $msg
|
1106 |
|
|
} {1 {bad entry index "@xyz"}}
|
1107 |
|
|
test entry-13.15 {GetEntryIndex procedure} {fonts} {
|
1108 |
|
|
.e index @4
|
1109 |
|
|
} {4}
|
1110 |
|
|
test entry-13.16 {GetEntryIndex procedure} {fonts} {
|
1111 |
|
|
.e index @11
|
1112 |
|
|
} {4}
|
1113 |
|
|
test entry-13.17 {GetEntryIndex procedure} {fonts} {
|
1114 |
|
|
.e index @12
|
1115 |
|
|
} {5}
|
1116 |
|
|
test entry-13.18 {GetEntryIndex procedure} {fonts} {
|
1117 |
|
|
.e index @[expr [winfo width .e] - 6]
|
1118 |
|
|
} {8}
|
1119 |
|
|
test entry-13.19 {GetEntryIndex procedure} {fonts} {
|
1120 |
|
|
.e index @[expr [winfo width .e] - 5]
|
1121 |
|
|
} {9}
|
1122 |
|
|
test entry-13.20 {GetEntryIndex procedure} {
|
1123 |
|
|
.e index @1000
|
1124 |
|
|
} {9}
|
1125 |
|
|
test entry-13.21 {GetEntryIndex procedure} {
|
1126 |
|
|
list [catch {.e index 1xyz} msg] $msg
|
1127 |
|
|
} {1 {bad entry index "1xyz"}}
|
1128 |
|
|
test entry-13.22 {GetEntryIndex procedure} {
|
1129 |
|
|
.e index -10
|
1130 |
|
|
} {0}
|
1131 |
|
|
test entry-13.23 {GetEntryIndex procedure} {
|
1132 |
|
|
.e index 12
|
1133 |
|
|
} {12}
|
1134 |
|
|
test entry-13.24 {GetEntryIndex procedure} {
|
1135 |
|
|
.e index 49
|
1136 |
|
|
} {21}
|
1137 |
|
|
test entry-13.25 {GetEntryIndex procedure} {fonts} {
|
1138 |
|
|
catch {destroy .e}
|
1139 |
|
|
entry .e -show .
|
1140 |
|
|
.e insert 0 XXXYZZY
|
1141 |
|
|
pack .e
|
1142 |
|
|
update
|
1143 |
|
|
list [.e index @7] [.e index @8]
|
1144 |
|
|
} {0 1}
|
1145 |
|
|
|
1146 |
|
|
# XXX Still need to write tests for EntryScanTo and EntrySelectTo.
|
1147 |
|
|
|
1148 |
|
|
set x {}
|
1149 |
|
|
for {set i 1} {$i <= 500} {incr i} {
|
1150 |
|
|
append x "This is line $i, out of 500\n"
|
1151 |
|
|
}
|
1152 |
|
|
test entry-14.1 {EntryFetchSelection procedure} {
|
1153 |
|
|
catch {destroy .e}
|
1154 |
|
|
entry .e
|
1155 |
|
|
.e insert end "This is a test string"
|
1156 |
|
|
.e select from 1
|
1157 |
|
|
.e select to 18
|
1158 |
|
|
selection get
|
1159 |
|
|
} {his is a test str}
|
1160 |
|
|
test entry-14.2 {EntryFetchSelection procedure} {
|
1161 |
|
|
catch {destroy .e}
|
1162 |
|
|
entry .e -show *
|
1163 |
|
|
.e insert end "This is a test string"
|
1164 |
|
|
.e select from 1
|
1165 |
|
|
.e select to 18
|
1166 |
|
|
selection get
|
1167 |
|
|
} {*****************}
|
1168 |
|
|
test entry-14.3 {EntryFetchSelection procedure} {
|
1169 |
|
|
catch {destroy .e}
|
1170 |
|
|
entry .e
|
1171 |
|
|
.e insert end $x
|
1172 |
|
|
.e select from 0
|
1173 |
|
|
.e select to end
|
1174 |
|
|
string compare [selection get] $x
|
1175 |
|
|
} 0
|
1176 |
|
|
|
1177 |
|
|
test entry-15.1 {EntryLostSelection} {
|
1178 |
|
|
catch {destroy .e}
|
1179 |
|
|
entry .e
|
1180 |
|
|
.e insert 0 "Text"
|
1181 |
|
|
.e select from 0
|
1182 |
|
|
.e select to 4
|
1183 |
|
|
set result [selection get]
|
1184 |
|
|
selection clear
|
1185 |
|
|
.e select from 0
|
1186 |
|
|
.e select to 4
|
1187 |
|
|
lappend result [selection get]
|
1188 |
|
|
} {Text Text}
|
1189 |
|
|
|
1190 |
|
|
# No tests for EventuallyRedraw.
|
1191 |
|
|
|
1192 |
|
|
catch {destroy .e}
|
1193 |
|
|
entry .e -width 10 -xscrollcommand scroll
|
1194 |
|
|
pack .e
|
1195 |
|
|
update
|
1196 |
|
|
|
1197 |
|
|
test entry-16.1 {EntryVisibleRange procedure} {fonts} {
|
1198 |
|
|
.e delete 0 end
|
1199 |
|
|
.e insert 0 .............................
|
1200 |
|
|
.e xview
|
1201 |
|
|
} {0 0.827586}
|
1202 |
|
|
test entry-16.2 {EntryVisibleRange procedure} {fonts} {
|
1203 |
|
|
.e configure -show X
|
1204 |
|
|
.e delete 0 end
|
1205 |
|
|
.e insert 0 .............................
|
1206 |
|
|
.e xview
|
1207 |
|
|
} {0 0.275862}
|
1208 |
|
|
.e configure -show ""
|
1209 |
|
|
test entry-16.3 {EntryVisibleRange procedure} {
|
1210 |
|
|
.e delete 0 end
|
1211 |
|
|
.e xview
|
1212 |
|
|
} {0 1}
|
1213 |
|
|
|
1214 |
|
|
catch {destroy .e}
|
1215 |
|
|
entry .e -width 10 -xscrollcommand scroll -font $fixed
|
1216 |
|
|
pack .e
|
1217 |
|
|
update
|
1218 |
|
|
test entry-17.1 {EntryUpdateScrollbar procedure} {
|
1219 |
|
|
.e delete 0 end
|
1220 |
|
|
.e insert 0 123
|
1221 |
|
|
update
|
1222 |
|
|
set scrollInfo
|
1223 |
|
|
} {0 1}
|
1224 |
|
|
test entry-17.2 {EntryUpdateScrollbar procedure} {
|
1225 |
|
|
.e delete 0 end
|
1226 |
|
|
.e insert 0 0123456789abcdef
|
1227 |
|
|
.e xview 3
|
1228 |
|
|
update
|
1229 |
|
|
set scrollInfo
|
1230 |
|
|
} {0.1875 0.8125}
|
1231 |
|
|
test entry-17.3 {EntryUpdateScrollbar procedure} {
|
1232 |
|
|
.e delete 0 end
|
1233 |
|
|
.e insert 0 abcdefghijklmnopqrs
|
1234 |
|
|
.e xview 6
|
1235 |
|
|
update
|
1236 |
|
|
set scrollInfo
|
1237 |
|
|
} {0.315789 0.842105}
|
1238 |
|
|
test entry-17.4 {EntryUpdateScrollbar procedure} {
|
1239 |
|
|
catch {destroy .e}
|
1240 |
|
|
proc bgerror msg {
|
1241 |
|
|
global x
|
1242 |
|
|
set x $msg
|
1243 |
|
|
}
|
1244 |
|
|
entry .e -width 5 -xscrollcommand bogus
|
1245 |
|
|
pack .e
|
1246 |
|
|
update
|
1247 |
|
|
rename bgerror {}
|
1248 |
|
|
list $x $errorInfo
|
1249 |
|
|
} {{invalid command name "bogus"} {invalid command name "bogus"
|
1250 |
|
|
while executing
|
1251 |
|
|
"bogus 0 1"
|
1252 |
|
|
(horizontal scrolling command executed by entry)}}
|
1253 |
|
|
|
1254 |
|
|
set l [interp hidden]
|
1255 |
|
|
eval destroy [winfo children .]
|
1256 |
|
|
|
1257 |
|
|
test entry-18.1 {Entry widget vs hiding} {
|
1258 |
|
|
catch {destroy .e}
|
1259 |
|
|
entry .e
|
1260 |
|
|
interp hide {} .e
|
1261 |
|
|
destroy .e
|
1262 |
|
|
list [winfo children .] [interp hidden]
|
1263 |
|
|
} [list {} $l]
|
1264 |
|
|
|
1265 |
|
|
# XXX Still need to write tests for EntryBlinkProc, EntryFocusProc,
|
1266 |
|
|
# and EntryTextVarProc.
|
1267 |
|
|
|
1268 |
|
|
|
1269 |
|
|
option clear
|