Debian Codegraph @

t/text.t

raw
1 #!/usr/bin/perl -w
2 # -*- perl -*-
3
4 # This file is a Tcl script to test the code in the file tkText.c.
5 # This file is organized in the standard fashion for Tcl tests.
6 #
7 # Copyright (c) 1992-1994 The Regents of the University of California.
8 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
9 # Copyright (c) 1998-1999 by Scriptics Corporation.
10 # All rights reserved.
11 #
12 # RCS: @(#) $Id: text.test,v 1.46 2006/10/17 10:21:50 patthoyts Exp $
13 #
14 # Translated to Perl/Tk by Slaven Rezic
15
16 use strict;
17 use FindBin;
18 use lib $FindBin::RealBin;
19 no warnings 'qw';
20
21 use Tk;
22
23 use TkTest qw(set_have_fixed_font with_fixed_font);
24
25 BEGIN {
26 if (!eval q{
27 use Test::More;
28 1;
29 }) {
30 print "1..0 # skip: no Test::More module\n";
31 exit;
32 }
33 }
34
35 plan tests => 415;
36
37 use Getopt::Long;
38 my $v;
39
40 GetOptions("v" => \$v)
41 or die "usage: $0 [-v]";
42
43 use_ok('Tk::Text');
44
45 my $mw = MainWindow->new;
46 $mw->geometry("+10+10");
47
48 sub deleteWindows () {
49 eval { $_->destroy } for $mw->children;
50 }
51
52 # Create entries in the option database to be sure that geometry options
53 # like border width have predictable values.
54
55 $mw->optionAdd('*Toplevel.borderWidth', 0);
56 $mw->optionAdd('*Text.borderWidth', 2);
57 $mw->optionAdd('*Text.highlightThickness', 2);
58 $mw->optionAdd('*Text.font', 'Courier -12');
59
60 my $t = $mw->Text(qw(Name t -width 20 -height 10));
61 isa_ok($t, "Tk::Text");
62 isa_ok($t, "Tk::Widget");
63 $t->pack(qw(-expand 1 -fill both));
64 # XXX what's the meaning of:
65 # pack append . .t {top expand fill}
66 #?
67 $t->update;
68 $t->debug("on");
69
70 {
71 my $font = $t->cget(-font);
72 my %fa = ($mw->fontActual($font),
73 $mw->fontMetrics($font));
74 my %expected = (
75 "-weight" => "normal",
76 "-underline" => 0,
77 "-family" => "courier",
78 "-slant" => "roman",
79 "-size" => -12,
80 "-overstrike" => 0,
81 "-ascent" => 10,
82 "-descent" => 3,
83 "-linespace" => 13,
84 "-fixed" => 1,
85 );
86 my $have_fixed_font = 1;
87 while(my($key,$val) = each %expected) {
88 if (lc $val ne lc $fa{$key}) {
89 diag "Value $key does not match: got $fa{$key}, expected $val\n" if $v;
90 $have_fixed_font = 0;
91 last;
92 }
93 }
94 set_have_fixed_font($have_fixed_font);
95 }
96
97 # The statements below reset the main window; it's needed if the window
98 # manager is mwm to make mwm forget about a previous minimum size setting.
99
100 $mw->withdraw;
101 $mw->minsize(1,1);
102 $mw->positionfrom("user");
103 $mw->deiconify;
104
105 my $te = $t->Entry(qw(Name e));
106 $te->insert(qw(end abcdefg));
107 $te->selection(qw(from 0));
108
109 $t->insert("1.0", q{Line 1
110 abcdefghijklm
111 12345
112 Line 4
113 bOy GIrl .#@? x_yz
114 !@#$%
115 Line 7});
116
117 my $t2 = $mw->Text(qw(Name t2));
118
119 my @tests =
120 (
121 [qw(-autoseparators yes 1)], # other booleans in Perl (was: nah)
122 [qw(-background #ff00ff #ff00ff <gorp>)],
123 [qw(-bd 4 4 foo)],
124 [qw(-bg blue blue #xx)],
125 #[qw(-blockcursor 0 0 xx)], # XXX not yet implemented???
126 [qw(-borderwidth 7 7 ++)],
127 [qw(-cursor watch watch lousy)],
128 [qw(-exportselection no 0)], # other booleans in Perl (was: maybe)
129 [qw(-fg red red stupid)],
130 #[qw(-font fixed fixed {})], # XXX cannot test for returned Font object
131 [qw(-foreground #012 #012 bogus)],
132 [qw(-height 5 5 bad)],
133 [qw(-highlightbackground #123 #123 bogus)],
134 [qw(-highlightcolor #234 #234 bogus)],
135 [qw(-highlightthickness -2 0 bad)],
136 #[qw(-inactiveselectbackground #ffff01234567 #ffff01234567 bogus)], # XXX not yet implemented?
137 [qw(-insertbackground green green <bogus>)],
138 [qw(-insertborderwidth 45 45 bogus)],
139 [qw(-insertofftime 100 100)], # no strict integer check in Perl (was: 2.4)
140 [qw(-insertontime 47 47 x1)],
141 [qw(-insertwidth 2.3 2 47d)],
142 [qw(-maxundo 5 5 noway)],
143 [qw(-padx 3.4 3 2.4.)],
144 [qw(-pady 82 82 bogus)],
145 [qw(-relief raised raised bumpy)],
146 [qw(-selectbackground #ffff01234567 #ffff01234567 bogus)],
147 [qw(-selectborderwidth 21 21 3x)],
148 [qw(-selectforeground yellow yellow #12345)],
149 [qw(-spacing1 20 20 1.3x)],
150 [qw(-spacing1 -5 0 bogus)],
151 [qw(-spacing2 5 5 bogus)],
152 [qw(-spacing2 -1 0 bogus)],
153 [qw(-spacing3 20 20 bogus)],
154 [qw(-spacing3 -10 0 bogus)],
155 [qw(-state d disabled foo)],
156 # [qw(-tabs), [qw{1i 2i 3i 4i}], [qw{1i 2i 3i 4i}], qw(bad_tabs)], # XXX things seem to screw up...
157 #[qw(-tabstyle wordprocessor wordprocessor garbage)], # XXX not yet implemented?
158 [qw(-undo 1 1)], # other booleans in Perl (was: eh)
159 [qw(-width 73 73)], # no strict integer check in Perl (was: 2.4)
160 [qw(-wrap w word bad_wrap)],
161 );
162
163 foreach my $test (@tests) {
164 my $name = $test->[0];
165 $t2->configure($name, $test->[1]);
166 is_deeply([$t2->cget($name)], [$test->[2]], "cget $name");
167 is(($t2->configure($name))[4], $t2->cget($name), "Comparing configure and cget values for $name");
168 SKIP: {
169 skip("No error test for $name", 1)
170 if !defined $test->[3];
171 eval {
172 $t2->configure($name, $test->[3]);
173 };
174 isnt($@, "", "Got error message for invalid $name");
175 }
176 }
177
178 {
179 $t2->configure(-takefocus => "any old thing");
180 is($t2->cget(-takefocus), q{any old thing}, "text options");
181
182 my @return;
183
184 $t2->configure(-xscrollcommand => "x scroll command");
185 @return = $t2->configure(-xscrollcommand);
186 isa_ok(pop @return, 'Tk::Callback', "callback not comparable in perl");
187 is_deeply([@return],
188 [qw{-xscrollcommand xScrollCommand ScrollCommand}, '']);
189
190 $t2->configure(-yscrollcommand => "test command");
191 @return = $t2->configure(-yscrollcommand);
192 isa_ok(pop @return, 'Tk::Callback');
193 is_deeply([@return],
194 [qw{-yscrollcommand yScrollCommand ScrollCommand}, '']);
195 }
196
197 {
198 eval { $t2->destroy } if Tk::Exists($t2);
199 eval { $t2 = $mw->Text(-gorp => "nofun") };
200 like($@, qr{Bad option `-gorp'}, "Tk_TextCmd procedure");
201 ok(!Tk::Exists($t2));
202 }
203
204 {
205 eval { $t2->destroy } if Tk::Exists($t2);
206 $t2 = $mw->Text(qw(-bd 2 -fg red));
207 is($t2->configure(-bd)->[4], 2);
208 is($t2->configure(-fg)->[4], 'red');
209 }
210
211 {
212 eval { $t2->destroy } if Tk::Exists($t2);
213 my $relief = ($Tk::platform eq 'MSWin32' ? 'flat' :
214 $Tk::platform eq 'aqua' ? 'solid' : 'raised');
215 $t2 = $mw->Text;
216 is($t2->tagCget('sel', -relief), $relief);
217 }
218
219 {
220 eval { $t2->destroy } if Tk::Exists($t2);
221 $t2 = $mw->Text;
222 is($t2->Class, 'Text');
223 }
224
225 {
226 eval { $t->gorp(qw(1.0 z 1.2)) };
227 like($@, qr{\QCan't locate auto/Tk/Text/gorp.al},
228 q{TextWidgetCmd procedure});
229 }
230
231 {
232 local $TODO = "Error NYI in Perl/Tk";
233
234 eval { $t->bbox };
235 like($@, qr{\Qwrong # args: should be ".t bbox index"},
236 q{TextWidgetCmd procedure, "bbox" option});
237 }
238
239 {
240 eval { $t->bbox(qw(a b)) };
241 like($@, qr{\Qwrong # args: should be ".t bbox index"});
242 }
243
244 {
245 eval { $t->bbox('bad_mark') };
246 like($@, qr{\Qbad text index "bad_mark"});
247 }
248
249 {
250 eval { $t->cget };
251 like($@, qr{\Qwrong # args: should be ".t cget option"},
252 q{TextWidgetCmd procedure, "cget" option});
253 }
254
255 {
256 eval { $t->cget(qw(a b)) };
257 like($@, qr{\Qwrong # args: should be ".t cget option"});
258 }
259
260 {
261 eval { $t->cget(-gorp) };
262 like($@, qr{\Qunknown option "-gorp"});
263 }
264
265 {
266 $t->configure(-bd => 17);
267 is($t->cget(-bd), 17);
268 # Restore
269 $t->configure(-bd => ($t->configure(-bd))[3]);
270 }
271
272 {
273 eval { $t->compare(qw(a b)) };
274 like($@, qr{\Qwrong # args: should be ".t compare index1 op index2"},
275 q{TextWidgetCmd procedure, "compare" option});
276 }
277
278 {
279 eval { $t->compare(qw(a b c d)) };
280 like($@, qr{\Qwrong # args: should be ".t compare index1 op index2"});
281 }
282
283 {
284 eval { $t->compare('@x', '==', '1.0') };
285 like($@, qr{\Qbad text index "\E\@x\Q"});
286 }
287
288 {
289 eval { $t->compare('1.0', '<', '@y') };
290 like($@, qr{\Qbad text index "\E\@y\Q"});
291 }
292
293 {
294 is($t->compare('1.1','<','1.0'), 0);
295 is($t->compare('1.1','<','1.1'), 0);
296 is($t->compare('1.1','<','1.2'), 1);
297
298 is($t->compare('1.1','<=','1.0'), 0);
299 is($t->compare('1.1','<=','1.1'), 1);
300 is($t->compare('1.1','<=','1.2'), 1);
301
302 is($t->compare('1.1','==','1.0'), 0);
303 is($t->compare('1.1','==','1.1'), 1);
304 is($t->compare('1.1','==','1.2'), 0);
305
306 is($t->compare('1.1','>=','1.0'), 1);
307 is($t->compare('1.1','>=','1.1'), 1);
308 is($t->compare('1.1','>=','1.2'), 0);
309
310 is($t->compare('1.1','>','1.0'), 1);
311 is($t->compare('1.1','>','1.1'), 0);
312 is($t->compare('1.1','>','1.2'), 0);
313
314 is($t->compare('1.1','!=','1.0'), 1);
315 is($t->compare('1.1','!=','1.1'), 0);
316 is($t->compare('1.1','!=','1.2'), 1);
317 }
318
319 {
320 eval { $t->compare('1.0', '<x', '1.2') };
321 like($@, qr{\Qbad comparison operator "<x": must be <, <=, ==, >=, >, or !=});
322
323 eval { $t->compare('1.0', '>>', '1.2') };
324 like($@, qr{\Qbad comparison operator ">>": must be <, <=, ==, >=, >, or !=});
325
326 eval { $t->compare('1.0', 'z', '1.2') };
327 like($@, qr{\Qbad comparison operator "z": must be <, <=, ==, >=, >, or !=});
328 }
329
330 # "configure" option is already covered above
331
332 {
333 eval { $t->debug(qw(0 1)) };
334 like($@, qr{\Qwrong # args: should be ".t debug boolean"},
335 q{TextWidgetCmd procedure, "debug" option});
336 }
337
338 {
339 $t->debug("true");
340 is($t->debug, 1);
341 }
342
343 {
344 $t->debug("false");
345 is($t->debug, 0);
346 }
347
348 {
349 eval { $t->delete };
350 like($@, qr{\Qwrong # args: should be ".t delete index1 ?index2 ...?"},
351 q{TextWidgetCmd procedure, "delete" option});
352 }
353
354 {
355 eval { $t->delete(qw(a b c)) };
356 like($@, qr{\Qbad text index "a"});
357 }
358
359 {
360 eval { $t->delete('@x', '2.2') };
361 like($@, qr{\Qbad text index "\E\@x\Q"});
362 }
363
364 {
365 eval { $t->delete('2.3', '@y') };
366 like($@, qr{\Qbad text index "\E\@y\Q"});
367 }
368
369 {
370 $t->configure(-state => "disabled");
371 $t->delete('2.3');
372 is($t->get('2.0', '2.end'), 'abcdefghijklm');
373 }
374
375 {
376 $t->configure(-state => 'normal');
377 $t->delete('2.3');
378 is($t->get('2.0', '2.end'), 'abcefghijklm');
379 }
380
381 {
382 $t->delete(qw(2.1 2.3));
383 is($t->get(qw(2.0 2.end)), 'aefghijklm');
384 }
385
386 {
387 eval { $t->delete(qw(2.1 2.3 foo)) };
388 like($@, qr{\Qbad text index "foo"});
389 is($t->get(qw(2.0 2.end)), 'aefghijklm',
390 'All indices are checked before we actually delete anything');
391 }
392
393 my $prevtext = $t->get('1.0', 'end-1c');
394
395 {
396 $t->delete(qw(1.0 end));
397 $t->insert('1.0', "foo\nabcdefghijklm");
398 $t->delete(qw(2.1 2.3 2.3));
399 is($t->get("1.0", "end-1c"), "foo\naefghijklm",
400 'auto-forward one byte if the last "pair" is just one');
401 }
402
403 {
404 $t->delete(qw(1.0 end));
405 $t->insert('1.0', "foo\nabcdefghijklm");
406 $t->delete(qw(2.0 2.3 2.7 2.9 2.4));
407 is($t->get('1.0', 'end-1c'), "foo\ndfgjklm",
408 'all indices will be ordered before deletion');
409 }
410
411 {
412 $t->delete(qw(1.0 end));
413 $t->insert('1.0', "foo\nabcdefghijklm");
414 $t->delete(qw(2.0 2.2 2.7 2.9 2.4 2.5));
415 is($t->get('1.0', 'end-1c'), "foo\ncdfgjklm",
416 "and check again with even pairs");
417 }
418
419 {
420 $t->delete(qw(1.0 end));
421 $t->insert('1.0', "foo\nabcdefghijklm");
422 $t->delete(qw(2.0 2.2 2.0 2.5 2.0 2.3 2.8 2.7));
423 is($t->get('1.0', 'end-1c'), "foo\nfghijklm",
424 "we should get the longest range on equal start indices");
425 }
426
427 {
428 $t->delete(qw(1.0 end));
429 $t->insert('1.0', "foo\nabcdefghijklm");
430 $t->delete(qw(2.0 2.2 1.2 2.6 2.0 2.5));
431 is($t->get('1.0', 'end-1c'), "foghijklm",
432 "we should get the longest range on equal start indices");
433 }
434
435 {
436 $t->delete(qw(1.0 end));
437 $t->insert('1.0', "foo\nabcdefghijklm");
438 $t->delete(qw(2.0 2.2 2.0 2.5 1.1 2.3 2.8 2.7));
439 is($t->get('1.0', 'end-1c'), "ffghijklm",
440 "we should get the longest range on equal start indices");
441 }
442
443 {
444 $t->delete(qw(1.0 end));
445 $t->insert('1.0', "foo\nabcdefghijklm");
446 $t->delete(qw(2.0 2.6 2.2 2.8));
447 is($t->get('1.0', 'end-1c'), "foo\nijklm",
448 "we should get the watch for overlapping ranges - "
449 # they should essentially be merged into one span.
450 );
451 }
452
453 {
454 $t->delete(qw(1.0 end));
455 $t->insert('1.0', "foo\nabcdefghijklm");
456 $t->delete(qw(2.0 2.6 2.2 2.4));
457 is($t->get('1.0', 'end-1c'), "foo\nghijklm");
458 }
459
460 $t->delete(qw(1.0 end));
461 $t->insert('1.0', $prevtext);
462
463 SKIP: {
464 skip("replace NYI in Perl/Tk", 1);
465 eval { $t->replace('1.3', '2.3') };
466 like($@, qr{\Qwrong # args: should be ".t replace index1 index2 chars ?tagList chars tagList ...?"},
467 q{TextWidgetCmd procedure, "replace" option});
468
469 # test text-8.17 {
470 # list [catch {.t replace 1.3 2.3} err] $err
471 # } {1
472 # test text-8.18 {TextWidgetCmd procedure, "replace" option} {
473 # list [catch {.t replace 3.1 2.3 foo} err] $err
474 # } {1 {Index "2.3" before "3.1" in the text}}
475 # test text-8.19 {TextWidgetCmd procedure, "replace" option} {
476 # list [catch {.t replace 2.1 2.3 foo} err] $err
477 # } {0 {}}
478 # .t delete 1.0 end; .t insert 1.0 $prevtext
479 # test text-8.20 {TextWidgetCmd procedure, "replace" option with undo} {
480 # .t configure -undo 0
481 # .t configure -undo 1
482 # # Ensure it is treated as a single undo action
483 # .t replace 2.1 2.3 foo
484 # .t edit undo
485 # .t configure -undo 0
486 # string equal [.t get 1.0 end-1c] $prevtext
487 # } {1}
488 # test text-8.21 {TextWidgetCmd procedure, "replace" option with undo} {
489 # .t configure -undo 0
490 # .t configure -undo 1
491 # .t replace 2.1 2.3 foo
492 # # Ensure we can override a text widget and intercept undo
493 # # actions. If in the future a different mechanism is available
494 # # to do this, then we should be able to change this test. The
495 # # behaviour tested for here is not, strictly speaking, documented.
496 # rename .t test.t
497 # set res {}
498 # proc .t {args} { lappend ::res $args ; uplevel 1 test.t $args }
499 # .t edit undo
500 # rename .t {}
501 # rename test.t .t
502 # .t configure -undo 0
503 # set res
504 # } {{edit undo} {delete 2.1 2.4} {mark set insert 2.1} {see insert} {insert 2.1 ef} {mark set insert 2.3} {see insert}}
505 # test text-8.22 {TextWidgetCmd procedure, "replace" option with undo} {
506 # .t configure -undo 0
507 # .t configure -undo 1
508 # # Ensure that undo (even composite undo like 'replace')
509 # # works when the widget shows nothing useful.
510 # .t replace 2.1 2.3 foo
511 # .t configure -start 1 -end 1
512 # .t edit undo
513 # .t configure -start {} -end {}
514 # .t configure -undo 0
515 # if {![string equal [.t get 1.0 end-1c] $prevtext]} {
516 # set res [list [.t get 1.0 end-1c] ne $prevtext]
517 # } else {
518 # set res 1
519 # }
520 # } {1}
521 # .t delete 1.0 end; .t insert 1.0 $prevtext
522 # test text-8.23 {TextWidgetCmd procedure, "replace" option with peers, undo} {
523 # .t configure -undo 0
524 # .t configure -undo 1
525 # .t peer create .tt -undo 1
526 # # Ensure that undo (even composite undo like 'replace')
527 # # works when the the event took place in one peer, which
528 # # is then deleted, before the undo takes place in another peer.
529 # .tt replace 2.1 2.3 foo
530 # .tt configure -start 1 -end 1
531 # destroy .tt
532 # .t edit undo
533 # .t configure -start {} -end {}
534 # .t configure -undo 0
535 # if {![string equal [.t get 1.0 end-1c] $prevtext]} {
536 # set res [list [.t get 1.0 end-1c] ne $prevtext]
537 # } else {
538 # set res 1
539 # }
540 # } {1}
541 # .t delete 1.0 end; .t insert 1.0 $prevtext
542 # test text-8.24 {TextWidgetCmd procedure, "replace" option with peers, undo} {
543 # .t configure -undo 0
544 # .t configure -undo 1
545 # .t peer create .tt -undo 1
546 # # Ensure that undo (even composite undo like 'replace')
547 # # works when the the event took place in one peer, which
548 # # is then deleted, before the undo takes place in another peer
549 # # which isn't showing everything.
550 # .tt replace 2.1 2.3 foo
551 # set res [.tt get 2.1 2.4]
552 # .tt configure -start 1 -end 1
553 # destroy .tt
554 # .t configure -start 3 -end 4
555 # # msg will actually be set to a silently ignored error message here,
556 # # (that the .tt command doesn't exist), but that is not important.
557 # lappend res [catch {.t edit undo} msg]
558 # .t configure -undo 0
559 # .t configure -start {} -end {}
560 # if {![string equal [.t get 1.0 end-1c] $prevtext]} {
561 # lappend res [list [.t get 1.0 end-1c] ne $prevtext]
562 # } else {
563 # lappend res 1
564 # }
565 # } {foo 0 1}
566
567 # .t delete 1.0 end; .t insert 1.0 $prevtext
568
569 }
570
571 {
572 local $TODO = "get -displaychars is missing in Perl/Tk";
573
574 eval { $t->get };
575 like($@, qr{\Qwrong # args: should be ".t get ?-displaychars? ?--? index1 ?index2 ...?"},
576 q{TextWidgetCmd procedure, "get" option});
577 }
578
579 {
580 eval { $t->get(qw(a b c)) };
581 like($@, qr{\Qbad text index "a"});
582 }
583
584 {
585 eval { $t->get('@q', '3.1') };
586 like($@, qr{\Qbad text index "\E\@q\Q"});
587 }
588
589 {
590 eval { $t->get('3.1', '@r') };
591 like($@, qr{\Qbad text index "\E\@r\Q"});
592 }
593
594 {
595 is($t->get("5.7", "5.3"), undef);
596 is($t->get("5.3", "5.5"), " G");
597 is($t->get("5.3", "end"), q{ GIrl .#@? x_yz
598 !@#$%
599 Line 7
600 });
601 }
602
603 {
604 $t->mark(qw(set a 5.3));
605 $t->mark(qw(set b 5.3));
606 $t->mark(qw(set c 5.5));
607 is($t->get(qw(5.2 5.7)), q{y GIr});
608 }
609
610 {
611 is($t->get('5.2'), q{y});
612 is($t->get(qw(5.2 5.4)), q{y });
613 }
614
615 {
616 # These tests went wrong in Tk804.027 (bizarre copy of array...)
617 is_deeply([$t->get(qw(5.2 5.4 5.4))], [q{y }, 'G']);
618 is_deeply([$t->get(qw(5.2 5.4 5.4 5.5))], [q{y }, 'G']);
619 is_deeply([$t->get(qw(5.2 5.4 5.5), "5.5+5c")], [q{y }, q{Irl .}]);
620 is_deeply([$t->get(qw(5.2 5.4 5.4 5.5 end-3c))], [q{y }, 'G', q{ }]);
621 is_deeply([$t->get(qw(5.2 5.4 5.4 5.5 end-3c end))], [q{y }, 'G', q{ 7
622 }]);
623 is_deeply([$t->get(qw(5.2 5.3 5.4 5.3))], ['y']);
624 }
625
626 SKIP: {
627 skip("indices index NYI in Perl/Tk", 1);
628 is($t->index("5.2 +3 indices"), '5.5', 'text index');
629 }
630
631 {
632 is($t->index("5.2 +3chars"), '5.5');
633 }
634
635 SKIP: {
636 skip("displayindices index NYI in Perl/Tk", 1);
637 is($t->index("5.2 +3displayindices"), '5.5');
638 }
639
640 {
641 $t->tag(qw(configure elide -elide 1));
642 $t->tag(qw(add elide 5.2 5.4));
643
644 eval { $t->get(qw(5.2 5.4 5.5 foo)) };
645 like($@, qr{\Qbad text index "foo"}, "wrong index in get");
646
647 is_deeply([$t->get(qw(5.2 5.4 5.4 5.5 end-3c end))],
648 [q{y }, 'G', q{ 7
649 }]);
650 }
651
652 ## indices not yet implemented
653 #test text-9.21 {TextWidgetCmd procedure, "get" option} {
654 # list [.t index "5.1 +4indices"] [.t index "5.1+4d indices"]
655 #} {5.5 5.7}
656 #test text-9.22 {TextWidgetCmd procedure, "get" option} {
657 # list [.t index "5.1 +4a chars"] [.t index "5.1+4d chars"]
658 #} {5.5 5.7}
659 #test text-9.23 {TextWidgetCmd procedure, "get" option} {
660 # list [.t index "5.5 -4indices"] [.t index "5.7-4d indices"]
661 #} {5.1 5.1}
662 #test text-9.24 {TextWidgetCmd procedure, "get" option} {
663 # list [.t index "5.5 -4a chars"] [.t index "5.7-4d chars"]
664 #} {5.1 5.1}
665 #.t window create 5.4
666 #test text-9.25 {TextWidgetCmd procedure, "get" option} {
667 # list [.t index "5.1 +4indices"] [.t index "5.1+4d indices"]
668 #} {5.5 5.7}
669 #test text-9.25a {TextWidgetCmd procedure, "get" option} {
670 # list [.t index "5.1 +4a chars"] [.t index "5.1+4d chars"]
671 #} {5.6 5.8}
672 #test text-9.26 {TextWidgetCmd procedure, "get" option} {
673 # list [.t index "5.5 -4indices"] [.t index "5.7-4d indices"]
674 #} {5.1 5.1}
675 #test text-9.26a {TextWidgetCmd procedure, "get" option} {
676 # list [.t index "5.6 -4a chars"] [.t index "5.8-4d chars"]
677 #} {5.1 5.1}
678
679 {
680 $t->delete('5.4');
681 $t->tag(qw(add elide 5.5 5.6));
682 ## -displaychars NYI
683 #is($t->get(qw(-displaychars 5.2 5.8)), q{Grl}, "get -displaychars");
684
685 $t->tag(qw(delete elide));
686 $t->mark(qw(unset a));
687 $t->mark(qw(unset b));
688 $t->mark(qw(unset c));
689 }
690
691 SKIP: {
692 skip("count not yet implemented in Perl/Tk", 1);
693
694 eval { $t->count };
695 like($@, qr{\Qwrong # args: should be ".t count ?options? index1 index2"},
696 q{TextWidgetCmd procedure, "count" option});
697
698 eval { $t->count(qw(blah 1.0 2.0)) };
699 like($@, qr{\Qbad option "blah" must be -chars, -displaychars, -displayindices, -displaylines, -indices, -lines, -update, -xpixels, or -ypixels});
700
701 eval { $t->count(qw(a b)) };
702 like($@, qr{\Qbad text index "a"});
703
704 eval { $t->count(qw(@q 3.1)) };
705 like($@, qr{\Qbad text index "\E\@\Qq"});
706
707 eval { $t->count(qw(3.1 @r)) };
708 like($@, qr{\Qbad text index "\E\@\Qr"});
709
710 is($t->count(qw(5.7 5.3)), -4);
711 is($t->count(qw(5.3 5.5)), 2);
712 is($t->count(qw(5.3 end)), 29);
713
714 # test text-9.2.7 {TextWidgetCmd procedure, "count" option} {
715 # .t count
716 # .t mark set a 5.3
717 # .t mark set b 5.3
718 # .t mark set c 5.5
719 # test text-9.2.8 {TextWidgetCmd procedure, "count" option} {
720 # .t count 5.2 5.7
721 # } {5}
722 # test text-9.2.9 {TextWidgetCmd procedure, "count" option} {
723 # .t count 5.2 5.3
724 # } {1}
725 # test text-9.2.10 {TextWidgetCmd procedure, "count" option} {
726 # .t count 5.2 5.4
727 # } {2}
728 # test text-9.2.17 {TextWidgetCmd procedure, "count" option} {
729 # list [catch {.t count 5.2 foo} msg] $msg
730 # } {1 {bad text index "foo"}}
731 # .t tag configure elide -elide 1
732 # .t tag add elide 2.2 3.4
733 # .t tag add elide 4.0 4.1
734 # test text-9.2.18 {TextWidgetCmd procedure, "count" option} {
735 # .t count -displayindices 2.0 3.0
736 # } {2}
737 # test text-9.2.19 {TextWidgetCmd procedure, "count" option} {
738 # .t count -displayindices 2.2 3.0
739 # } {0}
740 # test text-9.2.20 {TextWidgetCmd procedure, "count" option} {
741 # .t count -displayindices 2.0 4.2
742 # } {5}
743 # # Create one visible and one invisible window
744 # frame .t.w1
745 # frame .t.w2
746 # .t mark set a 2.2
747 # # Creating this window here means that the elidden text
748 # # now starts at 2.3, but 'a' is automatically moved to 2.3
749 # .t window create 2.1 -window .t.w1
750 # .t window create 3.1 -window .t.w2
751 # test text-9.2.21 {TextWidgetCmd procedure, "count" option} {
752 # .t count -displayindices 2.0 3.0
753 # } {3}
754 # test text-9.2.22 {TextWidgetCmd procedure, "count" option} {
755 # .t count -displayindices 2.2 3.0
756 # } {1}
757 # test text-9.2.23 {TextWidgetCmd procedure, "count" option} {
758 # .t count -displayindices a 3.0
759 # } {0}
760 # test text-9.2.24 {TextWidgetCmd procedure, "count" option} {
761 # .t count -displayindices 2.0 4.2
762 # } {6}
763 # test text-9.2.25 {TextWidgetCmd procedure, "count" option} {
764 # .t count -displaychars 2.0 3.0
765 # } {2}
766 # test text-9.2.26 {TextWidgetCmd procedure, "count" option} {
767 # .t count -displaychars 2.2 3.0
768 # } {1}
769 # test text-9.2.27 {TextWidgetCmd procedure, "count" option} {
770 # .t count -displaychars a 3.0
771 # } {0}
772 # test text-9.2.28 {TextWidgetCmd procedure, "count" option} {
773 # .t count -displaychars 2.0 4.2
774 # } {5}
775 # test text-9.2.29 {TextWidgetCmd procedure, "count" option} {
776 # list [.t count -indices 2.2 3.0] [.t count 2.2 3.0]
777 # } {10 10}
778 # test text-9.2.30 {TextWidgetCmd procedure, "count" option} {
779 # list [.t count -indices a 3.0] [.t count a 3.0]
780 # } {9 9}
781 # test text-9.2.31 {TextWidgetCmd procedure, "count" option} {
782 # .t count -indices 2.0 4.2
783 # } {21}
784 # test text-9.2.32 {TextWidgetCmd procedure, "count" option} {
785 # .t count -chars 2.2 3.0
786 # } {10}
787 # test text-9.2.33 {TextWidgetCmd procedure, "count" option} {
788 # .t count -chars a 3.0
789 # } {9}
790 # test text-9.2.34 {TextWidgetCmd procedure, "count" option} {
791 # .t count -chars 2.0 4.2
792 # } {19}
793 # destroy .t.w1
794 # destroy .t.w2
795 # set current [.t get 1.0 end-1c]
796 # .t delete 1.0 end
797 # .t insert end [string repeat "abcde " 50]\n
798 # .t insert end [string repeat "fghij " 50]\n
799 # .t insert end [string repeat "klmno " 50]
800 # test text-9.2.35 {TextWidgetCmd procedure, "count" option} {
801 # .t count -lines 1.0 end
802 # } {3}
803 # test text-9.2.36 {TextWidgetCmd procedure, "count" option} {
804 # .t count -lines end 1.0
805 # } {-3}
806 # test text-9.2.37 {TextWidgetCmd procedure, "count" option} {
807 # list [catch {.t count -lines 1.0 2.0 3.0} res] $res
808 # } {1 {bad option "1.0" must be -chars, -displaychars, -displayindices, -displaylines, -indices, -lines, -update, -xpixels, or -ypixels}}
809 # test text-9.2.38 {TextWidgetCmd procedure, "count" option} {
810 # .t count -lines end end
811 # } {0}
812 # test text-9.2.39 {TextWidgetCmd procedure, "count" option} {
813 # .t count -lines 1.5 2.5
814 # } {1}
815 # test text-9.2.40 {TextWidgetCmd procedure, "count" option} {
816 # .t count -lines 2.5 "2.5 lineend"
817 # } {0}
818 # test text-9.2.41 {TextWidgetCmd procedure, "count" option} {
819 # .t count -lines 2.7 "1.0 lineend"
820 # } {-1}
821 # test text-9.2.42 {TextWidgetCmd procedure, "count" option} {
822 # set old_wrap [.t cget -wrap]
823 # .t configure -wrap none
824 # set res [.t count -displaylines 1.0 end]
825 # .t configure -wrap $old_wrap
826 # set res
827 # } {3}
828 # test text-9.2.43 {TextWidgetCmd procedure, "count" option} {
829 # .t count -lines -chars -indices -displaylines 1.0 end
830 # } {3 903 903 45}
831 # .t configure -wrap none
832 #
833 #
834 # # Newer tags are higher priority
835 # .t tag configure elide1 -elide 0
836 # .t tag configure elide2 -elide 1
837 # .t tag configure elide3 -elide 0
838 # .t tag configure elide4 -elide 1
839 #
840 # test text-0.2.44.0 {counting with tag priority eliding} {
841 # .t delete 1.0 end
842 # .t insert end "hello"
843 # list [.t count -displaychars 1.0 1.0] \
844 # [.t count -displaychars 1.0 1.1] \
845 # [.t count -displaychars 1.0 1.2] \
846 # [.t count -displaychars 1.0 1.3] \
847 # [.t count -displaychars 1.0 1.4] \
848 # [.t count -displaychars 1.0 1.5] \
849 # [.t count -displaychars 1.0 1.6] \
850 # [.t count -displaychars 1.0 2.6] \
851 # } {0 1 2 3 4 5 5 6}
852 # test text-0.2.44 {counting with tag priority eliding} {
853 # .t delete 1.0 end
854 # .t insert end "hello"
855 # .t tag add elide1 1.2 1.4
856 # .t count -displaychars 1.0 1.5
857 # } {5}
858 # test text-0.2.45 {counting with tag priority eliding} {
859 # .t delete 1.0 end
860 # .t insert end "hello"
861 # .t tag add elide2 1.2 1.4
862 # .t count -displaychars 1.0 1.5
863 # } {3}
864 # test text-0.2.46 {counting with tag priority eliding} {
865 # set res {}
866 # .t delete 1.0 end
867 # .t insert end "hello"
868 # .t tag add elide2 1.2 1.4
869 # .t tag add elide1 1.2 1.4
870 # lappend res [.t count -displaychars 1.0 1.5]
871 # .t delete 1.0 end
872 # .t insert end "hello"
873 # .t tag add elide1 1.2 1.4
874 # .t tag add elide2 1.2 1.4
875 # lappend res [.t count -displaychars 1.0 1.5]
876 # } {3 3}
877 # test text-0.2.47 {counting with tag priority eliding} {
878 # set res {}
879 # .t delete 1.0 end
880 # .t insert end "hello"
881 # .t tag add elide2 1.2 1.4
882 # .t tag add elide3 1.2 1.4
883 # lappend res [.t count -displaychars 1.0 1.5]
884 # .t delete 1.0 end
885 # .t insert end "hello"
886 # .t tag add elide3 1.2 1.4
887 # .t tag add elide3 1.2 1.4
888 # lappend res [.t count -displaychars 1.0 1.5]
889 # } {5 5}
890 # test text-0.2.48 {counting with tag priority eliding} {
891 # set res {}
892 # .t delete 1.0 end
893 # .t insert end "hello"
894 # .t tag add elide2 1.2 1.4
895 # .t tag add elide3 1.2 1.4
896 # .t tag add elide4 1.2 1.4
897 # .t tag add elide1 1.2 1.4
898 # lappend res [.t count -displaychars 1.0 1.5]
899 # .t delete 1.0 end
900 # .t insert end "hello"
901 # .t tag add elide1 1.2 1.4
902 # .t tag add elide4 1.2 1.4
903 # .t tag add elide2 1.2 1.4
904 # .t tag add elide3 1.2 1.4
905 # lappend res [.t count -displaychars 1.0 1.5]
906 # } {3 3}
907 # test text-0.2.49 {counting with tag priority eliding} {
908 # set res {}
909 # .t delete 1.0 end
910 # .t insert end "hello"
911 # .t tag add elide2 1.2 1.4
912 # .t tag add elide3 1.2 1.4
913 # .t tag add elide1 1.2 1.4
914 # lappend res [.t count -displaychars 1.0 1.5]
915 # .t delete 1.0 end
916 # .t insert end "hello"
917 # .t tag add elide1 1.2 1.4
918 # .t tag add elide2 1.2 1.4
919 # .t tag add elide3 1.2 1.4
920 # lappend res [.t count -displaychars 1.0 1.5]
921 # } {5 5}
922 # test text-0.2.50 {counting with tag priority eliding} {
923 # set res {}
924 # .t delete 1.0 end
925 # .t insert end "hello"
926 # .t tag add elide2 1.0 1.5
927 # .t tag add elide1 1.2 1.4
928 # lappend res [.t count -displaychars 1.0 1.5]
929 # lappend res [.t count -displaychars 1.1 1.5]
930 # lappend res [.t count -displaychars 1.2 1.5]
931 # lappend res [.t count -displaychars 1.3 1.5]
932 # .t delete 1.0 end
933 # .t insert end "hello"
934 # .t tag add elide1 1.0 1.5
935 # .t tag add elide2 1.2 1.4
936 # lappend res [.t count -displaychars 1.0 1.5]
937 # lappend res [.t count -displaychars 1.1 1.5]
938 # lappend res [.t count -displaychars 1.2 1.5]
939 # lappend res [.t count -displaychars 1.3 1.5]
940 # } {0 0 0 0 3 2 1 1}
941 # test text-0.2.51 {counting with tag priority eliding} {
942 # set res {}
943 # .t delete 1.0 end
944 # .t tag configure WELCOME -elide 1
945 # .t tag configure SYSTEM -elide 0
946 # .t tag configure TRAFFIC -elide 1
947 # .t insert end "\n" {SYSTEM TRAFFIC}
948 # .t insert end "\n" WELCOME
949 # lappend res [.t count -displaychars 1.0 end]
950 # lappend res [.t count -displaychars 1.0 end-1c]
951 # lappend res [.t count -displaychars 1.0 1.2]
952 # lappend res [.t count -displaychars 2.0 end]
953 # lappend res [.t count -displaychars 2.0 end-1c]
954 # lappend res [.t index "1.0 +1 indices"]
955 # lappend res [.t index "1.0 +1 display indices"]
956 # lappend res [.t index "1.0 +1 display chars"]
957 # lappend res [.t index end]
958 # lappend res [.t index "end -1 indices"]
959 # lappend res [.t index "end -1 display indices"]
960 # lappend res [.t index "end -1 display chars"]
961 # lappend res [.t index "end -2 indices"]
962 # lappend res [.t index "end -2 display indices"]
963 # lappend res [.t index "end -2 display chars"]
964 # } {1 0 0 1 0 2.0 4.0 4.0 4.0 3.0 3.0 3.0 2.0 1.0 1.0}
965 #
966 # $t->delete(qw(1.0 end));
967 # $t->insert('end', $current);
968 # undef $current;
969 }
970
971 {
972 eval { $t->index };
973 like($@, qr{\Qwrong # args: should be ".t index index"},
974 q{TextWidgetCmd procedure, "index" option});
975
976 eval { $t->index(qw(a b)) };
977 like($@, qr{\Qwrong # args: should be ".t index index"});
978
979 eval { $t->index(qw(@xyz)) };
980 like($@, qr{\Qbad text index "\E\@\Qxyz"});
981
982 is($t->index("1.2"), "1.2");
983 }
984
985 {
986 eval { $t->insert("1.2") };
987 like($@, qr{\Qwrong # args: should be ".t insert index chars ?tagList chars tagList ...?"},
988 q{TextWidgetCmd procedure, "insert" option});
989 }
990
991 {
992 $t->configure(-state => "disabled");
993 $t->insert("1.2", "xyzzy");
994 is($t->get("1.0", "1.end"), "Line 1");
995 }
996 $t->configure(-state => "normal");
997 {
998 $t->insert("1.2", "xyzzy");
999 is($t->get("1.0", "1.end"), "Lixyzzyne 1");
1000 }
1001 {
1002 $t->delete("1.0", "end");
1003 $t->insert("1.0", "Sample text", "x");
1004 is_deeply([$t->tag(qw(ranges x))],
1005 ["1.0", "1.11"], "Insert with tag");
1006 }
1007 {
1008 $t->delete("1.0", "end");
1009 $t->insert("1.0", "Sample text", "x");
1010 $t->insert("1.2", "XYZ", "y");
1011 is_deeply([$t->tag(qw(ranges x))],
1012 [qw(1.0 1.2 1.5 1.14)]);
1013 is_deeply([$t->tag(qw(ranges y))],
1014 [qw(1.2 1.5)]);
1015 }
1016 {
1017 $t->delete("1.0", "end");
1018 $t->insert("1.0", "Sample text", [qw(x y z)]);
1019 for (qw(x y z)) {
1020 is_deeply([$t->tagRanges($_)], [qw(1.0 1.11)]);
1021 }
1022 }
1023 {
1024 $t->delete("1.0", "end");
1025 $t->insert("1.0", "Sample text", [qw(x y z)]);
1026 $t->insert("1.3", "A", [qw(a b z)]);
1027 for (qw(a b)) {
1028 is_deeply([$t->tagRanges($_)], [qw(1.3 1.4)]);
1029 }
1030 for (qw(x y)) {
1031 is_deeply([$t->tagRanges($_)], [qw(1.0 1.3 1.4 1.12)]);
1032 }
1033 is_deeply([$t->tagRanges('z')], [qw(1.0 1.12)]);
1034 }
1035 {
1036 $t->delete("1.0", "end");
1037 $t->insert("1.0", "First", "bold", " ", [], "second", [qw(x y z)], " third");
1038 is($t->get("1.0", "1.end"), q{First second third});
1039 is_deeply([$t->tagRanges("bold")], [qw{1.0 1.5}]);
1040 for (qw(x y z)) {
1041 is_deeply([$t->tagRanges($_)], [qw{1.6 1.12}]);
1042 }
1043 }
1044 {
1045 $t->delete("1.0", "end");
1046 $t->insert("1.0", "First", "bold", " second", "silly");
1047 is($t->get("1.0", "1.end"), q{First second});
1048 is_deeply([$t->tagRanges("bold")], [qw{1.0 1.5}]);
1049 is_deeply([$t->tagRanges("silly")], [qw{1.5 1.12}]);
1050 }
1051
1052 # Edit, mark, scan, search, see, tag, window, xview, and yview actions are tested elsewhere.
1053
1054 {
1055 eval { $t2->configure(-state => "foobar") };
1056 like($@, qr{\Qbad state value "foobar": must be normal or disabled},
1057 q{ConfigureText procedure});
1058 }
1059 {
1060 $t2->configure(-spacing1 => -2, -spacing2 => 1, -spacing3 => 1);
1061 is($t2->cget(-spacing1), 0);
1062 is($t2->cget(-spacing2), 1);
1063 is($t2->cget(-spacing3), 1);
1064 }
1065 {
1066 $t2->configure(qw(-spacing1 1 -spacing2 -1 -spacing3 1));
1067 is($t2->cget(-spacing1), 1);
1068 is($t2->cget(-spacing2), 0);
1069 is($t2->cget(-spacing3), 1);
1070 }
1071 {
1072 $t2->configure(qw(-spacing1 1 -spacing2 1 -spacing3 -3));
1073 is($t2->cget(-spacing1), 1);
1074 is($t2->cget(-spacing2), 1);
1075 is($t2->cget(-spacing3), 0);
1076 }
1077 {
1078 eval { $t2->configure(-tabs => '30 foo') };
1079 like($@, qr{\Qbad tab alignment "foo": must be left, right, center, or numeric});
1080 }
1081 {
1082 $t2->configure(-tabs => [qw{10 20 30}]);
1083 $t2->configure(-tabs => []);
1084 is_deeply([$t2->cget(-tabs)],[]);
1085 }
1086 {
1087 eval { $t2->configure(-wrap => "bogus") };
1088 like($@, qr{\Qbad wrap mode "bogus": must be char, none, or word});
1089 }
1090 {
1091 $t2->configure(qw(-selectborderwidth 17
1092 -selectforeground #332211
1093 -selectbackground #abc));
1094 is(($t2->tagConfigure('sel', -borderwidth))[4], 17);
1095 is(($t2->tagConfigure('sel', -foreground))[4], '#332211');
1096 is(($t2->tagConfigure('sel', -background))[4], '#abc');
1097 }
1098 {
1099 $t2->configure(-selectborderwidth => "");
1100 is($t2->tagCget('sel', '-borderwidth'), "");
1101 $t2->configure(-selectborderwidth => undef);
1102 is($t2->tagCget('sel', '-borderwidth'), "");
1103 }
1104 {
1105 eval { $t2->configure(-selectborderwidth => "foo") };
1106 like($@, qr{\Qbad screen distance "foo"});
1107 }
1108 {
1109 $t2->destroy if Tk::Exists($t2);
1110 $te->selection(qw(to 2));
1111 $t2 = $mw->Text(-exportselection => 1);
1112 is($mw->SelectionGet, "ab");
1113 }
1114 {
1115 $t2->destroy if Tk::Exists($t2);
1116 $te->selection(qw(to 2));
1117 $t2 = $mw->Text(-exportselection => 0);
1118 $t2->insert('insert', '1234657890');
1119 $t2->tag(qw(add sel 1.0 1.4));
1120 is($mw->SelectionGet, "ab");
1121 }
1122 {
1123 $t2->destroy if Tk::Exists($t2);
1124 $te->selection(qw(to 1));
1125 $t2 = $mw->Text(-exportselection => 1);
1126 $t2->insert('insert', '1234657890');
1127 $t2->tag(qw(add sel 1.0 1.4));
1128 is($mw->SelectionGet, "1234");
1129 }
1130 {
1131 $t2->destroy if Tk::Exists($t2);
1132 $te->selection(qw(to 1));
1133 $t2 = $mw->Text(-exportselection => 0);
1134 $t2->insert('insert', '1234657890');
1135 $t2->tag(qw(add sel 1.0 1.4));
1136 $t2->configure(-exportselection => 1);
1137 is($mw->SelectionGet, "1234");
1138 }
1139 {
1140 $t2->destroy if Tk::Exists($t2);
1141 $t2 = $mw->Text(-exportselection => 1);
1142 $t2->insert('insert', '1234657890');
1143 $t2->tag(qw(add sel 1.0 1.4));
1144 is($mw->SelectionGet, "1234");
1145 $t2->configure(-exportselection => 0);
1146 eval { $mw->SelectionGet };
1147 like($@, qr{\QPRIMARY selection doesn't exist or form "STRING" not defined});
1148 }
1149 {
1150 # This test is non-portable because the window size will vary depending
1151 # on the font size, which can vary.
1152 $t2->destroy if Tk::Exists($t2);
1153 $t2 = $mw->Toplevel;
1154 my $t2t = $t2->Text(qw(-width 20 -height 10));
1155 $t2t->pack(-side => 'top'); # XXX append?
1156 $t2->geometry("+0+0");
1157 $t2->update;
1158 ## There is no guarantee that the toplevel will be positioned at
1159 ## +0+0 if overrideredirect is not used. At least with the compiz
1160 ## wm the test would fail, so check only the width and height
1161 ## portions of the geometry.
1162 # is($t2->geometry, q{150x140+0+0}); # the original test as in Tcl/Tk
1163 with_fixed_font { like($t2->geometry, qr{^150x140\+}, "Toplevel width and height expected for given -width/-height") };
1164 }
1165 {
1166 # This test was failing Windows because the title bar on .t2
1167 # was a certain minimum size and it was interfering with the size
1168 # requested by the -setgrid. The "overrideredirect" gets rid of the
1169 # titlebar so the toplevel can shrink to the appropriate size.
1170 $t2->destroy if Tk::Exists($t2);
1171 $t2 = $mw->Toplevel;
1172 $t2->overrideredirect(1);
1173 my $t2t = $t2->Text(qw(-width 20 -height 10 -setgrid 1));
1174 $t2t->pack(-side => "top"); # XXX append?
1175 $t2->geometry('+0+0');
1176 $t2->update;
1177 is($t2->geometry, q{20x10+0+0}, "geometry with -setgrid");
1178 }
1179 {
1180 # This test was failing on Windows because the title bar on .t2
1181 # was a certain minimum size and it was interfering with the size
1182 # requested by the -setgrid. The "overrideredirect" gets rid of the
1183 # titlebar so the toplevel can shrink to the appropriate size.
1184 $t2->destroy if Tk::Exists($t2);
1185 $t2 = $mw->Toplevel;
1186 $t2->overrideredirect(1);
1187 my $t2t = $t2->Text(qw(-width 20 -height 10 -setgrid 1));
1188 $t2t->pack(-side => "top"); # XXX append?
1189 $t2->geometry('+0+0');
1190 $t2->update;
1191 is($t2->geometry, q{20x10+0+0});
1192 $t2->geometry("15x8");
1193 $t2->update;
1194 is($t2->geometry, q{15x8+0+0});
1195 $t2t->configure(-wrap => 'word');
1196 $t2->update;
1197 is($t2->geometry, q{15x8+0+0});
1198 }
1199 {
1200 $t2->destroy if Tk::Exists($t2);
1201 $t2 = $mw->Text(qw(-width 20 -height 10));
1202 with_fixed_font {
1203 is($t2->reqheight, 140,
1204 q{TextWorldChanged procedure, spacing options}
1205 );
1206 };
1207 $t2->configure(-spacing1 => 2);
1208 with_fixed_font { is($t2->reqheight, 160) };
1209 $t2->configure(-spacing3 => 1);
1210 with_fixed_font { is($t2->reqheight, 170) };
1211 $t2->configure(-spacing1 => 0);
1212 with_fixed_font { is($t2->reqheight, 150) };
1213 }
1214
1215 # (Skipped tests text-15.* because of non-existing "rename" in Perl/Tk
1216
1217 {
1218 $t2->destroy if Tk::Exists($t2);
1219 $t2 = $mw->Text;
1220 $t2->insert("2.0", "abcd\n");
1221 is($t2->get("1.0", "end"), q{abcd
1222
1223 }, q{InsertChars procedure});
1224 }
1225
1226 {
1227 $t2->destroy if Tk::Exists($t2);
1228 $t2 = $mw->Text;
1229 $t2->insert("1.0", "abcd\n");
1230 $t2->insert("end", "123\n");
1231 is($t2->get("1.0", "end"), q{abcd
1232 123
1233
1234 });
1235 }
1236
1237 {
1238 $t2->destroy if Tk::Exists($t2);
1239 $t2 = $mw->Text;
1240 $t2->insert("1.0", "abcd\n");
1241 $t2->insert("10.0", "123");
1242 is($t2->get("1.0", "end"), q{abcd
1243 123
1244 });
1245 }
1246
1247 {
1248
1249 $t2->destroy if Tk::Exists($t2);
1250 $t2 = $mw->Text(qw(-width 20 -height 4 -wrap word))->pack;
1251 $t2->insert('insert', "Now is the time for all great men to come to the ");
1252 $t2->insert('insert', "aid of their party.\n");
1253 $t2->insert('insert', "Now is the time for all great men.\n");
1254 $t2->see('end');
1255 $mw->update;
1256 $t2->insert('1.0' => "Short\n");
1257 with_fixed_font {
1258 is($t2->index('@0,0'), '2.56',
1259 q{InsertChars procedure, inserting on top visible line});
1260 };
1261 }
1262
1263 {
1264 $t2->destroy if Tk::Exists($t2);
1265 $t2 = $mw->Text(qw(-width 20 -height 4 -wrap word))->pack;
1266 $t2->insert('insert', "Now is the time for all great men to come to the ");
1267 $t2->insert('insert', "aid of their party.\n");
1268 $t2->insert('insert', "Now is the time for all great men.\n");
1269 $t2->see('end');
1270 $mw->update;
1271 $t2->insert('1.55' => "Short\n");
1272 with_fixed_font { is($t2->index('@0,0'), '2.0') };
1273 }
1274
1275 {
1276 $t2->destroy if Tk::Exists($t2);
1277 $t2 = $mw->Text(qw(-width 20 -height 4 -wrap word))->pack;
1278 $t2->insert('insert', "Now is the time for all great men to come to the ");
1279 $t2->insert('insert', "aid of their party.\n");
1280 $t2->insert('insert', "Now is the time for all great men.\n");
1281 $t2->see('end');
1282 $mw->update;
1283 $t2->insert('1.56' => "Short\n");
1284 with_fixed_font { is($t2->index('@0,0'), '1.56') };
1285 }
1286
1287 {
1288 $t2->destroy if Tk::Exists($t2);
1289 $t2 = $mw->Text(qw(-width 20 -height 4 -wrap word))->pack;
1290 $t2->insert('insert', "Now is the time for all great men to come to the ");
1291 $t2->insert('insert', "aid of their party.\n");
1292 $t2->insert('insert', "Now is the time for all great men.\n");
1293 $t2->see('end');
1294 $mw->update;
1295 $t2->insert('1.57' => "Short\n");
1296 with_fixed_font { is($t2->index('@0,0'), '1.56') };
1297 }
1298
1299 $t2->destroy if Tk::Exists($t2);
1300
1301 sub setup () {
1302 $t->delete(qw(1.0 end));
1303 $t->insert('1.0', "Line 1
1304 abcde
1305 12345
1306 Line 4");
1307 }
1308
1309 {
1310 $t->delete('1.0', 'end');
1311 is($t->get('1.0', 'end'), "\n",
1312 q{DeleteChars procedure});
1313 }
1314
1315 {
1316 eval { $t->delete("foobar") };
1317 like($@, qr{\Qbad text index "foobar"});
1318 }
1319
1320 {
1321 eval { $t->delete("1.0", "lousy") };
1322 like($@, qr{\Qbad text index "lousy"});
1323 }
1324
1325 {
1326 setup;
1327 $t->delete("2.1");
1328 is($t->get('1.0', 'end'), q{Line 1
1329 acde
1330 12345
1331 Line 4
1332 });
1333 }
1334
1335 {
1336 setup;
1337 $t->delete("2.3");
1338 is($t->get('1.0', 'end'), q{Line 1
1339 abce
1340 12345
1341 Line 4
1342 });
1343 }
1344
1345 {
1346 setup;
1347 $t->delete("2.end");
1348 is($t->get('1.0', 'end'), q{Line 1
1349 abcde12345
1350 Line 4
1351 });
1352 }
1353
1354 {
1355 setup;
1356 $t->tag(qw(add sel 4.2 end));
1357 $t->delete(qw(4.2 end));
1358 is($t->tagRanges('sel'), undef);
1359 is($t->get('1.0', 'end'), q{Line 1
1360 abcde
1361 12345
1362 Li
1363 });
1364 }
1365
1366 {
1367 setup;
1368 $t->tag('add', 'sel', '1.0', 'end');
1369 $t->delete('4.0', 'end');
1370 is_deeply([$t->tagRanges('sel')], [qw(1.0 3.5)]);
1371 is($t->get('1.0', 'end'), q{Line 1
1372 abcde
1373 12345
1374 });
1375 }
1376
1377 {
1378 setup;
1379 $t->delete(qw(2.2 2.2));
1380 is($t->get(qw(1.0 end)), q{Line 1
1381 abcde
1382 12345
1383 Line 4
1384 });
1385 }
1386
1387 {
1388 setup;
1389 $t->delete(qw(2.3 2.1));
1390 is($t->get(qw(1.0 end)), q{Line 1
1391 abcde
1392 12345
1393 Line 4
1394 });
1395 }
1396
1397 {
1398 $t2->destroy if Tk::Exists($t2);
1399 $t2 = $mw->Toplevel;
1400 my $t2t = $t2->Text(qw(-width 20 -height 5))->pack;
1401 $t2->geometry("+0+0");
1402 $t2t->insert("1.0", "abc\n123\nx\ny\nz\nq\nr\ns");
1403 $mw->update;
1404 $t2t->delete("1.0", "3.0");
1405 is($t2t->index('@0,0'), '1.0');
1406 is($t2t->get('@0,0'), 'x');
1407 }
1408
1409 {
1410 $t2->destroy if Tk::Exists($t2);
1411 $t2 = $mw->Toplevel;
1412 my $t2t = $t2->Text(qw(-width 20 -height 5))->pack;
1413 $t2->geometry("+0+0");
1414 $t2t->insert("1.0", "abc\n123\nx\ny\nz\nq\nr\ns");
1415 $t2t->yview('3.0');
1416 $mw->update;
1417 $t2t->delete(qw(2.0 4.0));
1418 is($t2t->index('@0,0'), '2.0');
1419 is($t2t->get('@0,0'), 'y');
1420 }
1421
1422 {
1423 $t2->destroy if Tk::Exists($t2);
1424 $t2 = $mw->Toplevel;
1425 my $t2t = $t2->Text(qw(-width 1 -height 10 -wrap char));
1426 my $t2f = $t2->Frame(qw(-width 200 -height 20 -relief raised -bd 2));
1427 Tk::pack($t2f, $t2t, -side => 'left');
1428 $t2->geometry('+0+0');
1429 $mw->update;
1430
1431 $t2t->delete(qw(1.0 end));
1432 $t2t->insert('end', "abcde\n12345\nqrstuv");
1433 $t2t->yview('2.1');
1434 $t2t->delete('1.4', '2.3');
1435 is($t2t->index('@0,0'), '1.2');
1436
1437 $t2t->delete(qw(1.0 end));
1438 $t2t->insert('end', "abcde\n12345\nqrstuv");
1439 $t2t->yview('2.1');
1440 $t2t->delete('2.3', '2.4');
1441 is($t2t->index('@0,0'), '2.0');
1442
1443 $t2t->delete(qw(1.0 end));
1444 $t2t->insert('end', "abcde\n12345\nqrstuv");
1445 $t2t->yview('1.3');
1446 $t2t->delete('1.0', '1.2');
1447 is($t2t->index('@0,0'), '1.1');
1448 }
1449
1450 {
1451 $t2->destroy if Tk::Exists($t2);
1452 $t2 = $mw->Toplevel;
1453 my $t2t = $t2->Text(qw(-width 6 -height 10 -wrap word))->pack(-side => "left");
1454 my $t2f = $t2->Frame(qw(-width 200 -height 20 -relief raised -bd 2))->pack(-side => "left");
1455 $t2->geometry('+0+0');
1456 $mw->update;
1457 $t2t->insert('end', "abc def\n01 2345 678 9101112\nLine 3\nLine 4\nLine 5\n6\n7\n8\n");
1458 $t2t->yview(qw(2.4));
1459 $t2t->delete(qw(2.5));
1460 with_fixed_font {
1461 is($t2t->index('@0,0'), '2.3',
1462 q{DeleteChars procedure, updates affecting topIndex});
1463 };
1464 $t2t->delete('2.5');
1465 is($t2t->index('@0,0'), '2.0');
1466 }
1467
1468 $t->delete('1.0', 'end');
1469 for my $i ('a' .. 'z') {
1470 $t->insert('end', "$i.0$i.1$i.2$i.3$i.4\n");
1471 }
1472
1473 {
1474 $t->tagAdd('sel', '1.3', '3.4');
1475 is($mw->SelectionGet, q{a.1a.2a.3a.4
1476 b.0b.1b.2b.3b.4
1477 c.0c}, q{TextFetchSelection procedure});
1478 }
1479
1480 {
1481 $t->tagAdd('x', '1.2');
1482 $t->tagAdd('x', '1.4');
1483 $t->tagAdd('x', '2.0');
1484 $t->tagAdd('x', '2.3');
1485 $t->tagRemove('sel', '1.0', 'end');
1486 $t->tagAdd('sel', '1.0', '3.4');
1487 is($mw->SelectionGet, q{a.0a.1a.2a.3a.4
1488 b.0b.1b.2b.3b.4
1489 c.0c});
1490 }
1491
1492 {
1493 $t->tagRemove('sel', '1.0', 'end');
1494 $t->tagAdd('sel', '13.3');
1495 is($mw->SelectionGet, 'm');
1496 }
1497
1498 {
1499 $t->tag(qw(remove x 1.0 end));
1500 $t->tag(qw(add sel 1.0 3.4));
1501 $t->tag(qw(remove sel 1.0 end));
1502 $t->tag(qw(add sel 1.2 1.5));
1503 $t->tag(qw(add sel 2.4 3.1));
1504 $t->tag(qw(add sel 10.0 10.end));
1505 $t->tag(qw(add sel 13.3));
1506 is($mw->SelectionGet, q{0a..1b.2b.3b.4
1507 cj.0j.1j.2j.3j.4m});
1508 }
1509
1510 {
1511 my $x = "";
1512 for(my $i = 1; $i < 200; $i++) {
1513 $x .= "This is line $i, padded to just about 53 characters.\n";
1514 }
1515
1516 $t->delete(qw(1.0 end));
1517 $t->insert('end', $x);
1518 $t->tagAdd('sel', '1.0', 'end');
1519 is($mw->SelectionGet, "$x\n", q{TextFetchSelection procedure, long selections});
1520 }
1521
1522 SKIP: {
1523 skip("Only for unix", 1)
1524 if $Tk::platform ne 'unix';
1525
1526 $t2->destroy if Tk::Exists($t2);
1527 $t2 = $mw->Text;
1528 $t2->insert('1.0', "abc\ndef\nghijk\n1234");
1529 $t2->tagAdd('sel', '1.2', '3.3');
1530 $te->selectionTo(1);
1531 is_deeply([$t2->tagRanges('sel')], [],
1532 q{TkTextLostSelection procedure});
1533 }
1534
1535 SKIP: {
1536 skip("Only for windows", 1)
1537 if $Tk::platform ne 'MSWin32';
1538
1539 $t2->destroy if Tk::Exists($t2);
1540 $t2 = $mw->Text;
1541 $t2->insert('1.0', "abc\ndef\nghijk\n1234");
1542 $t2->tagAdd('sel', '1.2', '3.3');
1543 $te->selectionTo(1);
1544 is_deeply([$t2->tagRanges('sel')], [qw(1.2 3.3)],
1545 q{TkTextLostSelection procedure});
1546 }
1547
1548 {
1549 $t2->destroy if Tk::Exists($t2);
1550 $t2 = $mw->Text;
1551 $t2->insert('1.0', "abcdef\nghijk\n1234");
1552 $t2->tagAdd('sel', '1.0', '1.3');
1553 is($mw->SelectionGet, 'abc');
1554 $mw->SelectionClear;
1555 eval { $mw->SelectionGet };
1556 like($@, qr{\QPRIMARY selection doesn't exist or form "STRING" not defined});
1557 $t2->tagAdd('sel', '1.0', '1.3');
1558 is($mw->SelectionGet, 'abc');
1559 }
1560
1561 {
1562 $t->delete('1.0', 'end');
1563 $t->insert("end", "xxyz xyz x. the\nfoo -forward bar xxxxx BaR foo\nxyz xxyzx");
1564
1565 {
1566 local $TODO = "Many options NYI in Perl/Tk";
1567
1568 eval { $t->search('-') };
1569 like($@, qr{\Qbad switch "-": must be --, -all, -backward, -count, -elide, -exact, -forward, -nocase, -nolinestop, -overlap, -regexp, or -strictlimits},
1570 q{TextSearchCmd procedure, argument parsing});
1571 }
1572
1573 is($t->search('-backwards', 'xyz', '1.4'), '1.1',
1574 q{TextSearchCmd procedure, -backwards option});
1575
1576 SKIP: {
1577 skip("-all NYI in Perl/Tk # TODO", 1);
1578
1579 is_deeply([$t->search('-all', 'xyz', '1.4')],
1580 [qw{1.5 3.0 3.5 1.1}],
1581 q{TextSearchCmd procedure, -all option});
1582 }
1583
1584 is($t->search('-forwards', 'xyz', '1.4'), '1.5',
1585 q{TextSearchCmd procedure, -forwards option});
1586
1587 is($t->search('-f', '-exact', 'x.', '1.0'), '1.9',
1588 q{TextSearchCmd procedure, -exact option});
1589
1590 is($t->search('-b', '-regexp', 'x.z', '1.4'), '1.1',
1591 q{TextSearchCmd procedure, -regexp option});
1592
1593 is($t->search('-b', '-regexp', qr{x.z}, '1.4'), '1.1',
1594 q{TextSearchCmd procedure, -regexp option with qr regexp});
1595
1596 is($t->search('-b', '-regexp', qr{X.Z}i, '1.4'), '1.1',
1597 q{TextSearchCmd procedure, -regexp option with qr regexp and flags});
1598
1599 is($t->search('-f', '-regexp', '(?i:BAR)', '1.0'), '2.13',
1600 q{Perl regexp, embedded option});
1601
1602 my $length = "unmodified";
1603 is($t->search(-count => \$length, 'x.', '1.4'), '1.9',
1604 q{TextSearchCmd procedure, -count option});
1605 is($length, 2);
1606
1607 ## It's not yet clear if the array form is also needed...
1608 # my @length;
1609 # is($t->search(-count => \@length, 'x.', '1.4'), '1.9',
1610 # q{TextSearchCmd procedure, -count option});
1611 # is_deeply(\@length, [2]);
1612
1613 eval { $t->search('-count') };
1614 like($@, qr{\Qno value given for "-count" option});
1615
1616 is($t->search(-nocase => 'BaR', '1.1'), '2.13',
1617 q{TextSearchCmd procedure, -nocase option});
1618 is($t->search('BaR', '1.1'), '2.23');
1619
1620 {
1621 local $TODO = "not clear if this should be a failure...";
1622
1623 eval { $t->search(qw(-n BaR 1.1)) };
1624 isnt($@, "", q{TextSearchCmd procedure, -n ambiguous option});
1625 }
1626
1627 is($t->search(-noc => 'BaR', '1.1'), '2.13');
1628
1629 {
1630 local $TODO = "-nolinestop NYI in Perl/Tk";
1631
1632 eval { $t->search(-nolinestop => 'BaR', '1.1') };
1633 like($@, qr{\Qthe "-nolinestop" option requires the "-regexp" option to be present},
1634 q{TextSearchCmd procedure, -nolinestop option});
1635 }
1636
1637 SKIP: {
1638 skip("-nolinestop NYI in Perl/Tk # TODO", 2);
1639
1640 my $msg = "";
1641 is($t->search(-nolinestop => -regexp => -count => \$msg, 'e.*o', '1.1'), '1.14');
1642 is($msg, "32");
1643 }
1644
1645 is($t->search('--', '-forward', '1.0'), '2.4',
1646 q{TextSearchCmd procedure, -- option});
1647
1648 eval { $t->search('abc') };
1649 like($@, qr{\Qwrong # args: should be ".t search ?switches? pattern index ?stopIndex?"},
1650 q{TextSearchCmd procedure, argument parsing});
1651
1652 eval { $t->search(qw(abc d e f)) };
1653 like($@, qr{\Qwrong # args: should be ".t search ?switches? pattern index ?stopIndex?"});
1654
1655 eval { $t->search(qw(abc gorp)) };
1656 like($@, qr{\Qbad text index "gorp"},
1657 q{TextSearchCmd procedure, check index});
1658
1659 is($t->search("non-existent", "end"), undef,
1660 q{TextSearchCmd procedure, startIndex == "end"});
1661
1662 eval { $t->search(qw(abc 1.0 lousy)) };
1663 like($@, qr{\Qbad text index "lousy"},
1664 q{TextSearchCmd procedure, bad stopIndex});
1665
1666 is($t->search(-nocase => BAR => '1.1'), "2.13",
1667 q{TextSearchCmd procedure, pattern case conversion});
1668
1669 is($t->search('BAR' => '1.1'), undef);
1670
1671 # This test causes a "Stack moved ........ => ........" message
1672 eval { $t->search(-regexp => 'a(', '1.0') };
1673 like($@, qr{Unmatched \( in regex}, # this is a perl error message, not a Tcl error message
1674 q{TextSearchCmd procedure, bad regular expression pattern});
1675
1676 is($t->search(-backwards => 'BaR', 'end', '1.0'), '2.23',
1677 q{TextSearchCmd procedure, skip dummy last line});
1678
1679 is($t->search(-backwards => "\n", "end", "1.0"), "3.9");
1680
1681 is($t->search("\n", "end"), "1.15");
1682
1683 is($t->search(-back => "\n", "1.0"), "3.9");
1684
1685 $t->tagAdd("foo", "1.2");
1686 $t->tagAdd("x", "1.3");
1687 $t->markSet("silly", "1.2");
1688 is($t->search("xyz", "3.6"), "1.1",
1689 q{TextSearchCmd procedure, extract line contents});
1690
1691 is($t->search("the\n", "1.0"), "1.12",
1692 q{TextSearchCmd procedure, stripping newlines});
1693
1694 {
1695 local $TODO = "This is probably implemented in tk8.5";
1696
1697 is($t->search(-regexp => "the\n", "1.0"), "1.12",
1698 q{TextSearchCmd procedure, handling newlines});
1699
1700 is($t->search(-regexp => "\n", "1.0"), "1.15");
1701 }
1702
1703 is($t->search(-regexp => q{the$}, "1.0"), "1.12",
1704 q{TextSearchCmd procedure, stripping newlines});
1705
1706 is($t->search(-nocase => "bar", "2.18"), "2.23",
1707 q{TextSearchCmd procedure, line case conversion});
1708 is($t->search('bar', '2.18'), "2.13");
1709
1710 is($t->search(-backwards => 'xyz', '1.6'), '1.5',
1711 q{TextSearchCmd procedure, firstChar and lastChar});
1712 is($t->search(-backwards => 'xyz', '1.5'), '1.1');
1713 is($t->search('xyz', '1.5'), '1.5');
1714 is($t->search('xyz', '1.6'), '3.0');
1715 is($t->search(undef, '1.end'), '1.15');
1716 is($t->search('', '1.end'), '1.15');
1717 is($t->search('f', '1.end'), '2.0');
1718 is($t->search(undef, 'end'), '1.0');
1719
1720 # Test for fix of bug #1643
1721 $t->insert("end", "\n");
1722 $t->SetCursor("4.0");
1723 is($t->search(-forward => -regexp => q{^$}, 'insert', 'end'), "4.0",
1724 q{TextSearchCmd procedure, regexp finds empty lines});
1725 }
1726
1727 {
1728 $t2->destroy if Tk::Exists($t2);
1729 $t2 = $mw->Toplevel;
1730 my $t2t = $t2->Text(qw(-width 30 -height 10))->pack;
1731 $t2t->insert('1.0', "This is a line\nand this is another");
1732 $t2t->insert('end', "\nand this is yet another");
1733 my $t2f = $t2->Frame(qw(-width 20 -height 20 -bd 2 -relief raised));
1734 $t2t->windowCreate("2.5", -window => $t2f);
1735
1736 is($t2t->search("his", "2.6"), "2.6",
1737 q{TextSearchCmd procedure, firstChar and lastChar});
1738 is($t2t->search("this", "2.6"), "3.4");
1739 is($t2t->search("is", "2.6"), "2.7");
1740 is($t2t->search("his", "2.7"), "3.5");
1741 is($t2t->search("-backwards", "his is another", "2.6"), "2.6");
1742 is($t2t->search("-backwards", "his is", "2.6"), "1.1");
1743
1744 $t2->destroy;
1745 }
1746
1747 {
1748 is($t->search(-backwards => 'forw', '2.5'), '2.5');
1749 is($t->search('forw', '2.5'), '2.5');
1750 }
1751
1752 {
1753 $t2->destroy if Tk::Exists($t2);
1754 $t2 = $mw->Text;
1755 is($t2->search("a", "1.0"), undef);
1756 is($t2->search(-backward, "a", "1.0"), undef);
1757 is_deeply([$t2->search("a", "1.0")], []);
1758 is_deeply([$t2->search(-backward, "a", "1.0")], []);
1759 }
1760
1761 {
1762 my $length = "unchanged";
1763 is($t->search(-regexp => -count => \$length, 'x(.)(.*)z', '1.1'), '1.1');
1764 is($length, 7, q{TextSearchCmd procedure, regexp match length});
1765 }
1766
1767 {
1768 my $length = "unchanged";
1769 is($t->search(-regexp => -backward => -count => \$length, 'fo*', '2.5'), '2.0');
1770 is($length, 3, q{TextSearchCmd procedure, regexp match length});
1771 }
1772
1773 {
1774 is($t->search("bar", "2.1", "2.13"), undef,
1775 q{TextSearchCmd procedure, checking stopIndex});
1776 is($t->search("bar", "2.1", "2.14"), "2.13");
1777 is($t->search("bar", "2.12", "2.14"), "2.13");
1778 is($t->search("bar", "2.14", "2.14"), undef);
1779 }
1780
1781 {
1782 is($t->search(qw(-backwards bar 2.20 2.13)), "2.13");
1783 is($t->search(qw(-backwards bar 2.20 2.14)), undef);
1784 is($t->search(qw(-backwards bar 2.14 2.13)), "2.13");
1785 is($t->search(qw(-backwards bar 2.13 2.13)), undef);
1786 }
1787
1788 SKIP:{
1789 skip("-strict NYI in Perl/Tk # TODO", 4);
1790
1791 is($t->search(qw(-backwards -strict bar 2.20 2.13)), "2.13");
1792 is($t->search(qw(-backwards -strict bar 2.20 2.14)), undef);
1793 is($t->search(qw(-backwards -strict bar 2.14 2.13)), undef);
1794 is($t->search(qw(-backwards -strict bar 2.13 2.13)), undef);
1795 }
1796
1797 {
1798 my @tf;
1799 $tf[$_] = $t->Frame(qw(-width 20 -height 20 -relief raised -bd 2))
1800 for 1 .. 4;
1801
1802 $t->windowCreate("2.10", -window => $tf[3]);
1803 $t->windowCreate("2.8", -window => $tf[2]);
1804 $t->windowCreate("2.8", -window => $tf[1]);
1805 $t->windowCreate("2.1", -window => $tf[4]);
1806
1807 my $x;
1808 is($t->search(-count => \$x, 'forward', '1.0'), "2.6",
1809 q{TextSearchCmd procedure, embedded windows and index/count});
1810 is($x, 10);
1811 is($t->search(-count => \$x, 'wa', '1.0'), "2.11");
1812 is($x, 2);
1813
1814 $t->delete("2.1");
1815 $t->delete("2.8", "2.10");
1816 $t->delete("2.10");
1817 }
1818
1819 {
1820 my $a = {};
1821 eval { $t->search(-count => \$a, qw(xyz 1.0)) };
1822 is($@, "");
1823 }
1824
1825 {
1826 is($t->search(-backwards => 'xyz', '1.1'), "3.5",
1827 q{TextSearchCmd procedure, wrap-around});
1828 is($t->search(qw(-backwards xyz 1.1 1.0)), undef);
1829 is($t->search(qw(xyz 3.6)), '1.1');
1830 is($t->search(qw(xyz 3.6 end)), undef);
1831 }
1832
1833 {
1834 is($t->search(qw(non_existent 3.5)), undef,
1835 q{TextSearchCmd procedure, no match});
1836 is($t->search(qw(-regexp non_existent 3.5)), undef);
1837 }
1838
1839 {
1840 is($t->search(qw(-back x 1.1)), '1.0',
1841 q{TextSearchCmd procedure, special cases});
1842 is($t->search(qw(-back x 1.0)), '3.8');
1843 is($t->search("\n", "end-2c"), '3.9');
1844 is($t->search("\n", "end"), '1.15');
1845 is($t->search(qw(x 1.0)), '1.0');
1846 }
1847
1848 {
1849 # This test doesn't return a result, but it will generate
1850 # a core leak if the pattern copy isn't properly freed.
1851 # (actually in Tk 8.5 objectification means there is no
1852 # longer a copy of the pattern, but we leave this test in
1853 # anyway).
1854
1855 my $p = "abcdefg1234567890";
1856 $p = "$p$p$p$p$p$p$p$p";
1857 $p = "$p$p$p$p$p";
1858 $t->search('-nocase', $p, '1.0');
1859 pass(q{TextSearchCmd, freeing copy of pattern});
1860 }
1861
1862 {
1863 $t->delete(qw(1.0 end));
1864 $t->insert(end => "foo\x{30c9}\x{30ca}bar");
1865 is($t->search("\x{30c9}\x{30ca}", "1.0"), "1.3",
1866 q{TextSearchCmd, unicode});
1867
1868 $t->delete(qw(1.0 end));
1869 $t->insert(end => "foo\x{30c9}\x{30ca}bar");
1870 my $n;
1871 is($t->search(-count => \$n, "\x{30c9}\x{30ca}", "1.0"), "1.3");
1872 is($n, 2);
1873 }
1874
1875 {
1876 $t->delete(qw(1.0 end));
1877 my $b1 = $mw->Button(-text => "baz");
1878 $t->insert(end => "foo\x{30c9}");
1879 $t->windowCreate(end => -window => $b1);
1880 $t->insert(end => "\x{30ca}bar");
1881 my $n;
1882 is($t->search(-count => \$n, "\x{30c9}\x{30ca}", "1.0"), "1.3",
1883 q{TextSearchCmd, unicode with non-text segments});
1884 is($n, 3);
1885 $b1->destroy;
1886 }
1887
1888 {
1889 deleteWindows;
1890 my $t2 = $mw->Text->pack;
1891 $t2->insert(end => "12345H7890");
1892 is($t2->search(qw(7 1.0)), "1.6",
1893 q{TextSearchCmd, hidden text does not affect match index});
1894 }
1895
1896 {
1897 deleteWindows;
1898 my $t2 = $mw->Text->pack;
1899 $t2->insert(end => "12345H7890");
1900 $t2->tagConfigure(hidden => -elide => "true");
1901 $t2->tagAdd(hidden => "1.5");
1902 is($t2->search(7, "1.0"), "1.6",
1903 q{TextSearchCmd, hidden text does not affect match index});
1904 }
1905
1906 {
1907 deleteWindows;
1908 my $t2 = $mw->Text->pack;
1909 $t2->insert(end => "foobar\nbarbaz\nbazboo");
1910 is($t2->search(boo => "1.0"), "3.3");
1911 }
1912
1913 {
1914 deleteWindows;
1915 my $t2 = $mw->Text->pack;
1916 $t2->insert(end => "foobar\nbarbaz\nbazboo");
1917 $t2->tagConfigure(hidden => -elide => "true");
1918 $t2->tagAdd(hidden => "2.0", "3.0");
1919 is($t2->search(boo => "1.0"), "3.3");
1920 }
1921
1922 {
1923 $t->destroy if Tk::Exists($t);
1924 $t = $mw->Text->pack;
1925 $t->insert(end => "word1", "word2");
1926 # the original regexp was {\mword.}
1927 is($t->search(-nocase => -regexp => qr{\bword.}, "1.0", "end"), "1.0",
1928 q{TextSearchCmd, -regexp -nocase searches});
1929 $t->destroy;
1930 }
1931
1932 {
1933 $t->destroy if Tk::Exists($t);
1934 $t = $mw->Text->pack;
1935 $t->insert(end => "word1", "word2");
1936 # the original regexp was {word.\M}
1937 is($t->search(-nocase => -regexp => qr{word.\b}, "1.0", "end"), "1.0",
1938 q{TextSearchCmd, -regexp -nocase searches});
1939 $t->destroy;
1940 }
1941
1942 {
1943 $t->destroy if Tk::Exists($t);
1944 $t = $mw->Text->pack;
1945 $t->insert(end => "word1 word2");
1946 is($t->search(-nocase => -regexp => qr{word.\W}, "1.0", "end"), "1.0",
1947 q{TextSearchCmd, -regexp -nocase searches});
1948 $t->destroy;
1949 }
1950
1951 {
1952 deleteWindows;
1953 my $t2 = $mw->Text->pack;
1954 $t2->insert("end", "foobar\nfoobar\nfoobar");
1955 is($t2->search(qw(bar 1.3)), "1.3",
1956 q{TextSearchCmd, hidden text and start index});
1957 }
1958
1959 SKIP: {
1960 skip("Seems to be buggy in Tk 8.4 and earlier", 1)
1961 if $Tk::VERSION < 805;
1962
1963 deleteWindows;
1964 my $t2 = $mw->Text->pack;
1965 $t2->insert("end", "foobar\nfoobar\nfoobar");
1966 $t2->tag(qw(configure hidden -elide true));
1967 $t2->tag(qw(add hidden 1.0 1.2));
1968 is($t2->search(qw(bar 1.3)), "1.3",
1969 q{TextSearchCmd, hidden text shouldn't influence start index});
1970 }
1971
1972 SKIP: {
1973 skip("Seems to be buggy in Tk 8.4 and earlier", 2)
1974 if $Tk::VERSION < 805;
1975
1976 deleteWindows;
1977 my $t2 = $mw->Text->pack;
1978 $t2->insert("end", "foobar\nfoobar\nfoobar");
1979 $t2->tag(qw(configure hidden -elide true));
1980 $t2->tag(qw(add hidden 1.2 1.4));
1981 my $foo;
1982 is($t2->search(-count => \$foo, qw(foar 1.3)), "1.0",
1983 q{TextSearchCmd, hidden text inside match must count in length});
1984 is($foo, 6);
1985 }
1986
1987 SKIP: {
1988 skip("-strict is NYI implemented", 3)
1989 if $Tk::VERSION < 805;
1990
1991 deleteWindows;
1992 my $t2 = $mw->Text->pack;
1993 $t2->insert("end", "foobar\nfoobar\nfoobar");
1994 $t2->tag(qw(configure hidden -elide true));
1995 $t2->tag(qw(add hidden 1.2 1.4));
1996 my $foo;
1997 is($t2->search(-strict => -count => \$foo, qw(foar 1.3)), undef);
1998 is($t2->search(-strict => -count => \$foo, qw(foar 2.3)), "1.0");
1999 is($foo, 6);
2000 }
2001
2002 {
2003 deleteWindows;
2004 my $t2 = $mw->Text->pack;
2005 $t2->insert("end", "foobar\nfoobar\nfoobar");
2006 is($t2->search(-regexp => bar => "1.3"), "1.3",
2007 q{TextSearchCmd, hidden text and start index});
2008 }
2009
2010 SKIP: {
2011 skip("Seems to be buggy in Tk 8.4 and earlier", 1)
2012 if $Tk::VERSION < 805;
2013
2014 deleteWindows;
2015 my $t2 = $mw->Text->pack;
2016 $t2->insert("end", "foobar\nfoobar\nfoobar");
2017 $t2->tag(qw(configure hidden -elide true));
2018 $t2->tag(qw(add hidden 1.0 1.2));
2019 is($t2->search(-regexp => bar => "1.3"), "1.3",
2020 q{TextSearchCmd, hidden text shouldn't influence start index});
2021 }
2022
2023 SKIP: {
2024 skip("Seems to be buggy in Tk 8.4 and earlier", 2)
2025 if $Tk::VERSION < 805;
2026
2027 deleteWindows;
2028 my $t2 = $mw->Text->pack;
2029 $t2->insert("end", "foobar\nfoobar\nfoobar");
2030 $t2->tag(qw(configure hidden -elide true));
2031 $t2->tag(qw(add hidden 1.2 1.4));
2032 my $foo;
2033 is($t2->search(-regexp => -count => \$foo, foar => "1.3"), "1.0",
2034 q{TextSearchCmd, hidden text inside match must count in length});
2035 is($foo, 6);
2036 }
2037
2038 SKIP: {
2039 skip("Seems to be buggy in Tk 8.4 and earlier", 2)
2040 if $Tk::VERSION < 805;
2041
2042 deleteWindows;
2043 my $t2 = $mw->Text->pack;
2044 $t2->insert("end", "foobar\nfoobar\nfoobar");
2045 $t2->tag(qw(configure hidden -elide true));
2046 $t2->tag(qw(add hidden 1.2 1.4));
2047 my $foo;
2048 is($t2->search(-count => \$foo, foar => "1.3"), "1.0");
2049 is($foo, 6);
2050 }
2051
2052 SKIP: {
2053 skip("-strict NYI implemented", 1)
2054 if $Tk::VERSION < 805;
2055
2056 deleteWindows;
2057 my $t2 = $mw->Text->pack;
2058 $t2->insert("end", "foobar\nfoobar\nfoobar");
2059 $t2->tag(qw(configure hidden -elide true));
2060 $t2->tag(qw(add hidden 1.2 1.4));
2061 my $foo;
2062 is($t2->search(-strict => -count => \$foo, foar => "1.3"), undef);
2063 }
2064
2065 SKIP: {
2066 skip("-all NYI implemented", 1)
2067 if $Tk::VERSION < 805;
2068
2069 deleteWindows;
2070 my $t2 = $mw->Text->pack;
2071 $t2->insert("end", "foobar\nfoobar\nfoobar");
2072 $t2->tag(qw(configure hidden -elide true));
2073 $t2->tag(qw(add hidden 1.2 1.4));
2074 $t2->tag(qw(add hidden 2.2 2.4));
2075 my $foo;
2076 is_deeply([$t2->search(-regexp => -all => -count => \$foo, foar => "1.3")],
2077 [qw(2.0 3.0 1.0)]);
2078 is_deeply($foo, [qw(6 4 6)]);
2079 }
2080
2081 SKIP: {
2082 skip("-all NYI implemented", 1)
2083 if $Tk::VERSION < 805;
2084
2085 deleteWindows;
2086 my $t2 = $mw->Text->pack;
2087 $t2->insert("end", "foobar\nfoobar\nfoobar");
2088 $t2->tag(qw(configure hidden -elide true));
2089 $t2->tag(qw(add hidden 1.2 1.4));
2090 $t2->tag(qw(add hidden 2.2 2.4));
2091 my $foo;
2092 is_deeply([$t2->search(-all => -count => \$foo, foar => "1.3")],
2093 [qw(2.0 3.0 1.0)]);
2094 is_deeply($foo, [qw(6 4 6)]);
2095 }
2096
2097 SKIP: {
2098 skip("-strict and -all NYI implemented", 1)
2099 if $Tk::VERSION < 805;
2100
2101 deleteWindows;
2102 my $t2 = $mw->Text->pack;
2103 $t2->insert("end", "foobar\nfoobar\nfoobar");
2104 $t2->tag(qw(configure hidden -elide true));
2105 $t2->tag(qw(add hidden 1.2 1.4));
2106 $t2->tag(qw(add hidden 2.2 2.4));
2107 my $foo;
2108 is_deeply([$t2->search(-strict => -all => -count => \$foo, foar => "1.3")],
2109 [qw(2.0 3.0)]);
2110 is_deeply($foo, [qw(6 4)]);
2111 }
2112
2113 __END__
2114
2115 test text-20.78.6 {TextSearchCmd, single line with -all} {
2116 deleteWindows
2117 pack [text .t2]
2118 .t2 insert end " X\n X\n X\n X\n X\n X\n"
2119 .t2 search -all -regexp { +| *\n} 1.0 end
2120 } {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}
2121 test text-20.79 {TextSearchCmd, multiline matching} {
2122 deleteWindows
2123 pack [text .t2]
2124 .t2 insert end "foobar\nfoobar\nfoobar"
2125 list [.t2 search -count foo foobar\nfoo 1.0] $foo
2126 } {1.0 10}
2127 test text-20.80 {TextSearchCmd, multiline matching} {
2128 deleteWindows
2129 pack [text .t2]
2130 .t2 insert end "foobar\nfoobar\nfoobar"
2131 list [.t2 search -count foo bar\nfoo 1.0] $foo
2132 } {1.3 7}
2133 test text-20.81 {TextSearchCmd, multiline matching} {
2134 deleteWindows
2135 pack [text .t2]
2136 .t2 insert end "foobar\nfoobar\nfoobar"
2137 list [.t2 search -count foo \nfoo 1.0] $foo
2138 } {1.6 4}
2139 test text-20.82 {TextSearchCmd, multiline matching} {
2140 deleteWindows
2141 pack [text .t2]
2142 .t2 insert end "foobar\nfoobar\nfoobar"
2143 list [.t2 search -count foo bar\nfoobar\nfoo 1.0] $foo
2144 } {1.3 14}
2145 test text-20.83 {TextSearchCmd, multiline matching} {
2146 deleteWindows
2147 pack [text .t2]
2148 .t2 insert end "foobar\nfoobar\nfoobar"
2149 .t2 search -count foo bar\nfoobar\nfoobanearly 1.0
2150 } {}
2151 test text-20.84 {TextSearchCmd, multiline matching} {
2152 deleteWindows
2153 pack [text .t2]
2154 .t2 insert end "foobar\nfoobar\nfoobar"
2155 list [.t2 search -regexp -count foo foobar\nfoo 1.0] $foo
2156 } {1.0 10}
2157 test text-20.85 {TextSearchCmd, multiline matching} {
2158 deleteWindows
2159 pack [text .t2]
2160 .t2 insert end "foobar\nfoobar\nfoobar"
2161 list [.t2 search -regexp -count foo bar\nfoo 1.0] $foo
2162 } {1.3 7}
2163 test text-20.86 {TextSearchCmd, multiline matching} {
2164 deleteWindows
2165 pack [text .t2]
2166 .t2 insert end "foobar\nfoobar\nfoobar"
2167 list [.t2 search -regexp -count foo \nfoo 1.0] $foo
2168 } {1.6 4}
2169 test text-20.87 {TextSearchCmd, multiline matching} {
2170 deleteWindows
2171 pack [text .t2]
2172 .t2 insert end "foobar\nfoobar\nfoobar"
2173 list [.t2 search -regexp -count foo bar\nfoobar\nfoo 1.0] $foo
2174 } {1.3 14}
2175 test text-20.88 {TextSearchCmd, multiline matching} {
2176 deleteWindows
2177 pack [text .t2]
2178 .t2 insert end "foobar\nfoobar\nfoobar"
2179 .t2 search -regexp -count foo bar\nfoobar\nfoobanearly 1.0
2180 } {}
2181 test text-20.89 {TextSearchCmd, multiline matching} {
2182 deleteWindows
2183 pack [text .t2]
2184 .t2 insert end "foobar\nfaoobar\nfoobar"
2185 .t2 search -regexp -count foo bar\nfoo 1.0
2186 } {2.4}
2187 test text-20.90 {TextSearchCmd, multiline matching end of window} {
2188 deleteWindows
2189 pack [text .t2]
2190 .t2 insert end "foobar\nfaoobar\nfoobar"
2191 .t2 search -regexp -count foo bar\nfoobar\n\n 1.0
2192 } {}
2193 test text-20.91 {TextSearchCmd, multiline matching end of window} {
2194 deleteWindows
2195 pack [text .t2]
2196 .t2 search "\n\n" 1.0
2197 } {}
2198 test text-20.92 {TextSearchCmd, multiline matching} {
2199 deleteWindows
2200 pack [text .t2]
2201 .t2 insert end "foobar\nfoobar\nfoobar"
2202 list [.t2 search -backwards -count foo foobar\nfoo end] $foo
2203 } {2.0 10}
2204 test text-20.93 {TextSearchCmd, multiline matching} {
2205 deleteWindows
2206 pack [text .t2]
2207 .t2 insert end "foobar\nfoobar\nfoobar"
2208 list [.t2 search -backwards -count foo bar\nfoo 1.0] $foo
2209 } {2.3 7}
2210 test text-20.94 {TextSearchCmd, multiline matching} {
2211 deleteWindows
2212 pack [text .t2]
2213 .t2 insert end "foobar\nfoobar\nfoobar"
2214 list [.t2 search -backwards -count foo \nfoo 1.0] $foo
2215 } {2.6 4}
2216 test text-20.95 {TextSearchCmd, multiline matching} {
2217 deleteWindows
2218 pack [text .t2]
2219 .t2 insert end "foobar\nfoobar\nfoobar"
2220 list [.t2 search -backwards -count foo bar\nfoobar\nfoo 1.0] $foo
2221 } {1.3 14}
2222 test text-20.96 {TextSearchCmd, multiline matching} {
2223 deleteWindows
2224 pack [text .t2]
2225 .t2 insert end "foobar\nfoobar\nfoobar"
2226 .t2 search -backwards -count foo bar\nfoobar\nfoobanearly 1.0
2227 } {}
2228 test text-20.97 {TextSearchCmd, multiline matching} {
2229 deleteWindows
2230 pack [text .t2]
2231 .t2 insert end "foobar\nfoobar\nfoobar"
2232 list [.t2 search -backwards -regexp -count foo foobar\nfoo end] $foo
2233 } {2.0 10}
2234 test text-20.97.1 {TextSearchCmd, multiline matching} {
2235 deleteWindows
2236 pack [text .t2]
2237 .t2 insert end "foobar\nfoobar\nfoobar"
2238 list [.t2 search -backwards -regexp -count foo foobar\nfo end] $foo
2239 } {2.0 9}
2240 test text-20.98 {TextSearchCmd, multiline matching} {
2241 deleteWindows
2242 pack [text .t2]
2243 .t2 insert end "foobar\nfoobar\nfoobar"
2244 list [.t2 search -backwards -regexp -count foo bar\nfoo 1.0] $foo
2245 } {2.3 7}
2246 test text-20.99 {TextSearchCmd, multiline matching} {
2247 deleteWindows
2248 pack [text .t2]
2249 .t2 insert end "foobar\nfoobar\nfoobar"
2250 list [.t2 search -backwards -regexp -count foo \nfoo 1.0] $foo
2251 } {2.6 4}
2252 test text-20.100 {TextSearchCmd, multiline matching} {
2253 deleteWindows
2254 pack [text .t2]
2255 .t2 insert end "foobar\nfoobar\nfoobar"
2256 list [.t2 search -backwards -regexp -count foo bar\nfoobar\nfoo 1.0] $foo
2257 } {1.3 14}
2258 test text-20.101 {TextSearchCmd, multiline matching} {
2259 deleteWindows
2260 pack [text .t2]
2261 .t2 insert end "foobar\nfoobar\nfoobar"
2262 .t2 search -backwards -regexp -count foo bar\nfoobar\nfoobanearly 1.0
2263 } {}
2264 test text-20.102 {TextSearchCmd, multiline matching} {
2265 deleteWindows
2266 pack [text .t2]
2267 .t2 insert end "foobar\nfaoobar\nfoobar"
2268 .t2 search -backwards -regexp -count foo bar\nfoo 1.0
2269 } {2.4}
2270 test text-20.103 {TextSearchCmd, multiline matching end of window} {
2271 deleteWindows
2272 pack [text .t2]
2273 .t2 insert end "foobar\nfaoobar\nfoobar"
2274 .t2 search -backwards -regexp -count foo bar\nfoobar\n\n 1.0
2275 } {}
2276 test text-20.104 {TextSearchCmd, multiline matching end of window} {
2277 deleteWindows
2278 pack [text .t2]
2279 .t2 search -backwards "\n\n" 1.0
2280 } {}
2281 test text-20.105 {TextSearchCmd, multiline regexp matching} {
2282 deleteWindows
2283 pack [text .t2]
2284 .t2 insert 1.0 { Tcl_Obj *objPtr));
2285 static Tcl_Obj* FSNormalizeAbsolutePath
2286 _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj *pathPtr));}
2287 set markExpr "^(\[A-Za-z0-9~_\]+\[ \t\n\r\]*\\(|(\[^ \t\(#\n\r/@:\*\]\[^=\(\r\n\]*\[ \t\]+\\*?)?"
2288 append markExpr "(\[A-Za-z0-9~_\]+(<\[^>\]*>)?(::)?(\[A-Za-z0-9~_\]+::)*\[-A-Za-z0-9~_+ <>\|\\*/\]+|\[A-Za-z0-9~_\]+)"
2289 append markExpr "\[ \n\t\r\]*\\()"
2290 .t2 search -forwards -regexp $markExpr 1.41 end
2291 } {}
2292 test text-20.106 {TextSearchCmd, multiline regexp matching} {
2293 # Practical example which used to crash Tk, but only after the
2294 # search is complete. This is memory corruption caused by
2295 # a bug in Tcl's handling of string objects.
2296 # (Tcl bug 635200)
2297 deleteWindows
2298 pack [text .t2]
2299 .t2 insert 1.0 {static int SetFsPathFromAny _ANSI_ARGS_((Tcl_Interp *interp,
2300 Tcl_Obj *objPtr));
2301 static Tcl_Obj* FSNormalizeAbsolutePath
2302 _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj *pathPtr));}
2303 set markExpr "^(\[A-Za-z0-9~_\]+\[ \t\n\r\]*\\(|(\[^ \t\(#\n\r/@:\*\]\[^=\(\r\n\]*\[ \t\]+\\*?)?"
2304 append markExpr "(\[A-Za-z0-9~_\]+(<\[^>\]*>)?(::)?(\[A-Za-z0-9~_\]+::)*\[-A-Za-z0-9~_+ <>\|\\*/\]+|\[A-Za-z0-9~_\]+)"
2305 append markExpr "\[ \n\t\r\]*\\()"
2306 .t2 search -forwards -regexp $markExpr 1.41 end
2307 } {}
2308 test text-20.107 {TextSearchCmd, multiline regexp matching} {
2309 deleteWindows
2310 pack [text .t2]
2311 .t2 insert 1.0 {
2312 static int SetFsPathFromAny _ANSI_ARGS_((Tcl_Interp *interp,
2313 Tcl_Obj *objPtr));
2314 static Tcl_Obj* FSNormalizeAbsolutePath
2315 _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj *pathPtr));}
2316 set markExpr "^(\[A-Za-z0-9~_\]+\[ \t\n\r\]*\\(|(\[^ \t\(#\n\r/@:\*\]\[^=\(\r\n\]*\[ \t\]+\\*?)?"
2317 append markExpr "(\[A-Za-z0-9~_\]+(<\[^>\]*>)?(::)?(\[A-Za-z0-9~_\]+::)*\[-A-Za-z0-9~_+ <>\|\\*/\]+|\[A-Za-z0-9~_\]+)"
2318 append markExpr "\[ \n\t\r\]*\\()"
2319 .t2 search -backwards -all -regexp $markExpr end
2320 } {2.0}
2321 test text-20.108 {TextSearchCmd, multiline matching} {
2322 deleteWindows
2323 pack [text .t2]
2324 .t2 insert end "foobar\nfoobar\nfoobar"
2325 .t2 search -all -regexp -count foo bar\nfoo 1.0
2326 } {1.3 2.3}
2327 test text-20.109 {TextSearchCmd, multiline matching} {
2328 deleteWindows
2329 pack [text .t2]
2330 .t2 insert end "foobar\nfoobar\nfoobar"
2331 .t2 search -all -backwards -regexp -count foo bar\nfoo 1.0
2332 } {2.3 1.3}
2333 test text-20.110 {TextSearchCmd, wrapping and limits} {
2334 deleteWindows
2335 pack [text .t2]
2336 .t2 insert end "foobar\nfoobar\nfoobar"
2337 .t2 search -- "blah" 3.3 1.3
2338 } {}
2339 test text-20.111 {TextSearchCmd, wrapping and limits} {
2340 deleteWindows
2341 pack [text .t2]
2342 .t2 insert end "foobar\nfoobar\nfoobar"
2343 .t2 search -backwards -- "blah" 1.3 3.3
2344 } {}
2345 test text-20.112 {TextSearchCmd, wrapping and limits} {
2346 deleteWindows
2347 pack [text .t2]
2348 .t2 insert end "if (stringPtr->uallocated > 0) \{x"
2349 .t2 search -backwards -regexp -- "\[\]\")\}\[(\{\]" "1.32" 1.0
2350 } {1.31}
2351 test text-20.113 {TextSearchCmd, wrapping and limits} {
2352 deleteWindows
2353 pack [text .t2]
2354 .t2 insert end "if (stringPtr->uallocated > 0) \{x"
2355 .t2 search -regexp -- "\[\]\")\}\[(\{\]" 1.30 "1.0 lineend"
2356 } {1.31}
2357 test text-20.114 {TextSearchCmd, wrapping and limits} {
2358 deleteWindows
2359 pack [text .t2]
2360 .t2 insert end "if (stringPtr->uallocated > 0) \{x"
2361 .t2 search -backwards -all -regexp -- "\[\]\")\}\[(\{\]" "1.32" 1.0
2362 } {1.31 1.29 1.3}
2363 test text-20.115 {TextSearchCmd, wrapping and limits} {
2364 deleteWindows
2365 pack [text .t2]
2366 .t2 insert end "if (stringPtr->uallocated > 0) \{x"
2367 .t2 search -all -regexp -- "\[\]\")\}\[(\{\]" 1.0 "1.0 lineend"
2368 } {1.3 1.29 1.31}
2369 test text-20.116 {TextSearchCmd, wrapping and limits} {
2370 deleteWindows
2371 pack [text .t2]
2372 .t2 insert end "if (stringPtr->uallocated > 0) \{x"
2373 .t2 search -backwards -- "\{" "1.32" 1.0
2374 } {1.31}
2375 test text-20.117 {TextSearchCmd, wrapping and limits} {
2376 deleteWindows
2377 pack [text .t2]
2378 .t2 insert end "if (stringPtr->uallocated > 0) \{x"
2379 .t2 search -- "\{" 1.30 "1.0 lineend"
2380 } {1.31}
2381 test text-20.118 {TextSearchCmd, multiline regexp matching} {
2382 deleteWindows
2383 pack [text .t2]
2384 .t2 insert 1.0 {
2385
2386 void
2387 Tcl_SetObjLength(objPtr, length)
2388 register Tcl_Obj *objPtr; /* Pointer to object. This object must
2389 * not currently be shared. */
2390 register int length; /* Number of bytes desired for string
2391 * representation of object, not including
2392 * terminating null byte. */
2393 \{
2394 char *new;
2395 }
2396 set markExpr "^(\[A-Za-z0-9~_\]+\[ \t\n\r\]*\\(|(\[^ \t\(#\n\r/@:\*\]\[^=\(\r\n\]*\[ \t\]+\\*?)?"
2397 append markExpr "(\[A-Za-z0-9~_\]+(<\[^>\]*>)?(::)?(\[A-Za-z0-9~_\]+::)*\[-A-Za-z0-9~_+ <>\|\\*/\]+|\[A-Za-z0-9~_\]+)"
2398 append markExpr "\[ \n\t\r\]*\\()"
2399 .t2 search -all -regexp -- $markExpr 1.0
2400 } {4.0}
2401 test text-20.119 {TextSearchCmd, multiline regexp matching} {
2402 deleteWindows
2403 pack [text .t2]
2404 .t2 insert 1.0 "first line\nlast line of text"
2405 set markExpr {^[a-z]+}
2406 # This should not match, and should not wrap
2407 .t2 search -regexp -- $markExpr end end
2408 } {}
2409 test text-20.120 {TextSearchCmd, multiline regexp matching} {
2410 deleteWindows
2411 pack [text .t2]
2412 .t2 insert 1.0 "first line\nlast line of text"
2413 set markExpr {^[a-z]+}
2414 # This should not match, and should not wrap
2415 .t2 search -regexp -- $markExpr end+10c end
2416 } {}
2417 test text-20.121 {TextSearchCmd, multiline regexp matching} {
2418 deleteWindows
2419 pack [text .t2]
2420 .t2 insert 1.0 "first line\nlast line of text"
2421 set markExpr {^[a-z]+}
2422 # This should not match, and should not wrap
2423 .t2 search -regexp -backwards -- $markExpr 1.0 1.0
2424 } {}
2425 test text-20.122 {TextSearchCmd, regexp linestop} {
2426 deleteWindows
2427 pack [text .t2]
2428 .t2 insert 1.0 "first line\nlast line of text"
2429 .t2 search -regexp -- {i.*x} 1.0
2430 } {2.6}
2431 test text-20.123 {TextSearchCmd, multiline regexp nolinestop matching} {
2432 deleteWindows
2433 pack [text .t2]
2434 .t2 insert 1.0 "first line\nlast line of text"
2435 .t2 search -regexp -nolinestop -- {i.*x} 1.0
2436 } {1.1}
2437 test text-20.124 {TextSearchCmd, regexp linestop} {
2438 deleteWindows
2439 pack [text .t2]
2440 .t2 insert 1.0 "first line\nlast line of text"
2441 .t2 search -regexp -all -overlap -- {i.*x} 1.0
2442 } {2.6}
2443 test text-20.124.1 {TextSearchCmd, regexp linestop} {
2444 deleteWindows
2445 pack [text .t2]
2446 .t2 insert 1.0 "first line\nlast line of text"
2447 .t2 search -regexp -all -- {i.*x} 1.0
2448 } {2.6}
2449 test text-20.125 {TextSearchCmd, multiline regexp nolinestop matching} {
2450 deleteWindows
2451 pack [text .t2]
2452 .t2 insert 1.0 "first line\nlast line of text"
2453 list [.t2 search -regexp -all -overlap -count c -nolinestop -- {i.*x} 1.0] $c
2454 } {{1.1 2.6} {26 10}}
2455 test text-20.125.1 {TextSearchCmd, multiline regexp nolinestop matching} {
2456 deleteWindows
2457 pack [text .t2]
2458 .t2 insert 1.0 "first line\nlast line of text"
2459 list [.t2 search -regexp -all -count c -nolinestop -- {i.*x} 1.0] $c
2460 } {1.1 26}
2461 test text-20.126 {TextSearchCmd, stop at end of line} {
2462 deleteWindows
2463 pack [text .t2]
2464 .t2 insert 1.0 " \t\n last line of text"
2465 .t2 search -regexp -nolinestop -- {[^ \t]} 1.0
2466 } {1.3}
2467 test text-20.127 {TextSearchCmd, overlapping all matches} {
2468 deleteWindows
2469 pack [text .t2]
2470 .t2 insert 1.0 "abcde abcde"
2471 list [.t2 search -regexp -all -overlap -count c -- {\w+} 1.0] $c
2472 } {{1.0 1.6} {5 5}}
2473 test text-20.127.1 {TextSearchCmd, non-overlapping all matches} {
2474 deleteWindows
2475 pack [text .t2]
2476 .t2 insert 1.0 "abcde abcde"
2477 list [.t2 search -regexp -all -count c -- {\w+} 1.0] $c
2478 } {{1.0 1.6} {5 5}}
2479 test text-20.128 {TextSearchCmd, stop at end of line} {
2480 deleteWindows
2481 pack [text .t2]
2482 .t2 insert 1.0 "abcde abcde"
2483 list [.t2 search -backwards -regexp -all -count c -- {\w+} 1.0] $c
2484 } {{1.6 1.0} {5 5}}
2485 test text-20.129 {TextSearchCmd, backwards search stop index } {
2486 deleteWindows
2487 pack [text .t2]
2488 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2489 list [.t2 search -backwards -regexp -count c -- {Z\w+} 1.21 1.5] $c
2490 } {1.8 8}
2491 test text-20.130 {TextSearchCmd, backwards search stop index } {
2492 deleteWindows
2493 pack [text .t2]
2494 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2495 list [.t2 search -backwards -all -overlap -regexp -count c -- {Z\w+} 1.21 1.5] $c
2496 } {1.8 8}
2497 test text-20.130.1 {TextSearchCmd, backwards search stop index } {
2498 deleteWindows
2499 pack [text .t2]
2500 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2501 list [.t2 search -backwards -all -regexp -count c -- {Z\w+} 1.21 1.5] $c
2502 } {1.8 8}
2503 test text-20.131 {TextSearchCmd, backwards search stop index } {
2504 deleteWindows
2505 pack [text .t2]
2506 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2507 list [.t2 search -backwards -overlap -all -regexp -count c -- {Z\w+} 1.21 1.1] $c
2508 } {1.4 12}
2509 test text-20.131.1 {TextSearchCmd, backwards search stop index } {
2510 deleteWindows
2511 pack [text .t2]
2512 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2513 list [.t2 search -backwards -overlap -all -regexp -count c -- {Z[^Z]+Z} 1.21 1.1] $c
2514 } {{1.8 1.4} {5 5}}
2515 test text-20.131.2 {TextSearchCmd, backwards search stop index } {
2516 deleteWindows
2517 pack [text .t2]
2518 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2519 list [.t2 search -backwards -all -regexp -count c -- {Z\w+} 1.21 1.1] $c
2520 } {1.4 12}
2521 test text-20.132 {TextSearchCmd, backwards search stop index } {
2522 deleteWindows
2523 pack [text .t2]
2524 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2525 .t2 insert 1.0 "bla ZabcZdefZghi and some text again\n"
2526 list [.t2 search -backwards -all -overlap -regexp -count c -- {Z\w+} 2.21 1.5] $c
2527 } {{2.4 1.8} {12 8}}
2528 test text-20.132.1 {TextSearchCmd, backwards search stop index } {
2529 deleteWindows
2530 pack [text .t2]
2531 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2532 .t2 insert 1.0 "bla ZabcZdefZghi and some text again\n"
2533 list [.t2 search -backwards -all -regexp -count c -- {Z\w+} 2.21 1.5] $c
2534 } {{2.4 1.8} {12 8}}
2535 test text-20.133 {TextSearchCmd, backwards search stop index } {
2536 deleteWindows
2537 pack [text .t2]
2538 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2539 .t2 insert 1.0 "bla ZabcZdefZghi and some text again\n"
2540 list [.t2 search -backwards -overlap -all -regexp -count c -- {Z\w+} 2.21 1.1] $c
2541 } {{2.4 1.4} {12 12}}
2542 test text-20.133.1 {TextSearchCmd, backwards search stop index } {
2543 deleteWindows
2544 pack [text .t2]
2545 .t2 insert 1.0 "bla ZabcZdefZghi and some text again"
2546 .t2 insert 1.0 "bla ZabcZdefZghi and some text again\n"
2547 list [.t2 search -backwards -all -regexp -count c -- {Z\w+} 2.21 1.1] $c
2548 } {{2.4 1.4} {12 12}}
2549 test text-20.134 {TextSearchCmd, search -all example} {
2550 deleteWindows
2551 pack [text .t2]
2552 .t2 insert 1.0 {
2553
2554 See the package: supersearch for more information.
2555
2556
2557 See the package: incrementalSearch for more information.
2558
2559 package: Brws .
2560
2561
2562 See the package: marks for more information.
2563
2564 }
2565 set pat {package: ([a-zA-Z0-9][-a-zA-Z0-9._+#/]*)}
2566 list [.t2 search -nolinestop -regexp -nocase -all -forwards \
2567 -count c -- $pat 1.0 end] $c
2568 } {{3.8 6.8 8.0 11.8} {20 26 13 14}}
2569 test text-20.135 {TextSearchCmd, backwards search overlaps} {
2570 deleteWindows
2571 pack [text .t2]
2572 .t2 insert 1.0 "foobarfoobaaaaaaaaaaarfoo"
2573 .t2 search -backwards -regexp {fooba+rfoo} end
2574 } {1.6}
2575 test text-20.135.1 {TextSearchCmd, backwards search overlaps} {
2576 deleteWindows
2577 pack [text .t2]
2578 .t2 insert 1.0 "foobarfoobaaaaaaaaaaarfoo"
2579 .t2 search -backwards -overlap -all -regexp {fooba+rfoo} end
2580 } {1.6 1.0}
2581 test text-20.135.2 {TextSearchCmd, backwards search overlaps} {
2582 deleteWindows
2583 pack [text .t2]
2584 .t2 insert 1.0 "foobarfoobaaaaaaaaaaarfoo"
2585 .t2 search -backwards -all -regexp {fooba+rfoo} end
2586 } {1.6}
2587 test text-20.135.3 {TextSearchCmd, forwards search overlaps} {
2588 deleteWindows
2589 pack [text .t2]
2590 .t2 insert 1.0 "foobarfoobaaaaaaaaaaarfoo"
2591 .t2 search -all -overlap -regexp {fooba+rfoo} end
2592 } {1.0 1.6}
2593 test text-20.135.4 {TextSearchCmd, forwards search overlaps} {
2594 deleteWindows
2595 pack [text .t2]
2596 .t2 insert 1.0 "foobarfoobaaaaaaaaaaarfoo"
2597 .t2 search -all -regexp {fooba+rfoo} end
2598 } {1.0}
2599 test text-20.136 {TextSearchCmd, forward exact search overlaps} {
2600 deleteWindows
2601 pack [text .t2]
2602 .t2 insert 1.0 "abababab"
2603 .t2 search -exact -overlap -all {abab} 1.0
2604 } {1.0 1.2 1.4}
2605 test text-20.136.1 {TextSearchCmd, forward exact search overlaps} {
2606 deleteWindows
2607 pack [text .t2]
2608 .t2 insert 1.0 "abababab"
2609 .t2 search -exact -all {abab} 1.0
2610 } {1.0 1.4}
2611 test text-20.137 {TextSearchCmd, backward exact search overlaps} {
2612 deleteWindows
2613 pack [text .t2]
2614 .t2 insert 1.0 "ababababab"
2615 .t2 search -exact -overlap -backwards -all {abab} end
2616 } {1.6 1.4 1.2 1.0}
2617 test text-20.137.1 {TextSearchCmd, backward exact search overlaps} {
2618 deleteWindows
2619 pack [text .t2]
2620 .t2 insert 1.0 "ababababab"
2621 .t2 search -exact -backwards -all {abab} end
2622 } {1.6 1.2}
2623 test text-20.137.2 {TextSearchCmd, backward exact search overlaps} {
2624 deleteWindows
2625 pack [text .t2]
2626 .t2 insert 1.0 "abababababab"
2627 .t2 search -exact -backwards -all {abab} end
2628 } {1.8 1.4 1.0}
2629 test text-20.138 {TextSearchCmd, forward exact search overlaps} {
2630 deleteWindows
2631 pack [text .t2]
2632 .t2 insert 1.0 "foo\nbar\nfoo\nbar\nfoo\nbar\nfoo\n"
2633 .t2 search -exact -overlap -all "foo\nbar\nfoo" 1.0
2634 } {1.0 3.0 5.0}
2635 test text-20.138.1 {TextSearchCmd, forward exact search no-overlaps} {
2636 deleteWindows
2637 pack [text .t2]
2638 .t2 insert 1.0 "foo\nbar\nfoo\nbar\nfoo\nbar\nfoo\n"
2639 .t2 search -exact -all "foo\nbar\nfoo" 1.0
2640 } {1.0 5.0}
2641 test text-20.139 {TextSearchCmd, backward exact search overlaps} {
2642 deleteWindows
2643 pack [text .t2]
2644 .t2 insert 1.0 "foo\nbar\nfoo\nbar\nfoo\nbar\nfoo\n"
2645 .t2 search -exact -overlap -backward -all "foo\nbar\nfoo" end
2646 } {5.0 3.0 1.0}
2647 test text-20.140 {TextSearchCmd, backward exact search no-overlaps} {
2648 deleteWindows
2649 pack [text .t2]
2650 .t2 insert 1.0 "foo\nbar\nfoo\nbar\nfoo\nbar\nfoo\n"
2651 .t2 search -exact -backward -all "foo\nbar\nfoo" end
2652 } {5.0 1.0}
2653 test text-20.141 {TextSearchCmd, backward exact search overlaps} {
2654 deleteWindows
2655 pack [text .t2]
2656 .t2 insert 1.0 "foo\nbar\nfoo\nbar\nfoo\nbar\nfoo\n"
2657 .t2 search -regexp -backward -overlap -all "foo\nbar\nfoo" end
2658 } {5.0 3.0 1.0}
2659 test text-20.142 {TextSearchCmd, backward regexp search no-overlaps} {
2660 deleteWindows
2661 pack [text .t2]
2662 .t2 insert 1.0 "foo\nbar\nfoo\nbar\nfoo\nbar\nfoo\n"
2663 .t2 search -regexp -backward -all "foo\nbar\nfoo" end
2664 } {5.0 1.0}
2665 test text-20.142a {TextSearchCmd, backward regexp search no-overlaps} {
2666 deleteWindows
2667 pack [text .t2]
2668 .t2 insert 1.0 " aasda asdj werwer"
2669 .t2 search -regexp -backward -- {(\$)?[\w:_]+} 1.9
2670 } {1.7}
2671 test text-20.143 {TextSearchCmd, backward regexp search no-overlaps} {
2672 deleteWindows
2673 pack [text .t2]
2674 .t2 insert 1.0 " aasda asdj werwer"
2675 .t2 search -regexp -backward -- {(\$)?[\w:_]+} 1.9 1.5
2676 } {1.7}
2677 test text-20.144 {TextSearchCmd, backward regexp search no-overlaps} {
2678 deleteWindows
2679 pack [text .t2]
2680 .t2 insert 1.0 " aasda asdj werwer"
2681 .t2 search -regexp -backward -- {(\$)?[\w:_]+} 1.9 1.7
2682 } {1.7}
2683 test text-20.145 {TextSearchCmd, backward regexp search no-overlaps} {
2684 deleteWindows
2685 pack [text .t2]
2686 .t2 insert 1.0 " aasda asdj werwer"
2687 .t2 search -regexp -backward -- {(\$)?[\w:_]+} 1.9 1.8
2688 } {1.8}
2689 test text-20.146 {TextSearchCmd, backward regexp search no-overlaps} {
2690 deleteWindows
2691 pack [text .t2]
2692 .t2 insert 1.0 " aasda asdj werwer"
2693 .t2 search -regexp -backward -all -- {(\$)?[\w:_]+} 1.9 1.3
2694 } {1.7 1.3}
2695 test text-20.147 {TextSearchCmd, backward regexp search no-overlaps} {
2696 deleteWindows
2697 pack [text .t2]
2698 .t2 insert 1.0 " aasda asdj werwer"
2699 .t2 search -regexp -backward -all -- {(\$)?[\w:_]+} 1.9 1.13
2700 } {}
2701 test text-20.148 {TextSearchCmd, backward regexp search no-overlaps} {
2702 deleteWindows
2703 pack [text .t2]
2704 .t2 insert 1.0 " aasda asdj werwer"
2705 .t2 search -regexp -backward -all -- {(\$)?[\w:_]+} 2.0 1.3
2706 } {1.12 1.7 1.3}
2707 test text-20.149 {TextSearchCmd, backward regexp search no-overlaps} {
2708 deleteWindows
2709 pack [text .t2]
2710 .t2 insert 1.0 " aasda asdj werwer"
2711 .t2 search -regexp -backward -all -- {(\$)?[\w:_]+} 1.3
2712 } {1.1 1.12 1.7 1.3}
2713 test text-20.150 {TextSearchCmd, backward regexp search no-overlaps} {
2714 deleteWindows
2715 pack [text .t2]
2716 .t2 insert 1.0 "abcde\nabcde\nabcde\n"
2717 .t2 search -regexp -backward -all -- {(\w+\n)+} end
2718 } {1.0}
2719 test text-20.151 {TextSearchCmd, backward regexp search no-overlaps} {
2720 deleteWindows
2721 pack [text .t2]
2722 .t2 insert 1.0 "abcde\nabcde\nabcde\n"
2723 .t2 search -regexp -backward -all -- {(\w+\n)+} end 1.5
2724 } {2.0}
2725 test text-20.152 {TextSearchCmd, backward regexp search no-overlaps} {
2726 deleteWindows
2727 pack [text .t2]
2728 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2729 .t2 search -regexp -backward -all -- {(\w+\n\w)+} end 1.5
2730 } {2.0}
2731 test text-20.153 {TextSearchCmd, backward regexp search no-overlaps} {
2732 deleteWindows
2733 pack [text .t2]
2734 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2735 list [.t2 search -regexp -all -count foo -- {(\w+\n)+} 1.0] $foo
2736 } {1.0 20}
2737 test text-20.154 {TextSearchCmd, backward regexp search no-overlaps} {
2738 deleteWindows
2739 pack [text .t2]
2740 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2741 set res {}
2742 lappend res \
2743 [list [.t2 search -regexp -all -count foo -- {(\w+\n)+} 1.0] $foo] \
2744 [list [.t2 search -regexp -all -count foo -- {(\w+)+} 1.0] $foo]
2745 } {{1.0 20} {{1.0 2.0 3.0 4.0} {5 5 5 1}}}
2746 test text-20.155 {TextSearchCmd, regexp search greedy} {
2747 deleteWindows
2748 pack [text .t2]
2749 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2750 list [.t2 search -regexp -all -nolinestop -count foo -- {.*} 1.0] $foo
2751 } {1.0 20}
2752 test text-20.156 {TextSearchCmd, regexp search greedy} {
2753 deleteWindows
2754 pack [text .t2]
2755 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2756 list [.t2 search -regexp -all -count foo -- {.*} 1.0] $foo
2757 } {{1.0 2.0 3.0 4.0} {5 5 5 1}}
2758 test text-20.157 {TextSearchCmd, regexp search greedy multi-line} {
2759 deleteWindows
2760 pack [text .t2]
2761 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2762 list [.t2 search -regexp -count foo -- {(\w+\n\w)+} 1.0] $foo
2763 } {1.0 19}
2764 test text-20.158 {TextSearchCmd, regexp search greedy multi-line} {
2765 deleteWindows
2766 pack [text .t2]
2767 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2768 list [.t2 search -regexp -backwards -count foo -- {(\w+\n\w)+} end] $foo
2769 } {1.0 19}
2770 test text-20.159 {TextSearchCmd, regexp search greedy multi-line} {
2771 deleteWindows
2772 pack [text .t2]
2773 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2774 list [.t2 search -regexp -all -backwards -count foo -- {(\w+\n\w)+} end] $foo
2775 } {1.0 19}
2776 test text-20.160 {TextSearchCmd, backward regexp search no-overlaps} {
2777 deleteWindows
2778 pack [text .t2]
2779 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2780 .t2 search -regexp -backward -all -- {(\w+\n\w)+} end 1.5
2781 } {2.0}
2782 test text-20.161 {TextSearchCmd, backward regexp search no-overlaps} {
2783 deleteWindows
2784 pack [text .t2]
2785 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2786 .t2 search -regexp -backward -all -- {(\w+\n\w)+} end 1.3
2787 } {1.3}
2788 test text-20.162 {TextSearchCmd, backward regexp search no-overlaps} {
2789 deleteWindows
2790 pack [text .t2]
2791 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2792 list [.t2 search -regexp -forward -count foo -- {(\w+\n\w)+} 1.3] $foo
2793 } {1.3 16}
2794 test text-20.163 {TextSearchCmd, backward regexp search no-overlaps} {
2795 deleteWindows
2796 pack [text .t2]
2797 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2798 list [.t2 search -regexp -forward -all -count foo -- {(\w+\n\w)+} 1.3] $foo
2799 # This result is somewhat debatable -- the two results do overlap,
2800 # but only because the search has totally wrapped around back to
2801 # the start.
2802 } {{1.3 1.0} {16 19}}
2803 test text-20.164 {TextSearchCmd, backward regexp search no-overlaps} {
2804 deleteWindows
2805 pack [text .t2]
2806 .t2 insert 1.0 "abcde\nabcde\nabcde\na"
2807 list [.t2 search -regexp -forward -all -count foo -- {(\w+\n\w)+} 1.0 1.3] $foo
2808 } {1.0 19}
2809 test text-20.165 {TextSearchCmd, regexp search multi-line} {
2810 deleteWindows
2811 pack [text .t2]
2812 .t2 insert 1.0 "aaaa\nbbbb\naaaa\nbbbb\n"
2813 list [.t2 search -regexp -forward -all -count foo -- {(a+\n(b+\n))+} 1.0] $foo
2814 } {1.0 20}
2815 test text-20.166 {TextSearchCmd, regexp search complex cases} {
2816 deleteWindows
2817 pack [text .t2]
2818 .t2 insert 1.0 "aaaa\nbbbb\naaaa\nbbbb\n"
2819 list [.t2 search -regexp -forward -all -count foo \
2820 -- {(a+\n(b+\n))+} 1.0] $foo
2821 } {1.0 20}
2822 test text-20.167 {TextSearchCmd, regexp search multi-line} {
2823 deleteWindows
2824 pack [text .t2]
2825 .t2 insert 1.0 "aaaa\nbbbb\ncccc\nbbbb\naaaa\n"
2826 set foo {}
2827 list [.t2 search -regexp -forward -all -count foo \
2828 -- {(b+\nc+\nb+)\na+} 1.0] $foo
2829 } {2.0 19}
2830 test text-20.168 {TextSearchCmd, regexp search multi-line} {knownBug} {
2831 deleteWindows
2832 pack [text .t2]
2833 .t2 insert 1.0 "aaaa\nbbbb\ncccc\nbbbb\naaaa\n"
2834 set foo {}
2835 list [.t2 search -regexp -forward -all -count foo \
2836 -- {(a+|b+\nc+\nb+)\na+} 1.0] $foo
2837 } {2.0 19}
2838 test text-20.169 {TextSearchCmd, regexp search multi-line} {knownBug} {
2839 deleteWindows
2840 pack [text .t2]
2841 .t2 insert 1.0 "aaaa\nbbbb\ncccc\nbbbb\naaaa\n"
2842 set foo {}
2843 list [.t2 search -regexp -forward -all -count foo \
2844 -- {(a+|b+\nc+\nb+)+\na+} 1.0] $foo
2845 } {2.0 19}
2846 test text-20.170 {TextSearchCmd, regexp search multi-line} {
2847 deleteWindows
2848 pack [text .t2]
2849 .t2 insert 1.0 "aaaa\nbbbb\ncccc\nbbbb\naaaa\n"
2850 set foo {}
2851 list [.t2 search -regexp -forward -all -count foo \
2852 -- {((a+|b+\nc+\nb+)+\n)+a+} 1.0] $foo
2853 } {1.0 24}
2854 test text-20.171 {TextSearchCmd, regexp search multi-line} {knownBug} {
2855 deleteWindows
2856 pack [text .t2]
2857 .t2 insert 1.0 "aaaa\nbbbb\nbbbb\nbbbb\nbbbb\n"
2858 list [.t2 search -regexp -backward -all -count foo \
2859 -- {b+\n|a+\n(b+\n)+} end] $foo
2860 } {1.0 25}
2861 test text-20.172 {TextSearchCmd, regexp search multi-line} {knownBug} {
2862 deleteWindows
2863 pack [text .t2]
2864 .t2 insert 1.0 "aaaa\nbbbb\nbbbb\nbbbb\nbbbb\n"
2865 .t2 search -regexp -backward -- {b+\n|a+\n(b+\n)+} end
2866 # Should match at 1.0 for a true greedy match
2867 } {1.0}
2868 test text-20.172.1 {TextSearchCmd, regexp search multi-line} {
2869 deleteWindows
2870 pack [text .t2]
2871 .t2 insert 1.0 "line0\nline1\nline1\nline1\nline1\nline2\nline2\nline2\nline3\n"
2872 .t2 search -nolinestop -regexp -nocase -forwards -- {^(.*)\n(\1\n)+} 1.0 end
2873 # Matches at 6.0 currently
2874 } {2.0}
2875 test text-20.173 {TextSearchCmd, regexp search multi-line} {
2876 deleteWindows
2877 pack [text .t2]
2878 .t2 insert 1.0 "\naaaxxx\nyyy\n"
2879 set res {}
2880 lappend res [.t2 search -count c -regexp -- {x*\ny*} 2.0] $c
2881 lappend res [.t2 search -count c -regexp -- {x*\ny*} 2.1] $c
2882 set res
2883 } {2.3 7 2.3 7}
2884 test text-20.174 {TextSearchCmd, regexp search multi-line} {
2885 deleteWindows
2886 pack [text .t2]
2887 .t2 insert 1.0 "\naaa\n\n\n\n\nxxx\n"
2888 set res {}
2889 lappend res [.t2 search -count c -regexp -- {\n+} 2.0] $c
2890 lappend res [.t2 search -count c -regexp -- {\n+} 2.1] $c
2891 set res
2892 } {2.3 5 2.3 5}
2893 test text-20.175 {TextSearchCmd, regexp search multi-line} {
2894 deleteWindows
2895 pack [text .t2]
2896 .t2 insert 1.0 "\naaa\n\n\t \n\t\t\t \n\nxxx\n"
2897 set res {}
2898 lappend res [.t2 search -count c -regexp -- {(\n+(\t+ *)*)+} 2.0] $c
2899 set res
2900 } {2.3 13}
2901 test text-20.176 {TextSearchCmd, empty search range} {
2902 deleteWindows
2903 pack [text .t2]
2904 .t2 insert 1.0 "a\na\na\n"
2905 .t2 search -- a 2.0 1.0
2906 } {}
2907 test text-20.177 {TextSearchCmd, empty search range} {
2908 deleteWindows
2909 pack [text .t2]
2910 .t2 insert 1.0 "a\na\na\n"
2911 .t2 search -backwards -- a 1.0 2.0
2912 } {}
2913 test text-20.178 {TextSearchCmd, empty search range} {
2914 deleteWindows
2915 pack [text .t2]
2916 .t2 insert 1.0 "a\na\na\n"
2917 .t2 search -- a 1.0 1.0
2918 } {}
2919 test text-20.179 {TextSearchCmd, empty search range} {
2920 deleteWindows
2921 pack [text .t2]
2922 .t2 insert 1.0 "a\na\na\n"
2923 .t2 search -backwards -- a 2.0 2.0
2924 } {}
2925 test text-20.180 {TextSearchCmd, elide up to match} {
2926 deleteWindows
2927 pack [text .t2]
2928 .t2 insert 1.0 "a\nb\nc"
2929 .t2 tag configure e -elide 1
2930 set res {}
2931 lappend res [.t2 search -regexp a 1.0]
2932 lappend res [.t2 search -regexp b 1.0]
2933 lappend res [.t2 search -regexp c 1.0]
2934 .t2 tag add e 1.0 2.0
2935 lappend res [.t2 search -regexp a 1.0]
2936 lappend res [.t2 search -regexp b 1.0]
2937 lappend res [.t2 search -regexp c 1.0]
2938 lappend res [.t2 search -elide -regexp a 1.0]
2939 lappend res [.t2 search -elide -regexp b 1.0]
2940 lappend res [.t2 search -elide -regexp c 1.0]
2941 } {1.0 2.0 3.0 {} 2.0 3.0 1.0 2.0 3.0}
2942 test text-20.181 {TextSearchCmd, elide up to match, backwards} {
2943 deleteWindows
2944 pack [text .t2]
2945 .t2 insert 1.0 "a\nb\nc"
2946 .t2 tag configure e -elide 1
2947 set res {}
2948 lappend res [.t2 search -backward -regexp a 1.0]
2949 lappend res [.t2 search -backward -regexp b 1.0]
2950 lappend res [.t2 search -backward -regexp c 1.0]
2951 .t2 tag add e 1.0 2.0
2952 lappend res [.t2 search -backward -regexp a 1.0]
2953 lappend res [.t2 search -backward -regexp b 1.0]
2954 lappend res [.t2 search -backward -regexp c 1.0]
2955 lappend res [.t2 search -backward -elide -regexp a 1.0]
2956 lappend res [.t2 search -backward -elide -regexp b 1.0]
2957 lappend res [.t2 search -backward -elide -regexp c 1.0]
2958 } {1.0 2.0 3.0 {} 2.0 3.0 1.0 2.0 3.0}
2959 test text-20.182 {TextSearchCmd, elide up to match} {
2960 deleteWindows
2961 pack [text .t2]
2962 .t2 insert 1.0 "a\nb\nc"
2963 .t2 tag configure e -elide 1
2964 set res {}
2965 lappend res [.t2 search a 1.0]
2966 lappend res [.t2 search b 1.0]
2967 lappend res [.t2 search c 1.0]
2968 .t2 tag add e 1.0 2.0
2969 lappend res [.t2 search a 1.0]
2970 lappend res [.t2 search b 1.0]
2971 lappend res [.t2 search c 1.0]
2972 lappend res [.t2 search -elide a 1.0]
2973 lappend res [.t2 search -elide b 1.0]
2974 lappend res [.t2 search -elide c 1.0]
2975 } {1.0 2.0 3.0 {} 2.0 3.0 1.0 2.0 3.0}
2976 test text-20.183 {TextSearchCmd, elide up to match, backwards} {
2977 deleteWindows
2978 pack [text .t2]
2979 .t2 insert 1.0 "a\nb\nc"
2980 .t2 tag configure e -elide 1
2981 set res {}
2982 lappend res [.t2 search -backward a 1.0]
2983 lappend res [.t2 search -backward b 1.0]
2984 lappend res [.t2 search -backward c 1.0]
2985 .t2 tag add e 1.0 2.0
2986 lappend res [.t2 search -backward a 1.0]
2987 lappend res [.t2 search -backward b 1.0]
2988 lappend res [.t2 search -backward c 1.0]
2989 lappend res [.t2 search -backward -elide a 1.0]
2990 lappend res [.t2 search -backward -elide b 1.0]
2991 lappend res [.t2 search -backward -elide c 1.0]
2992 } {1.0 2.0 3.0 {} 2.0 3.0 1.0 2.0 3.0}
2993 test text-20.184 {TextSearchCmd, elide up to match} {
2994 deleteWindows
2995 pack [text .t2]
2996 .t2 insert 1.0 "aa\nbb\ncc"
2997 .t2 tag configure e -elide 1
2998 set res {}
2999 lappend res [.t2 search ab 1.0]
3000 lappend res [.t2 search bc 1.0]
3001 .t2 tag add e 1.1 2.1
3002 lappend res [.t2 search ab 1.0]
3003 lappend res [.t2 search b 1.0]
3004 .t2 tag remove e 1.0 end
3005 .t2 tag add e 2.1 3.1
3006 lappend res [.t2 search bc 1.0]
3007 lappend res [.t2 search c 1.0]
3008 .t2 tag remove e 1.0 end
3009 .t2 tag add e 2.1 3.0
3010 lappend res [.t2 search bc 1.0]
3011 lappend res [.t2 search c 1.0]
3012 } {{} {} 1.0 2.1 2.0 3.1 2.0 3.0}
3013 test text-20.185 {TextSearchCmd, elide up to match} {
3014 deleteWindows
3015 pack [text .t2]
3016 .t2 insert 1.0 "aa\nbb\ncc"
3017 .t2 tag configure e -elide 1
3018 set res {}
3019 lappend res [.t2 search -regexp ab 1.0]
3020 lappend res [.t2 search -regexp bc 1.0]
3021 .t2 tag add e 1.1 2.1
3022 lappend res [.t2 search -regexp ab 1.0]
3023 lappend res [.t2 search -regexp b 1.0]
3024 .t2 tag remove e 1.0 end
3025 .t2 tag add e 2.1 3.1
3026 lappend res [.t2 search -regexp bc 1.0]
3027 lappend res [.t2 search -regexp c 1.0]
3028 .t2 tag remove e 1.0 end
3029 .t2 tag add e 2.1 3.0
3030 lappend res [.t2 search -regexp bc 1.0]
3031 lappend res [.t2 search -regexp c 1.0]
3032 } {{} {} 1.0 2.1 2.0 3.1 2.0 3.0}
3033 test text-20.186 {TextSearchCmd, strict limits} {
3034 deleteWindows
3035 pack [text .t2]
3036 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3037 .t2 search -strictlimits -- "world" 1.3 1.8
3038 } {}
3039 test text-20.187 {TextSearchCmd, strict limits} {
3040 deleteWindows
3041 pack [text .t2]
3042 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3043 .t2 search -strictlimits -- "world" 1.3 1.10
3044 } {}
3045 test text-20.188 {TextSearchCmd, strict limits} {
3046 deleteWindows
3047 pack [text .t2]
3048 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3049 .t2 search -strictlimits -- "world" 1.3 1.11
3050 } {1.6}
3051 test text-20.189 {TextSearchCmd, strict limits backwards} {
3052 deleteWindows
3053 pack [text .t2]
3054 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3055 .t2 search -strictlimits -backward -- "world" 2.3 1.8
3056 } {}
3057 test text-20.190 {TextSearchCmd, strict limits backwards} {
3058 deleteWindows
3059 pack [text .t2]
3060 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3061 .t2 search -strictlimits -backward -- "world" 2.3 1.6
3062 } {1.6}
3063 test text-20.191 {TextSearchCmd, strict limits backwards} {
3064 deleteWindows
3065 pack [text .t2]
3066 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3067 .t2 search -strictlimits -backward -- "world" 2.3 1.7
3068 } {}
3069 test text-20.192 {TextSearchCmd, strict limits} {
3070 deleteWindows
3071 pack [text .t2]
3072 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3073 .t2 search -regexp -strictlimits -- "world" 1.3 1.8
3074 } {}
3075 test text-20.193 {TextSearchCmd, strict limits} {
3076 deleteWindows
3077 pack [text .t2]
3078 .t2 insert 1.0 "Hello world!\nThis is a test\n"
3079 .t2 search -regexp -strictlimits -backward -- "world" 2.3 1.8
3080 } {}
3081
3082 deleteWindows
3083 text .t2 -highlightthickness 0 -bd 0 -relief flat -padx 0 -width 100
3084 pack .t2
3085 .t2 insert end "1\t2\t3\t4\t55.5"
3086
3087 test text-21.1 {TkTextGetTabs procedure} {
3088 list [catch {.t2 configure -tabs "\{{}"} msg] $msg
3089 } {1 {unmatched open brace in list}}
3090 test text-21.2 {TkTextGetTabs procedure} {
3091 list [catch {.t2 configure -tabs xyz} msg] $msg
3092 } {1 {bad screen distance "xyz"}}
3093 test text-21.3 {TkTextGetTabs procedure} {
3094 .t2 configure -tabs {100 200}
3095 update idletasks
3096 list [lindex [.t2 bbox 1.2] 0] [lindex [.t2 bbox 1.4] 0]
3097 } {100 200}
3098 test text-21.4 {TkTextGetTabs procedure} {
3099 .t2 configure -tabs {100 right 200 left 300 center 400 numeric}
3100 update idletasks
3101 list [expr [lindex [.t2 bbox 1.2] 0] + [lindex [.t2 bbox 1.2] 2]] \
3102 [lindex [.t2 bbox 1.4] 0] \
3103 [expr [lindex [.t2 bbox 1.6] 0] + [lindex [.t2 bbox 1.6] 2]/2] \
3104 [lindex [.t2 bbox 1.10] 0]
3105 } {100 200 300 400}
3106 test text-21.5 {TkTextGetTabs procedure} {
3107 .t2 configure -tabs {105 r 205 l 305 c 405 n}
3108 update idletasks
3109 list [expr [lindex [.t2 bbox 1.2] 0] + [lindex [.t2 bbox 1.2] 2]] \
3110 [lindex [.t2 bbox 1.4] 0] \
3111 [expr [lindex [.t2 bbox 1.6] 0] + [lindex [.t2 bbox 1.6] 2]/2] \
3112 [lindex [.t2 bbox 1.10] 0]
3113 } {105 205 305 405}
3114 test text-21.6 {TkTextGetTabs procedure} {
3115 list [catch {.t2 configure -tabs {100 left 200 lork}} msg] $msg
3116 } {1 {bad tab alignment "lork": must be left, right, center, or numeric}}
3117 test text-21.7 {TkTextGetTabs procedure} {
3118 list [catch {.t2 configure -tabs {100 !44 200 lork}} msg] $msg
3119 } {1 {bad screen distance "!44"}}
3120
3121 deleteWindows
3122 text .t
3123 pack .t
3124 .t insert 1.0 "One Line"
3125 .t mark set insert 1.0
3126
3127 test text-22.1 {TextDumpCmd procedure, bad args} {
3128 list [catch {.t dump} msg] $msg
3129 } {1 {Usage: .t dump ?-all -image -text -mark -tag -window? ?-command script? index ?index2?}}
3130 test text-22.2 {TextDumpCmd procedure, bad args} {
3131 list [catch {.t dump -all} msg] $msg
3132 } {1 {Usage: .t dump ?-all -image -text -mark -tag -window? ?-command script? index ?index2?}}
3133 test text-22.3 {TextDumpCmd procedure, bad args} {
3134 list [catch {.t dump -command} msg] $msg
3135 } {1 {Usage: .t dump ?-all -image -text -mark -tag -window? ?-command script? index ?index2?}}
3136 test text-22.4 {TextDumpCmd procedure, bad args} {
3137 list [catch {.t dump -bogus} msg] $msg
3138 } {1 {bad option "-bogus": must be -all, -command, -image, -mark, -tag, -text, or -window}}
3139 test text-22.5 {TextDumpCmd procedure, bad args} {
3140 list [catch {.t dump bogus} msg] $msg
3141 } {1 {bad text index "bogus"}}
3142 test text-22.6 {TextDumpCmd procedure, one index} {
3143 .t dump -text 1.2
3144 } {text e 1.2}
3145 test text-22.7 {TextDumpCmd procedure, two indices} {
3146 .t dump -text 1.0 1.end
3147 } {text {One Line} 1.0}
3148 test text-22.8 {TextDumpCmd procedure, "end" index} {
3149 .t dump -text 1.end end
3150 } {text {
3151 } 1.8}
3152 test text-22.9 {TextDumpCmd procedure, same indices} {
3153 .t dump 1.5 1.5
3154 } {}
3155 test text-22.10 {TextDumpCmd procedure, negative range} {
3156 .t dump 1.5 1.0
3157 } {}
3158 .t delete 1.0 end
3159 .t insert end "Line One\nLine Two\nLine Three\nLine Four"
3160 .t mark set insert 1.0
3161 .t mark set current 1.0
3162 test text-22.11 {TextDumpCmd procedure, stop at begin-line} {
3163 .t dump -text 1.0 2.0
3164 } {text {Line One
3165 } 1.0}
3166 test text-22.12 {TextDumpCmd procedure, span multiple lines} {
3167 .t dump -text 1.5 3.end
3168 } {text {One
3169 } 1.5 text {Line Two
3170 } 2.0 text {Line Three} 3.0}
3171 .t tag add x 2.0 2.end
3172 .t tag add y 1.0 end
3173 .t mark set m 2.4
3174 .t mark set n 4.0
3175 .t mark set END end
3176 test text-22.13 {TextDumpCmd procedure, tags only} {
3177 .t dump -tag 2.1 2.8
3178 } {}
3179 test text-22.14 {TextDumpCmd procedure, tags only} {
3180 .t dump -tag 2.0 2.8
3181 } {tagon x 2.0}
3182 test text-22.15 {TextDumpCmd procedure, tags only} {
3183 .t dump -tag 1.0 4.end
3184 } {tagon y 1.0 tagon x 2.0 tagoff x 2.8}
3185 test text-22.16 {TextDumpCmd procedure, tags only} {
3186 .t dump -tag 1.0 end
3187 } {tagon y 1.0 tagon x 2.0 tagoff x 2.8 tagoff y 5.0}
3188 .t mark set insert 1.0
3189 .t mark set current 1.0
3190 test text-22.17 {TextDumpCmd procedure, marks only} {
3191 .t dump -mark 1.1 1.8
3192 } {}
3193 test text-22.18 {TextDumpCmd procedure, marks only} {
3194 .t dump -mark 2.0 2.8
3195 } {mark m 2.4}
3196 test text-22.19 {TextDumpCmd procedure, marks only} {
3197 .t dump -mark 1.1 4.end
3198 } {mark m 2.4 mark n 4.0}
3199 test text-22.20 {TextDumpCmd procedure, marks only} {
3200 .t dump -mark 1.0 end
3201 } {mark current 1.0 mark insert 1.0 mark m 2.4 mark n 4.0 mark END 5.0}
3202 button .hello -text Hello
3203 .t window create 3.end -window .hello
3204 for {set i 0} {$i < 100} {incr i} {
3205 .t insert end "-\n"
3206 }
3207 .t window create 100.0 -create { }
3208 test text-22.21 {TextDumpCmd procedure, windows only} {
3209 .t dump -window 1.0 5.0
3210 } {window .hello 3.10}
3211 test text-22.22 {TextDumpCmd procedure, windows only} {
3212 .t dump -window 5.0 end
3213 } {window {} 100.0}
3214 .t delete 1.0 end
3215 eval {.t mark unset} [.t mark names]
3216 .t insert end "Line One\nLine Two\nLine Three\nLine Four"
3217 .t mark set insert 1.0
3218 .t mark set current 1.0
3219 .t tag add x 2.0 2.end
3220 .t mark set m 2.4
3221 proc Append {varName key value index} {
3222 upvar #0 $varName x
3223 lappend x $key $index $value
3224 }
3225 test text-22.23 {TextDumpCmd procedure, command script} {
3226 set x {}
3227 .t dump -command {Append x} -all 1.0 end
3228 set x
3229 } {mark 1.0 current mark 1.0 insert text 1.0 {Line One
3230 } tagon 2.0 x text 2.0 Line mark 2.4 m text 2.4 { Two} tagoff 2.8 x text 2.8 {
3231 } text 3.0 {Line Three
3232 } text 4.0 {Line Four
3233 }}
3234 test text-22.24 {TextDumpCmd procedure, command script} {
3235 set x {}
3236 .t dump -mark -command {Append x} 1.0 end
3237 set x
3238 } {mark 1.0 current mark 1.0 insert mark 2.4 m}
3239 catch {unset x}
3240 test text-22.25 {TextDumpCmd procedure, unicode characters} {
3241 catch {destroy .t}
3242 text .t
3243 .t delete 1.0 end
3244 .t insert 1.0 \xb1\xb1\xb1
3245 .t dump -all 1.0 2.0
3246 } "text \xb1\xb1\xb1 1.0 mark insert 1.3 mark current 1.3 text {\n} 1.3"
3247 test text-22.26 {TextDumpCmd procedure, unicode characters} {
3248 catch {destroy .t}
3249 text .t
3250 .t delete 1.0 end
3251 .t insert 1.0 abc\xb1\xb1\xb1
3252 .t dump -all 1.0 2.0
3253 } "text abc\xb1\xb1\xb1 1.0 mark insert 1.6 mark current 1.6 text {\n} 1.6"
3254
3255 set l [interp hidden]
3256 deleteWindows
3257
3258 test text-23.1 {text widget vs hidden commands} {
3259 catch {destroy .t}
3260 text .t
3261 interp hide {} .t
3262 destroy .t
3263 list [winfo children .] [interp hidden]
3264 } [list {} $l]
3265
3266 test text-24.1 {bug fix - 1642} {
3267 catch {destroy .t}
3268 text .t
3269 pack .t
3270 .t insert end "line 1\n"
3271 .t insert end "line 2\n"
3272 .t insert end "line 3\n"
3273 .t insert end "line 4\n"
3274 .t insert end "line 5\n"
3275 tk::TextSetCursor .t 3.0
3276 .t search -backward -regexp "\$" insert 1.0
3277 } {2.6}
3278
3279 test text-25.1 {TextEditCmd procedure, argument parsing} {
3280 list [catch {.t edit} msg] $msg
3281 } {1 {wrong # args: should be ".t edit option ?arg arg ...?"}}
3282 test text-25.2 {TextEditCmd procedure, argument parsing} {
3283 list [catch {.t edit gorp} msg] $msg
3284 } {1 {bad edit option "gorp": must be modified, redo, reset, separator, or undo}}
3285 test text-25.3 {TextEditUndo procedure, undoing changes} {
3286 catch {destroy .t}
3287 text .t -undo 1
3288 pack .t
3289 .t insert end "line 1\n"
3290 .t delete 1.4 1.6
3291 .t insert end "should be gone after undo\n"
3292 .t edit undo
3293 .t get 1.0 end
3294 } "line\n\n"
3295 test text-25.4 {TextEditRedo procedure, redoing changes} {
3296 catch {destroy .t}
3297 text .t -undo 1
3298 pack .t
3299 .t insert end "line 1\n"
3300 .t delete 1.4 1.6
3301 .t insert end "should be back after redo\n"
3302 .t edit undo
3303 .t edit redo
3304 .t get 1.0 end
3305 } "line\nshould be back after redo\n\n"
3306 test text-25.5 {TextEditUndo procedure, resetting stack} {
3307 catch {destroy .t}
3308 text .t -undo 1
3309 pack .t
3310 .t insert end "line 1\n"
3311 .t delete 1.4 1.6
3312 .t insert end "should be back after redo\n"
3313 .t edit reset
3314 catch {.t edit undo} msg
3315 set msg
3316 } "nothing to undo"
3317 test text-25.6 {TextEditCmd procedure, insert separator} {
3318 catch {destroy .t}
3319 text .t -undo 1
3320 pack .t
3321 .t insert end "line 1\n"
3322 .t edit separator
3323 .t insert end "line 2\n"
3324 .t edit undo
3325 .t get 1.0 end
3326 } "line 1\n\n"
3327 test text-25.7 {-autoseparators configuration option} {
3328 catch {destroy .t}
3329 text .t -undo 1 -autoseparators 0
3330 pack .t
3331 .t insert end "line 1\n"
3332 .t delete 1.4 1.6
3333 .t insert end "line 2\n"
3334 .t edit undo
3335 .t get 1.0 end
3336 } "\n"
3337 test text-25.8 {TextEditCmd procedure, modified flag} {
3338 catch {destroy .t}
3339 text .t
3340 pack .t
3341 .t insert end "line 1\n"
3342 .t edit modified
3343 } {1}
3344 test text-25.9 {TextEditCmd procedure, reset modified flag} {
3345 catch {destroy .t}
3346 text .t
3347 pack .t
3348 .t insert end "line 1\n"
3349 .t edit modified 0
3350 .t edit modified
3351 } {0}
3352 test text-25.10 {TextEditCmd procedure, set modified flag} {
3353 catch {destroy .t}
3354 text .t
3355 pack .t
3356 .t edit modified 1
3357 .t edit modified
3358 } {1}
3359 test text-25.11 {<<Modified>> virtual event} {
3360 set ::retval unmodified
3361 catch {destroy .t}
3362 text .t -undo 1
3363 pack .t
3364 bind .t <<Modified>> "set ::retval modified"
3365 update idletasks
3366 .t insert end "nothing special\n"
3367 set ::retval
3368 } {modified}
3369 test text-25.12 {<<Selection>> virtual event} {
3370 set ::retval no_selection
3371 catch {destroy .t}
3372 text .t -undo 1
3373 pack .t
3374 bind .t <<Selection>> "set ::retval selection_changed"
3375 update idletasks
3376 .t insert end "nothing special\n"
3377 .t tag add sel 1.0 1.1
3378 set ::retval
3379 } {selection_changed}
3380 test text-25.13 {-maxundo configuration option} {
3381 catch {destroy .t}
3382 text .t -undo 1 -autoseparators 1 -maxundo 2
3383 pack .t
3384 .t insert end "line 1\n"
3385 .t delete 1.4 1.6
3386 .t insert end "line 2\n"
3387 catch {.t edit undo}
3388 catch {.t edit undo}
3389 catch {.t edit undo}
3390 .t get 1.0 end
3391 } "line 1\n\n"
3392 test text-25.15 {bug fix 1536735 - undo with empty text} {
3393 catch {destroy .t}
3394 text .t -undo 1
3395 set r [.t edit modified]
3396 .t delete 1.0
3397 lappend r [.t edit modified]
3398 lappend r [catch {.t edit undo}]
3399 lappend r [.t edit modified]
3400 } {0 0 1 0}
3401
3402 test text-26.1 {bug fix - 624372, ControlUtfProc long lines} {
3403 destroy .t
3404 pack [text .t -wrap none]
3405 .t insert end [string repeat "\1" 500]
3406 } {}
3407
3408 test text-27.1 {tabs - must be positive and must be increasing} {
3409 destroy .t
3410 pack [text .t -wrap none]
3411 list [catch {.t configure -tabs {0}} msg] $msg
3412 } {1 {tab stop "0" is not at a positive distance}}
3413 test text-27.2 {tabs - must be positive and must be increasing} {
3414 destroy .t
3415 pack [text .t -wrap none]
3416 list [catch {.t configure -tabs {-5}} msg] $msg
3417 } {1 {tab stop "-5" is not at a positive distance}}
3418 test text-27.3 {tabs - must be positive and must be increasing} {knownBug} {
3419 # This bug will be fixed in Tk 9.0, when we can allow a minor
3420 # incompatibility with Tk 8.x
3421 destroy .t
3422 pack [text .t -wrap none]
3423 list [catch {.t configure -tabs {10c 5c}} msg] $msg
3424 } {1 {tabs must be monotonically increasing, but "5c" is smaller than or equal to the previous tab}}
3425 test text-27.4 {tabs - must be positive and must be increasing} {
3426 destroy .t
3427 pack [text .t -wrap none]
3428 .t insert end "a\tb\tc\td\te"
3429 catch {.t configure -tabs {10c 5c}}
3430 update ; update ; update
3431 # This test must simply not go into an infinite loop to succeed
3432 set result 1
3433 } {1}
3434
3435 test text-28.0 {repeated insert and scroll} {
3436 foreach subcmd {
3437 {moveto 1}
3438 {scroll 1 pages}
3439 {scroll 100 pixels}
3440 {scroll 10 units}
3441 } {
3442 destroy .t
3443 pack [text .t]
3444 for {set i 0} {$i < 30} {incr i} {
3445 .t insert end "blabla\n"
3446 eval .t yview $subcmd
3447 }
3448 }
3449 # This test must simply not crash to succeed
3450 set result 1
3451 } {1}
3452
3453 test text-29.0 {peer widgets} {
3454 destroy .t .tt
3455 toplevel .tt
3456 pack [text .t]
3457 pack [.t peer create .tt.t]
3458 destroy .t .tt
3459 } {}
3460 test text-29.1 {peer widgets} {
3461 destroy .t .t1 .t2
3462 toplevel .t1
3463 toplevel .t2
3464 pack [text .t]
3465 pack [.t peer create .t1.t]
3466 pack [.t peer create .t2.t]
3467 .t insert end "abcd\nabcd"
3468 update
3469 destroy .t1
3470 update
3471 .t insert end "abcd\nabcd"
3472 update
3473 destroy .t .t2
3474 update
3475 } {}
3476 test text-29.2 {peer widgets} {
3477 destroy .t .t1 .t2
3478 toplevel .t1
3479 toplevel .t2
3480 pack [text .t]
3481 pack [.t peer create .t1.t]
3482 pack [.t peer create .t2.t]
3483 .t insert end "abcd\nabcd"
3484 update
3485 destroy .t
3486 update
3487 .t2.t insert end "abcd\nabcd"
3488 update
3489 destroy .t .t2
3490 update
3491 } {}
3492 test text-29.3 {peer widgets} {
3493 destroy .t .tt
3494 toplevel .tt
3495 pack [text .t]
3496 for {set i 1} {$i < 20} {incr i} {
3497 .t insert end "Line $i\n"
3498 }
3499 pack [.t peer create .tt.t -start 5 -end 11]
3500 update
3501 destroy .t .tt
3502 } {}
3503 test text-29.4 {peer widgets} {
3504 destroy .t .tt
3505 toplevel .tt
3506 pack [text .t]
3507 for {set i 1} {$i < 20} {incr i} {
3508 .t insert end "Line $i\n"
3509 }
3510 pack [.t peer create .tt.t -start 5 -end 11]
3511 pack [.tt.t peer create .tt.t2]
3512 set res [list [.tt.t index end] [.tt.t2 index end]]
3513 update
3514 destroy .t .tt
3515 set res
3516 } {7.0 7.0}
3517 test text-29.4.1 {peer widgets} {
3518 destroy .t .tt
3519 toplevel .tt
3520 pack [text .t]
3521 for {set i 1} {$i < 20} {incr i} {
3522 .t insert end "Line $i\n"
3523 }
3524 pack [.t peer create .tt.t -start 5 -end 11]
3525 pack [.tt.t peer create .tt.t2 -start {} -end {}]
3526 set res [list [.tt.t index end] [.tt.t2 index end]]
3527 update
3528 destroy .t .tt
3529 set res
3530 } {7.0 21.0}
3531 test text-29.5 {peer widgets} {
3532 destroy .t .tt
3533 toplevel .tt
3534 pack [text .t]
3535 for {set i 1} {$i < 20} {incr i} {
3536 .t insert end "Line $i\n"
3537 }
3538 pack [.t peer create .tt.t -start 5 -end 11]
3539 update ; update
3540 set p1 [.tt.t count -update -ypixels 1.0 end]
3541 set p2 [.t count -update -ypixels 5.0 11.0]
3542 if {$p1 == $p2} {
3543 set res "ok"
3544 } else {
3545 set res "$p1 and $p2 not equal"
3546 }
3547 destroy .t .tt
3548 set res
3549 } {ok}
3550 test text-29.6 {peer widgets} {
3551 destroy .t .tt
3552 toplevel .tt
3553 pack [text .t]
3554 for {set i 1} {$i < 20} {incr i} {
3555 .t insert end "Line $i\n"
3556 }
3557 pack [.t peer create .tt.t -start 5 -end 11]
3558 update ; update
3559 .t delete 3.0 6.0
3560 set res [.tt.t index end]
3561 destroy .t .tt
3562 set res
3563 } {6.0}
3564 test text-29.7 {peer widgets} {
3565 destroy .t .tt
3566 toplevel .tt
3567 pack [text .t]
3568 for {set i 1} {$i < 20} {incr i} {
3569 .t insert end "Line $i\n"
3570 }
3571 pack [.t peer create .tt.t -start 5 -end 11]
3572 update ; update
3573 .t delete 8.0 12.0
3574 set res [.tt.t index end]
3575 destroy .t .tt
3576 set res
3577 } {4.0}
3578 test text-29.8 {peer widgets} {
3579 destroy .t .tt
3580 toplevel .tt
3581 pack [text .t]
3582 for {set i 1} {$i < 20} {incr i} {
3583 .t insert end "Line $i\n"
3584 }
3585 pack [.t peer create .tt.t -start 5 -end 11]
3586 update ; update
3587 .t delete 3.0 13.0
3588 set res [.tt.t index end]
3589 destroy .t .tt
3590 set res
3591 } {1.0}
3592 test text-29.9 {peer widgets} {
3593 destroy .t
3594 pack [text .t]
3595 for {set i 1} {$i < 100} {incr i} {
3596 .t insert end "Line $i\n"
3597 }
3598 .t tag add sel 1.0 end-1c
3599 set res {}
3600 lappend res [.t tag ranges sel]
3601 .t configure -start 10 -end 20
3602 lappend res [.t tag ranges sel]
3603 destroy .t
3604 set res
3605 } {{1.0 100.0} {1.0 11.0}}
3606 test text-29.10 {peer widgets} {
3607 destroy .t
3608 pack [text .t]
3609 for {set i 1} {$i < 100} {incr i} {
3610 .t insert end "Line $i\n"
3611 }
3612 .t tag add sel 1.0 end-1c
3613 set res {}
3614 lappend res [.t tag ranges sel]
3615 .t configure -start 11
3616 lappend res [.t tag ranges sel]
3617 destroy .t
3618 set res
3619 } {{1.0 100.0} {1.0 90.0}}
3620 test text-29.11 {peer widgets} {
3621 destroy .t
3622 pack [text .t]
3623 for {set i 1} {$i < 100} {incr i} {
3624 .t insert end "Line $i\n"
3625 }
3626 .t tag add sel 1.0 end-1c
3627 set res {}
3628 lappend res [.t tag ranges sel]
3629 .t configure -end 90
3630 lappend res [.t tag ranges sel]
3631 destroy .t
3632 set res
3633 } {{1.0 100.0} {1.0 90.0}}
3634 test text-29.12 {peer widgets} {
3635 destroy .t
3636 pack [text .t]
3637 for {set i 1} {$i < 20} {incr i} {
3638 .t insert end "Line $i\n"
3639 }
3640 .t tag add sel 1.0 3.0 5.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0
3641 set res {}
3642 lappend res [.t tag prevrange sel 1.0]
3643 .t configure -start 6 -end 12
3644 lappend res [.t tag ranges sel]
3645 lappend res "next" [.t tag nextrange sel 4.0] \
3646 [.t tag nextrange sel 5.0] [.t tag nextrange sel 6.0] \
3647 [.t tag nextrange sel 7.0]
3648 lappend res "prev" [.t tag prevrange sel 1.0] \
3649 [.t tag prevrange sel 2.0] [.t tag prevrange sel 3.0] \
3650 [.t tag prevrange sel 4.0]
3651 destroy .t
3652 set res
3653 } {{} {1.0 2.0 4.0 6.0} next {4.0 6.0} {} {} {} prev {} {1.0 2.0} {1.0 2.0} {1.0 2.0}}
3654 test text-29.13 {peer widgets} {
3655 destroy .t
3656 pack [text .t]
3657 for {set i 1} {$i < 20} {incr i} {
3658 .t insert end "Line $i\n"
3659 }
3660 .t tag add sel 1.0 3.0 9.0 11.0 13.0 15.0 17.0 19.0
3661 set res {}
3662 .t configure -start 6 -end 12
3663 lappend res [.t tag ranges sel]
3664 lappend res "next" [.t tag nextrange sel 4.0] \
3665 [.t tag nextrange sel 5.0] [.t tag nextrange sel 6.0] \
3666 [.t tag nextrange sel 7.0]
3667 lappend res "prev" [.t tag prevrange sel 1.0] \
3668 [.t tag prevrange sel 2.0] [.t tag prevrange sel 3.0] \
3669 [.t tag prevrange sel 4.0]
3670 destroy .t
3671 set res
3672 } {{4.0 6.0} next {4.0 6.0} {} {} {} prev {} {} {} {}}
3673 test text-29.14 {peer widgets} {
3674 destroy .t
3675 pack [text .t]
3676 for {set i 1} {$i < 20} {incr i} {
3677 .t insert end "Line $i\n"
3678 }
3679 .t tag add sel 1.0 7.0 9.0 11.0 13.0 15.0 17.0 19.0
3680 set res {}
3681 .t configure -start 6 -end 12
3682 lappend res [.t tag ranges sel]
3683 lappend res "next" [.t tag nextrange sel 4.0] \
3684 [.t tag nextrange sel 5.0] [.t tag nextrange sel 6.0] \
3685 [.t tag nextrange sel 7.0]
3686 lappend res "prev" [.t tag prevrange sel 1.0] \
3687 [.t tag prevrange sel 2.0] [.t tag prevrange sel 3.0] \
3688 [.t tag prevrange sel 4.0]
3689 destroy .t
3690 set res
3691 } {{1.0 2.0 4.0 6.0} next {4.0 6.0} {} {} {} prev {} {1.0 2.0} {1.0 2.0} {1.0 2.0}}
3692 test text-29.15 {peer widgets} {
3693 destroy .t
3694 pack [text .t]
3695 for {set i 1} {$i < 20} {incr i} {
3696 .t insert end "Line $i\n"
3697 }
3698 set res {}
3699 .t tag add sel 1.0 11.0
3700 lappend res [.t tag ranges sel]
3701 lappend res [catch {.t configure -start 15 -end 10}]
3702 lappend res [.t tag ranges sel]
3703 .t configure -start 6 -end 12
3704 lappend res [.t tag ranges sel]
3705 .t configure -start {} -end {}
3706 lappend res [.t tag ranges sel]
3707 destroy .t
3708 set res
3709 } {{1.0 11.0} 1 {1.0 11.0} {1.0 6.0} {1.0 11.0}}
3710 test text-29.16 {peer widgets} {
3711 destroy .t
3712 pack [text .t]
3713 for {set i 1} {$i < 20} {incr i} {
3714 .t insert end "Line $i\n"
3715 }
3716 set res {}
3717 .t tag add sel 1.0 11.0
3718 lappend res [.t index sel.first]
3719 lappend res [.t index sel.last]
3720 destroy .t
3721 set res
3722 } {1.0 11.0}
3723 test text-29.17 {peer widgets} {
3724 destroy .t
3725 pack [text .t]
3726 for {set i 1} {$i < 20} {incr i} {
3727 .t insert end "Line $i\n"
3728 }
3729 set res {}
3730 .t tag delete sel
3731 set res [list [catch {.t index sel.first} msg] $msg]
3732 destroy .t
3733 set res
3734 } {1 {text doesn't contain any characters tagged with "sel"}}
3735
3736 proc makeText {} {
3737 set w .g
3738 set font "Times 11"
3739 destroy .g
3740 toplevel .g
3741 frame $w.f -highlightthickness 2 -borderwidth 2 -relief sunken
3742 set t $w.f.text
3743 text $t -yscrollcommand "$w.scroll set" -setgrid true -font $font -width 70 \
3744 -height 35 -wrap word -highlightthickness 0 -borderwidth 0
3745 pack $t -expand yes -fill both
3746 scrollbar $w.scroll -command "$t yview"
3747 pack $w.scroll -side right -fill y
3748 pack $w.f -expand yes -fill both
3749 $t tag configure center -justify center -spacing1 5m -spacing3 5m
3750 $t tag configure buttons -lmargin1 1c -lmargin2 1c -rmargin 1c \
3751 -spacing1 3m -spacing2 0 -spacing3 0
3752 for {set i 0} {$i < 40} {incr i} {
3753 $t insert end "${i}word "
3754 }
3755 return $t
3756 }
3757
3758 test text-30.1 {line heights on creation} {
3759 set w [makeText]
3760 update ; after 1000 ; update
3761 set before [$w count -ypixels 1.0 2.0]
3762 $w insert 1.0 "a"
3763 update
3764 set after [$w count -ypixels 1.0 2.0]
3765 destroy .g
3766 if {$before != $after} {
3767 set res "Count changed: $before $after"
3768 } else {
3769 set res "ok"
3770 }
3771 } {ok}
3772
3773 destroy .t
3774 text .t
3775 test text-31.1 {TextWidgetCmd procedure, "peer" option} {
3776 list [catch {.t peer foo 1} msg] $msg
3777 } {1 {bad peer option "foo": must be create or names}}
3778 test text-31.2 {TextWidgetCmd procedure, "peer" option} {
3779 list [catch {.t peer names foo} msg] $msg
3780 } {1 {wrong # args: should be ".t peer names"}}
3781 test text-31.3 {TextWidgetCmd procedure, "peer" option} {
3782 list [catch {.t p names} msg] $msg
3783 } {0 {}}
3784 test text-31.4 {TextWidgetCmd procedure, "peer" option} {
3785 .t peer names
3786 } {}
3787 test text-31.5 {TextWidgetCmd procedure, "peer" option} {
3788 list [catch {.t peer create foo} msg] $msg
3789 } {1 {bad window path name "foo"}}
3790 test text-31.6 {TextWidgetCmd procedure, "peer" option} {
3791 .t peer create .t2
3792 set res {}
3793 lappend res [.t peer names]
3794 lappend res [.t2 peer names]
3795 destroy .t2
3796 lappend res [.t peer names]
3797 } {.t2 .t {}}
3798 test text-31.7 {peer widget -start, -end} {
3799 set res [list [catch {.t configure -start 10 -end 5} msg] $msg]
3800 .t configure -start {} -end {}
3801 set res
3802 } {0 {}}
3803 test text-31.8 {peer widget -start, -end} {
3804 .t delete 1.0 end
3805 for {set i 1} {$i < 100} {incr i} {
3806 .t insert end "Line $i\n"
3807 }
3808 list [catch {.t configure -start 10 -end 5} msg] $msg
3809 } {1 {-startline must be less than or equal to -endline}}
3810 test text-31.9 {peer widget -start, -end} {
3811 .t delete 1.0 end
3812 for {set i 1} {$i < 100} {incr i} {
3813 .t insert end "Line $i\n"
3814 }
3815 set res [list [catch {.t configure -start 5 -end 10} msg] $msg]
3816 .t configure -start {} -end {}
3817 set res
3818 } {0 {}}
3819 test text-31.10 {peer widget -start, -end} {
3820 .t delete 1.0 end
3821 for {set i 1} {$i < 100} {incr i} {
3822 .t insert end "Line $i\n"
3823 }
3824 set res [.t index end]
3825 lappend res [catch {.t configure -start 5 -end 10 -tab foo}]
3826 lappend res [.t index end]
3827 lappend res [catch {.t configure -tab foo -start 15 -end 20}]
3828 lappend res [.t index end]
3829 .t configure -start {} -end {}
3830 lappend res [.t index end]
3831 set res
3832 } {101.0 1 101.0 1 101.0 101.0}
3833 test text-31.11 {peer widget -start, -end} {
3834 .t delete 1.0 end
3835 for {set i 1} {$i < 100} {incr i} {
3836 .t insert end "Line $i\n"
3837 }
3838 set res [.t index end]
3839 lappend res [catch {.t configure -start 5 -end 15}]
3840 lappend res [.t index end]
3841 lappend res [catch {.t configure -start 10 -end 40}]
3842 lappend res [.t index end]
3843 .t configure -start {} -end {}
3844 lappend res [.t index end]
3845 set res
3846 } {101.0 0 11.0 0 31.0 101.0}
3847
3848 test text-32.1 {peer widget -start, -end and selection} {
3849 .t delete 1.0 end
3850 for {set i 1} {$i < 100} {incr i} {
3851 .t insert end "Line $i\n"
3852 }
3853 .t tag add sel 10.0 20.0
3854 set res {}
3855 lappend res [.t tag ranges sel]
3856 .t configure -start 5 -end 30
3857 lappend res [.t tag ranges sel]
3858 .t configure -start 5 -end 15
3859 lappend res [.t tag ranges sel]
3860 .t configure -start 15 -end 30
3861 lappend res [.t tag ranges sel]
3862 .t configure -start 15 -end 16
3863 lappend res [.t tag ranges sel]
3864 .t configure -start 25 -end 30
3865 lappend res [.t tag ranges sel]
3866 .t configure -start {} -end {}
3867 lappend res [.t tag ranges sel]
3868 set res
3869 } {{10.0 20.0} {6.0 16.0} {6.0 11.0} {1.0 6.0} {1.0 2.0} {} {10.0 20.0}}
3870
3871 test text-33.1 {widget dump -command alters tags} {
3872 .t delete 1.0 end
3873 .t insert end "abc\n" a "---" {} "def" b " \n" {} "ghi\n" c
3874 .t tag configure b -background red
3875 proc Dumpy {key value index} {
3876 #puts "KK: $key, $value"
3877 .t tag add $value [list $index linestart] [list $index lineend]
3878 }
3879 .t dump -all -command Dumpy 1.0 end
3880 set result "ok"
3881 } {ok}
3882 test text-33.2 {widget dump -command makes massive changes} {
3883 .t delete 1.0 end
3884 .t insert end "abc\n" a "---" {} "def" b " \n" {} "ghi\n" c
3885 .t tag configure b -background red
3886 proc Dumpy {key value index} {
3887 #puts "KK: $key, $value"
3888 .t delete 1.0 end
3889 }
3890 .t dump -all -command Dumpy 1.0 end
3891 set result "ok"
3892 } {ok}
3893 test text-33.3 {widget dump -command destroys widget} {
3894 .t delete 1.0 end
3895 .t insert end "abc\n" a "---" {} "def" b " \n" {} "ghi\n" c
3896 .t tag configure b -background red
3897 proc Dumpy {key value index} {
3898 #puts "KK: $key, $value"
3899 destroy .t
3900 }
3901 .t dump -all -command Dumpy 1.0 end
3902 set result "ok"
3903 } {ok}
3904
3905 deleteWindows
3906 option clear
3907
3908 # cleanup
3909 cleanupTests
3910 return
3911
3912 __END__