1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
|
'\"
'\" Copyright (c) 1992 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH text n 8.5 Tk "Tk Built-In Commands"
.so man.macros
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
text, \%tk_mergeRange, \%tk_textCopy, \%tk_textCut, \%tk_textInsert, \%tk_textPaste, \%tk_textRebindMouseWheel, \%tk_textReplace \- Create and manipulate 'text' hypertext editing widgets
.SH SYNOPSIS
.nf
\fBtext\fR \fIpathName \fR?\fIoptions\fR?
\fBtk_mergeRange \fIvarName range\fR
\fBtk_textCopy\fR \fIpathName\fR
\fBtk_textCut\fR \fIpathName\fR
\fBtk_textInsert\fR \fIpathName\fR ?\fB\-hyphentags\fI tagList\fR? \fIindex chars\fR ?\fItagList chars tagList ...\fR?
\fBtk_textPaste\fR \fIpathName\fR
\fBtk_textRebindMouseWheel\fR \fIpathName\fR ?\fIpathName ...\fR?
\fBtk_textReplace\fR \fIpathName\fR ?\fB\-hyphentags\fR \fItagList\fR? \fIindex chars\fR ?\fItagList chars tagList ...\fR?
.SO
\-background \-highlightthickness \-relief
\-borderwidth \-insertbackground \-selectbackground
\-cursor \-insertborderwidth \-selectborderwidth
\-exportselection \-insertofftime \-selectforeground
\-font \-insertontime \-setgrid
\-foreground \-insertwidth \-takefocus
\-highlightbackground \-padx \-xscrollcommand
\-highlightcolor \-pady \-yscrollcommand
.SE
.SH "WIDGET-SPECIFIC OPTIONS"
.OP \-autoseparators autoSeparators AutoSeparators
Specifies a boolean that says whether separators are automatically inserted in
the undo stack. Only meaningful when the \fB\-undo\fR option is true.
.OP \-blockcursor blockCursor BlockCursor
Specifies a boolean that says whether the blinking insertion cursor should be
drawn as a character-sized rectangular block. If false (the default) a thin
vertical line is used for the insertion cursor. See section \fBTHE INSERTION CURSOR\fR
for more details.
.OP \-eolchar eolChar EolChar
Specifies the character to use when displaying the end of line symbol
(see option \fB\-showendofline\fR). An empty argument will force the use of
the default symbol (U+00B6 = PILCROW SIGN).
.OP \-eolcolor eolColor EolColor
Specifies the foreground color to use when displaying the end of line symbol
(see option \fB\-showendofline\fR). An empty argument will force the use of
the foreground color (set with \fB\-foreground\fR; this is the default).
.OP \-eotchar eotChar EotChar
Specifies the character to use when displaying the end of text symbol
(see option \fB\-showendoftext\fR). An empty argument will force the use of
the same symbol as used for showing the end of line symbol (see \fB\-eolchar\fR).
.OP \-eotcolor eotColor EotColor
Specifies the foreground color to use when displaying the end of text symbol
(see option \fB\-showendoftext\fR). An empty argument will force the use
of the same color as used for the end of line symbol (see \fB\-eolcolor\fR).
.OP \-hyphencolor hyphenColor HyphenColor
Specifies the foreground color to use when displaying the soft hyphen
character (U+00AD). An empty argument will force the use of the foreground
color (set with \fB\-foreground\fR; this is the default).
.OP \-endindex endIndex EndIndex
Specifies an index representing the end of the underlying textual data store
that should be contained in the widget. This allows a text widget to reflect
only a portion of a larger piece of text. Instead of an index, the empty string
can be provided to this configuration option, which will configure the widget
to the end index in the textual data store. Instead of an empty string the
special index specifier \fBend\fR can be used.
.OP \-endline endLine EndLine
Note that this option is deprecated, option \fB\-endindex\fR should be used
instead. For compatibility reasons this option still will be supported, but
may be removed in a future version.
.PP
.RS
Specifies an integer line index representing the line of the underlying
textual data store that should be just after the last line contained in
the widget. This allows a text widget to reflect only a portion of a
larger piece of text. Instead of an integer, the empty string can be
provided to this configuration option, which will configure the widget
to end at the very last line in the textual data store.
.RE
.OP \-height height Height
Specifies the desired height for the window, in units of characters in the
font given by the \fB\-font\fR option. Must be at least one.
.OP \-inactiveselectbackground inactiveSelectBackground Foreground
Specifies the colour to use for the selection (the \fBsel\fR tag) when the
window does not have the input focus. If empty, \fB{}\fR, then no selection is
shown when the window does not have the focus.
.OP \-inactiveselectforeground inactiveSelectForeground Foreground
Specifies the foreground colour to use for the selection (the \fBsel\fR tag)
when the window does not have the input focus. If empty, \fB{}\fR, then the
colour specified with widget option \fB\-selectforeground\fR will be used.
.OP \-hyphenrules hyphenRules HyphenRules
Specifies a list of spelling change rules for hyphenated words, given by the
identifier of the rules. Only the rules given with this set will be used for
spelling changes. Per default the set of rules is empty, this means that all
rules are allowed. The rules are important when command \%\fBtk_textInsert\fR
(or \%\fBtk_textReplace\fR) will be used with automatic spelling changes. An
exception will be thrown if one of the given rules is not defined. See
section for more details \fBHYPHENATION RULES\fR about the defined rules.
.RS
.PP
If also option \fB\-lang\fR is specified for a particular soft hyphen, then
only the rules belonging to this language will be applied to this soft
hyphen. This supports simpler hyphenators, not knowing spelling changes.
.PP
This is the way how the hyphen rules will be applied (
.QW "\e+"
denotes the soft hyphen character):
.IP "\fBck\fR"
If the soft hyphen is the right neighbor of character
.QW c ,
and the right neighbor is character
.QW k ,
then the \fBck\fR hyphenation rule will be
applied to this hyphen. Example: the German word
.QW Druc\e+ker
hyphenates into
.QW Druk-ker .
This rule belongs to language German (de).
.IP "\fBgemination\fR"
If the soft hyphen is the left neighbor of a geminated letter 'l' (or 'L'),
then the \fBgemination\fR hyphenation rule will be applied. Example: the
Catalan word
.QW para\e+l\N'183'lel
hyphenates into
.QW paral-lel .
This rule belongs to the Catalan language (ca).
.IP "\fBdoublevowel\fR"
If the soft hyphen is the right neighbor of any vowel, and the right
neighbor is the same vowel, then the \fBdoublevowel\fR hyphenation rule will
be applied to this hyphen. If this vowel is an
.QW e
then a conversion to e-acute will be done. Example: the Dutch word
.QW opaa\e+tje
hyphenates into
.QW opa-tje ,
and
.QW cafee\e+tje
becomes
.QW caf\['e]-tje .
This rule belongs to the Dutch language (nl).
.IP "\fBdoubledigraph\fR"
In Polish language the following spelling change will be applied with this
rule:
.QW c\e+cs
becomes
.QW cs-cs ,
.QW g\e+gy
becomes
.QW gy-gy ,
.QW l\e+ly
becomes
.QW ly-ly ,
.QW n\e+ny
becomes
.QW ny-ny ,
.QW t\e+ty
becomes
.QW ty-ty ,
.QW z\e+zs
becomes
.QW zs-zs ,
and
.QW s\e+sz
becomes
.QW sz-sz .
.IP "\fBrepeathyphen\fR"
In Polish the hyphen will be repeated after line break, this means for
example that
.QW tech\e+nik
becomes
.QW "tech- -nik" .
.IP "\fBtrema\fR"
If the soft hyphen is the right neighbor of any vowel, and the right neighbor
of any vowel with trema (umlaut), then the \fBtrema\fR hyphenation rule will
be applied to this hyphen. Example: the Dutch word
.QW re\e+\[:e]el
hyphenates into
.QW re-eel .
This rule belongs to the Dutch language (nl).
.IP "\fBtripleconsonant\fR"
If the soft hyphen is the right neighbor of a double consonant, and the
right neighbor is the same consonant, and this consonant is followed by a
vowel (or by letter
.QW j
\- Norwegian), then the \fBtripleconsonant\fR
hyphenation rule will be applied when \fBnot\fR hyphenating at this point.
Examples: the German word
.QW Schiff\e+fahrt
hyphenates into
.QW Schiff-fahrt ,
but will be written
.QW Schiffahrt
when no hyphenation will be done. The Swedish word
.QW tugg\e+gummi
becomes
.QW tuggummi ,
and the Norwegian word
.QW buss\e+sj\[oa]f\[/o]r
becomes
.QW "bussj\[oa]f\[/o]r" .
This rule belongs to languages German (de), Norwegian (no, nb, nn), and
Swedish (sv).
.RE
.OP \-hyphens hyphens Hyphens
Specifies a boolean indicating whether the hyphenation support will be
activated. If activated, then in state \fBnormal\fR or \fBreadonly\fR the
soft hyphen (Unicode point U+00AD) \- also called SHY \- will be invisible
unless it is used at line end for displaying a hyphen character in case of
dividing a word for line adjusting. If the widget is in state \fBnormal\fR
then the hyphen will be displayed like a normal character (with codepoint
U+2010), it will not be used for hyphenation (but may be used for line
wrapping, depending on the value of option \fB\-wrap\fR).
.OP \-insertforeground insertForeground InsertForeground
Specifies the color to use as foreground for the characters in the area
covered by the insertion cursor. This color will not be overridden with
tagging options. Note that this color will not be used unless option
\fB\-showinsertforeground\fR is enabled.
.OP \-insertunfocussed insertUnfocussed InsertUnfocussed
.VS 8.6
Specifies how to display the insertion cursor when the widget does not have
the focus. Must be \fBnone\fR (the default) which means to not display the
cursor, \fBhollow\fR which means to display a hollow box, or \fBsolid\fR which
means to display a solid box. Note that \fBhollow\fR and \fBsolid\fR will
appear very similar when the \fB\-blockcursor\fR option is false.
.VE 8.6
.OP \-justify justify Justify
Setting the style how lines will be justified. This style will be used for
the whole text, even for wrapped lines, but tags may override this style for
individual lines.
.RS
.PP
The following styles are possible:
.IP "\fBleft\fR"
The text is aligned along the left margin. This is the default.
.IP "\fBright\fR"
The text is aligned along the right margin.
.IP "\fBfull\fR"
The text is aligned along the left margin, and word-spacing is adjusted so
that the text flush with both margins.
.IP "\fBcenter\fR"
The text is aligned to neither the left nor the right margin, there is an
even gap on each side of each line.
.RE
.OP \-lang lang Lang
Setting the language code of the text content. The language code will be
used for line breaking (but only if option \fB\-useunibreak\fR is also set),
and it may be used to restrict the hyphenation rules (see
\fB\-hyphenrules\fR). An empty string is unsetting the language.
.RS
.PP
The language code will be specified as ISO 639-1 code. The language code
will not be verified, but it must be a string with two consecutive lowercase
letters (for example
.QW en
), or an empty string, otherwise an error will be thrown.
.RE
.OP \-maxredo maxRedo MaxRedo
Specifies the maximum number of redo actions on the undo stack. A zero value
will prevent any redo action, only undoes are possible. A negative value
imply an unlimited number of redo actions (this is the default; note that
the number of redo actions is always bound by the number of undo actions on
the stack). Setting a lower positive value (including zero) than the
previous (positive) number will reduce the redo stack immediately.
.RS
.PP
This option is especially useful for setting an undo stack without redo
capability; this means that in practice normally only the values -1 and 0
(zero) are useful (redo capability is on or off). When using a value greater
than zero, mind that as soon as the redo stack size exceeds, all the redo
items on the stack must expire (and will be deleted).
.RE
.OP \-maxundo maxUndo MaxUndo
Specifies the maximum number of compound undo actions on the undo stack. A
zero or a negative value imply an unlimited number of compound undo actions.
Setting a lower value (greater than zero) than the previous (positive)
number will reduce the stack immediately.
.OP \-maxundosize maxUndoSize MaxUndoSize
Specifies the maximal number of bytes stored on the undo stack, only
characters will be counted (the byte size of the characters), and also
embedded images and windows (each embedded item will be count with byte size
one). A zero or a negative value imply an unlimited number of bytes. If a
positive (non-zero) number of bytes is defined, option \fB\-maxundosize\fR
will have a higher priority than option \fB\-maxundo\fR. Setting a number of
bytes less than the number of bytes currently kept on the stack will not
immediately reduce the stack.
.OP \-responsiveness responsiveness Responsiveness
Specifies the delay before the widget will repick (sending
enter/leave/motion events when entering/leaving/hovering tagged regions)
after scroll operations. The default value is 50 milliseconds. When setting
the value to zero (or less than zero) the repick will be done immediately.
The higher the responsiveness, the less the display will flicker while the
widget is scrolling.
.OP \-showendofline showEndOfLine ShowEndOfLine
Specifies a boolean value determining whether manual line breaks (
.QW \en
) will be emphasized with an end of line symbol (default is U+00B6 =
PILCROW SIGN) at the end of the line, in this case that symbol does not
belong to the text content and cannot be edited or selected. Per default the
end of line symbol will not be shown.
.OP \-showendoftext showEndOfText ShowEndOfText
If this option is enabled the end of the text (after end of very last line)
will be emphasized with an end of text symbol (per default this is the end of
line symbol). This symbol does not belong to the text content and cannot
be edited or selected. Per default the end of text symbol will not be shown.
.OP \-showinsertforeground showInsertForeground ShowInsertForeground
Use color option \fB\-insertforeground\fR for the foreground of characters
covered by the insert cursor if this option is enabled, otherwise the color
of the characters will not change when coverd by the insertion cursor. Per
default this option is disabled.
.OP \-spacemode spaceMode SpaceMode
Specifies the mode how spaces (U+0020) will be displayed. Default is
\fBnone\fR, this means that spaces will be displayed like any character, but
when breaking lines at a space this space will be gobbled if option
\fB\-wrap\fR is set to \fBword\fR or \fBcodepoint\fR (this is the common
behavior of text editors). When setting to \fBexact\fR, no space character
will be gobbled at all, even when breaking lines. Mode \fBtrim\fR may be
used for trimming consecutive space characters, but a single space will
never be trimmed, instead it will be gobbled when a line break happens at
this space (if option \fB\-wrap\fR is set to \fBword\fR or \fBcodepoint\fR).
Normally the latter mode will not be used in conjunction with state
\fBnormal\fR (see option \fB\-state\fR).
.OP \-spacing1 spacing1 Spacing1
Requests additional space above each text line in the widget, using any of the
standard forms for screen distances. If a line wraps, this option only applies
to the first line on the display. This option may be overridden with
\fB\-spacing1\fR options in tags.
.OP \-spacing2 spacing2 Spacing2
For lines that wrap (so that they cover more than one line on the display)
this option specifies additional space to provide between the display lines
that represent a single line of text. The value may have any of the standard
forms for screen distances. This option may be overridden with
\fB\-spacing2\fR options in tags.
.OP \-spacing3 spacing3 Spacing3
Requests additional space below each text line in the widget, using any of the
standard forms for screen distances. If a line wraps, this option only applies
to the last line on the display. This option may be overridden with
\fB\-spacing3\fR options in tags.
.OP \-startindex startIndex StartIndex
Specifies an index representing the start of the underlying textual data store
that should be contained in the widget. This allows a text widget to reflect only
a portion of a larger piece of text. Instead of an index, the empty string can be
provided to this configuration option, which will configure the widget to the
start index in the textual data store. Instead of an empty string the special
index specifier \fBbegin\fR can be used.
.OP \-startline startLine StartLine
Note that this option is deprecated, option \fB\-startindex\fR should be used
instead. For compatibility reasons this option still will be supported, but
may be removed in a future version.
.PP
.RS
Specifies an integer line index representing the first line of the underlying
textual data store that should be contained in the widget. This allows a text
widget to reflect only a portion of a larger piece of text. Instead of an
integer, the empty string can be provided to this configuration option, which
will configure the widget to start at the very first line in the textual data
store.
.RE
.OP \-state state State
Specifies one of three states for the text: \fBnormal\fR, \fBdisabled\fR, or
\fBreadonly\fR. If the text is disabled then characters may not be inserted
or deleted and no insertion cursor will be displayed, even if the input
focus is in the widget. If the state is readonly then characters can be
inserted and deleted, but the widget does not receive any modifications from
GUI, the user cannot delete or insert, and no insertion cursor will be
displayed.
.RS
.PP
When hyphenation support is enabled (widget option \fB\-hyphens\fR)
switching the state to \fBnormal\fR is re-displaying the text content
without the use of soft hyphens for line break. Switching the state back to
\fBreadonly\fR, or \fBdisabled\fR, is re-displaying the content regarding
soft hyphens for possible line breaks.
.RE
.OP \-steadymarks steadyMarks SteadyMarks
This option, if activated, will change the behavior of marks. Every mark now
behaves simultaneously as an invisible character. One side effect is
that the gravity will also apply to the insertion of marks. Another side
effect is that every reference specified by a mark now will reference the
pseudo-character position of that mark. (But it is important to mention
that the real character position count will not be affected.)
.RS
.PP
The change of this behavior will apply to all peers of this widget, it's not
possible to have a different behavior in different peers.
.PP
This option cannot be set if the widget is not overall clean (see command
\fBisclean \-overall\fR), an error will be thrown if this is not satisified.
(It is not useful to switch this option, or setting this option, if the
widget is not overall clean, this may cause errors in the order of the
marks, therefore this is forbidden.)
.PP
This option is facilitating programmed editor control, because the shuffle
effect is eliminated, any every mark now has a defined order relative to other
marks, this order is not changing as long as the mark will not be moved with
\fBmark set\fR. Note that the handling of marks, especially the change of
the gravity, will be performed more efficiently when this option is
activated.
.RE
.OP \-synctime syncTime SyncTime
Specifies the timeout in milliseconds of the asynchronous line metrics
calculation after any change which is affecting the geometry. Note that the
calculation will be splitted into short line ranges (except if timeout is
zero). The default value is 150 and will be changed only in seldom cases.
For most applications this value offers a good responsiveness, and gives the
impression of a better performance, compared to the behavior with a low
timeout.
.RS
.PP
When set to zero the line metrics update will be performed synchronous; this
means the whole update will be performed immediately; with most applications
this behavior would cause performance problems. When set to 1 the
computation is already asynchronous, but the computation starts with each
event loop cycle (this may also cause performance problems).
.RE
.OP \-tabs tabs Tabs
Specifies a set of tab stops for the window. The option's value consists of a
list of screen distances giving the positions of the tab stops, each of which
is a distance relative to the left edge of the widget (excluding borders,
padding, etc). Each position may optionally be followed in the next list
element by one of the keywords \fBleft\fR, \fBright\fR, \fBcenter\fR, or
\fBnumeric\fR, which specifies how to justify text relative to the tab stop.
\fBLeft\fR is the default; it causes the text following the tab character to
be positioned with its left edge at the tab position. \fBRight\fR means that
the right edge of the text following the tab character is positioned at the
tab position, and \fBcenter\fR means that the text is centered at the tab
position. \fBNumeric\fR means that the decimal point in the text is positioned
at the tab position; if there is no decimal point then the least significant
digit of the number is positioned just to the left of the tab position; if
there is no number in the text then the text is right-justified at the tab
position. For example,
.QW "\fB\-tabs {2c left 4c 6c center}\fR"
creates three tab stops at two-centimeter intervals; the first two use left
justification and the third uses center justification.
.RS
.PP
If the list of tab stops does not have enough elements to cover all of the
tabs in a text line, then Tk extrapolates new tab stops using the spacing and
alignment from the last tab stop in the list. Tab distances must be strictly
positive, and must always increase from one tab stop to the next (if not, an
error is thrown). The value of the \fB\-tabs\fR option may be overridden by
\fB\-tabs\fR options in tags.
.PP
If no \fB\-tabs\fR option is specified, or if it is specified as an empty
list, then Tk uses default tabs spaced every eight (average size) characters.
To achieve a different standard spacing, for example every 4 characters,
simply configure the widget with
.QW "\fB\-tabs \N'34'[expr {4 * [font measure $font 0]}] left\N'34' \-tabstyle wordprocessor\fR" .
.RE
.OP \-tabstyle tabStyle TabStyle
Specifies how to interpret the relationship between tab stops on a line and
tabs in the text of that line. The value must be \fBtabular\fR (the default)
or \fBwordprocessor\fR. Note that tabs are interpreted as they are encountered
in the text. If the tab style is \fBtabular\fR then the \fIn\fR'th tab
character in the line's text will be associated with the \fIn\fR'th tab stop
defined for that line. If the tab character's x coordinate falls to the right
of the \fIn\fR'th tab stop, then a gap of a single space will be inserted as a
fallback. If the tab style is \fBwordprocessor\fR then any tab character being
laid out will use (and be defined by) the first tab stop to the right of the
preceding characters already laid out on that line. The value of the
\fB\-tabstyle\fR option may be overridden by \fB\-tabstyle\fR options in tags.
.OP \-tagging tagging Tagging
Setting the mode how characters will be tagged when inserting text without
explicit tagging information.
.RS
.PP
The following modes are defined:
.IP "\fBwithin\fR"
The new text will receive any tags that are present on both before and after
the insertion point, regardless whether it's a character (including the
invisible newline), a soft hyphen, an embedded window, or an embedded image;
if a tag is present on only one of these characters (windows, or images)
then it will not be applied to the new text. This is the default tagging
mode (and the way how the older versions of the text widget worked).
.IP "\fBgravity\fR"
The new text will receive any tags that are present at one side of the
insertion point: if the insert cursor has right gravity then the text will
receive the tags of the character after the insertion point (including the
invisible newline), otherwise, if the insertion cursor has left gravity, it
will receive the tags of the character before the insertion point (Arabian
mode), but only if a preceding character exists in this line. This mode is
commonly used in some text editors.
.IP "\fBnone\fR"
The new text will not receive any tags from surrounded text.
.RE
.OP \-undo undo Undo
Specifies a boolean that says whether the undo mechanism is active or not.
.OP \-width width Width
Specifies the desired width for the window in units of characters in the font
given by the \fB\-font\fR option. If the font does not have a uniform width
then the width of the character
.QW 0
is used in translating from character units to screen units.
.OP \-useunibreak useUniBreak UseUniBreak
If this option is enabled then wrap mode \fBcodepoint\fR (see option
\fB\-wrap\fR) will use the external library \fIlibunibreak\fR (from Wu Yongwei)
for the computation of line breaks, but only if this library is available
(currently only UNIX). This library even supports language dependent line
breaking. Otherwise, if this option is not enabled, or if \fIlibunibreak\fR is not
available, a simpler algorithm (also based on the recommendations of the
Unicode consortium, but restricted to Latin-1 and most non-language
dependent characters, without regarding combined marks, and without language
support) will be used for the computation of the breaks. Per default this
option is not enabled.
.RS
.PP
For a simple test whether the unibreak libary is available see command \fBbrks\fR.
.RE
.OP \-wrap wrap Wrap
Specifies how to handle lines in the text that are too long to be displayed
in a single line of the text's window. The value must be \fBnone\fR,
\fBchar\fR, \fBword\fR, or \fBcodepoint\fR. A wrap mode of \fBnone\fR means
that each line of text appears as exactly one line on the screen; extra
characters that do not fit on the screen are not displayed. In the other
modes each line of text will be broken up into several screen lines if
necessary to keep all the characters visible. In \fBchar\fR mode a screen
line break may occur after any character; in \fBword\fR mode a line break
will only be made at word boundaries. The elaborated mode \fBcodepoint\fR is
based on Unicode code points, and conforms exactly (with \fIlibunibreak\fR) or
mostly (with internal algorithm) to the recommendations of the Unicode
consortium. If option \fB\-useunibreak\fR is set, then the unibreak library
(from Wu Yongwei) will be used for the line break computation. This library
even supports language dependent line breaking (see option \fB\-lang\fR for
language support). Otherwise, if \fB\-useunibreak\fR is not set, or if the
unibreak library is not available, a simpler algorithm \- also based on the
recommendations of the Unicode consortium, but restricted to Latin-1 and
most non-language dependent characters, without regarding combined marks,
and without language support \- will be used for the computation of the
breaks.
.BE
.SH DESCRIPTION
.PP
The \fBtext\fR command creates a new window (given by the \fIpathName\fR
argument) and makes it into a text widget. Additional options, described
above, may be specified on the command line or in the option database to
configure aspects of the text such as its default background color and relief.
The \fBtext\fR command returns the path name of the new window.
.PP
A text widget displays one or more lines of text and allows that text to be
edited. Text widgets support four different kinds of annotations on the text,
called tags, marks, embedded windows or embedded images. Tags allow different
portions of the text to be displayed with different fonts and colors. In
addition, Tcl commands can be associated with tags so that scripts are invoked
when particular actions such as keystrokes and mouse button presses occur in
particular ranges of the text. See \fBTAGS\fR below for more details.
.PP
The second form of annotation consists of floating markers in the text called
.QW marks .
Marks are used to keep track of various interesting positions in the text as
it is edited. See \fBMARKS\fR below for more details.
.PP
The third form of annotation allows arbitrary windows to be embedded in a text
widget. See \fBEMBEDDED WINDOWS\fR below for more details.
.PP
The fourth form of annotation allows Tk images to be embedded in a text
widget. See \fBEMBEDDED IMAGES\fR below for more details.
.PP
The text widget also has a built-in undo/redo mechanism. See
\fBTHE UNDO MECHANISM\fR below for more details.
.PP
The text widget allows for the creation of peer widgets. These are other text
widgets which share the same underlying data (text, marks, tags, images, etc).
See \fBPEER WIDGETS\fR below for more details.
.SH INDICES
.PP
Many of the widget commands for texts take one or more indices as arguments.
An index is a string used to indicate a particular place within a text, such
as a place to insert characters or one endpoint of a range of characters to
delete. Indices have the syntax
.PP
.CS
\fIbase modifier modifier modifier ...\fR
.CE
.PP
Where \fIbase\fR gives a starting point and the \fImodifier\fRs adjust the
index from the starting point (e.g. move forward or backward one character).
Every index must contain a \fIbase\fR, but the \fImodifier\fRs are optional.
Most modifiers (as documented below) allow an optional submodifier. Valid
submodifiers are \fBany\fR and \fBdisplay\fR. If the submodifier is
abbreviated, then it must be followed by whitespace, but otherwise there need
be no space between the submodifier and the following \fImodifier\fR.
Typically the \fBdisplay\fR submodifier adjusts the meaning of the following
\fImodifier\fR to make it refer to visual or non-elided units rather than
logical units, but this is explained for each relevant case below. Lastly,
where \fIcount\fR is used as part of a modifier, it can be positive or
negative, so
.QW "\fIbase\fR \- \-3 lines"
is perfectly valid (and equivalent to
.QW "\fIbase\fR +3lines" ).
.PP
The \fIbase\fR for an index must have one of the following forms:
.TP 12
\fIline\fB.\fIchar\fR
.
Indicates \fIchar\fR'th character on line \fIline\fR. Lines are numbered from
1 for consistency with other UNIX programs that use this numbering scheme.
Within a line, characters are numbered from 0. If \fIchar\fR is \fBend\fR then
it refers to the newline character that ends the line, and if \fIchar\fR is \fBbegin\fR
then it refers the first character at start of the line.
.TP 12
\fB@\fIx\fB,\fIy\fR
.
Indicates the character that covers the pixel whose x and y coordinates within
the text's window are \fIx\fR and \fIy\fR.
.TP 12
\fBbegin\fR
.
Indicates the start of the text (the character just at the start of the first line).
.TP 12
\fBend\fR
.
Indicates the end of the text (the character just after the last newline).
.TP 12
\fImark\fR
.
Indicates the character just after the mark whose name is \fImark\fR.
.TP 12
\fItag\fB.first\fR
.
Indicates the first character in the text that has been tagged with \fItag\fR.
This form generates an error if no characters are currently tagged with
\fItag\fR.
.TP 12
\fItag\fB.last\fR
.
Indicates the character just after the last one in the text that has been
tagged with \fItag\fR. This form generates an error if no characters are
currently tagged with \fItag\fR.
.TP 12
\fItag\fB.current.first\fR
.
Indicates the first character in the region (a connected span of text sharing
the same \fItag\fR) nearby the current mark (it is left from, right from,
or inside the tagged region) that has been tagged with \fItag\fR. This form
generates an error if no character is currently tagged with \fItag\fR
nearby the current mark.
.TP 12
\fItag\fB.current.last\fR
.
Indicates the character just after the last one in the region (a connected span
of text sharing the same \fItag\fR) nearby the current mark (it is left from,
right from, or inside the tagged region) that has been tagged with \fItag\fR.
This form generates an error if no character is currently tagged with \fItag\fR
nearby the current mark.
.TP 12
\fIpathName\fR
.
Indicates the position of the embedded window whose name is \fIpathName\fR.
This form generates an error if there is no embedded window by the given name.
.TP 12
\fIimageName\fR
.
Indicates the position of the embedded image whose name is \fIimageName\fR.
This form generates an error if there is no embedded image by the given name.
.PP
If the \fIbase\fR could match more than one of the above forms, such as a
\fImark\fR and \fIimageName\fR both having the same value, then the form
earlier in the above list takes precedence. If modifiers follow the base
index, each one of them must have one of the forms listed below. Keywords such
as \fBchars\fR and \fBwordend\fR may be abbreviated as long as the
abbreviation is unambiguous.
.TP
\fB+ \fIcount\fR ?\fIsubmodifier\fR? \fBchars\fR
.
Adjust the index forward by \fIcount\fR characters, moving to later lines in
the text if necessary. If there are fewer than \fIcount\fR characters in the
text after the current index, then set the index to the last index in the
text. Spaces on either side of \fIcount\fR are optional. If the \fBdisplay\fR
submodifier is given, elided characters are skipped over without being
counted. If \fBany\fR is given, then all characters are counted.
.TP
\fB\- \fIcount\fR ?\fIsubmodifier\fR? \fBchars\fR
.
Adjust the index backward by \fIcount\fR characters, moving to earlier lines
in the text if necessary. If there are fewer than \fIcount\fR characters in
the text before the current index, then set the index to the first index in
the text (1.0). Spaces on either side of \fIcount\fR are optional. If the
\fBdisplay\fR submodifier is given, elided characters are skipped over without
being counted. If \fBany\fR is given, then all characters are counted.
.TP
\fB+ \fIcount\fR ?\fIsubmodifier\fR? \fBindices\fR
.
Adjust the index forward by \fIcount\fR index positions, moving to later lines
in the text if necessary. If there are fewer than \fIcount\fR index positions
in the text after the current index, then set the index to the last index
position in the text. Spaces on either side of \fIcount\fR are optional. Note
that an index position is either a single character or a single embedded image
or embedded window. If the \fBdisplay\fR submodifier is given, elided indices
are skipped over without being counted. If \fBany\fR is given, then all
indices are counted; this is also the default behaviour if no modifier is
given.
.TP
\fB\- \fIcount\fR ?\fIsubmodifier\fR? \fBindices\fR
.
Adjust the index backward by \fIcount\fR index positions, moving to earlier
lines in the text if necessary. If there are fewer than \fIcount\fR index
positions in the text before the current index, then set the index to the
first index position (1.0) in the text. Spaces on either side of \fIcount\fR
are optional. If the \fBdisplay\fR submodifier is given, elided indices are
skipped over without being counted. If \fBany\fR is given, then all indices
are counted; this is also the default behaviour if no modifier is given.
.TP
\fB+ \fIcount\fR ?\fIsubmodifier\fR? \fBlines\fR
.
Adjust the index forward by \fIcount\fR lines, retaining the same position
within the line. If there are fewer than \fIcount\fR lines after the
line containing the current index, then set the index to refer to the same
position on the last line of the text. Then, if the line is not long enough
to contain a character at the indicated position, adjust the character position
to refer to the last character of the line (the newline). Spaces on either side
of \fIcount\fR are optional.
.RS
.PP
If the \fBdisplay\fR submodifier is given, then each visual display line is
counted separately, and in this case the position is determined by the
current pixel position.
.PP
Otherwise, if \fBany\fR (or no modifier) is given, then each logical line
(no matter how many times it is visually wrapped) counts just once, and the
position is determined by the character position.
.RE
.TP
\fB\- \fIcount\fR ?\fIsubmodifier\fR? \fBlines\fR
.
Adjust the index backward by \fIcount\fR logical lines, retaining the same
position within the line. If there are fewer than \fIcount\fR lines before
the line containing the current index, then set the index to refer to the
same position on the first line of the text. Then, if the line is not long
enough to contain a character at the indicated position, adjust the character
position to refer to the last character of the line (the newline). Spaces
on either side of \fIcount\fR are optional.
.RS
.PP
If the \fBdisplay\fR submodifier is given, then each visual display line is
counted separately, and in this case the character position is determined
by the current pixel position.
.PP
Otherwise, if \fBany\fR (or no modifier) is given, then each logical line
(no matter how many times it is visually wrapped) counts just once, and the
character position is determined by the index position.
.RE
.TP
?\fIsubmodifier\fR? \fBlinestart\fR
.
Adjust the index to refer to the first index on the line. If the \fBdisplay\fR
submodifier is given, this is the first index on the display line, otherwise
on the logical line.
.TP
?\fIsubmodifier\fR? \fBlineend\fR
.
Adjust the index to refer to the last index on the line (the newline). If the
\fBdisplay\fR submodifier is given, this is the last index on the display
line, otherwise on the logical line.
.TP
?\fIsubmodifier\fR? \fBwordstart\fR
.
Adjust the index to refer to the first character of the word containing the
current index. A word consists of any number of adjacent characters that are
letters, digits, or underscores, or a single character that is not one of
these. If the \fBdisplay\fR submodifier is given, this only examines
non-elided characters, otherwise all characters (elided or not) are examined.
.TP
?\fIsubmodifier\fR? \fBwordend\fR
.
Adjust the index to refer to the character just after the last one of the word
containing the current index. If the current index refers to the last
character of the text then it is not modified. If the \fBdisplay\fR
submodifier is given, this only examines non-elided characters, otherwise all
characters (elided or not) are examined.
.PP
If more than one modifier is present then they are applied in left-to-right
order. For example, the index
.QW "\fBend \- 1 chars\fR"
refers to the next-to-last character in the text and
.QW "\fBinsert wordstart \- 1 c\fR"
refers to the character just before the first one in the word containing the
insertion cursor. Modifiers are applied one by one in this left to right
order, and after each step the resulting index is constrained to be a valid
index in the text widget. So, for example, the index
.QW "\fB1.0 \-1c +1c\fR"
refers to the index
.QW \fB2.0\fR .
.PP
Where modifiers result in index changes by display lines, display chars or
display indices, and the \fIbase\fR refers to an index inside an elided tag,
that base index is considered to be equivalent to the first following
non-elided index.
.SH TAGS
.PP
The first form of annotation in text widgets is a tag. A tag is a textual
string that is associated with some of the characters in a text. Tags may
contain arbitrary characters, but it is probably best to avoid using the
characters
.QW " "
(space),
.QW \fC@\fR ,
.QW \fC.\fR ,
.QW \fC+\fR ,
or
.QW \fC\-\fR :
these characters have special
meaning in indices, so tags containing them cannot be used as indices. There
may be any number of tags associated with characters in a text. Each tag may
refer to a single character, a range of characters, or several ranges of
characters. An individual character may have any number of tags associated
with it.
.PP
A priority order is defined among tags, and this order is used in implementing
some of the tag-related functions described below. When a tag is defined (by
associating it with characters or setting its display options or binding
commands to it), it is given a priority higher than any existing tag. The
priority order of tags may be redefined using the
.QW "\fIpathName \fBtag raise\fR"
and
.QW "\fIpathName \fBtag lower\fR"
widget commands.
.PP
Tags serve three purposes in text widgets. First, they control the way
information is displayed on the screen. By default, characters are displayed
as determined by the \fB\-background\fR, \fB\-font\fR, and \fB\-foreground\fR
options for the text widget. However, display options may be associated with
individual tags using the
.QW "\fIpathName \fBtag configure\fR"
widget command. If a character has been tagged, then the display options
associated with the tag override the default display style. The following
options are currently supported for tags:
.TP
\fB\-background \fIcolor\fR
.
\fIColor\fR specifies the background color to use for characters associated
with the tag. It may have any of the forms accepted by \fBTk_GetColor\fR.
.TP
\fB\-bgstipple \fIbitmap\fR
.
\fIBitmap\fR specifies a bitmap that is used as a stipple pattern for the
background. It may have any of the forms accepted by \fBTk_GetBitmap\fR. If
\fIbitmap\fR has not been specified, or if it is specified as an empty string,
then a solid fill will be used for the background.
.TP
\fB\-borderwidth \fIpixels\fR
.
\fIPixels\fR specifies the width of a border to draw around the tag using any
of the forms accepted by \fBTk_GetPixels\fR. This option should be used in
conjunction with the \fB\-relief\fR option to provide the desired border.
.TP
\fB\-elide \fIboolean\fR
.
\fIElide\fR specifies whether the data should be elided. Elided data (characters,
soft hyphens, images, embedded windows, etc) is not displayed and takes no
space on screen, but further on behaves just as normal data. An empty string
(instead of a boolean value) is clearing the elide option of this tag. It is
not allowed to set this option with the special selection tag \fBsel\fR.
.TP
\fB\-eolcolor \fIcolor\fR
.
Specifies the foreground color to use when displaying the end of line symbol
inside the tagged region. An empty argument will force the use of the
foreground color (set with \fB\-foreground\fR; this is the default).
.TP
\fB\-fgstipple \fIbitmap\fR
.
\fIBitmap\fR specifies a bitmap that is used as a stipple pattern when drawing
text and other foreground information such as underlines. It may have any of
the forms accepted by \fBTk_GetBitmap\fR. If \fIbitmap\fR has not been
specified, or if it is specified as an empty string, then a solid fill will be
used.
.TP
\fB\-font \fIfontName\fR
.
\fIFontName\fR is the name of a font to use for drawing characters. It may
have any of the forms accepted by \fBTk_GetFont\fR.
.TP
\fB\-foreground \fIcolor\fR
.
\fIColor\fR specifies the color to use when drawing text and other foreground
information such as underlines. It may have any of the forms accepted by
\fBTk_GetColor\fR.
.TP
\fB\-hyphencolor \fIcolor\fR
.
Specifies the foreground color to use when displaying the soft hyphen
character (U+00AD) inside the tagged region. An empty argument will force
the use of the foreground color (set with \fB\-foreground\fR; this is the
default).
.TP
\fB\-hyphenrules \fIrules\fR
.
Specifies a list of spelling change rules for hyphenated words, specified by
the identifier of the rules. Only the rules given with this set will be used
for spelling changes. The rules will be applied in the given order of this
list. Per default the set of rules is empty. An exception will be thrown if
one of the given rules is not defined.
.RS
.PP
This tag option overrules the global option \fB\-hyphenrules\fR, this means
that the global rules will be applied only to hyphens without tagged rules.
.PP
For the definition of hyphenation rules see widget option
\fB\-hyphenrules\fR.
.RE
.TP
\fB\-inactivebackground \fIcolor\fR
.
Color specifies the background color to use for characters associated with the
tag, when the window does not have the focus.
It may have any of the forms accepted by Tk_GetColor.
If specified then it will overrule the \fB\-background\fR option of the
\fBsel\fR tag, provided that the actual tag has a higher priority.
.TP
\fB\-inactiveforeground \fIcolor\fR
.
Color specifies the color to use when drawing text and other foreground
information such as underlines, when the window does not have the focus.
It may have any of the forms accepted by Tk_GetColor.
If specified then it will overrule the \fB\-foreground\fR option of the
\fBsel\fR tag, provided that the actual tag has a higher priority.
.TP
\fB\-inactiveselectbackground \fIcolor\fR
.
\fIColor\fR specifies the background color to use when displaying selected
items, when the window does not have the focus.
It may have any of the forms accepted by \fBTk_GetColor\fR.
If \fIcolor\fR has not been specified, or if it is specified as an empty string,
then the color specified by the \fB\-selectbackground\fR tag option is used.
If specified then it will overrule the \fB\-inactivebackground\fR option of the
\fBsel\fR tag, provided that the actual tag has a higher priority.
.TP
\fB\-inactiveselectforeground \fIcolor\fR
.
\fIColor\fR specifies the foreground color to use when displaying selected
items, when the window does not have the focus.
It may have any of the forms accepted by \fBTk_GetColor\fR.
If \fIcolor\fR has not been specified, or if it is specified as an empty string,
then the color specified by the \fB\-selectforeground\fR tag option is used.
If specified then it will overrule the \fB\-inactiveforeground\fR option of the
\fBsel\fR tag, provided that the actual tag has a higher priority.
.TP
\fB\-indentbackground \fIboolean\fR
.
If true then the background, set with \fB\-background\fR tag option, will be
indented according to the \fB\-lmargin1\fR, and \fB\-lmargin2\fR tag
options. This has the (intended) side effect that hovering the margin (left
from indented text) will not trigger events.
.TP
\fB\-justify \fIjustify\fR
.
If the first non-elided character of a display line has a tag for which this
option has been specified, then justify determines how to justify the line.
It must be one of \fBleft\fR, \fBright\fR, \fBfull\fR, or \fBcenter\fR. If a
line wraps, then the justification for each line on the display is
determined by the first non-elided character of that display line.
.TP
\fB\-lang \fIcode\fR
.
Setting the language code of the text content inside the tagged region. If
this tag option is specified, it overrides the \fB\-lang\fR option for the
text widget. For a detailed description of this option see widget option
\fB\-lang\fR.
.TP
\fB\-lmargin1 \fIpixels\fR
.
If the first non-elided character of a text line has a tag for which this
option has been specified, then \fIpixels\fR specifies how much the line
should be indented from the left edge of the window. \fIPixels\fR may have any
of the standard forms for screen distances. If a line of text wraps, this
option only applies to the first line on the display; the \fB\-lmargin2\fR
option controls the indentation for subsequent lines.
.TP
\fB\-lmargin2 \fIpixels\fR
.
If the first non-elided character of a display line has a tag for which this
option has been specified, and if the display line is not the first for its
text line (i.e., the text line has wrapped), then \fIpixels\fR specifies how
much the line should be indented from the left edge of the window.
\fIPixels\fR may have any of the standard forms for screen distances. This
option is only used when wrapping is enabled, and it only applies to the
second and later display lines for a text line.
.TP
\fB\-lmargincolor \fIcolor\fR
.
\fIColor\fR specifies the background color to use in regions that do not
contain characters because they are indented by \fB\-lmargin1\fR or
\fB\-lmargin2\fR. It may have any of the forms accepted by
\fBTk_GetColor\fR. If \fIcolor\fR has not been specified, or if it is
specified as an empty string, then the color used is specified by the
\fB\-background\fR tag option (or, if this is also unspecified, by the
\fB\-background\fR widget option).
.TP
\fB\-offset \fIpixels\fR
.
\fIPixels\fR specifies an amount by which the text's baseline should be offset
vertically from the baseline of the overall line, in pixels. For example, a
positive offset can be used for superscripts and a negative offset can be used
for subscripts. \fIPixels\fR may have any of the standard forms for screen
distances.
.TP
\fB\-overstrike \fIboolean\fR
.
Specifies whether or not to draw a horizontal rule through the middle of
characters. \fIBoolean\fR may have any of the forms accepted by
\fBTcl_GetBoolean\fR.
.TP
\fB\-overstrikecolor\fR \fIcolor\fR
.
\fIColor\fR specifies the color to use when displaying the overstrike. It may have
any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not been specified,
or if it is specified as an empty string, then the color specified by the
\fB\-foreground\fR tag option is used.
.TP
\fB\-overstrikefg \fIcolor\fR
.
Note that this option is deprecated, option \fB\-overstrikecolor\fR should be used
instead. For compatibility reasons this option still will be supported, but
may be removed in a future version.
See equivalent tag option \fB\-overstrikecolor\fR for a description.
.TP
\fB\-relief \fIrelief\fR
.
\fIRelief\fR specifies the relief style to use for drawing the border, in any
of the forms accepted by \fBTk_GetRelief\fR. This option is used in
conjunction with the \fB\-borderwidth\fR option to enable to the desired
border appearance.
.TP
\fB\-rmargin \fIpixels\fR
.
If the first non-elided character of a display line has a tag for which this
option has been specified, then \fIpixels\fR specifies how wide a margin to
leave between the end of the line and the right edge of the window.
\fIPixels\fR may have any of the standard forms for screen distances. This
option is only used when wrapping is enabled. If a text line wraps, the right
margin for each line on the display is determined by the first non-elided
character of that display line.
.TP
\fB\-rmargincolor \fIcolor\fR
.
\fIColor\fR specifies the background color to use in regions that do not
contain characters because they are indented by \fB\-rmargin1\fR. It may
have any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not
been specified, or if it is specified as an empty string, then the color
used is specified by the \fB\-background\fR tag option (or, if this is also
unspecified, by the \fB\-background\fR widget option).
.TP
\fB\-selectbackground \fIcolor\fR
\fIColor\fR specifies the background color to use when displaying selected
items. It may have any of the forms accepted by \fBTk_GetColor\fR. If
\fIcolor\fR has not been specified, or if it is specified as an empty
string, then the color specified by the \fB\-background\fR tag option is
used.
.TP
\fB\-selectforeground \fIcolor\fR
\fIColor\fR specifies the foreground color to use when displaying selected
items. It may have any of the forms accepted by \fBTk_GetColor\fR. If
\fIcolor\fR has not been specified, or if it is specified as an empty
string, then the color specified by the \fB\-foreground\fR tag option is
used.
.TP
\fB\-spacing1 \fIpixels\fR
.
\fIPixels\fR specifies how much additional space should be left above each
text line, using any of the standard forms for screen distances. If a line
wraps, this option only applies to the first line on the display.
.TP
\fB\-spacing2 \fIpixels\fR
.
For lines that wrap, this option specifies how much additional space to leave
between the display lines for a single text line. \fIPixels\fR may have any of
the standard forms for screen distances.
.TP
\fB\-spacing3 \fIpixels\fR
.
\fIPixels\fR specifies how much additional space should be left below each
text line, using any of the standard forms for screen distances. If a line
wraps, this option only applies to the last line on the display.
.TP
\fB\-tabs \fItabList\fR
.
\fITabList\fR specifies a set of tab stops in the same form as for the
\fB\-tabs\fR option for the text widget. This option only applies to a display
line if it applies to the first non-elided character on that display line. If
this option is specified as an empty string, it cancels the option, leaving it
unspecified for the tag (the default). If the option is specified as a
non-empty string that is an empty list, such as \fB\-tabs\0{\0}\fR, then it
requests default 8-character tabs as described for the \fB\-tabs\fR widget
option.
.TP
\fB\-tabstyle \fIstyle\fR
.
\fIStyle\fR specifies either the \fItabular\fR or \fIwordprocessor\fR style of
tabbing to use for the text widget. This option only applies to a display line
if it applies to the first non-elided character on that display line. If this
option is specified as an empty string, it cancels the option, leaving it
unspecified for the tag (the default).
.TP
\fB\-underline \fIboolean\fR
.
\fIBoolean\fR specifies whether or not to draw an underline underneath
characters. It may have any of the forms accepted by \fBTcl_GetBoolean\fR.
.TP
\fB\-underlinecolor\fR \fIcolor\fR
.
\fIColor\fR specifies the color to use when displaying the underline. It may have
any of the forms accepted by \fBTk_GetColor\fR. If \fIcolor\fR has not been specified,
or if it is specified as an empty string, then the color specified by the
\fB\-foreground\fR tag option is used.
.TP
\fB\-underlinefg \fIcolor\fR
.
Note that this option is deprecated, option \fB\-underlinecolor\fR should be used
instead. For compatibility reasons this option still will be supported, but
may be removed in a future version.
See equivalent tag option \fB\-underlinecolor\fR for a description.
.TP
\fB\-undo \fIboolean\fR
.
Specifies whether adding/removing this tag to/from text will be undone with
\fBundo\fR operation. If this flag is \fIfalse\fR, then changes of tag
associations will not be undone for this tag. The default is \fItrue\fR, except
for the special selection flag \fBsel\fR, the default for this tag is \fIfalse\fR.
.TP
\fB\-wrap \fImode\fR
.
\fIMode\fR specifies how to handle lines that are wider than the text's
window. This option only applies to a display line if it applies to the
first non-elided character on that display line. It has the same legal
values as the \fB\-wrap\fR option for the text widget: \fBnone\fR,
\fBchar\fR, \fBword\fR, or \fBcodepoint\fR. If this tag option is specified,
it overrides the \fB\-wrap\fR option for the text widget.
.PP
If a character has several tags associated with it, and if their display
options conflict, then the options of the highest priority tag are used. If a
particular display option has not been specified for a particular tag, or if
it is specified as an empty string, then that option will never be used; the
next-highest-priority tag's option will used instead. If no tag specifies a
particular display option, then the default style for the widget will be used.
.PP
The second purpose for tags is event bindings. You can associate bindings with
a tag in much the same way you can associate bindings with a widget class:
whenever particular X events occur on characters with the given tag, a given
Tcl command will be executed. Tag bindings can be used to give behaviors to
ranges of characters; among other things, this allows hypertext-like features
to be implemented. For details, see the description of the
.QW "\fIpathName \fBtag bind\fR"
widget command below. Tag bindings are shared between all peer widgets
(including any bindings for the special \fBsel\fR tag).
.PP
The third use for tags is in managing the selection. See \fBTHE SELECTION\fR
below. With the exception of the special \fBsel\fR tag, all tags are shared
between peer text widgets, and may be manipulated on an equal basis from any
such widget. The \fBsel\fR tag exists separately and independently in each
peer text widget (but any tag bindings to \fBsel\fR are shared).
.SH MARKS
.PP
The second form of annotation in text widgets is a mark. The name of a mark
may contain arbitrary characters, but it is probably best to avoid using the
characters
.QW " "
(space),
.QW \fC@\fR ,
.QW \fC.\fR ,
.QW \fC+\fR ,
or
.QW \fC\-\fR :
these characters have special
meaning in indices. Marks are used for
remembering particular places in a text. They are something like tags, in that
they have names and they refer to places in the file, but a mark is not
associated with particular characters. Instead, a mark is associated with the
gap between two characters. Only a single position may be associated with a
mark at any given time. If the characters around a mark are deleted the mark
will still remain; it will just have new neighbor characters. In contrast, if
the characters containing a tag are deleted then the tag will no longer have
an association with characters in the file. Marks may be manipulated with the
.QW "\fIpathName \fBmark\fR"
widget command, and their current locations may be determined by using the
mark name as an index in widget commands.
.PP
Each mark also has a
.QW gravity ,
which is either \fBleft\fR or \fBright\fR. The gravity for a mark specifies
what happens to the mark when text is inserted at the point of the mark. If a
mark has left gravity, then the mark is treated as if it were attached to the
character on its left, so the mark will remain to the left of any text
inserted at the mark position. If the mark has right gravity, new text
inserted at the mark position will appear to the left of the mark (so that the
mark remains rightmost). The gravity for a mark defaults to \fBright\fR.
.PP
The name space for marks is different from that for tags: the same name may be
used for both a mark and a tag, but they will refer to different things.
.PP
Two marks have special significance. First, the mark \fBinsert\fR is
associated with the insertion cursor, as described under
\fBTHE INSERTION CURSOR\fR
below. Second, the mark \fBcurrent\fR is associated with the
character closest to the mouse and is adjusted automatically to track the
mouse position and any changes to the text in the widget (one exception:
\fBcurrent\fR is not updated in response to mouse motions if a mouse button is
down; the update will be deferred until all mouse buttons have been released).
Neither of these special marks may be deleted. With the exception of these two
special marks, all marks are shared between peer text widgets, and may be
manipulated on an equal basis from any peer.
.PP
Generated marks (created with command \fBmark generate\fR) have a special meaning.
They will be discarded by the undo mechanism (relevant only if widget option
\fB\-steadymarks\fR is enabled). Furthermore these marks are
.QW invisible ,
only command \fBdump\fR is showing generated marks, the commands \fBmark names\fR,
\fBmark next\fR, and \fBmark previous\fR, cannot
.QW see
generated marks.
.SH "EMBEDDED WINDOWS"
.PP
The third form of annotation in text widgets is an embedded window. Each
embedded window annotation causes a window to be displayed at a particular
point in the text. There may be any number of embedded windows in a text
widget, and any widget may be used as an embedded window (subject to the usual
rules for geometry management, which require the text window to be the parent
of the embedded window or a descendant of its parent).
.PP
The embedded window's position on the screen will be updated as the text is
modified or scrolled, and it will be mapped and unmapped as it moves into and
out of the visible area of the text widget. Each embedded window occupies one
unit's worth of index space in the text widget, and it may be referred to
either by the name of its embedded window or by its position in the widget's
index space. If the range of text containing the embedded window is deleted,
and this range is not saved on undo stack, then the window is destroyed.
Similarly if the text widget as a whole is deleted, then the window is
destroyed. If this automatic destroy behavior is not wanted then option
\fB\-owner\fR should be set accordingly.
.PP
Eliding an embedded window immediately after scheduling it for creation via
\fIpathName \fBwindow create \fIindex \fB\-create\fR will prevent it from being
effectively created. Uneliding an elided embedded window scheduled for creation
via \fIpathName \fBwindow create \fIindex \fB\-create\fR will automatically
trigger the associated creation script. After destroying an elided embedded
window, the latter won't get automatically recreated.
.PP
When an embedded window is added to a text widget with the \fIpathName
\fBwindow create\fR widget command, several configuration options may be
associated with it. These options may be modified later with the \fIpathName
\fBwindow configure\fR widget command. The following options are currently
supported:
.TP
\fB\-align \fIwhere\fR
.
If the window is not as tall as the line in which it is displayed, this option
determines where the window is displayed in the line. \fIWhere\fR must have
one of the values \fBtop\fR (align the top of the window with the top of the
line), \fBcenter\fR (center the window within the range of the line),
\fBbottom\fR (align the bottom of the window with the bottom of the line's
area), or \fBbaseline\fR (align the bottom of the window with the baseline of
the line).
.TP
\fB\-create \fIscript\fR
.
Specifies a Tcl script that may be evaluated to create the window for the
annotation. If no \fB\-window\fR option has been specified for the annotation
this script will be evaluated when the annotation is about to be displayed on
the screen. \fIScript\fR must create a window for the annotation and return
the name of that window as its result. Two substitutions will be performed in
\fIscript\fR before evaluation. \fI%W\fR will be substituted by the name of
the parent text widget, and \fI%%\fR will be substituted by a single \fI%\fR.
If the annotation's window should ever be deleted, \fIscript\fR will be
evaluated again the next time the annotation is displayed.
.TP
\fB\-owner \fIboolean\fR
.
If true then the text widget is the owner of the embedded window. Only if it
is the owner the window will be destroyed if the range of text containing
the embedded window is deleted, and the deleted text is not saved on undo
stack. Per default this option is true. Setting this option to false should
be done with care, because in this case the text widget is not responsible
for the lifetime of the embedded window.
.TP
\fB\-padx \fIpixels\fR
.
\fIPixels\fR specifies the amount of extra space to leave on each side of the
embedded window. It may have any of the usual forms defined for a screen
distance.
.TP
\fB\-pady \fIpixels\fR
.
\fIPixels\fR specifies the amount of extra space to leave on the top and on
the bottom of the embedded window. It may have any of the usual forms defined
for a screen distance.
.TP
\fB\-stretch \fIboolean\fR
.
If the requested height of the embedded window is less than the height of the
line in which it is displayed, this option can be used to specify whether the
window should be stretched vertically to fill its line. If the \fB\-pady\fR
option has been specified as well, then the requested padding will be retained
even if the window is stretched.
.TP
\fB\-tags \fItagList\fR
.
Specifies a set of tags to apply to the embedded window. \fITagList\fR consists
of a list of tag names, which replace any existing tags for the embedded window.
\fITagList\fR may be an empty list. Note that it is not possible to add or
remove the special selection tag \fBsel\fR, it will be left untouched with this
option.
.TP
\fB\-window \fIpathName\fR
.
Specifies the name of a window to display in the annotation. Note that if a
\fIpathName\fR has been set, then later configuring a window to the empty
string will not delete the widget corresponding to the old \fIpathName\fR.
Rather it will remove the association between the old \fIpathName\fR and the
text widget. If multiple peer widgets are in use, it is usually simpler to use
the \fB\-create\fR option if embedded windows are desired in each peer.
.SH "EMBEDDED IMAGES"
.PP
The final form of annotation in text widgets is an embedded image. Each
embedded image annotation causes an image to be displayed at a particular
point in the text. There may be any number of embedded images in a text
widget, and a particular image may be embedded in multiple places in the same
text widget.
.PP
The embedded image's position on the screen will be updated as the text is
modified or scrolled. Each embedded image occupies one unit's worth of index
space in the text widget, and it may be referred to either by its position in
the widget's index space, or the name it is assigned when the image is inserted
into the text widget with \fIpathName \fBimage create\fR. If the range of text
containing the embedded image is deleted then that copy of the image is removed
from the screen.
.PP
Eliding an embedded image immediately after scheduling it for creation via
\fIpathName \fBimage create \fIindex \fB\-create\fR will prevent it from being
effectively created. Uneliding an elided embedded image scheduled for creation
via \fIpathName \fBimage create \fIindex \fB\-create\fR will automatically
trigger the associated creation script. After destroying an elided embedded
image, the latter won't get automatically recreated.
.PP
When an embedded image is added to a text widget with the \fIpathName \fBimage
create\fR widget command, a name unique to this instance of the image is
returned. This name may then be used to refer to this image instance. The name
is taken to be the value of the \fB\-name\fR option (described below). If the
\fB\-name\fR option is not provided, the \fB\-image\fR name is used instead.
If the \fIimageName\fR is already in use in the text widget, then \fB#\fInn\fR
is added to the end of the \fIimageName\fR, where \fInn\fR is an arbitrary
integer. This insures the \fIimageName\fR is unique. Once this name is
assigned to this instance of the image, it does not change, even though the
\fB\-image\fR or \fB\-name\fR values can be changed with \fIpathName \fBimage
configure\fR.
.PP
When an embedded image is added to a text widget with the \fIpathName \fBimage
create\fR widget command, several configuration options may be associated with
it. These options may be modified later with the \fIpathName \fBimage
configure\fR widget command. The following options are currently supported:
.TP
\fB\-align \fIwhere\fR
.
If the image is not as tall as the line in which it is displayed, this option
determines where the image is displayed in the line. \fIWhere\fR must have one
of the values \fBtop\fR (align the top of the image with the top of the line),
\fBcenter\fR (center the image within the range of the line), \fBbottom\fR
(align the bottom of the image with the bottom of the line's area), or
\fBbaseline\fR (align the bottom of the image with the baseline of the line).
.TP
\fB\-image \fIimage\fR
.
Specifies the name of the Tk image to display in the annotation. If
\fIimage\fR is not a valid Tk image, then an error is returned.
.TP
\fB\-name \fIImageName\fR
.
Specifies the name by which this image instance may be referenced in the text
widget. If \fIImageName\fR is not supplied, then the name of the Tk image is
used instead. If the \fIimageName\fR is already in use, \fI#nn\fR is appended
to the end of the name as described above.
.TP
\fB\-padx \fIpixels\fR
.
\fIPixels\fR specifies the amount of extra space to leave on each side of the
embedded image. It may have any of the usual forms defined for a screen
distance.
.TP
\fB\-pady \fIpixels\fR
.
\fIPixels\fR specifies the amount of extra space to leave on the top and on
the bottom of the embedded image. It may have any of the usual forms defined
for a screen distance.
.TP
\fB\-tags \fItagList\fR
.
Specifies a set of tags to apply to the embedded image. \fITagList\fR consists
of a list of tag names, which replace any existing tags for the embedded image.
\fITagList\fR may be an empty list. Note that it is not possible to add or
remove the special selection tag \fBsel\fR, it will be left untouched with this
option.
.SH "EXTRA FUNCTIONS"
.SS "MERGE RANGE"
.TP
NAME
.
tk_mergeRange \- insert/merge a given range into a sorted list of ranges.
.TP
SYNOPSYS
.
\fBtk_mergeRange \fIvarName range\fR
.TP
DESCRIPTION
.
This procedure is inserting \fIrange\fR into a sorted list of ranges, given
with \fIvarName\fR. If given range is adjacent to, or intersecting a range in given list, then it will be amalgamated. This means that the result is a sorted list of disjoint ranges. This procedure return the new content of \fIvarName\fR.
.SS "INSERT TEXT"
.TP
NAME
.
tk_textInsert \- insert characters into a text widget regarding soft hyphen pattern.
.TP
SYNOPSYS
.
\fBtk_textInsert\fR \fIpathName\fR ?\fB\-hyphentags\fI tagList\fR? \fIindex chars\fR ?\fItagList chars tagList ...\fR?
.TP
DESCRIPTION
.
This procedure is especially supporting the predefined spelling changes
(see section \fBHYPHENATION RULES\fR).
.RS
.PP
The procedure \%\fBtk_textInsert\fR inserts all of the \fIchars\fR arguments just
before the character at \fIindex\fR in the specified text widget, see
command \fBinsert\fR of the text widget for a detailed description. This
procedure will pre-parse the \fIchars\fR arguments before it calls command
\fBinsert\fR of \fIpathName\fR for the execution of the insertion. The
parser is recognizing the following escape sequences:
.IP \(bu 3
The sequence
.QW \e-
will be replaced by the soft hyphen character. Example:
.QW Sen\e\e-tence
will hyphenate into
.QW Sen-tence .
.IP \(bu 3
The sequence
.QW \e+
will be replaced by the soft hyphen character, and, provided that no tagged
list of rules is given (in \fItagList\fR), a special tag with all known hyphen
rules (regarding option \fB\-lang\fR) will be attached to this hyphen (this
means that all known hyphenation rules will be applied to this hyphen \-
probably restricted by option \fB\-lang\fR).
.IP \(bu 3
The sequence
.QW \e:\fIRULE\fR:
\- \fIRULE\fR is the identifier for a defined hyphenation rule (see section
\fBHYPHENATION RULES\fR) \- will be replaced with a soft hyphen, and applies a tag with the specified hyphenation rule \fIRULE\fR to this soft hyphen character. An
error will be thrown if the specified rule is not defined, or if the
trailing colon is missing.
.IP \(bu 3
Any other escaped character (not
.QW \fC\-\fR ,
nor
.QW \fC+\fR ,
nor
.QW \fC:\fR
) will be replaced by this character; this means that the former escape
character will be removed.
.PP
The latter case is required to allow the escape character inside a string \- it
has to be doubled \- otherwise an unambiguous identification is not possible. Example: the character string
.QW \e\e-
will be interpreted as
.QW \e-
(a string), but the character string
.QW \e-
will be interpreted as soft hyphen character. (Please note that all the
statements about the escape character are related to the list notation,
inside the string notation every escape character has to be doubled.)
.PP
It is allowed to abbreviate all rules with a two-letter code:
.IP \(bu 3
:ck: is already an abbreviation
.IP \(bu 3
:dd: is :doubledigraph:
.IP \(bu 3
:dv: is :doublevowel:
.IP \(bu 3
:ge: is :gemination:
.IP \(bu 3
:tc: is :tripleconsonant:
.IP \(bu 3
:tr: is :trema:
.IP \(bu 3
:rh: is :repeathyphen:
.PP
If option \fB\-hyphentags\fR is specified then the associated \fItagList\fR
will additionally be associated with all soft hyphens in new text; combined
with the inherited tags, or the specified tags. This is especially useful
for hiding/showing soft hyphens (see tag option \fB\-elide\fR).
.RE
.SS "REBIND MOUSE WHEEL EVENT"
.TP
NAME
.
tk_textRebindMouseWheel \- rebind the mouse wheel event.
.TP
SYNOPSYS
.
\fBtk_textRebindMouseWheel\fR \fIpathName\fR ?\fIpathName ...\fR?
.TP
DESCRIPTION
.
This procedure provides a portable way to rebind the mouse wheel events of
embedded windows, so that the text widget will receive the events, as if
the embedded windows are transparent for mouse wheel events. Without rebinding
only the embedded window may receive the mouse wheel events, this might break
the expected scroll behavior of the text widget.
.RS
.PP
The first \fBpathName\fR is the receiver of the mouse wheel events, i.e. the
text widget which contains the embedded windows. If no further argument is
specified, then all currently embedded windows will be rebound. Otherwise only
the specified embedded windows, starting with the second provided argument,
will be rebound.
.RE
.SS "REPLACE TEXT"
.TP
NAME
.
tk_textReplace \- replace a range of characters inside a text widget regarding soft hyphen pattern.
.TP
SYNOPSYS
.
\fBtk_textReplace\fR \fIpathName\fR ?\fB\-hyphentags\fR \fItagList\fR? \fIindex chars\fR ?\fItagList chars tagList ...\fR?
.TP
DESCRIPTION
.
This procedure is especially supporting the predefined spelling changes (see
section \fBHYPHENATION RULES\fR).
.RS
.PP
The procedure \%\fBtk_textReplace\fR replaces the range of characters between
\fIindex1\fR and \fIindex2\fR, see command \fBreplace\fR for a detailed
description. This procedure will pre-parse the \fIchars\fR arguments before
it calls command \fBreplace\fR of \fIpathName\fR for the execution of the
replacement. The parser is recognizing the escape sequences
.QW \e- ,
.QW \e+ ,
and
.QW \e:RULE: ,
see procedure \%\fBtk_textInsert\fR which works in a similar way.
.PP
If option \fB\-hyphentags\fR is specified then the associated \fItagList\fR
will additionally be associated with all soft hyphens in new text; combined
with the inherited tags, or the specified tags. This is especially useful
for hiding/showing soft hyphens (see tag option \fB\-elide\fR).
.RE
.SH "HYPHENATION RULES"
.PP
The rules are:
.IP [1] 4
In natural (pre-reform) German orthography, a
.QW c
before the hyphenation point can change into a
.QW k :
.QW Drucker
hyphenates into
.QW Druk-ker .
This spelling change will be called \fBck\fR rule.
.IP [2] 4
In modern Dutch, an e-diaeresis after the hyphenation point can change into
a simple
.QW e
:
.QW re\[:e]el
hyphenates into
.QW re-eel .
This also applies for i-diaeresis, o-diaeresis, and u-diaeresis. This
spelling change will be called \fBtrema\fR rule.
.IP [3] 4
In German, Norwegian, and Swedish, a triple consonant can change into a
double consonant: Swedish
.QW tugg-gummi
becomes
.QW tuggummi
when not hyphenated, Norwegian
.QW buss-sj\[oa]f\[/o]r
becomes
.QW bussj\[oa]f\[/o]r ,
and German
.QW Schiff-fahrt
becomes
.QW Schiffahrt
(in pre-reform orthography). This spelling change will be called
\fBtripleconsonant\fR rule. (Note that is a reverse rule, applied when a
word will not be hyphenated at this point).
.IP [4] 4
In Dutch, a letter can disappear inside a doubled vowel:
.QW opaatje
hyphenates into
.QW opa-tje .
In case of an double
.QW e
it will change to the corresponding vowel with accute, for example
.QW cafeetje
becomes
.QW caf\['e]-tje .
This spelling change will be called \fBdoublevowel\fR rule.
.IP [5] 4
Hungarian has an unusual hyphenation case which involves reinsertion of a
root-letter, as in the following example:
.QW vissza
becomes
.QW visz-sza .
These special cases, occurring when the characters are in the middle of a
word are:
.QW ccs
becomes
.QW cs-cs ,
.QW ggy
becomes
.QW gy-gy ,
.QW lly
becomes
.QW ly-ly ,
.QW nny
becomes
.QW ny-ny ,
.QW tty
becomes
.QW ty-ty ,
.QW zzs
becomes
.QW zs-zs ,
.QW ssz
becomes
.QW sz-sz .
This rule is named \fBdoubledigraph\fR.
.IP [6] 4
In Catalan, a geminated consonant can be split: the word
.QW paral\N'183'lel
hyphenates into
.QW paral-lel .
The name for this rule is \fBgemination\fR.
.IP [7] 4
In Polish the hyphen will be repeated after line break, this means for
example that
.QW tech-nik
becomes
.QW "tech- -nik" .
The name of this rule is \fBrepeathyphen\fR.
.PP
Applying hyphenation rule \fIRULE\fR (which may result into spelling
changes) will be done automatically in the following cases:
.IP [1] 4
The hyphen is tagged with hyphenation rule \fIRULE\fR (tag option
\fB\-hyphenrules\fR includes \fIRULE\fR).
.IP [2] 4
The widget option \fB\-hyphenrules\fR contains rule \fIRULE\fR, and no tag
(attached to this hyphen) is overruling.
.SH "INSERTING TEXT WITH SOFT HYPHENS"
.PP
When spelling changes are involved it might be convenient to use the helper
functions \%\fBtk_textInsert\fR and \%\fBtk_textReplace\fR.
These functions are providing a simple way to insert hyphenated text
regarding the spelling changes based on rules. Example:
.PP
.CS
\fBtk_textInsert end .t "Nach dem Ein\\\\-le\\\\-gen des Pa\\\\-piers soll\\\\-ten\\\fR
\fBdie Druc\\\\+ker\\\\-ein\\\\-stel\\\\-lun\\\\-gen \[:u]ber\\\\-pr\[:u]ft wer\\\\-den."\fR
.CE
.PP
This text in German may be hyphenated and displayed in the following way:
.PP
.CS
Nach dem Einlegen des Papiers sollten die Druk-
kereinstellungen \[:u]berpr\[:u]ft werden.
.CE
.PP
Second example:
.PP
.CS
\fBtk_textInsert end .t "Nach dem Ein\\\\-le\\\\-gen des Pa\\\\-piers soll\\\\-ten\\\fR
\fBdie Druc\\\\:ck:ker\\\\-ein\\\\-stel\\\\-lun\\\\-gen \[:u]ber\\\\-pr\[:u]ft wer\\\\-den."\fR
.CE
.PP
This gives the same result, but here the \fBck\fR rule is explictly specified.
.PP
.CS
\fBtk_textInsert end .t "Nach dem Ein\\\\+le\\\\+gen des Pa\\\\+piers soll\\\\+ten\\\fR
\fBdie Druc\\\\+ker\\\\+ein\\\\+stel\\\\+lun\\\\+gen \[:u]ber\\\\+pr\[:u]ft wer\\\\+den."\fR
.CE
.PP
This will also give the same result, because only the \fBck\fR rule will be detected
for spelling changes.
.PP
.CS
\fBtk_textInsert end .t "Nach dem Ein\\\\-le\\\\-gen des Pa\\\\-piers soll\\\\-ten\\\fR
\fBdie Druc\\\\-ker\\\\-ein\\\\-stel\\\\-lun\\\\-gen \[:u]ber\\\\-pr\[:u]ft wer\\\\-den." ck\fR
\fB.t tag configure ck -hyphenrules {ck}\fR
.CE
.PP
The same result as before, because the \fBck\fR rule is applied explictly
(to all soft hyphens).
.PP
.CS
\fBtk_textInsert end .t {Nach dem Ein\\-le\\-gen des Pa\\-piers soll\\-ten\\\fR
\fBdie Druc\\-ker\\-ein\\-stel\\-lun\\-gen \[:u]ber\\-pr\[:u]ft wer\\-den.} trema\fR
\fB.t tag configure trema -hyphenrules {trema}\fR
.CE
.PP
In this case only the \fBtrema\fR rule will be applied to the text - the \fBck\fR
rule is missing - thus we cannot get here the correct result, this text may be
(wrongly) hyphenated in the following way:
.PP
.CS
Nach dem Einlegen des Papiers sollten die Druc-
kereinstellungen \[:u]berpr\[:u]ft werden.
.CE
.PP
The explicit specification of the hyphenation rule is the preferred method (second
example), however it depends on the quality of the hyphenator which method will be
used. For instance, the TeX hyphenator does not know about spelling changes, and here
the method with the use of
.QW "\\\\+"
(for any hyphenation point like in the third example) may give fairly good results.
Of course, the use of
.QW "\\\\+"
is (currently) only useful for the languages Catalan, Dutch, German, Hungarian,
Norwegian, Polish, and Swedish.
.SH "THE SELECTION"
.PP
Selection support is implemented via tags. If the \fB\-exportselection\fR option
for the text widget is true then the \fBsel\fR tag will be associated with the
selection:
.IP [1] 4
Whenever characters are tagged with \fBsel\fR the text widget will claim
ownership of the selection.
.IP [2] 4
Attempts to retrieve the selection will be serviced by the text widget,
returning all the characters with the \fBsel\fR tag.
.IP [3] 4
If the selection is claimed away by another application or by another window
within this application, then the \fBsel\fR tag will be removed from all
characters in the text.
.IP [4] 4
Whenever the \fBsel\fR tag range changes a virtual event \fB<<Selection>>\fR
is generated.
.PP
The \fBsel\fR tag is automatically defined when a text widget is created, and
it may not be deleted with the
.QW "\fIpathName \fBtag delete\fR"
widget command. Furthermore, the \fB\-selectbackground\fR,
\fB\-selectborderwidth\fR, \fB\-selectforeground\fR,
\fB\-inactiveselectbackground\fR, \fB\-inactiveselectforeground\fR, and
\fB\-selectborderwidth\fR options for the text widget are tied to the
\fB\-background\fR, \fB\-borderwidth\fR, \fB\-foreground\fR,
\fB\-inactiveselectbackground\fR, \fB\-inactiveselectforeground\fR, and
\fB\-borderwidth\fR options for the \fBsel\fR tag: changes
in either will automatically be reflected in the other. This allows
programmatic control over the visualization of the \fBsel\fR tag for
foreground and background windows, or to have \fBsel\fR not shown at all
for background windows. Each peer text widget has its own \fBsel\fR tag
which can be separately configured and set.
.PP
The \fBsel\fR tag is overruling all other tags, except if a tag with higher
priority has explicitly defined the selection attributes
(\fB\-selectbackground\fR and \fB\-selectforeground\fR if the window is
active; \fB\-inactiveselectbackground\fR and \fB\-inactiveselectforeground\fR
if the window is inactive).
.PP
Note the specific behavior if \fB\-inactiveselectbackground\fR is not defined
(empty): if the window does not have the focus, then the selection attributes
of the text widget and all the attributes of the \fBsel\fR tag will not be
regarded; this means that in general no selection will be shown, this is the
default behavior on Windows.
.PP
Note the specific behavior on Mac: if the window does not have the focus, and
does not have state \fBnormal\fR (see widget option \fB\-state\fR),
then the selection attributes of the text widget and all the attributes of
the \fBsel\fR tag will not be regarded; this means that per default no selection
will be shown.
.SH "THE INSERTION CURSOR"
.PP
The mark named \fBinsert\fR has special significance in text widgets. It is
defined automatically when a text widget is created and it may not be unset
with the
.QW "\fIpathName \fBmark unset\fR"
widget command. The \fBinsert\fR mark represents the position of the insertion
cursor, and the insertion cursor will automatically be drawn at this point
whenever the text widget has the input focus.
.PP
The cursor shape (vertical line or rectangular block) can be specified with
option \fB\-blockcursor\fR. But note that in general the block cursor is
useful only if also the options \fB\-showendofline\fR and \fB\-showendoftext\fR
are enabled (otherwise the cursor handling is unsatisfying). With a block
cursor the optimal width (option \fB\-insertwidth\fR) is 2, and with a bar
cursor (vertical line) the optimal width is 2 as well, or even 1 if the cursor
is blinking. When disabling the blinking, or when setting a block cursor shape,
it is recommended to specify the cursor width (option \fB\-insertwidth\fR)
explicitly. Of course, in most cases the default settings for the cursor will
be preferred.
.SH "THE MODIFIED FLAG"
.PP
The text widget can keep track of changes to the textual content of the widget
by means of the modified flag. Inserting or deleting text will set this flag.
The flag can be queried, set and cleared programmatically as well. Whenever
the flag changes state a \fB<<Modified>>\fR virtual event is generated. See
the \fIpathName \fBedit modified\fR widget command for more details.
.SH "THE ALTERED FLAG"
.PP
It's possible to keep track of any change which has an affect on text content,
even if only the representation is affected. Also any change in tag associations
will be seen as a change in the representation. If option \fB\-steadymarks\fR is
enabled, also the mark operations may have effects on the text content (although
indirectly). Whenever the flag changes state a \fB<<Altered>>\fR virtual event
is generated. See the \fIpathName \fBedit altered\fR widget command for more
details.
.SH "THE IRREVERSIBLE FLAG"
.PP
As a supplement to the
.QW altered
flag also the
.QW irreversible
flag is provided. This flag informs whether the original content
(before any modification/operation has been performed) can be restored. Whenever
the state of this flag is changing, the virtual event \fB<<Irreversible>>\fR is
fired. For more details see the \fIpathName \fBedit irreversible\fR widget command.
.SH "THE UNDO MECHANISM"
.PP
The text widget has an unlimited undo and redo mechanism (when the
\fB\-undo\fR widget option is true) which records every insert and delete
action on a stack, including the insertion and deletion of embedded windows and
embedded images. Furthermore any change of tag associations will be recorded.
If option \fB\-steadymarks\fR is enabled even operations on marks will push
an undo operation on the stack.
.PP
Boundaries (called
.QW separators )
are inserted between edit actions. The purpose of these separators is to group
inserts, deletes and replaces into one compound edit action. When undoing a
change everything between two separators will be undone. The undone changes
are then moved to the redo stack, so that an undone edit can be redone again.
The redo stack is cleared whenever new edit actions are recorded on the undo
stack. The undo and redo stacks can be cleared to keep their depth under
control.
.PP
Separators are inserted automatically when the \fB\-autoseparators\fR widget
option is true. You can insert separators programmatically as well. If a
separator is already present at the top of the undo stack no other will be
inserted. That means that two separators on the undo stack are always
separated by at least one undoable action.
.PP
The \fB<<UndoStack>>\fR virtual event is generated every time the undo stack
or the redo stack is changing.
.PP
The undo mechanism is also linked to the
.QW modified
and
.QW altered
flag. This means that undoing or redoing changes can take a modified/altered
text widget back to the unmodified/unaltered state or vice versa. The
modified/altered flag will be set automatically to the appropriate state. The
automatic coupling of the
.QW modified
flag does not work when the
.QW modified
flag has been set by the user, until the flag has been reset again.
.PP
See below for the \fIpathName \fBedit\fR widget command that controls the undo
mechanism.
.SH "PEER WIDGETS"
.PP
The text widget has a separate store of all its data concerning each line's
textual contents, marks, tags, images and windows, and the undo stack.
.PP
While this data store cannot be accessed directly (i.e. without a text widget
as an intermediary), multiple text widgets can be created, each of which
present different views on the same underlying data. Such text widgets are
known as peer text widgets.
.PP
As text is added, deleted, edited and coloured in any one widget, and as
images, marks, tags are adjusted, all such changes will be reflected in all
peers.
.PP
All data and markup is shared, except for a few small details. First, the
\fBsel\fR tag may be set and configured (in its display style) differently for
each peer. Second, each peer has its own \fBinsert\fR and \fBcurrent\fR mark
positions (but all other marks are shared). Third, embedded windows, which are
arbitrary other widgets, cannot be shared between peers. This means the
\fB\-window\fR option of embedded windows is independently set for each peer
(it is advisable to use the \fB\-create\fR script capabilities to allow each
peer to create its own embedded windows as needed). Fourth, all of the
configuration options of each peer (e.g. \fB\-font\fR, etc) can be set
independently, with the exception of \fB\-undo\fR, \fB\-maxundo\fR,
\fB\-maxundosize\fR, \fB\-maxredo\fR, \fB\-autoseparators\fR (i.e. all undo,
redo and modified state issues are shared). Also option \fB\-steadymarks\fR
cannot be set independently.
.PP
Finally any single peer need not contain the whole content from the
underlying data store. When creating a peer, a contiguous range (e.g. only
range
.QW 52.begin
through
.QW 125.end
) may be specified. This allows a peer to contain just a small portion of
the overall text. The range will expand and contract as text is inserted or
deleted. If the peer's contents contracts to nothing (i.e. the start of the
content is after last newline, as a result of a deletion from another
widget), then it is impossible for new content to be inserted. The peer will
simply become an empty shell (dead peer) on which the background can be
configured, but which will never show any content (without manual
reconfiguration of the start and end range). Note that a peer which does not
contain all of the underlying data store still has indices numbered from
.QW 1.0
to
.QW end .
It is simply that those indices reflect a subset of the total data, and data
outside the contained range is not accessible to the peer. This means that
the command \fIpeerName \fBindex end\fR may return quite different values in
different peers. Similarly, commands like \fIpeerName \fBtag ranges\fR will not
return index ranges outside that which is meaningful to the peer. The
configuration options \fB\-startindex\fR and \fB\-endindex\fR may be used to
control how much of the underlying data is contained in any given text widget.
.PP
Note that peers are really peers. Deleting the
.QW original
text widget will not cause any other peers to be deleted, or otherwise
affected.
.PP
See below for the \fIpathName \fBpeer\fR widget command that controls the
creation of peer widgets.
.SH "ASYNCHRONOUS UPDATE OF LINE HEIGHTS"
.PP
In order to maintain a responsive user-experience, the text widget calculates
lines metrics (line heights in pixels) asynchronously. Because of this, some
commands of the text widget may return wrong results if the asynchronous
calculations are not finished at the time of calling. This applies to
\fIpathName \fBcount -ypixels\fR and \fIpathName \fByview\fR.
.PP
Again for performance reasons, it would not be appropriate to let these
commands always wait for the end of the update calculation each time they are
called. In most use cases of these commands a more or less inaccurate result
does not really matter compared to execution speed.
.PP
In case accurate result is needed (and if the text widget is managed by a
geometry manager), one can resort to \fIpathName \fBsync\fR and \fIpathName
\fBpendingsync\fR to control the synchronization of the view of text widgets.
Alternatively, in very special cases (in general this would cause performance
problem), setting widget option \fB\-synctime\fR to zero provides accurate
results at any time.
.PP
The \fB<<WidgetViewSync>>\fR virtual event fires when the line heights of the
text widget become obsolete (due to some editing command or configuration
change), and again when the internal data of the text widget are back in sync
with the widget view. The detail field (%d substitution) is either true (when
the widget is in sync) or false (when it is not).
.PP
\fIpathName \fBsync\fR, \fIpathName \fBpendingsync\fR and
\fB<<WidgetViewSync>>\fR apply to each text widget independently of its peers.
.SS "EXAMPLES OF USE"
.PP
This immediately completes line metrics at any cost; the GUI
unresponsive while this is occurring:
.PP
.CS
\fB$w sync\fR
$w yview moveto $fraction
.CE
.PP
This synchronously waits for up-to-date line metrics (but with the GUI
responsive) before executing the scheduled command, but does not block
execution flow:
.PP
.CS
\fB$w sync\fR -command [list $w yview moveto $fraction]
.CE
.PP
This synchronously waits for up-to-date line metrics while keeping the
GUI responsive:
.PP
.CS
# init
set yud($w) 0
proc updateaction w {
set ::yud($w) 1
# any other update action here...
}
# runtime
\fB$w sync\fR -command [list updateaction $w]
vwait yud($w)
$w yview moveto $fraction
.CE
.PP
This is an extension of the previous example with a list of actions to
perform once the synchronization is completed.
.PP
.CS
# init
set todo($w) {}
proc updateaction w {
foreach cmd $::todo($w) {uplevel #0 $cmd}
set todo($w) {}
}
# runtime
lappend todo($w) [list $w yview moveto $fraction]
\fB$w sync\fR -command [list updateaction $w]
.CE
.PP
This detects whether a synchronization is pending, and if so just
postpones the code until that synchronization is done, detecting that
happening with a virtual event.
.PP
.CS
# init
set todo($w) {}
bind $w \fB<<WidgetViewSync>>\fR {
if {%d} {
foreach cmd $todo(%W) {eval $cmd}
set todo(%W) {}
}
}
# runtime
if {![\fB$w pendingsync\fR]} {
$w yview moveto $fraction
} else {
lappend todo($w) [list $w yview moveto $fraction]
}
.CE
.SH "IMPROVING THE PERFORMANCE WITH TAGS"
.PP
The use of thousands of different tags when inserting text is a bit slow.
Often such a large number of different tags can be avoided. Example:
.PP
.CS
set n 0
foreach i $items {
$w insert insert $i [incr n] " "
$w tag bind $n <Enter> [list Hilite $w $n yellow]
$w tag bind $n <Leave> [list Hilite $w $n {}]
$w tag bind $n <1> [list Action $w $n]
}
proc Hilite {w n bg} {
$w tag configure $n -background $bg
}
proc Action {w n} {
# do any action based on number $n
}
.CE
.PP
This piece of code assigns an unique tag to each item, used for
highlighting and identifying the item. But this can be solved in a
different way, with only two tags:
.PP
.CS
set n 0
foreach i $items {
$w mark set [incr n] insert left
$w insert end $i item " "
}
$w tag configure hilite -background yellow
$w tag bind item <Enter> {Enter %W}
$w tag bind item <Leave> {Leave %W}
$w tag bind item <1> {Action %W}
proc Enter {w} {
$w tag add hilite item.current.first item.current.last
}
proc Leave {w} {
$w tag remove hilite begin end
}
proc Action {w} {
set n [$w mark previous item.current.last {[0-9]*}]
# do any action based on number $n
}
.CE
.PP
The latter method may improve the performance of text insertion
significantly, because marks are very efficient, even if thousands
of marks are in usage. Also the number of bindings will be reduced,
so the overall consumption of resources is improved.
.PP
.SH "WIDGET COMMAND"
.PP
The \fBtext\fR command creates a new Tcl command whose name is the same as the
path name of the text's window. This command may be used to invoke various
operations on the widget. It has the following general form:
.CS
\fIpathName option \fR?\fIarg arg ...\fR?
.CE
\fIPathName\fR is the name of the command, which is the same as the text
widget's path name. \fIOption\fR and the \fIarg\fRs determine the exact
behavior of the command. The following commands are possible for text widgets:
.TP
\fIpathName \fBbbox\fR ?\fB\-extents\fR? \fIindex\fR
.
Returns a list of four elements describing the screen area of the character
given by \fIindex\fR. The first two elements of the list give the x and y
coordinates of the upper-left corner of the area occupied by the character,
and the last two elements give the width and height of the area. If the
character is only partially visible on the screen, then the return value
reflects just the visible part. If the character is not visible on the screen
then the return value is an empty list.
.RS
.PP
If space mode \fBtrim\fR is set (see option \fB\-spacemode\fR) then the trimmed
spaces will be measured with a width of zero.
.PP
If option \fB\-extents\fR is specified then a list of four elements describing
the invisible extents of the bounding box will returned. If x/y (first/second
value) is not zero, then the first x/y pixels are not visible on screen. If
width/height (third/fourth value) is not zero, then the last width/height
pixels are not visible on screen. If the line which contains this character
is not visible on the screen, then the return value is an empty list.
.RE
.TP
\fIpathName \fBbrks\fR \fIstring\fR \fI?lang\fR?
.
This command expects a \fIstring\fR of characters, and the result is a list of
integers. This list has exactly the character length of the given string,
and integer value 1 in this list denotes a potential line break point at
this character position, value 2 denotes a mandatory line break point, and
value 0 (zero) denotes no line break at this character position. If the
optional language code is specified (see widget option \fB\-lang\fR for
language codes), then the external library \fIlibunibreak\fR (from Wu
Yongwei) will be used for the line break computation; an error will be
thrown if this library is not available. If no language code is specified,
then the internal wrap algorithm will be used: also based on the
recommendations of the Unicode consortium, but restricted to Latin-1 and
most non-language dependent characters, without regarding combined marks,
and without language support.
.RS
.PP
This command has three purposes:
.IP [1] 4
It provides a simple check whether \fIlibunibreak\fR is available or not
(even an empty string, and any language code, e.g.
.QW xx ,
works for this check). An error will be thrown if \fIlibunibreak\fR
is not available, but a language code has been specified (\fB\-lang\fR).
.IP [2] 4
For a proof of the line break algorithm, especially for testing the internal
algorithm.
.IP [3] 4
It is also conceivable to use this function for the computation of line
breaks inside other widgets.
.RE
.TP
\fIpathName \fBcget\fR \fIoption\fR
.
Returns the current value of the configuration option given by \fIoption\fR.
\fIOption\fR may have any of the values accepted by the \fBtext\fR command.
.TP
\fIpathName \fBchecksum\fR
.
Computes a checksum over the whole widget content. The result is platform
independent.
.RS
.PP
One or more of the following switches (or abbreviations thereof) may be
specified to control the extraction:
.IP \fB\-all\fR
Computes the checksum over all these elements: chars (characters and soft
hyphens), tags, images, and windows. This is the default, and includes the
following switches: \fB\-chars\fR, \fB\-image\fR, \fB\-tag\fR,
\fB\-window\fR.
.IP \fB\-chars\fR
The computation considers all characters and soft hyphens.
.IP \fB\-displaychars\fR
If this option is given, then only those characters and soft hyphens which
are not elided will be considered in the computation of the checksum.
.IP \fB\-displaytext\fR
If this option is given, then only those characters which are not elided
will be considered in the computation of the checksum. Note that soft
hyphens (Unicode point U+00AD) do not belong to this result.
.IP \fB\-image\fR
The computation considers all embedded images. In case of an image the name
of the image will be used for the checksum computation.
.IP \fB\-mark\fR
The computation considers all marks. In case of a mark the name of the mark
and his gravity will be used for the checksum computation. Note that the
computation discards generated marks, and it discards the special marks
\fBcurrent\fR, and \fBinsert\fR.
.IP \fB\-tag\fR
Consider tag information in the checksum computation. The name of the tags
associated to this data (characters, soft hyphen, image, or window) will be
used for the checksum computation. But this computation also considers the
priority of the tags.
.IP \fB\-text\fR
The computation considers all characters. Note that soft hyphens (Unicode
point U+00AD) do not belong to this result.
.IP \fB\-window\fR
The computation considers all embedded windows. In case of a window the
pathname of the window will be used for the checksum computation.
.RE
.TP
\fIpathName \fBclear\fR
.
This command is clearing the overall widget, this affects all the
characters, soft hyphens, embedded images, embedded windows, tag
information, and marks. This is not bounded by restrictions, given with
option \fB\-startindex\fR/\fB\-endindex\fR. Also the undo stack will be cleared.
It's like a reset to the initial state, without resetting the options of the
widget, and without clearing widget bindings. Also the states
\fBedit modified\fR, \fBedit altered\fR, and \fBedit irreversible\fR will be
resetted to false. The widget now will be overall clean (see command
\fBisclean \-overall\fR). Note that this operation cannot be undone.
.TP
\fIpathName \fBcompare\fR \fIindex1 op index2\fR
.
Compares the indices given by \fIindex1\fR and \fIindex2\fR according to the
relational operator given by \fIop\fR, and returns 1 if the relationship is
satisfied and 0 if it is not. \fIOp\fR must be one of the operators <, <=, ==,
>=, >, or !=. If \fIop\fR is == then 1 is returned if the two indices refer to
the same character, if \fIop\fR is < then 1 is returned if \fIindex1\fR refers
to an earlier character in the text than \fIindex2\fR, and so on.
.TP
\fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
.
Query or modify the configuration options of the widget. If no \fIoption\fR is
specified, returns a list describing all of the available options for
\fIpathName\fR (see \fBTk_ConfigureInfo\fR for information on the format of
this list). If \fIoption\fR is specified with no \fIvalue\fR, then the command
returns a list describing the one named option (this list will be identical to
the corresponding sublist of the value returned if no \fIoption\fR is
specified). If one or more \fIoption\-value\fR pairs are specified, then the
command modifies the given widget option(s) to have the given value(s); in
this case the command returns an empty string. \fIOption\fR may have any of
the values accepted by the \fBtext\fR command.
.TP
\fIpathName \fBcount\fR \fI?options\fR? \fIindex1 index2\fR
.
Counts the number of relevant things between the two indices. If
\fIindex1\fR is after \fIindex2\fR, the result will be a negative number
(and this holds for each of the possible options). The actual items which
are counted depend on the options given. The result is a list of integers,
one for the result of each counting option given. Valid counting options are
\fB\-chars\fR, \fB\-displaychars\fR, \fB\-displayhyphens\fR,
\fB\-displayindices\fR, \fB\-displaylines\fR, \fB\-displaytext\fR,
\fB\-hyphens\fR, \fB\-indices\fR, \fB\-lines\fR, \fB\-text\fR,
\fB\-xpixels\fR and \fB\-ypixels\fR. The default value, if no option is
specified, is \fB\-indices\fR. There is an additional possible option
\fB\-update\fR which is a modifier. If given (and if the text widget is
managed by a geometry manager), then all subsequent options ensure that any
possible out of date information is recalculated. This currently only has
any effect for the \fB\-ypixels\fR count (which, if \fB\-update\fR is not
given, will use the text widget's current cached value for each line). The
count options are interpreted as follows:
.RS
.IP \fB\-chars\fR
count all characters, whether elided or not, this also includes soft
hyphens. Do not count embedded windows or images.
.IP \fB\-displaychars\fR
count all non-elided characters (see \fB\-chars\fR).
.IP \fB\-displayhyphens\fR
count all non-elided soft hyphens.
.IP \fB\-displayindices\fR
count all non-elided characters, soft hyphens, windows and images (see
\fB\-indices\fR).
.IP \fB\-displaylines\fR
count all display lines (i.e. counting one for each time a line wraps) from
the line of the first index up to, but not including the display line of the
second index. Therefore if they are both on the same display line, zero will
be returned. By definition displaylines are visible and therefore this only
counts portions of actual visible lines.
.IP \fB\-displaytext\fR
count all non-elided characters, but discard soft hyphens (see
\fB\-text\fR).
.IP \fB\-hyphens\fR
count all soft hyphens, whether elided or not.
.IP \fB\-indices\fR
count all characters, soft hyphens, and embedded windows or images (i.e.
everything which counts in text-widget index space), whether they are elided
or not.
.IP \fB\-lines\fR
count all logical lines (irrespective of wrapping) from the line of the
first index up to, but not including the line of the second index. Therefore
if they are both on the same line, zero will be returned. Logical lines are
counted whether they are currently visible (non-elided) or not.
.IP \fB\-text\fR
count all characters, whether elided or not, but discard soft hyphens.
.IP \fB\-xpixels\fR
count the number of horizontal pixels from the first pixel of the first
index to (but not including) the first pixel of the second index. To count
the total desired width of the text widget (assuming wrapping is not
enabled, and the used font is ideally monospaced), first find the longest
line and then use
.QW ".text count \-xpixels \N'34'${line}.0\N'34' \N'34'${line}.0 lineend\N'34'" .
.IP \fB\-ypixels\fR
count the number of vertical pixels from the first pixel of the first index
to (but not including) the first pixel of the second index. If both indices
are on the same display line, zero will be returned. To count the total
number of vertical pixels in the text widget, use
.QW ".text count \-ypixels begin end" ,
and to ensure this is up to date, use
.QW ".text count \-update \-ypixels begin end" .
.RE
.TP
\fIpathName \fBdebug \fR?\fIboolean\fR?
.
If \fIboolean\fR is specified, then it must have one of the true or false
values accepted by Tcl_GetBoolean. If the value is a true one then internal
consistency checks will be turned on in the B-tree code associated with text
widgets. If \fIboolean\fR has a false value then the debugging checks will be
turned off. In either case the command returns an empty string. If
\fIboolean\fR is not specified then the command returns \fBon\fR or \fBoff\fR
to indicate whether or not debugging is turned on. There is a single debugging
switch shared by all text widgets: turning debugging on or off in any widget
turns it on or off for all widgets. For widgets with large amounts of text,
the consistency checks may cause a noticeable slow-down.
.RS
.PP
When debugging is turned on, the drawing routines of the text widget set the
global variables \%\fBtk_textRedraw\fR and \%\fBtk_textRelayout\fR to the lists of
indices that are redrawn. The values of these variables are tested by Tk's
test suite.
.RE
.TP
\fIpathName \fBdelete \fI?options\fR? \fIindex1\fR ?\fIindex2 ...\fR?
.
Delete a range of characters from the text. If both \fIindex1\fR and
\fIindex2\fR are specified, then delete all the characters starting with the
one given by \fIindex1\fR and stopping just before \fIindex2\fR (i.e. the
character at \fIindex2\fR is not deleted). If \fIindex2\fR does not specify
a position later in the text than \fIindex1\fR then no characters are
deleted. If \fIindex2\fR is not specified then the single character at
\fIindex1\fR is deleted. Attempts to delete characters in a way that would
leave the text without a newline as the last character will be tweaked by
the text widget to avoid this. In particular, deletion of text up to the end
of the text (inclusively the last newline) will not delete the last newline,
but the tag associations of this newline will be cleared. The command
returns an empty string. If more indices are given, multiple ranges of text
will be deleted. All indices are first checked for validity before any
deletions are made. They are sorted and the text is removed from the last
range to the first range so deleted text does not cause an undesired index
shifting side-effects. If multiple ranges with the same start index are
given, then the longest range is used. If overlapping ranges are given, then
they will be merged into spans that do not cause deletion of text outside
the given ranges due to text shifted during deletion.
.RS
.PP
This command allows the following options:
.IP \fB\-marks\fR
Additionally all the marks belonging to the specified range will be deleted.
Here the indices will be interpreted differenty (but it's important to note
that this re-interpretation is not affecting the range of character
deletion). If \fIindex1\fR is specified in a numerical form the deletion of
the marks starts with the first mark at this position, otherwise it starts
with the next mark after that mark; provided that a mark at this position
exists, otherwise the deletion starts at first character position. If
\fIindex2\fR is specified in a numerical form the deletion ends with the
first mark at this position (not including this mark), otherwise it ends
immediately before that mark; provided that a mark at this position exists,
otherwise the deletion ends just before last character position (specified
with \fIindex2\fR). If \fIindex2\fR is unspecified then \fIindex2\fR will be
assumed as equal to "$index1+1c". This option is especially intended for
programmed editor control, if option \fB\-steadymarks\fR is activated. Note
that the special marks
.QW insert
and
.QW current ,
and also generated marks (see
\fBmark generate\fR), will not be deleted.
.IP \fB\-inclusive\fR
This option is useful only if combined with option \fB\-marks\fR. It causes
that also the marks referred to by \fIindex1\fR and \fIindex2\fR will be
deleted (provided that the concerned mark is neither a special mark \- \fBinsert\fR
or \fBcurrent\fR, \- nor a generated mark).
.RE
.TP
\fIpathName \fBdlineinfo\fR ?\fB\-extents\fR? \fIindex\fR
.
Returns a list with five elements describing the area occupied by the display
line containing \fIindex\fR. The first two elements of the list give the x and
y coordinates of the upper-left corner of the area occupied by the line, the
third and fourth elements give the width and height of the area, and the fifth
element gives the position of the baseline for the line, measured down from
the top of the area. All of this information is measured in pixels. If the
current wrap mode is \fBnone\fR and the line extends beyond the boundaries of
the window, the area returned reflects the entire area of the line, including
the portions that are out of the window. If the line is shorter than the full
width of the window then the area returned reflects just the portion of the
line that is occupied by characters and embedded windows. If the display line
containing \fIindex\fR is not visible on the screen then the return value is
an empty list.
.RS
.PP
If option \fB\-extents\fR is specified then a list of four elements describing
the invisible extents of the bounding box will returned, plus a fifth value
for the baseline position. If x/y (first/second value) is not zero, then the
first x/y pixels are not visible on screen. If width/height (third/fourth
value) is not zero, then the last width/height pixels are not visible on
screen. If the display line containing \fIindex\fR is not visible on the
screen then the return value is an empty list.
.RE
.TP
\fIpathName \fBdump \fR?\fIswitches\fR? \fIindex1 \fR?\fIindex2\fR?
.
Return the contents of the text widget from \fIindex1\fR up to, but not
including \fIindex2\fR, including the text and information about marks, tags,
and embedded windows, and images. If \fIindex2\fR is not specified, then it
defaults to one character past \fIindex1\fR. The information is returned in
the following format:
.RS
.LP
\fIkey1 value1 index1 key2 value2 index2\fR ...
.LP
The possible \fIkey\fR values are \fBtext\fR, \fBhyphen\fR, \fBmark\fR,
\fBtagon\fR, \fBtagoff\fR, \fBimage\fR, \fBwindow\fR and \fBnode\fR. The
corresponding \fIvalue\fR is the text, mark name, tag name, image name,
window name or node identifier, the hyphen has no value (this means the
value is empty). The \fIindex\fR information is the index of the start of
the text, hyphen, mark, tag transition, image, window or node. One or more
of the following switches (or abbreviations thereof) may be specified to
control the dump:
.TP
\fB\-all\fR
.
Return information about all elements: text, hyphens, marks, tags, images
and windows (but not nodes). This is the default.
.TP
\fB\-chars\fR
.
Include information about text (characters and soft hyphens) in the dump
results. The value is the text up to the next element or the end of range
indicated by \fIindex2\fR. A text element does not span newlines. A
multi-line block of text that contains no marks or tag transitions will
still be dumped as a set of text segments that each end with a newline. The
newline is part of the value.
.TP
\fB\-command \fIcommand\fR
.
Instead of returning the information as the result of the dump operation,
invoke the \fIcommand\fR on each element of the text widget within the range.
The command has three arguments appended to it before it is evaluated: the
\fIkey\fR, \fIvalue\fR, and \fIindex\fR.
.TP
\fB\-image\fR
.
Include information about images in the dump results.
.TP
\fB\-mark\fR
.
Include information about marks in the dump results.
.TP
\fB\-node\fR
This information is for debugging only. It informs that the following
content will belong to this B-Tree node.
.TP
\fB\-tag\fR
.
Include information about tag transitions in the dump results. Tag information
is returned as \fBtagon\fR and \fBtagoff\fR elements that indicate the begin
and end of each range of each tag, respectively.
.TP
\fB\-text\fR
.
Include information about text (characters) in the dump results. The value
is the text up to the next element or the end of range indicated by
\fIindex2\fR. A text element does not span newlines. A multi-line block of
text that contains no marks or tag transitions will still be dumped as a set
of text segments that each end with a newline. The newline is part of the
value. Note that soft hyphens (Unicode point U+00AD) do not belong to this
result.
.TP
\fB\-tags \fItagList\fR
.
Specifies a set of tags to apply to the embedded window. \fITagList\fR consists
of a list of tag names, which replace any existing tags for the embedded window.
\fITagList\fR may be an empty list. Note that it is not possible to add or
remove the special selection tag \fBsel\fR, it will be left untouched with this
option.
.TP
\fB\-window\fR
.
Include information about embedded windows in the dump results. The value of a
window is its Tk pathname, unless the window has not been created yet. (It
must have a create script.) In this case an empty string is returned, and you
must query the window by its index position to get more information.
.TP
\fB\--\fR
.
This switch has no effect except to terminate the list of switches: the next
argument will be treated as pattern even if it starts with \-.
.RE
.TP
\fIpathName \fBedit \fIoption \fR?\fIarg arg ...\fR?
.
This command controls the undo mechanism and the modified flag. The exact
behavior of the command depends on the \fIoption\fR argument that follows the
\fBedit\fR argument. The following forms of the command are currently
supported:
.RS
.TP
\fIpathName \fBedit altered\fR
.
Returns whether changes have been done (eventual) affecting the text
content, or the representation of the text content. Any of the following
commands can set this flag to true:
.RS
.IP [1] 4
\fIpathName \fBdelete\fR
.IP [2] 4
\fIpathName \fBedit redo\fR
.IP [3] 4
\fIpathName \fBinsert\fR
.IP [4] 4
\fIpathName \fBmark gravity|set|unset\fR
(but only if \fB\-steadymarks\fR is enabled)
.IP [5] 4
\fIpathName \fBtag add|clear|lower|raise|remove\fR
(but not if \fB\-undo\fR of affected tag is false)
.IP [6] 4
\fIpathName \fBinsert\fR
.RE
.RS
.PP
This flag will be false before any of these operations have been done. It
can never be false if \fBedit irreversible\fR reports true. It will be true
after \fBclear\fR and \fBload\fR, and it will be true again if all changes
have been undone (with \fBedit undo\fR or \fBedit recover\fR). Also enabling
the undo stack (via widget option \fB\-undo\fR) will reset this state to false.
.PP
Any change of this state, if caused by an operation with (eventual) effects
on the (representation of the) text content, will trigger the virtual event
\fB<<Altered>>\fR.
.RE
.TP
\fIpathName \fBedit canredo\fR
.
Note that this command is deprecated, command \fIpathName\fR \fBedit info\fR
should be used instead. For compatibility reasons this command still will be
supported, but may be removed in a future version.
.RS
.PP
Returns a boolean true if redo is possible, i.e. when the redo stack is not
empty. Otherwise returns false.
.RE
.TP
\fIpathName \fBedit canundo\fR
.
Note that this command is deprecated, command \fIpathName\fR \fBedit info\fR
should be used instead. For compatibility reasons this command still will be
supported, but may be removed in a future version.
.RS
.PP
Returns a boolean true if undo is possible, i.e. when the undo stack is not
empty. Otherwise returns false.
.RE
.TP
\fIpathName \fBedit info\fR \fI?array\fR?
.
Stores an array of some edit information in given variable \fIarray\fR, if
\fIarray\fR is not given then an unnamed variable will be used.
.RS
.PP
This command returns the array name \fIarray\fR, or an empty string (unnamed
variable) if \fIarray\fR is not specified.
.PP
This is the available information related to this widget:
.IP
\fBbytesize\fR
.
.RS
Current byte size, only characters have been counted (a character may have
more than one byte).
.RE
.IP
\fBlines\fR
.
.RS
Current number of lines.
.RE
.IP
\fBvisibleimages\fR
.
.RS
Number of visible embedded images.
.RE
.IP
\fBvisiblewindows\fR
.
.RS
Number of visible embedded windows.
.RE
.PP
This is the available information related to whole content:
.IP
\fBtotalbytesize\fR
.
.RS
Current byte size, only characters have been counted (a character may have
more than one byte).
.RE
.IP
\fBundodepth\fR
.
.RS
The depth (number of undoable actions) of the undo stack.
.RE
.IP
\fBredodepth\fR
.
.RS
The depth (number of redoable actions) of the redo stack.
.RE
.IP
\fBundostacksize\fR
.
.RS
Current number of items on undo stack.
.RE
.IP
\fBredostacksize\fR
.
.RS
Current number of items on redo stack.
.RE
.IP
\fBundobytesize\fR
.
.RS
Current number of bytes on the undo stack, only characters have been counted
(a character may have more than one byte).
.RE
.IP
\fBredobytesize\fR
.
.RS
Current number of bytes on the redo stack, only characters have been counted
(a character may have more than one byte).
.RE
.IP
\fBundocommands\fR
.
.RS
If the current undo stack action does not contain an undo atom, then this
information is empty. Otherwise it contains the list of commands that have
been pushed for undoing onto the stack since last inserted separator. A
command is one of: \fIdelete\fR, \fIimage\fR, \fIinsert\fR, \fImark\fR,
\fItag\fR, or \fIwindow\fR. Note that \fImark\fR can only occur when option
\fB\-steadymarks\fR is enabled. Also note that the \fBreplace\fR command is
pushing either \fIdelete\fR and \fIinsert\fR. Further note that this list
contains all edit operations of the current undo atom, this means that some
commands can occur repeatedly.
.RE
.IP
\fBredocommands\fR
.
.RS
If the current undo stack action does not contain an redo atom, then this
information is empty. Otherwise it contains the list of commands that have
been undone with current undo command, see \fBundocommands\fR for more
details.
.RE
.IP
\fBtotallines\fR
.
.RS
Current number of lines.
.RE
.IP
\fBimages\fR
.
.RS
Number of embedded images.
.RE
.IP
\fBwindows\fR
.
.RS
Number of embedded windows.
.RE
.IP
\fBtags\fR
.
.RS
Number of currently defined tags.
.RE
.IP
\fBusedtags\fR
.
.RS
Number of tags currently used.
.RE
.IP
\fBmarks\fR
.
.RS
Number of currently defined marks, this does not include the special marks
\fIinsert\fR and \fIcurrent\fR, nor the generated marks (see
\fBmark generate\fR).
.RE
.IP
\fBgeneratedmarks\fR
.
.RS
Number of generated marks currently defined (see \fBmark generate\fR).
.RE
.PP
This information is unrelated to the content:
.IP
\fBlinespernode\fR
.
.RS
Minimal number of lines per node in B-Tree, this information is only useful
for testing.
.RE
.PP
In the future the information might be extended. Note that embedded windows
and images will each be count with byte size one.
.RE
.TP
\fIpathName \fBedit inspect\fR \fI?stack\fR?
.
Returns information about all undo, or redo, atoms. If \fIstack\fR is
specified (must be either \fBundo\fR or \fBredo\fR), then only the
information of this stack will be returned, otherwise the result contains
two lists, firstly all undo atoms, and secondly all redo atoms. Any atom
information contains at least one sub-atom. Each sub-atom is a list where the
first element of the list (at least) describes the nature of the sub-atom.
.RS
.PP
This is an informal description about the sub-atom content:
.PP
{\fBclear\fR}
.RS
Redo clearing tag associations (\fBtag clear\fR).
.RE
.PP
{\fBclear \fItag-list skip length\fR ...}
.RS
Undo clearing tag associations (\fBtag clear\fR).
.RE
.PP
{\fBdelete\fR}
.RS
Redo the deletion either of characters, hyphen, embedded image, or embedded
window (\fBdelete\fR).
.RE
.PP
{\fBdelete character \fIstring tag-list\fR}
.RS
Undo the deletion of characters (\fBdelete\fR), does not contain soft
hyphens.
.RE
.PP
{\fBdelete hyphen \fItag-list\fR}
.RS
Undo the deletion of a soft hyphen (\fBdelete\fR).
.RE
.PP
{\fBdelete image \fItag-list image-options\fR}
.RS
Undo the deletion of an embedded image (\fBdelete\fR).
.RE
.PP
{\fBdelete window \fItag-list window-options\fR}
.RS
Undo the deletion of an embedded window (\fBdelete\fR).
.RE
.PP
{\fBinsert\fR}
.RS
Undo an \fBinsert\fR operation; either characters, hyphen, embedded image,
or embedded window.
.RE
.PP
{\fBinsert character \fIstring tag-list\fR}
.RS
Redo an \fBinsert\fR operation of characters.
.RE
.PP
{\fBinsert hyphen \fItag-list\fR}
.RS
Redo an \fBinsert\fR operation of a soft hyphen.
.RE
.PP
{\fBinsert image \fItag-list image-options\fR}
.RS
Redo an \fBinsert\fR operation of an embedded image.
.RE
.PP
{\fBinsert window \fItag-list window-options\fR}
.RS
Redo an \fBinsert\fR operation of an embedded window.
.RE
.PP
{\fBmark gravity \fIname\fR}
.RS
Undo/redo toggling the gravity of a mark; either from \fIleft\fR to
\fIright\fR, or from \fIright\fR to \fIleft\fR (\fBtag gravity\fR).
.RE
.PP
{\fBmark set \fIname\fB left\fR}
.RS
Undo/redo setting a mark with left gravity (\fBmark set\fR).
.RE
.PP
{\fBmark set \fIname\fB right\fR}
.RS
Undo/redo setting a mark with right gravity (\fBmark set\fR).
.RE
.PP
{\fBmark unset \fIname\fR}
.RS
Undo/redo unsetting a mark (\fBmark unset\fR).
.RE
.PP
{\fBtag add \fItag\fR}
.RS
Undo/redo adding an association with tags (\fBtag add\fR).
.RE
.PP
{\fBtag remove \fItag\fR}
.RS
Undo/redo removing an association with tags (\fBtag delete\fR).
.RE
.RE
.TP
\fIpathName \fBedit irreversible\fR
.
Returns a flag whether the content of the text widget is irreversible. The
content is irreversible if the undo stack is not enabled when performing
undoable edit operations, or the undo stack is enabled, but incomplete due
to the limitation of stack depth and/or stack byte size. Also disabling
widget option \fB\-undo\fR will become an irreversible state if the undo
stack was not empty at this time. A change of this state, if caused by an
operation with (eventual) effects on the (representation of the) text
content (see \fBedit altered\fR for details), will trigger the virtual event
\fB<<Irreversible>>\fR. The state will be resetted to false if one of the
following commands will be performed: \fBclear\fR, \fBload\fR,
\fBedit reset\fR, or \fBedit reset undo\fR (but not \fBedit reset redo\fR).
The state will also be resetted to false when widget option \fB\-undo\fR
will be enabled.
.TP
\fIpathName \fBedit modified \fR?\fIboolean\fR?
.
If \fIboolean\fR is not specified, returns the modified flag of the widget.
The \fBinsert\fR, \fBdelete\fR, \fBedit undo\fR, \fBedit redo\fR and
\fBedit recover\fR commands or the user can set or clear the modified flag.
If \fIboolean\fR is specified, sets the modified flag of the widget to
\fIboolean\fR.
.TP
\fIpathName \fBedit recover\fR
.
Applies all undo items, without adding redo items. The initial text (before
any modification has been done since the undo stack is enabled) will be
recovered. The undo stack is empty afterwards.
.RS
.PP
Note: If \fBedit irreversible\fR returns true (before calling this function),
then it's not possible to recover the initial text, in this case it will be
recovered as much as possible. If \fBedit irreversible\fR returns false (before
calling this function), then the state \fBedit altered\fR will change to false.
.RE
.TP
\fIpathName \fBedit redo\fR
.
When the \fB\-undo\fR option is true, reapplies the last undone edits
provided no other edits were done since then. Generates an error when the
redo stack is empty. Does nothing when the \fB\-undo\fR option is false.
.TP
\fIpathName \fBedit reset\fR \fI?stack\fR?
.
If \fIstack\fR is not specified, then clear the undo and redo stacks.
Otherwise only clear the specified stack. The specified stack must be either
\fBundo\fR or \fBredo\fR, otherwise an error will be thrown.
.TP
\fIpathName \fBedit separator\fR ?\fB\-immediately\fR?
.
Inserts a separator (boundary) on the undo stack. Does nothing when the
\fB\-undo\fR option is false. Per default the insertion of the separator
will be postponed until the next
\fBinsert\fR/\fBdelete\fR/\fBreplace\fR/\fBedit undo\fR/\fBedit redo\fR/\fBedit recover\fR
command will be performed. If option \fB\-immediately\fR is specified then
the separator will be pushed immediately; this is required if mark or tag
operations should be separated.
.TP
\fIpathName \fBedit undo\fR
.
Undoes the last edit action when the \fB\-undo\fR option is true. An edit
action is defined as all the commands modifying any text, or tag
associations (but not the changes of tag options) that are recorded on the
undo stack in between two separators, furthermore this includes the
(dis-)embedding of images and windows, but not changes of the content or
options of images and windows. Generates an error when the undo stack is
empty. Does nothing when the \fB\-undo\fR option is false, or when
\fB\-maxredo\fR is set to zero.
.RS
.PP
The marks are not influencing the display, thus operations on marks will not
be recorded, except if option \fB\-steadymarks\fR is enabled: this is the
appropriate mode for programmed editor control, and here the recovery of the
marks (position and gravity) is essential. But operations on the special
marks \fBinsert\fR and \fBcurrent\fR, as well as operations on generated
marks, will never be recorded, these marks should in general not be used if
undoing the operation on a mark is essential.
.RE
.RE
.TP
\fIpathName \fBget\fR ?\fIswitch\fR? ?\fB\-\-\fR? \fIindex1\fR ?\fIindex2 ...\fR?
.
Return a range of characters from the text. The return value will be all the
characters in the text starting with the one whose index is \fIindex1\fR and
ending just before the one whose index is \fIindex2\fR (the character at
\fIindex2\fR will not be returned). If \fIindex2\fR is omitted then the
single character at \fIindex1\fR is returned. If there are no characters in
the specified range (e.g. \fIindex1\fR is past the end of the file or
\fIindex2\fR is less than or equal to \fIindex1\fR) then an empty string is
returned. If the specified range contains embedded windows, no information
about them is included in the returned string. If multiple index pairs are
given, multiple ranges of text will be returned in a list. Invalid ranges
will not be represented with empty strings in the list. The ranges are
returned in the order passed to \fIpathName \fBget\fR. The \fIswitch\fR will
be interpreted as follows:
.RS
.TP
\fB\-chars\fR
.
all characters within the ranges will be returned, whether elided or not,
this also includes soft hyphens. This is the default, if no switch is given.
.TP
\fB\-text\fR
.
all characters, which are not soft hyphens, within the ranges will be
returned, whether elided or not.
.TP
\fB\-displaychars\fR
.
only those characters which are not elided will be returned, this also
includes soft hyphens. This may have the effect that some of the returned
ranges are empty strings.
.TP
\fB\-displaytext\fR
.
only those characters, which are neither soft hyhens, nor elided, will be
returned. This may have the effect that some of the returned ranges are
empty strings.
.RE
.TP
\fIpathName \fBimage \fIoption \fR?\fIarg arg ...\fR?
.
This command is used to manipulate embedded images. The behavior of the
command depends on the \fIoption\fR argument that follows the \fBtag\fR
argument. The following forms of the command are currently supported:
.RS
.TP
\fIpathName \fBimage cget \fIindex option\fR
.
Returns the value of a configuration option for an embedded image. \fIIndex\fR
identifies the embedded image, and \fIoption\fR specifies a particular
configuration option, which must be one of the ones listed in the section
\fBEMBEDDED IMAGES\fR.
.TP
\fIpathName \fBimage configure \fIindex\fR ?\fIoption value ...\fR?
.
Query or modify the configuration options for an embedded image. If no
\fIoption\fR is specified, returns a list describing all of the available
options for the embedded image at \fIindex\fR (see \fBTk_ConfigureInfo\fR for
information on the format of this list). If \fIoption\fR is specified with no
\fIvalue\fR, then the command returns a list describing the one named option
(this list will be identical to the corresponding sublist of the value
returned if no \fIoption\fR is specified). If one or more \fIoption\-value\fR
pairs are specified, then the command modifies the given option(s) to have the
given value(s); in this case the command returns an empty string. See
\fBEMBEDDED IMAGES\fR for information on the options that are supported.
.TP
\fIpathName \fBimage create \fIindex\fR ?\fIoption value ...\fR?
.
This command creates a new image annotation, which will appear in the text at
the position given by \fIindex\fR. Any number of \fIoption\-value\fR pairs may
be specified to configure the annotation. Returns a unique identifier that may
be used as an index to refer to this image. See \fBEMBEDDED IMAGES\fR for
information on the options that are supported, and a description of the
identifier returned.
.TP
\fIpathName \fBimage names\fR
.
Returns a list whose elements are the names of all image instances currently
embedded in \fIwindow\fR.
.RE
.TP
\fIpathName \fBindex \fIindex\fR
.
Returns the position corresponding to \fIindex\fR in the form \fIline.char\fR
where \fIline\fR is the line number and \fIchar\fR is the character number.
\fIIndex\fR may have any of the forms described under \fBINDICES\fR above.
.TP
\fIpathName \fBinsert \fIindex chars \fR?\fItagList chars tagList ...\fR?
.
Inserts all of the \fIchars\fR arguments just before the character at
\fIindex\fR. If \fIindex\fR refers to the end of the text (the character
after the last newline) then the new text is inserted just before the last
newline instead. If there is a single \fIchars\fR argument and no
\fItagList\fR, then the new text will receive any tags depending on the
tagging mode (see option \fB\-tagging\fR). If \fItagList\fR is specified
then it consists of a list of tag names; the new characters will receive all
of the tags in this list and no others, regardless of the tagging mode. If
multiple \fIchars\fR\-\fItagList\fR argument pairs are present, they produce
the same effect as if a separate \fIpathName \fBinsert\fR widget command had
been issued for each pair, in order. The last \fItagList\fR argument may be
omitted.
.TP
\fIpathName \fBinspect\fR ?\fIswitches\fR?
.
Return the content of the text widget, including the text and optionally
information about tags, embedded windows, and embedded images. The information
is returned in the following format (notated in EBNF; BEG denotes the start of
a list, end END denotes the end of the list; white spaces will not be taken
into consideration):
.RS
.RS 3
.PP
.CS
\fIInspect\fR = BEG, \fISetup\fR?, \fIConfigure\fR?, \fISegment\fR+, END;
\fISetup\fR = BEG, "\fBsetup\fR", \fIPathName\fR, \fITextOptions\fR, END;
\fIConfigure\fR = BEG, "\fBconfigure\fR", \fITagName\fR, (BEG, \fITagOptions\fR, END)?, END;
\fIBindings\fR = BEG, "\fBbind\fR", \fITagName\fR, (BEG, \fIScript\fR, END), END;
\fISegment\fR = BEG, ((\fIContent\fR, \fITagInfo\fR) | \fIMark\fR | \fIElide\fR | \fIBinding\fR), END;
\fIContent\fR = \fIText\fR | \fIHyphen\fR | \fIBreak\fR | \fIEmbImage\fR | \fIEmbWindow\fR;
\fIText\fR = "\fBtext\fR", BEG, \fICharacter\fR+, END;
\fIHyphen\fR = "\fBhyphen\fR";
\fIEmbImage\fR = "\fBimage\fR", \fIImageOptions\fR;
\fIEmbWindow\fR = "\fBwindow\fR", \fIWindowOptions\fR;
\fIMark\fR = \fIGravity\fR, \fIMarkName\fR;
\fIGravity\fR = "\fBleft\fR" | "\fBright\fR";
\fIElide\fR = "\fBelide\fR", ("\fBon\fR" | "\fBoff\fR");
\fITagInfo\fR = (\fITags\fR, \fITags\fR?)?;
\fITags\fR = BEG, \fITagName\fR* , END;
\fICharacter\fR = ?Any character except newline?;
\fINewline\fR = ?The newline character?;
\fITextOptions\fR = ?See \fBSTANDARD OPTIONS\fR and \fBWIDGET-SPECIFIC OPTIONS\fR?;
\fITagOptions\fR = ?See \fBTAGS\fR?;
\fIImageOptions\fR = ?See \fBEMBEDDED IMAGES\fR?;
\fIWindowOptions\fR = ?See \fBEMBEDDED WINDOWS\fR?;
\fIPathName\fR = ?Any valid widget pathname?;
\fITagName\fR = ?Any tag name?;
\fIMarkName\fR = ?Any mark name?;
.CE
.RE
.PP
We will also provide an informal description of the items; note that
the optional \fItagList\fR will be provided only if option \fB\-nested\fR is
specified:
.PP
{\fBsetup\fR \fIpathName configurationList\fR}
.RS
Provides the overall information about the inspected widget, notably its
\fIpathName\fR and configuration options.
.RE
.PP
{\fBconfigure\fR \fItagName\fR ?\fIconfigurationList\fR?}
.RS
Describes the configuration of a particular tag.
.RE
.PP
{\fBbind\fR \fItagName event script\fR}
.RS
Describes a binding applied to a tag
.RE
.PP
{\fBtext\fR \fIcontent ?tagList\fR ?\fItagList\fR??}
.RS
Describes a character sequence, optionally including what tags were applied to it.
.RE
.PP
{\fBbreak\fR \fItagList\fR ?\fItagList\fR?}
.RS
Describes a newline character, including what tags were applied to it.
.RE
.PP
{\fBhyphen\fR \fItagList\fR ?\fItagList\fR?}
.RS
Describes a soft hyphen, including what tags were applied to it.
.RE
.PP
{\fBimage\fR \fIimageOptions ?tagList\fR ?\fItagList\fR??}
.RS
Describes an image that was embedded, optionally including what tags were applied to it.
.RE
.PP
{\fBwindow\fR \fIwindowOptions ?tagList\fR ?\fItagList\fR??}
.RS
Describes a window that was embedded, optionally including what tags were applied to it.
.RE
.PP
{\fBleft\fR \fImarkName\fR}
.RS
Describes a mark with left gravity.
.RE
.PP
{\fBright\fR \fImarkName\fR}
.RS
Describes a mark with right gravity.
.RE
.PP
{\fBelide\fR \fBon\fR|\fBoff\fR}
.RS
Describes whether elision is turned on or off at the current handling point.
.RE
.PP
One or more of the following switches (or abbreviations thereof) may be
specified to control the extraction:
.RS
.TP
\fB\-all\fR
.
Return information about all elements: text (characters and soft hyphens),
marks, tags, images, and windows. This is the default, and includes the following
switches: \fB\-chars\fR, \fB\-mark\fR \fB\-tag\fR, \fB\-image\fR, and \fB\-window\fR.
.TP
\fB\-complete\fR
.
Return complete information, this includes the following switches:
\fB\-all\fR, \fB\-bindings\fR, \fB\-configurations\fR, \fB\-elide\fR,
\fB\-includedbconfig\fR, \fB\-includedefaultconfig\fR, \fB\-includeselection\fR,
\fB\-includesyscolors\fR, \fB\-includesysconfig\fR, \fB\-insertmark\fR, and
\fB\-setup\fR.
.TP
\fB\-bindings\fR
.
Include all tag bindings into the result.
.TP
\fB\-chars\fR
.
Include information about characters and soft hyphens in the dump results. The content of this segment is the text up to the next segment. The segmentation of text depends on the tagging information, any change in tagging is starting a new segment.
.TP
\fB\-configurations\fR
.
Include all the tag configurations.
.TP
\fB\-displaychars\fR
.
If this option is given, then only those characters and soft hyphens which
are not elided will be included into the result of the text element.
.TP
\fB\-displaytext\fR
.
If this option is given, then only those characters which are not elided
will be included into the result of the text element. Note that soft hyphens
(Unicode point U+00AD) do not belong to this result.
.TP
\fB\-dontresolvecolors\fR
.
Do not resolve system color names (this is affecting the content of \fB\-setup\fR,
and \fB\-configurations\fR). Resolving system color names is required for
portability, but in case of system dependent use (if all system color names will be
resolvable) it is not required. Per default system color names will be resolved.
.TP
\fB\-dontresolvefonts\fR
.
Do not resolve font names (this is affecting the content of \fB\-setup\fR,
and \fB\-configurations\fR). Resolving font names is required for
portability, but in case of private use (if all font names will be
resolvable) it is not required. Per default font names will be resolved.
.TP
\fB\-elide\fR
.
The result will also include information about elided regions. It is for
information only \- better visibility of elided text. The \fBload\fR command
will ignore these elements.
.TP
\fB\-image\fR
.
Include information about images in the result. The content of the image is
a list containing the image options.
.TP
\fB\-includedbconfig\fR
.
This option makes sense only if also option \fB\-setup\fR (or \fB\-all\fR) is
specified. With this option a configuration option will be included into the
list of configuration even if the value of this option is equal to the value
from option database (per default database values are excluded).
.TP
\fB\-includedefaultconfig\fR
.
This option makes sense only if also option \fB\-setup\fR (or \fB\-all\fR) is
specified. With this option a configuration option will be included into the
list of configuration even if the value of this option is equal to the default
value (per default the default values are excluded). Note that the options
\fB\-includedbconfig\fR and \fB\-includesysconfig\fR have higher priority.
.TP
\fB\-includeselection\fR
.
This option makes sense only if also option \fB\-tag\fR (or \fB\-all\fR) is
specified. With this option the selection tag \fBsel\fR will be included into the
result. Per default the selection will be discarded when inspecting the content.
.TP
\fB\-includesyscolors\fR
.
When inspecting widget or tag option values normally system colors (like
.QW SystemHighlight ,
or
.QW systemHighlight )
will be discarded, except if option \fB\-includesyscolors\fR is specified.
.TP
\fB\-includesysconfig\fR
.
This option makes sense only if also option \fB\-setup\fR (or \fB\-all\fR) is
specified. With this option a configuration option will be included into the
list of configuration even if the value of this option is equal to the system
value (per default the system values are excluded). Note that option
\fB\-includedbconfig\fR has a higher priority.
.TP
\fB\-insertmark\fR
.
Include information about the
.QW insert
mark in the dump results. Without this option, this mark will not be printed.
.TP
\fB\-mark\fR
.
Include information about marks in the dump results. Depending on the
gravity the type of this segment is either left or right. The segment
content is the name of the mark. The special marks \fBinsert\fR and
\fBcurrent\fR will be discarded (but see option \fB\-insertmark\fR), and
generated marks will also be discarded.
.TP
\fB\-nested\fR
.
This option will only be regarded in conjunction with switch \fB\-tag\fR,
see description of switch \fB\-tag\fR below.
.TP
\fB\-setup\fR
.
Include the pathname of the widget, and a list of configuration options. Per
default a configuration option will be included only if the value is neither
equal to the default value, nor equal to the system value, nor equal to the
value from option database. This can be modified with options
\fB\-includedefaultconfig\fR, \fB\-includesysconfig\fR, and
\fB\-includedbconfig\fR.
.TP
\fB\-tag\fR
.
Include information about tags in the result. If additionally option
\fB\-nested\fR is specified, then two tag sets will be provided: firstly all
the tags starting with this content, and secondly all the tags ending after
this content (similar to the \fItagon\fR and \fItagoff\fR ranges in the
\fBdump\fR format). Without the \fB\-nested\fR option (this is the default) only
one list will be provided, namely all the tags associated to this segment
content. The tag list will be sorted in order from lowest priority to highest
priority.
.TP
\fB\-text\fR
.
Include information about text (characters) in the dump result. The content
of this segment is the text up to the next segment. The segmentation of text
depends on the tagging information, any change in tagging is starting a new
segment. Note that soft hyphens (Unicode point U+00AD) do not belong to this
result.
.TP
\fB\-window\fR
.
Include information about embedded windows in the result. The content of a
window is a list containing the window options.
.RE
.PP
The result of this command can be used for loading a widget with a snapshot
(see command \fBload\fR).
.RE
.TP
\fIpathName \fBisclean\fR ?\fB\-overall\fR? ?\fB\-discardselection\fR?
.
Returns whether this widget does not contain any character, soft hyphen,
embedded window, or embedded image, except an untagged sole newline.
Furthermore a clean widget does not contain any marks, except the special
marks \fBcurrent\fR and \fBinsert\fR, and generated marks. If option
\fB\-overall\fR is specified, then this test will discard any restrictions
given with widget options \fB\-startindex\fR and \fB\-endindex\fR. If option
\fB\-discardselection\fR is given, the special selection tag \fBsel\fR
will be discarded when testing whether the sole newline is tagged.
.TP
\fIpathName \fBisdead\fR
.
A text widget is dead if it does not contain any line (in this case no
insertion is possible anymore). This only happens if one of the widget
options \fB\-startindex\fR/\fB\-endindex\fR is specified.
.TP
\fIpathName \fBisempty\fR ?\fB\-overall\fR?
.
Returns whether this widget does not contain any character, soft hyphen,
embedded window, or embedded image, except a sole newline. If the
\fB\-overall\fR option is specified, then this test will discard any restrictions
given with widget options \fB\-startindex\fR and \fB\-endindex\fR.
.TP
\fIpathName \fBlineno\fR \fIindex\fR
.
Returns the line number corresponding to \fIindex\fR. \fIIndex\fR may have
any of the forms described under \fBINDICES\fR above.
.RS
.PP
If the widget is dead (i.e., does not contain lines, which is possible
only if option \fB\-startline\fR/\fB\-endline\fR is involved), then 0 (zero)
will be returned.
.RE
.TP
\fIpathName \fBload\fR ?\fB\-validconfig\fR? \fIserialContent\fR
.
Load the text widget with given content \fIserialContent\fR. The widget will
be cleared before the load will be done, this includes all marks, but not
the tag definitions. The format of \fIserialContent\fR is described in the
\fBinspect\fR subcommand, which produces it. Normally invalid configuaration
options will be skipped, except if option \fB\-validconfig\fR is specified,
in this case an error will be thrown if an invalid option value will be
encountered. Normally the latter only may happen if the given content is
produced under a different system.
.RS
.PP
For a complete recovery of the text widget content the following is
required:
.IP \(bu 3
The content contains the complete information (see flag \fB\-all\fR of
command \fBinspect\fR).
.IP \(bu 3
All embedded images have to exist.
.IP \(bu 3
Either the embedded windows have to exist, or the \fBwindow\fR item
contains an executable \fBcreate\fR option.
.PP
The states \fBedit modified\fR, \fBedit altered\fR, and
\fBedit irreversible\fR will be resetted to false. Note that this operation
cannot be undone.
.RE
.TP
\fIpathName \fBmark \fIoption \fR?\fIarg arg ...\fR?
.
This command is used to manipulate marks. The exact behavior of the command
depends on the \fIoption\fR argument that follows the \fBmark\fR argument. The
following forms of the command are currently supported:
.RS
.TP
\fIpathName \fBmark compare\fR \fImarkName1 op markName2\fR
.
Compares the marks given by \fImarkName1\fR and \fImarkName2\fR according to
the relational operator given by \fIop\fR, and returns 1 if the relationship
is satisfied and 0 if it is not. \fIOp\fR must be one of the operators <,
<=, ==, >=, >, or !=. If \fIop\fR is == then 1 is returned if the two marks
are the same, if \fIop\fR is < then 1 is returned if \fImarkName1\fR refers
to an earlier mark in the text than \fImarkName2\fR, and so on. If one of
the given operands is not an exisiting mark, then an error will be thrown.
This command is especially useful when option \fB\-steadymarks\fR is
enabled.
.TP
\fIpathName \fBmark exists\fR \fImarkName\fR
.
Returns whether the specified mark is already existing at any position.
.TP
\fIpathName \fBmark generate\fR
.
Creates a mark, either for temporary use, or for static use. This mark has
the following properties:
.RS
.IP [1] 4
Operations on this mark will not be stacked onto the undo stack (relevant
only if option \fB\-steadymarks\fR is enabled).
.IP [2] 4
It is not visible, this means that the commands \fBmark names\fR,
\fBmark next\fR, and \fBmark previous\fR will not return generated marks,
and command \fBinspect\fR will not print this mark (but command \fBdump\fR
will print it, it has the form
.QW "##ID##[:hexdigit:]+##[:hexdigit:]+##[:digit:]+##" ).
.IP [3] 4
This mark cannot be deleted except with command \fBmark unset\fR (this means
that \fBdelete \-marks\fR will not delete this kind of marks).
.IP [4] 4
Commands \fBclear\fR and \fBload\fR will not delete this mark, but the
relative order to other (generated) marks may change after clearing the text
content (command \fBload\fR is also clearing before loading).
.IP [5] 4
After deletion of a generated mark (with \fBmark unset\fR) this mark will
expire, which means that a subsequent call of \fBmark set\fR with this mark
will throw an error.
.PP
The initial position of this mark is at start of text. This command returns
the generated name of the mark.
.RE
.TP
\fIpathName \fBmark gravity \fImarkName\fR ?\fIdirection\fR?
.
If \fIdirection\fR is not specified, returns \fBleft\fR or \fBright\fR to
indicate which of its adjacent characters \fImarkName\fR is attached to. If
\fIdirection\fR is specified, it must be \fBleft\fR or \fBright\fR, the
gravity of \fImarkName\fR is set to the given value.
.TP
\fIpathName \fBmark names\fR ?\fB\-discardspecial\fR? ?\fIpattern\fR?
.
Returns a list whose elements are the names of all the marks that are
currently set. If an optional \fIpattern\fR is specified, then only
the names matching this pattern will be included in the result; see
\fBstring match\fR about the rules of pattern matching. If option
\fB\-discardspecial\fR is specified, then exclude the special marks
\fBinsert\fR and \fBcurrent\fR from result, even when matching the
given \fIpattern\fR.
.TP
\fIpathName \fBmark next\fR ?\fB-discardspecial\fR? \fIindex\fR ?\fIpattern\fR?
.
Returns the name of the next mark at or after \fIindex\fR. If \fIindex\fR is
specified in numerical form, then the search for the next mark begins at that
index. If \fIindex\fR is the name of a mark, then the search for the next mark
begins immediately after that mark. This can still return a mark at the same
position if there are multiple marks at the same index. These semantics mean
that the \fBmark next\fR operation can be used to step through all the marks
in a text widget in the same order as the mark information returned by the
\fIpathName \fBdump\fR operation. If a mark has been set to the special
\fBend\fR index, then it appears to be \fIafter\fR \fBend\fR with respect to
the \fIpathName \fBmark next\fR operation. An empty string is returned if
there are no marks after \fIindex\fR.
.RS
.PP
If an optional \fIpattern\fR is specified, then skip all the marks not matching
this pattern during the search; see \fBstring match\fR about the rules of pattern
matching.
.PP
If option \fB\-discardspecial\fR is specified, then skip the special marks
\fBinsert\fR and \fBcurrent\fR during the search.
.RE
.TP
\fIpathName \fBmark previous\fR ?\fB\-discardspecial\fR? \fIindex\fR ?\fIpattern\fR?
.
Returns the name of the mark at or before \fIindex\fR. If \fIindex\fR is
specified in numerical form, then the search for the previous mark begins with
the character just before that index. If \fIindex\fR is the name of a mark,
then the search for the next mark begins immediately before that mark. This
can still return a mark at the same position if there are multiple marks at
the same index. These semantics mean that the \fIpathName \fBmark previous\fR
operation can be used to step through all the marks in a text widget in the
reverse order as the mark information returned by the \fIpathName \fBdump\fR
operation. An empty string is returned if there are no marks before
\fIindex\fR.
.RS
.PP
If an optional \fIpattern\fR is specified, then skip all the marks not matching
this pattern during the search; see \fBstring match\fR about the rules of pattern
matching.
.PP
If option \fB\-discardspecial\fR is specified, then skip the special marks
\fBinsert\fR and \fBcurrent\fR during the search.
.RE
.TP
\fIpathName \fBmark set \fImarkName index\fR ?\fIdirection\fR?
.
Sets the mark named \fImarkName\fR to a position just before the character at
\fIindex\fR. If \fImarkName\fR already exists, it is moved from its old
position; if it does not exist, a new mark is created. If the third parameter
\fIdirection\fR is specified - it must be \fBleft\fR or \fBright\fR - the
gravity of \fImarkName\fR is set to the given value (the gravity for a mark
defaults to \fBright\fR). This command returns an empty string.
.RS
.PP
If widget option \fB\-steadymarks\fR is enabled, and \fIindex\fR is the name
of an existing mark, then \fImarkName\fR will be set left or right from
\fIindex\fR (but at the same numerical position), according to the gravity of
\fIindex\fR.
.RE
.TP
\fIpathName \fBmark unset \fImarkName \fR?\fImarkName markName ...\fR?
.
Remove the mark corresponding to each of the \fImarkName\fR arguments. The
removed marks will not be usable in indices and will not be returned by future
calls to
.QW "\fIpathName \fBmark names\fR" ,
.QW "\fIpathName \fBmark next\fR" ,
and
.QW "\fIpathName \fBmark previous\fR" .
When removing a generated mark (see \fBmark generate\fR) a future call of
\fBmark set\fR with this mark will throw an error (even after clearing the widget).
This command returns an empty string.
.RE
.TP
\fIpathName \fBpeer \fIoption args\fR
.
This command is used to create and query widget peers. It has two forms,
depending on \fIoption\fR:
.RS
.TP
\fIpathName \fBpeer create \fInewPathName\fR ?\fIoptions\fR?
.
Creates a peer text widget with the given \fInewPathName\fR, and any optional
standard configuration options (as for the \fItext\fR command). By default the
peer will have the same start and end line as the parent widget, but these can
be overridden with the standard configuration options.
.TP
\fIpathName \fBpeer names\fR
.
Returns a list of peers of this widget (this does not include the widget
itself). The order within this list is undefined.
.RE
.TP
\fIpathName \fBpendingsync\fR
.
Returns 1 if the line heights calculations are not up-to-date, 0 otherwise.
.TP
\fIpathName \fBreplace\fR \fIindex1 index2 chars\fR ?\fItagList chars tagList ...\fR?
.
Replaces the range of characters between \fIindex1\fR and \fIindex2\fR
with the given characters and tags. See the section on \fIpathName
\fBinsert\fR for an explanation of the handling of the \fItagList...\fR
arguments, and the section on \fIpathName
\fBdelete\fR for an explanation of the handling of the indices. If
\fIindex2\fR corresponds to an index earlier in the text than
\fIindex1\fR, an error will be generated.
.RS
.PP
The deletion and insertion are arranged so that no unnecessary scrolling of
the window or movement of insertion cursor occurs. In addition the undo/redo
stack are correctly modified, if undo operations are active in the text
widget. The command returns an empty string.
.RE
.TP
\fIpathName \fBscan \fIoption args\fR
.
This command is used to implement scanning on texts. It has two forms,
depending on \fIoption\fR:
.RS
.TP
\fIpathName \fBscan mark \fIx y\fR
.
Records \fIx\fR and \fIy\fR and the current view in the text window, for use
in conjunction with later \fIpathName \fBscan dragto\fR commands. Typically
this command is associated with a mouse button press in the widget. It returns
an empty string.
.TP
\fIpathName \fBscan dragto \fIx y\fR
.
This command computes the difference between its \fIx\fR and \fIy\fR arguments
and the \fIx\fR and \fIy\fR arguments to the last \fIpathName \fBscan mark\fR
command for the widget. It then adjusts the view by 10 times the difference in
coordinates. This command is typically associated with mouse motion events in
the widget, to produce the effect of dragging the text at high speed through
the window. The return value is an empty string.
.RE
.TP
\fIpathName \fBsearch \fR?\fIswitches\fR? \fIpattern index \fR?\fIstopIndex\fR?
.
Searches the text in \fIpathName\fR starting at \fIindex\fR for a range of
characters that matches \fIpattern\fR. If a match is found, the index of the
first character in the match is returned as result; otherwise an empty string
is returned. One or more of the following switches (or abbreviations thereof)
may be specified to control the search:
.RS
.TP
\fB\-forwards\fR
.
The search will proceed forward through the text, finding the first matching
range starting at or after the position given by \fIindex\fR. This is the
default.
.TP
\fB\-backwards\fR
.
The search will proceed backward through the text, finding the matching range
closest to \fIindex\fR whose first character is before \fIindex\fR (it is not
allowed to be at \fIindex\fR). Note that, for a variety of reasons, backwards
searches can be substantially slower than forwards searches (particularly when
using \fB\-regexp\fR), so it is recommended that performance-critical code use
forward searches.
.TP
\fB\-exact\fR
.
Use exact matching: the characters in the matching range must be identical to
those in \fIpattern\fR. This is the default.
.TP
\fB\-regexp\fR
.
Treat \fIpattern\fR as a regular expression and match it against the text
using the rules for regular expressions (see the \fBregexp\fR command
and the \fBre_syntax\fR page for
details). The default matching automatically passes both the
\fB\-lineanchor\fR and \fB\-linestop\fR options to the regexp engine (unless
\fB\-nolinestop\fR is used), so that \fI^$\fR match beginning and end of line,
and \fI.\fR, \fI[^\fR sequences will never match the newline character
\fI\en\fR.
.TP
\fB\-nolinestop\fR
.
This allows \fI.\fR and \fI[^\fR sequences to match the newline character
\fI\en\fR, which they will otherwise not do (see the \fBregexp\fR command for
details). This option is only meaningful if \fB\-regexp\fR is also given, and
an error will be thrown otherwise. For example, to match the entire text, use
.QW "\fIpathName \fBsearch \-nolinestop \-regexp\fR \N'34'.*\N'34' 1.0" .
.TP
\fB\-nocase\fR
.
Ignore case differences between the pattern and the text.
.TP
\fB\-count\fI varName\fR
.
The argument following \fB\-count\fR gives the name of a variable; if a match
is found, the number of index positions between beginning and end of the
matching range will be stored in the variable. If there are no embedded images
or windows in the matching range (and there are no elided characters if
\fB\-elide\fR is not given), this is equivalent to the number of characters
matched. In either case, the range \fImatchIdx\fR to \fImatchIdx + $count
chars\fR will return the entire matched text.
.TP
\fB\-all\fR
.
Find all matches in the given range and return a list of the indices of the
first character of each match. If a \fB\-count\fI varName\fR switch is given,
then \fIvarName\fR is also set to a list containing one element for each
successful match. Note that, even for exact searches, the elements of this
list may be different, if there are embedded images, windows or hidden text.
Searches with \fB\-all\fR behave very similarly to the Tcl command \fBregexp
\-all\fR, in that overlapping matches are not normally returned. For example,
applying an \fB\-all\fR search of the pattern
.QW \ew+
against
.QW "hello there"
will just match twice, once for each word, and matching
.QW "Z[a\-z]+Z"
against
.QW ZooZooZoo
will just match once.
.TP
\fB\-overlap\fR
.
When performing \fB\-all\fR searches, the normal behaviour is that matches
which overlap an already-found match will not be returned. This switch changes
that behaviour so that all matches which are not totally enclosed within
another match are returned. For example, applying an \fB\-overlap\fR search of
the pattern
.QW \ew+
against
.QW "hello there"
will just match twice (i.e. no different to just \fB\-all\fR), but matching
.QW Z[a\-z]+Z
against
.QW ZooZooZoo
will now match twice. An error will be thrown if this switch is used without
\fB\-all\fR.
.TP
\fB\-strictlimits\fR
.
When performing any search, the normal behaviour is that the start and stop
limits are checked with respect to the start of the matching text. With the
\fB\-strictlimits\fR flag, the entire matching range must lie inside the start
and stop limits specified for the match to be valid.
.TP
\fB\-elide\fR
.
Find elided (hidden) text as well. By default only displayed text is searched.
.TP
\fB\-discardhyphens\fR
.
Do not match with soft hyphens, this means that soft hyphens inside widget
content will be discarded while performing the search operation. If the text
contains soft hyphen this option is often a must.
.TP
\fB\-\|\-\fR
.
This switch has no effect except to terminate the list of switches: the next
argument will be treated as \fIpattern\fR even if it starts with \fB\-\fR.
.PP
The matching range may be within a single line of text, or run across multiple
lines (if parts of the pattern can match a new-line). For regular expression
matching one can use the various newline-matching features such as \fB$\fR to
match the end of a line, \fB^\fR to match the beginning of a line, and to
control whether \fB.\fR is allowed to match a new-line. If \fIstopIndex\fR is
specified, the search stops at that index: for forward searches, no match at
or after \fIstopIndex\fR will be considered; for backward searches, no match
earlier in the text than \fIstopIndex\fR will be considered. If
\fIstopIndex\fR is omitted, the entire text will be searched: when the
beginning or end of the text is reached, the search continues at the other end
until the starting location is reached again; if \fIstopIndex\fR is specified,
no wrap-around will occur. This means that, for example, if the search is
\fB\-forwards\fR but \fIstopIndex\fR is earlier in the text than
\fIstartIndex\fR, nothing will ever be found. See \fBKNOWN BUGS\fR below for a
number of minor limitations of the \fIpathName \fBsearch\fR command.
.RE
.TP
\fIpathName \fBsee \fIindex\fR
.
Adjusts the view in the window so that the character given by \fIindex\fR is
completely visible. If \fIindex\fR is already visible then the command does
nothing. If \fIindex\fR is a short distance out of view, the command adjusts
the view just enough to make \fIindex\fR visible at the edge of the window.
If \fIindex\fR is far out of view, then the command centers \fIindex\fR in the
window.
.TP
\fIpathName \fBsync\fR ?\fB\-command \fIcommand\fR?
.
Controls the synchronization of the view of the text widget.
.RS
.TP
\fIpathName \fBsync\fR
.
Immediately brings the line metrics up-to-date by forcing computation of any
outdated line heights. The command returns immediately if there is no such
outdated line heights, otherwise it returns only at the end of the computation.
It is guaranteed that the \fB<<WidgetViewSync>>\fR virtual event fires after
executing this command, even if no line was outdated. The command returns an
empty string.
.TP
\fIpathName \fBsync \-command\fR
.
Returns the command which will be scheduled as soon an the line metric
calculation is up-to-date, or an empty string if no command is available.
.TP
\fIpathName \fBsync \-command \fIcommand\fR
.
Schedules \fIcommand\fR to be executed (by the event loop) exactly once as soon
as all line heights are up-to-date. A new script will replace any existing
script, but if the first character is
.QW \fC+\fR
then the new script augments an existing script. If there is no pending line
metrics computation, the scheduling is immediate (as if the line metrics
computation will finish now). \fIbgerror\fR is called on \fIcommand\fR
failure. This command returns an empty string.
.PP
If a command is given (with \fB\-command\fR \fIcommand\fR) then it is ensured
that \fIcommand\fR will be called only when all line height values currently
are up-to-date. When waiting for event \fB<<WidgetViewSync>>\fR it is possible
that some race conditions will affect the received state.
.RE
.TP
\fIpathName \fBtag \fIoption \fR?\fIarg arg ...\fR?
.
This command is used to manipulate tags. The exact behavior of the command
depends on the \fIoption\fR argument that follows the \fBtag\fR argument. The
following forms of the command are currently supported:
.RS
.TP
\fIpathName \fBtag add \fItagName index1 \fR?\fIindex2 index1 index2 ...\fR?
.
Associate the tag \fItagName\fR with all of the characters starting with
\fIindex1\fR and ending just before \fIindex2\fR (the character at
\fIindex2\fR is not tagged). A single command may contain any number of
\fIindex1\fR\-\fIindex2\fR pairs. If the last \fIindex2\fR is omitted then the
single character at \fIindex1\fR is tagged. If there are no characters in the
specified range (e.g. \fIindex1\fR is past the end of the file or \fIindex2\fR
is less than or equal to \fIindex1\fR) then the command has no effect.
.TP
\fIpathName \fBtag bind \fItagName\fR ?\fIsequence\fR? ?\fIscript\fR?
.
This command associates \fIscript\fR with the tag given by \fItagName\fR.
Whenever the event sequence given by \fIsequence\fR occurs for a character
that has been tagged with \fItagName\fR, the script will be invoked. This
'\" TODO how can we include the "bind" ref explicitly?
widget command is similar to the \fBbind\fR command except that it operates on
characters in a text rather than entire widgets. See the \fBbind\fR manual
entry for complete details on the syntax of \fIsequence\fR and the
substitutions performed on \fIscript\fR before invoking it. If all arguments
are specified then a new binding is created, replacing any existing binding
for the same \fIsequence\fR and \fItagName\fR (if the first character of
\fIscript\fR is
.QW \fC+\fR
then \fIscript\fR augments an existing binding rather than replacing it). In
this case the return value is an empty string. If \fIscript\fR is omitted then
the command returns the \fIscript\fR associated with \fItagName\fR and
\fIsequence\fR (an error occurs if there is no such binding). If both
\fIscript\fR and \fIsequence\fR are omitted then the command returns a list of
all the sequences for which bindings have been defined for \fItagName\fR.
.RS
.PP
The only events for which bindings may be specified are those related to the
mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButtonPress\fR,
\fBMotion\fR, and \fBKeyPress\fR) or virtual events. Event bindings for a text
widget use the \fBcurrent\fR mark described under \fBMARKS\fR above. An
\fBEnter\fR event triggers for a tag when the tag first becomes present on the
current character, and a \fBLeave\fR event triggers for a tag when it ceases
to be present on the current character. \fBEnter\fR and \fBLeave\fR events can
happen either because the \fBcurrent\fR mark moved or because the character at
that position changed. Note that these events are different than \fBEnter\fR
and \fBLeave\fR events for windows. Mouse and keyboard events are directed to
the current character. If a virtual event is used in a binding, that binding
can trigger only if the virtual event is defined by an underlying
mouse-related or keyboard-related event.
.PP
It is possible for the current character to have multiple tags, and for each
of them to have a binding for a particular event sequence. When this occurs,
one binding is invoked for each tag, in order from lowest-priority to highest
priority. If there are multiple matching bindings for a single tag, then the
most specific binding is chosen (see the manual entry for the \fBbind\fR
command for details). \fBcontinue\fR and \fBbreak\fR commands within binding
scripts are processed in the same way as for bindings created with the
\fBbind\fR command.
.PP
If bindings are created for the widget as a whole using the \fBbind\fR
command, then those bindings will supplement the tag bindings. The tag
bindings will be invoked first, followed by bindings for the window as a
whole.
.RE
.TP
\fIpathName \fBtag cget \fItagName option\fR
.
This command returns the current value of the option named \fIoption\fR
associated with the tag given by \fItagName\fR. \fIOption\fR may have any of
the values accepted by the \fIpathName \fBtag configure\fR widget command.
.TP
\fIpathName \fBtag clear\fR ?\fB\-discardselection\fR? \fIindex1\fR \fI?index2 index1 index2 ...\fR?
.
Remove all tags from all of the characters starting at \fIindex1\fR and
ending just before \fIindex2\fR (the character at \fIindex2\fR is not
affected). A single command may contain any number of
\fIindex1\fR-\fIindex2\fR pairs. If the last \fIindex2\fR is omitted then
all tags will be removed from the single character at \fIindex1\fR. If there
are no characters in the specified range (e.g. \fIindex1\fR is past the end
of the file or \fIindex2\fR is less than or equal to \fIindex1\fR) then the
command has no effect. This command returns a list of all removed tags,
sorted in order from lowest priority to highest priority. If option
\fB\-discardselection\fR is given then the special selection tag \fBsel\fR
will not be removed.
.TP
\fIpathName \fBtag configure \fItagName\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR?
.
This command is similar to the \fIpathName \fBconfigure\fR widget command
except that it modifies options associated with the tag given by \fItagName\fR
instead of modifying options for the overall text widget. If no \fIoption\fR
is specified, the command returns a list describing all of the available
options for \fItagName\fR (see \fBTk_ConfigureInfo\fR for information on the
format of this list). If \fIoption\fR is specified with no \fIvalue\fR, then
the command returns a list describing the one named option (this list will be
identical to the corresponding sublist of the value returned if no
\fIoption\fR is specified). If one or more \fIoption\-value\fR pairs are
specified, then the command modifies the given option(s) to have the given
value(s) in \fItagName\fR; in this case the command returns an empty string.
See \fBTAGS\fR above for details on the options available for tags.
.TP
\fIpathName \fBtag delete \fItagName \fR?\fItagName ...\fR?
.
Deletes all tag information for each of the \fItagName\fR arguments. The
command removes the tags from all characters in the file and also deletes any
other information associated with the tags, such as bindings and display
information. The command returns an empty string.
.TP
\fIpathName \fBtag findnext\fR ?\fB\-discardselection\fR? \fIindex\fR
.
Finds the first tagged character either at specified position \fIindex\fR,
or right from specified position \fIindex\fR, and returns the index of the
detected character. The value of the result will be empty if no character
can be found. If option \fB\-discardselection\fR is given then the special
selection tag \fBsel\fR will be discarded.
.TP
\fIpathName \fBtag findprev\fR ?\fB\-discardselection\fR? \fIindex\fR
.
Finds the first tagged character either at specified position \fIindex\fR,
or left from specified position \fIindex\fR, and returns the index of the
detected character. The value of the result will be empty if no character
can be found. If option \fB\-discardselection\fR is given then the special
selection tag \fBsel\fR will be discarded.
.TP
\fIpathName \fBtag getrange\fR \fItagName index\fR
.
Returns the range of text that have been tagged with \fItagName\fR, and
which includes the character at the specified position \fIindex\fR
(inclusive start of range, but exclusive end of range). If the character at
specified position \fIindex\fR is not tagged with \fItagName\fR, then the
returned value will be empty.
.TP
\fIpathName\fB tag lower \fItagName \fR?\fIbelowThis\fR?
.
Changes the priority of tag \fItagName\fR so that it is just lower in priority
than the tag whose name is \fIbelowThis\fR. If \fIbelowThis\fR is omitted,
then \fItagName\fR's priority is changed to make it lowest priority of all
tags.
.TP
\fIpathName \fBtag names\fR \fI?switches\fR? \fI?index\fR?
.
Returns a list whose elements are the names of all the tags that are active at
the character position given by \fIindex\fR. If \fIindex\fR is omitted, then
the return value will describe all of the tags that exist for the text. The
list will be sorted in order from lowest priority to highest priority.
.RS
.PP
One or more of the following switches (or abbreviations thereof) may be
specified to control the result:
.TP
\fB\-all\fR
.
Return all tags that exist for the text (this includes all tags that have
been named in a
.QW "pathName \fBtag\fR"
widget command but have not been deleted by a
.QW "pathName \fBtag delete\fR"
widget command, even if no characters/soft hyphens/embedded images/embedded
windows are currently marked with the tag). This is the default.
.TP
\fB\-discardselection\fR
.
Discard the special selection tag \fBsel\fR. (This option is identical to
option \fB\-noselection\fR, and only provided to be conform with other tag
sub-commands.)
.TP
\fB\-display\fR
.
Include all tags (eventually) influencing the display of text.
.TP
\fB\-nodisplay\fR
.
Discard all tags (eventually) influencing the display of text.
.TP
\fB\-elide\fR
.
Include all tags where option \fB\-elide\fR is enabled.
.TP
\fB\-noelide\fR
.
Discard all tags where option \fB\-elide\fR is enabled.
.TP
\fB\-geometry\fR
.
Include all tags (eventually) influencing the display geometry.
.TP
\fB\-nogeometry\fR
.
Discard all tags (eventually) influencing the display geometry.
.TP
\fB\-lineheight\fR
.
Include all tags (eventually) influencing the line height.
.TP
\fB\-nolineheight\fR
.
Discard all tags (eventually) influencing the line height.
.TP
\fB\-selection\fR
.
Include all tags affecting selected text. Currently this is only the
\fBsel\fR tag.
.TP
\fB\-noselection\fR
.
Discard all tags affecting selected text. Currently this is discarding only
the \fBsel\fR tag. (This option is identical to option
\fB\-discardselection\fR).
.TP
\fB\-undo\fR
.
Include all tags where option \fB\-undo\fR is enabled.
.TP
\fB\-noundo\fR
.
Discard all tags where option \fB\-undo\fR is enabled.
.TP
\fB\-used\fR
.
Include all tags which are currently used for associations with any
character, soft hyphen, embedded image, or embedded window.
.TP
\fB\-noused\fR
.
Discard all tags which are currently used for associations with any
character, soft hyphen, embedded image, or embedded window.
.TP
\fB\-unused\fR
.
This option is identical to option \fB\-noused\fR, and only provided for
convenience.
.RE
.TP
\fIpathName \fBtag nextrange \fItagName index1 \fR?\fIindex2\fR?
.
This command searches the text for a range of characters tagged with
\fItagName\fR where the first character of the range is no earlier than the
character at \fIindex1\fR and no later than the character just before
\fIindex2\fR (a range starting at \fIindex2\fR will not be considered). If
several matching ranges exist, the first one is chosen. The command's return
value is a list containing two elements, which are the index of the first
character of the range and the index of the character just after the last one
in the range. If no matching range is found then the return value is an empty
string. If \fIindex2\fR is not given then it defaults to the end of the text.
.TP
\fIpathName \fBtag prevrange \fItagName index1 \fR?\fIindex2\fR?
.
This command searches the text for a range of characters tagged with
\fItagName\fR where the first character of the range is before the character
at \fIindex1\fR and no earlier than the character at \fIindex2\fR (a range
starting at \fIindex2\fR will be considered). If several matching ranges
exist, the one closest to \fIindex1\fR is chosen. The command's return value
is a list containing two elements, which are the index of the first character
of the range and the index of the character just after the last one in the
range. If no matching range is found then the return value is an empty string.
If \fIindex2\fR is not given then it defaults to the beginning of the text.
.TP
\fIpathName \fBtag priority \fItagName\fR
.
Returns the priority (a positive integer value, or zero) of the specified tag.
This allows to compare the priority of tags.
.TP
\fIpathName\fB tag raise \fItagName \fR?\fIaboveThis\fR?
.
Changes the priority of tag \fItagName\fR so that it is just higher in
priority than the tag whose name is \fIaboveThis\fR. If \fIaboveThis\fR is
omitted, then \fItagName\fR's priority is changed to make it highest priority
of all tags.
.TP
\fIpathName \fBtag ranges \fItagName\fR
.
Returns a list describing all of the ranges of text that have been tagged with
\fItagName\fR. The first two elements of the list describe the first tagged
range in the text, the next two elements describe the second range, and so on.
The first element of each pair contains the index of the first character of
the range, and the second element of the pair contains the index of the
character just after the last one in the range. If there are no characters
tagged with \fItag\fR then an empty string is returned.
.TP
\fIpathName \fBtag remove \fItagName index1 \fR?\fIindex2 index1 index2 ...\fR?
.
Remove the tag \fItagName\fR from all of the characters starting at
\fIindex1\fR and ending just before \fIindex2\fR (the character at
\fIindex2\fR is not affected). A single command may contain any number of
\fIindex1\fR\-\fIindex2\fR pairs. If the last \fIindex2\fR is omitted then the
tag is removed from the single character at \fIindex1\fR. If there are no
characters in the specified range (e.g. \fIindex1\fR is past the end of the
file or \fIindex2\fR is less than or equal to \fIindex1\fR) then the command
has no effect. This command returns an empty string.
.RE
.TP
\fIpathName\fR \fBwatch\fR ?\fB\-always\fR? ?\fIcommandPrefix\fR?
.
Monitors widget modifications, it causes a Tcl command to be executed
whenever certain widget modifications are done. In general only user (GUI)
modifications will be watched. But if option \fB\-always\fR is specified
then all modifications will be watched. In fact the triggering depends on
the way how a certain modification will be executed:
.RS
.IP \(bu 3
If option \fB\-always\fR is not specified then the \fBdelete\fR command
triggers only if the argument \fIindex1\fR (the starting point of the
deletion) is specified with
.QW insert
(the insertion cursor).
.IP \(bu 3
If option \fB\-always\fR is not specified then the \fBinsert\fR command
triggers only if the argument \fIindex\fR (the starting point of the
insertion) is specified with
.QW insert
(the insertion cursor).
.IP \(bu 3
If option \fB\-always\fR is not specified then the \fBmark set\fR command
triggers only if the argument \fImarkName\fR (the name of the mark) is
specified with
.QW insert
(the insertion cursor).
.IP \(bu 3
If option \fB\-always\fR is not specified then the \fBreplace\fR command
triggers only if the argument \fIindex1\fR (the starting point of the
replacement) is specified with
.QW insert
(the insertion cursor).
.IP \(bu 3
\fBedit undo\fR|\fBredo\fR|\fBrecover\fR will trigger the corresponding
\fBundo\fR|\fBredo\fR event.
.IP \(bu 3
A resize or content change of a displayed image will trigger event \fBimage\fR.
.IP \(bu 3
Any change of a displayed window (resize, map, or unmap) will trigger
event \fBwindow\fR.
.RE
.RS
.PP
Additionally any of the following commands may trigger because the view may
change:
.IP \(bu 3
\fIpathName \fBclear\fR|\fBload\fR
.IP \(bu 3
\fIpathName \fBconfigure\fR
.IP \(bu 3
\fIpathName \fBedit recover\fR|\fBredo\fR|\fBundo\fR
.IP \(bu 3
\fIpathName \fBimage\fR \fBconfigure\fR|\fBcreate\fR
.IP \(bu 3
\fIpathName \fBmark gravity\fR|\fBset\fR|\fBunset\fR
.IP \(bu 3
\fIpathName \fBsee\fR
.IP \(bu 3
\fIpathName \fBtag add\fR|\fBdelete\fR|\fBlower\fR|\fBraise\fR|\fBremove\fR
.IP \(bu 3
\fIpathName \fBwindow configure\fR|\fBcreate\fR
.IP \(bu 3
\fIpathName \fBxview\fR \fIarg\fR...
.IP \(bu 3
\fIpathName \fByview\fR \fIarg\fR...
.PP
Also destroying an embedded window may trigger due to a changed view.
.PP
Note that the \fBdelete\fR, and the \fBinsert\fR operation will be handled
in the same way as the \fBreplace\fR operation, this means that firstly the
deletion part triggers, and secondly the insertion part will be triggered.
In case of \fBdelete\fR the insertion part is empty (zero characters), and
in case of \fBinsert\fR the deletion range is empty.
.PP
\fICommandPrefix\fR will be resolved using the usual namespace resolution
rules used by commands. If the command does not exist, an error will be
thrown (except the command argument is empty). When a certain widget
modification triggers, a number of arguments are appended to
\fIcommandPrefix\fR so that the actual command is as follows:
.PP
.CS
\fIcommandPrefix... pathName op index1 index2 info userFlag\fR
.CE
.PP
\fIUserFlag\fR informs whether this is a user (GUI) modification. Note that
this flag is meaningful only if \fIop\fR is \fBdelete\fR, or \fBinsert\fR.
.PP
\fIOp\fR indicates which operation has been performed:
.TP
\fBinsert\fR
.
Zero or more characters have been inserted, this event will be triggered
after the insertion has been realized. \fIIndex1\fR and \fIindex2\fR are
specifying the range of the new characters after insertion, this range can
be empty. \fIInfo\fR will contain five items:
.RS
.IP [1] 4
The inserted characters.
.IP [2] 4
A list of tags applied to the character just before the inserted
characters.
.IP [3] 4
A list of tags applied to the character just after the inserted
characters.
.IP [4] 4
A list of tags applied to the newly inserted characters.
.IP [5] 4
A boolean flag indicating whether this is the final part of a
multi-insert/replace.
.PP
It should be avoided to call commands inside this event which will insert or
delete as long as \fIfinal\fR is false, the result can be unexpected. Such
commands should be postponed, either with the \fBafter\fR command, or until
\fIfinal\fR state is true.
.PP
This event will also be triggered for \fBdelete\fR, and \fBreplace\fR
operations, in these cases zero characters may be inserted, and \fIindex1\fR
refers to the start position of the deletion.
.RE
.TP
\fBdelete\fR
.
Zero or more characters will be deleted, this event will be triggered before
the deletion has been realized. \fIIndex1\fR and \fIindex2\fR are specifying
the range of the characters to be deleted, this range can be empty.
\fIInfo\fR will contain six items:
.RS
.IP [1] 4
The deleted characters.
.IP [2] 4
A list of tags applied to the character just before the deleted
characters.
.IP [3] 4
A list of tags applied to the character just after the deleted
characters.
.IP [4] 4
A list of tage applied to the first deleted character.
.IP [5] 4
A list of tage applied to the last deleted character.
.IP [6] 4
A boolean flag indicating whether this is the final part of a
multi-delete/replace.
.PP
This event will also be triggered for \fBinsert\fR, and \fBreplace\fR
operations, in these cases the deletion range may be empty, and \fIindex1\fR
refers to the start position of the insertion.
.PP
It should be avoided to call commands inside this event which will insert or
delete, the result can be unexpected. Such commands should be postponed,
either with the \fBafter\fR command, or until the corresponding \fBinsert\fR
event will be triggered.
.RE
.TP
\fBcursor\fR
.
The position of the insertion cursor has been moved. \fIIndex1\fR is the old
character position, and can be empty, \fIindex2\fR is the new character
position of the cursor. Here \fIinfo\fR contains a list of tags which would
be applied if the user (GUI) is inserting a character at the new cursor
position.
.TP
\fBview\fR
.
The view of the widget has changed (scrolling the widget, moving the cursor,
the see command has been executed, or any other modifying command has been
performed \- see the list of modifiying commands above). Here \fIindex1\fR
specifies the pixel position of the upper left corner in the form @x,y, and
\fIindex2\fR specifies the pixel position of the lower right corner.
\fIInfo\fR does not have a meaning here and will be empty.
.TP
\fBundo\fR
.
An undo action has been performed. \fIInfo\fR contains two elements. The
first is the performed undo command, one of: \fIdelete\fR, \fIimage\fR,
\fIinsert\fR, \fImark\fR, \fItag\fR, or \fIwindow\fR. The second is a
boolean flag indicating whether this is the final part of a multi-undo
action.
.RS
.PP
It is not allowed to perform any textual modification, nor is it allowed to
reset the undo/redo stack, an error will be thrown.
.RE
.TP
\fBredo\fR
.
A redo action has been performed. \fIInfo\fR contains two elements. The
first is the performed redo command, one of: \fIdelete\fR, \fIimage\fR,
\fIinsert\fR, \fImark\fR, \fItag\fR, or \fIwindow\fR. The second is a
boolean flag indicating whether this is the final part of a multi-redo
action.
.RS
.PP
It is not allowed to perform any textual modification, nor is it allowed to
reset the undo/redo stack, an error will be thrown.
.RE
.TP
\fBimage\fR
.
An image has been resized, or the content has changed. \fIInfo\fR contains
the name of the affected image as first element. In case of a change in
size the width and height of the image before resizing will be the second
and third element of \fIinfo\fR.
.TP
\fBwindow\fR
.
Either a window has changed the display state (mapped or unmapped), or the
size of the window has changed. \fIInfo\fR contains the name of the affected
window as first element. And if the size of the window has changed, then
\fIinfo\fR will provide the old width and height with a second and third
element.
.PP
\fIPathName\fR is the name of the widget where the modification has been
done. In case of \fBinsert\fR/\fBdelete\fR also the modifications in a
different peer will be triggered for this widget, provided that the range of
the modification is inside the displayed range. It is guaranteed that the
widget, where the \fBinsert\fR/\fBdelete\fR has been done, will be triggered
at first, but the order of triggering other peers is unspecified.
.PP
If \fIcommandPrefix\fR is not specified, then the watch of modifications
will be terminated. Otherwise it will replace any existing script, but if
the first character is
.QW \fC+\fR
then the new script augments an existing script.
.PP
This command returns the command prefix which has been set before this call,
this can be empty if a command prefix was not set.
.RE
.TP
\fIpathName \fBwindow \fIoption \fR?\fIarg arg ...\fR?
.
This command is used to manipulate embedded windows. The behavior of the
command depends on the \fIoption\fR argument that follows the \fBwindow\fR
argument. The following forms of the command are currently supported:
.RS
.TP
\fIpathName \fBwindow cget \fIindex option\fR
.
Returns the value of a configuration option for an embedded window.
\fIIndex\fR identifies the embedded window, and \fIoption\fR specifies a
particular configuration option, which must be one of the ones listed in the
section \fBEMBEDDED WINDOWS\fR.
.TP
\fIpathName \fBwindow configure \fIindex\fR ?\fIoption value ...\fR?
.
Query or modify the configuration options for an embedded window. If no
\fIoption\fR is specified, returns a list describing all of the available
options for the embedded window at \fIindex\fR (see \fBTk_ConfigureInfo\fR for
information on the format of this list). If \fIoption\fR is specified with no
\fIvalue\fR, then the command returns a list describing the one named option
(this list will be identical to the corresponding sublist of the value
returned if no \fIoption\fR is specified). If one or more \fIoption\-value\fR
pairs are specified, then the command modifies the given option(s) to have the
given value(s); in this case the command returns an empty string. See
\fBEMBEDDED WINDOWS\fR for information on the options that are supported.
.TP
\fIpathName \fBwindow create \fIindex\fR ?\fIoption value ...\fR?
.
This command creates a new window annotation, which will appear in the text at
the position given by \fIindex\fR. Any number of \fIoption\-value\fR pairs may
be specified to configure the annotation. See \fBEMBEDDED WINDOWS\fR for
information on the options that are supported. Returns an empty string.
.TP
\fIpathName \fBwindow names\fR
.
Returns a list whose elements are the names of all windows currently embedded
in \fIwindow\fR.
.RE
.TP
\fIpathName \fBxview \fIoption args\fR
.
This command is used to query and change the horizontal position of the text
in the widget's window. It can take any of the following forms:
.RS
.TP
\fIpathName \fBxview\fR
.
Returns a list containing two elements. Each element is a real fraction
between 0 and 1; together they describe the portion of the document's
horizontal span that is visible in the window. For example, if the first
element is .2 and the second element is .6, 20% of the text is off-screen to
the left, the middle 40% is visible in the window, and 40% of the text is
off-screen to the right. The fractions refer only to the lines that are
actually visible in the window: if the lines in the window are all very short,
so that they are entirely visible, the returned fractions will be 0 and 1,
even if there are other lines in the text that are much wider than the window.
These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
option.
.TP
\fIpathName \fBxview moveto\fI fraction\fR
.
Adjusts the view in the window so that \fIfraction\fR of the horizontal span
of the text is off-screen to the left. \fIFraction\fR is a fraction between 0
and 1.
.TP
\fIpathName \fBxview scroll \fInumber what\fR
.
This command shifts the view in the window left or right according to
\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBunits\fR, \fBpages\fR or
\fBpixels\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then \fInumber\fR
must be an integer, otherwise number may be specified in any of the forms
acceptable to \fBTk_GetPixels\fR, such as
.QW 2.0c
or
.QW 1i
(the result is rounded to the nearest integer value. If no units are given,
pixels are assumed). If \fIwhat\fR is \fBunits\fR, the view adjusts left or
right by \fInumber\fR average-width characters on the display; if it is
\fBpages\fR then the view adjusts by \fInumber\fR screenfuls; if it is
\fBpixels\fR then the view adjusts by \fInumber\fR pixels. If \fInumber\fR is
negative then characters farther to the left become visible; if it is positive
then characters farther to the right become visible.
.RE
.TP
\fIpathName \fByview \fR?\fIargs\fR?
.
This command is used to query and change the vertical position of the text in
the widget's window. It can take any of the following forms:
.RS
.TP
\fIpathName \fByview\fR
.
Returns a list containing two elements, both of which are real fractions
between 0 and 1. The first element gives the position of the first visible
pixel of the first character (or image, etc) in the top line in the window,
relative to the text as a whole (0.5 means it is halfway through the text, for
example). The second element gives the position of the first pixel just after
the last visible one in the bottom line of the window, relative to the text as
a whole. These are the same values passed to scrollbars via the
\fB\-yscrollcommand\fR option.
.TP
\fIpathName \fByview moveto\fI fraction\fR
.
Adjusts the view in the window so that the pixel given by \fIfraction\fR
appears at the top of the top line of the window. \fIFraction\fR is a fraction
between 0 and 1; 0 indicates the first pixel of the first character in the
text, 0.33 indicates the pixel that is one-third the way through the text; and
so on. Values close to 1 will indicate values close to the last pixel in the
text (1 actually refers to one pixel beyond the last pixel), but in such cases
the widget will never scroll beyond the last pixel, and so a value of 1 will
effectively be rounded back to whatever fraction ensures the last pixel is at
the bottom of the window, and some other pixel is at the top.
.TP
\fIpathName \fByview scroll \fInumber what\fR
.
This command adjust the view in the window up or down according to
\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBunits\fR, \fBpages\fR or
\fBpixels\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then \fInumber\fR
must be an integer, otherwise number may be specified in any of the forms
acceptable to \fBTk_GetPixels\fR, such as
.QW 2.0c
or
.QW 1i
(the result is rounded to the nearest integer value. If no units are given,
pixels are assumed). If \fIwhat\fR is \fBunits\fR, the view adjusts up or down
by \fInumber\fR lines on the display; if it is \fBpages\fR then the view
adjusts by \fInumber\fR screenfuls; if it is \fBpixels\fR then the view
adjusts by \fInumber\fR pixels. If \fInumber\fR is negative then earlier
positions in the text become visible; if it is positive then later positions
in the text become visible.
.TP
\fIpathName \fByview \fR?\fB\-pickplace\fR? \fIindex\fR
.
Changes the view in the widget's window to make \fIindex\fR visible. If the
\fB\-pickplace\fR option is not specified then \fIindex\fR will appear at the
top of the window. If \fB\-pickplace\fR is specified then the widget chooses
where \fIindex\fR appears in the window:
.RS
.IP [1]
If \fIindex\fR is already visible somewhere in the window then the command
does nothing.
.IP [2]
If \fIindex\fR is only a few lines off-screen above the window then it will be
positioned at the top of the window.
.IP [3]
If \fIindex\fR is only a few lines off-screen below the window then it will be
positioned at the bottom of the window.
.IP [4]
Otherwise, \fIindex\fR will be centered in the window.
.PP
The \fB\-pickplace\fR option has been obsoleted by the \fIpathName \fBsee\fR
widget command (\fIpathName \fBsee\fR handles both x- and y-motion to make a
location visible, whereas the \fB\-pickplace\fR mode only handles motion in
y).
.RE
.TP
\fIpathName \fByview \fInumber\fR
.
This command makes the first character on the line after the one given by
\fInumber\fR visible at the top of the window. \fINumber\fR must be an
integer. This command used to be used for scrolling, but now it is obsolete.
.RE
.SH BINDINGS
.PP
Tk automatically creates class bindings for texts that give them the following
default behavior. In the descriptions below,
.QW word
is dependent on the value of the \fBtcl_wordchars\fR variable. See
\fBtclvars\fR(n).
.IP [1]
Clicking mouse button 1 positions the insertion cursor just before the
character underneath the mouse cursor, sets the input focus to this widget,
and clears any selection in the widget. Dragging with mouse button 1 strokes
out a selection between the insertion cursor and the character under the
mouse.
.IP [2]
Double-clicking with mouse button 1 selects the word under the mouse and
positions the insertion cursor at the start of the word. Dragging after a
double click will stroke out a selection consisting of whole words.
.IP [3]
Triple-clicking with mouse button 1 selects the line under the mouse and
positions the insertion cursor at the start of the line. Dragging after a
triple click will stroke out a selection consisting of whole lines.
.IP [4]
The ends of the selection can be adjusted by dragging with mouse button 1
while the Shift key is down; this will adjust the end of the selection that
was nearest to the mouse cursor when button 1 was pressed. If the button is
double-clicked before dragging then the selection will be adjusted in units of
whole words; if it is triple-clicked then the selection will be adjusted in
units of whole lines.
.IP [5]
Clicking mouse button 1 with the Control key down will reposition the
insertion cursor without affecting the selection.
.IP [6]
If any normal printing characters are typed, they are inserted at the point of
the insertion cursor.
.IP [7]
The view in the widget can be adjusted by dragging with mouse button 2. If
mouse button 2 is clicked without moving the mouse, the selection is copied
into the text at the position of the mouse cursor. The Insert key also inserts
the selection, but at the position of the insertion cursor.
.IP [8]
If the mouse is dragged out of the widget while button 1 is pressed, the entry
will automatically scroll to make more text visible (if there is more text
off-screen on the side where the mouse left the window).
.IP [9]
The Left and Right keys move the insertion cursor one character to the left or
right; they also clear any selection in the text. If Left or Right is typed
with the Shift key down, then the insertion cursor moves and the selection is
extended to include the new character. Control-Left and Control-Right move the
insertion cursor by words, and Control-Shift-Left and Control-Shift-Right move
the insertion cursor by words and also extend the selection. Control-b and
Control-f behave the same as Left and Right, respectively. Meta-b and Meta-f
behave the same as Control-Left and Control-Right, respectively.
.IP [10]
The Up and Down keys move the insertion cursor one line up or down and clear
any selection in the text. If Up or Right is typed with the Shift key down,
then the insertion cursor moves and the selection is extended to include the
new character. Control-Up and Control-Down move the insertion cursor by
paragraphs (groups of lines separated by blank lines), and Control-Shift-Up
and Control-Shift-Down move the insertion cursor by paragraphs and also extend
the selection. Control-p and Control-n behave the same as Up and Down,
respectively.
.IP [11]
The Next and Prior keys move the insertion cursor forward or backwards by one
screenful and clear any selection in the text. If the Shift key is held down
while Next or Prior is typed, then the selection is extended to include the
new character.
.IP [12]
Control-Next and Control-Prior scroll the view right or left by one page
without moving the insertion cursor or affecting the selection.
.IP [13]
Home and Control-a move the insertion cursor to the beginning of its display
line and clear any selection in the widget. Shift-Home moves the insertion
cursor to the beginning of the display line and also extends the selection to
that point.
.IP [14]
End and Control-e move the insertion cursor to the end of the display line and
clear any selection in the widget. Shift-End moves the cursor to the end of
the display line and extends the selection to that point.
.IP [15]
Control-Home and Meta-< move the insertion cursor to the beginning of the text
and clear any selection in the widget. Control-Shift-Home moves the insertion
cursor to the beginning of the text and also extends the selection to that
point.
.IP [16]
Control-End and Meta-> move the insertion cursor to the end of the text and
clear any selection in the widget. Control-Shift-End moves the cursor to the
end of the text and extends the selection to that point.
.IP [17]
The Select key and Control-Space set the selection anchor to the position of
the insertion cursor. They do not affect the current selection. Shift-Select
and Control-Shift-Space adjust the selection to the current position of the
insertion cursor, selecting from the anchor to the insertion cursor if there
was not any selection previously.
.IP [18]
Control-/ selects the entire contents of the widget.
.IP [19]
Control-\e clears any selection in the widget.
.IP [20]
The F16 key (labelled Copy on many Sun workstations) or Meta-w copies the
selection in the widget to the clipboard, if there is a selection. This
action is carried out by the command \%\fBtk_textCopy\fR.
.IP [21]
The F20 key (labelled Cut on many Sun workstations) or Control-w copies the
selection in the widget to the clipboard and deletes the selection. This
action is carried out by the command \%\fBtk_textCut\fR. If there is no
selection in the widget then these keys have no effect.
.IP [22]
The F18 key (labelled Paste on many Sun workstations) or Control-y inserts the
contents of the clipboard at the position of the insertion cursor. This action
is carried out by the command \%\fBtk_textPaste\fR.
.IP [23]
The Delete key deletes the selection, if there is one in the widget. If there
is no selection, it deletes the character to the right of the insertion
cursor.
.IP [24]
Backspace and Control-h delete the selection, if there is one in the widget.
If there is no selection, they delete the character to the left of the
insertion cursor.
.IP [25]
Control-d deletes the character to the right of the insertion cursor.
.IP [26]
Meta-d deletes the word to the right of the insertion cursor.
.IP [27]
Control-k deletes from the insertion cursor to the end of its line; if the
insertion cursor is already at the end of a line, then Control-k deletes the
newline character.
.IP [28]
Control-o opens a new line by inserting a newline character in front of the
insertion cursor without moving the insertion cursor.
.IP [29]
Meta-backspace and Meta-Delete delete the word to the left of the insertion
cursor.
.IP [30]
Control-x deletes whatever is selected in the text widget after copying it to
the clipboard.
.IP [31]
Control-t reverses the order of the two characters to the right of the
insertion cursor.
.IP [32]
Control-z undoes the last edit action if the \fB\-undo\fR option is true.
Does nothing otherwise.
.IP [33]
Control-Z (or Control-y on Windows) reapplies the last undone edit action if
the \fB\-undo\fR option is true. Does nothing otherwise.
.PP
If the widget is disabled using the \fB\-state\fR option, then its view can
still be adjusted and text can still be selected, but no insertion cursor will
be displayed and no text modifications will take place.
.PP
The behavior of texts can be changed by defining new bindings for individual
widgets or by redefining the class bindings.
.SH "DEPRECIATION WARNINGS"
.PP
Some functions/options now are marked as deprecated and will be removed in a
later version. Here is an overview about all possible depreciation warnings,
with possible solutions:
.PP
.IP \(bu 3
\fBtk::text: Option "-startline" is deprecated, please use option "-startindex".\fR
.PP
Replace all occurrences of
.QW "\fB$w -startline 4\fR"
with
.QW "\fB$w -startindex 4.0\fR".
.IP \(bu 3
\fBtk::text: Option "-endline" is deprecated, please use option "-endindex".\fR
.PP
Replace all occurrences of
.QW "\fB$w -endline 4\fR"
with
.QW "\fB$w -endindex 3.end\fR" .
.IP \(bu 3
\fBtk::text: Attempt to modify a disabled widget is deprecated.\fR
.PP
Remove this useless expression, a disabled widget cannot be
modified.
.IP \(bu 3
\fBtk::text: Attempt to modify a dead widget is deprecated.\fR
.PP
Remove this useless expression, a dead widget (does not contain
lines and does not show an insertion cursor) cannot be modified.
.IP \(bu 3
\fBtk::text: Command "edit canredo" is deprecated, please use "edit info".\fR
.PP
Replace all occurrences
.QW "\fB[$w edit canredo]\fR"
with
.QW "\fB[set [$w edit info](redodepth)]\fR" .
.IP \(bu 3
\fBtk::text: Command "edit canundo" is deprecated, please use "edit info".\fR
.PP
Replace all occurrences
.QW "\fB[$w edit canundo]\fR"
with
.QW "\fB[set [$w edit info](undodepth)]\fR" .
.IP \(bu 3
\fBtk::text: "begin" is a reserved index identifier and shouldn't be used for mark names anymore.\fR
.PP
Replace this mark name with a different mark name,
but do this at all places where \fBbegin\fR is used as a name for a mark.
.IP \(bu 3
\fBtk::text: Tag option "-overstrikefg" is deprecated, please use option "-overstrikecolor".\fR
.PP
Replace all occurrences
.QW "\fB$w tag configure -overstrikefg black\fR"
with
.QW "\fB$w tag configure -overstrikecolor black\fR" .
.IP \(bu 3
\fBtk::text: Tag option "-underlinefg" is deprecated, please use option "-underlinecolor".\fR
.PP
Replace all occurrences
.QW "\fB$w tag configure -underlinefg black\fR"
with
.QW "\fB$w tag configure -underlinecolor black\fR" .
.SH "KNOWN ISSUES"
.SS "ISSUES CONCERNING INDICES"
.PP
Currently the special index specifier \fBbegin\fR has the lowest precedence,
although it should have the same precedence as the special index special
\fBend\fR (see section \fBINDICES\fR). In a future release this will be
corrected. The current behavior is a workaround, avoiding that existing
applications will break with the introduction of \fBbegin\fR.
.SS "PERFORMANCE ISSUES"
.PP
Text widgets should run efficiently under a variety of conditions. The text
widget uses about 2-3 bytes of main memory for each byte of text, so texts
containing a megabyte or more should be practical on most workstations. Text
is represented internally with a modified B-tree structure that makes
operations relatively efficient even with large texts. Tags are included in
the B-tree structure in a way that allows tags to span large ranges or have
many disjoint smaller ranges without loss of efficiency. Marks are also
implemented in a way that allows large numbers of marks. In most cases it is
fine to have large numbers of unique tags, or a tag that has many distinct
ranges.
.PP
One performance problem can arise if you have hundreds or thousands of
different tags that all have the following characteristics: the first and last
ranges of each tag are near the beginning and end of the text, respectively,
or a single tag range covers most of the text widget. The cost of adding and
deleting tags like this is proportional to the number of other tags with the
same properties. In contrast, there is no problem with having thousands of
distinct tags if their overall ranges are localized and spread uniformly
throughout the text.
.PP
The display line with the insert cursor is redrawn each time the cursor
blinks, which causes a steady stream of graphics traffic. Set the
\fB\-insertofftime\fR attribute to zero for avoiding this.
.SS "KNOWN BUGS"
.PP
The \fIpathName \fBsearch \-regexp\fR sub-command attempts to perform
sophisticated regexp matching across multiple lines in an efficient fashion
(since Tk 8.5), examining each line individually, and then in small groups of
lines, whether searching forwards or backwards. Under certain conditions the
search result might differ from that obtained by applying the same regexp to
the entire text from the widget in one go. For example, when searching with a
greedy regexp, the widget will continue to attempt to add extra lines to the
match as long as one of two conditions are true: either Tcl's regexp library
returns a code to indicate a longer match is possible (but there are known
bugs in Tcl which mean this code is not always correctly returned); or if each
extra line added results in at least a partial match with the pattern. This
means in the case where the first extra line added results in no match and
Tcl's regexp system returns the incorrect code and adding a second extra line
would actually match, the text widget will return the wrong result. In
practice this is a rare problem, but it can occur, for example:
.PP
.CS
pack [\fBtext\fR .t]
\%.t insert 1.0 "aaaa\enbbbb\encccc\enbbbb\enaaaa\en"
\%.t search \-regexp \-\- {(a+|b+\enc+\enb+)+\ena+} 1.0
.CE
.PP
will not find a match when one exists of 19 characters starting from the first
.QW b .
.PP
Whenever one possible match is fully enclosed in another, the search command
will attempt to ensure only the larger match is returned. When performing
backwards regexp searches it is possible that Tcl will not always achieve
this, in the case where a match is preceded by one or more short,
non-overlapping matches, all of which are preceded by a large match which
actually encompasses all of them. The search algorithm used by the widget does
not look back arbitrarily far for a possible match which might cover large
portions of the widget. For example:
.PP
.CS
pack [\fBtext\fR .t]
\%.t insert 1.0 "aaaa\enbbbb\enbbbb\enbbbb\enbbbb\\n"
\%.t search \-regexp \-backward \-\- {b+\en|a+\en(b+\en)+} end
.CE
.PP
matches at
.QW 5.0
when a true greedy match would match at
.QW 1.0 .
Similarly if we add \fB\-all\fR to this case, it matches at all of
.QW 5.0 ,
.QW 4.0 ,
.QW 3.0
and
.QW 1.0 ,
when really it should only match at
.QW 1.0
since that match encloses all the others.
.SH "SEE ALSO"
entry(n), scrollbar(n)
.SH KEYWORDS
text, widget, tkvars
'\" Local Variables:
'\" mode: nroff
'\" End:
|