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 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466
|
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"
# This is "ding",
# * A dictionary lookup program,
# * DIctionary Nice Grep,
# * A Front-End to [ae]grep, ispell, dict, ...
# * Ding {n} :: thing
#
# Copyright (c) Frank Richter <frank.richter@hrz.tu-chemnitz.de> 1999 - 2020
# GNU public license
# Ding comes with ABSOLUTELY NO WARRANTY.
#
set pinfo(pname) {Ding: Dictionary Lookup}
set pinfo(version) {1.9}
set pinfo(homepage) {https://www-user.tu-chemnitz.de/~fri/ding/}
set ding_usage(en) \
" word\tStart seaching this word
-x or --selection\tStart searching for selected word (X selection)
-m or --mini\tStart with minimal size (search form only)\n
-r or --remote\tStart search in an already running program
-R or --remote-new\tStart search in an already running program
\tor start a new program\n
--noconf\tDo not save preferences
-D # or --debug #\tStart with debug output, # = number (1..15)\n
These options may be combined, such as:
$argv0 -R -x\tStart searching for selected word in an already
\trunning program or start a new program\n"
set ding_usage(de) "
Suchwort\tStarte Suche nach Suchwort
-x oder --selection\tStarte Suche mit markiertem Text
-m oder --mini\tStarte in Mini-Gre (nur Sucheingabe)\n
-r oder --remote\tStarte Suche in bereits laufendem Programm
-R oder --remote-new\tStarte Suche in bereits laufendem Programm
\toder starte neues Programm\n
--noconf\tKein Speichern der Einstellungen
-D # oder --debug #\tDebug-Ausschriften, # = Zahl (1..15)\n
Die Optionen knnen natrlich kombiniert werden, z.B.:
$argv0 -R -x\tStarte Suche nach markiertem Wort in bereits
\tlaufendem Programm oder starte neues Programm\n"
proc Usage {} {
global pinfo argv0 env ding_usage
puts "\n$pinfo(pname) version $pinfo(version)"
if {[info exists env(LANG)] && [info exists ding_usage([string range $env(LANG) 0 1])]} {
puts "Usage: $argv0 \[Optionen\] \[Suchwort\]"
puts $ding_usage([string range $env(LANG) 0 1])
puts "Siehe WWW-Homepage: $pinfo(homepage)"
} else {
puts "Usage: $argv0 \[options\] \[word\]"
puts $ding_usage(en)
puts "See WWW homepage: $pinfo(homepage)"
}
}
if { ![info exists tk_version] } {
Usage
exit
}
if {$tk_version < 8.3} {
tk_messageBox -type ok -icon error -message {
Sorry, wish version >= 8.3 is required. Try to install a newer Tk version.
Die Version von Tcl/Tk ist zu alt, bitte Version 8.3 oder hher installieren.
Exiting ...}
exit
}
set param(isunix) [expr {$tcl_platform(platform) == {unix}}]
set param(iswin) [expr {$tcl_platform(platform) == {windows}}]
# Config options you may want to change:
# Startup file
set param(rcfile) [expr {$param(isunix) == 1 ? "$env(HOME)/.dingrc" : "[file dirname argv0]/dingrc.tcl"}]
set param(noticefile) [expr {$param(isunix) == 1 ? "$env(HOME)/.dingnotice.txt" : "[file dirname argv0]/dingntc.txt"}]
# The default search methods
# The provided German-English dictionary:
set default_searchmeth(0,name) {Dictionary}
set default_searchmeth(0,grepcmds) {agrep tre-agrep egrep internal_search}
set default_searchmeth(0,dictfile) [expr {$param(isunix) ? "/usr/share/dict/de-en.txt" : "[file dirname argv0]/de-en.txt"}]
set default_searchmeth(0,separator) { :: }
set default_searchmeth(0,language1) {Deutsch}
set default_searchmeth(0,language2) {English}
set default_searchmeth(0,foldedresult) 1
# spell checker
set default_searchmeth(1,name) {Spell check}
set default_searchmeth(1,grepcmds) {hunspell aspell ispell}
set default_searchmeth(1,language1) "English spell check"
set default_searchmeth(1,grepopts) "-B -d en_US -a"
# --encoding utf-8
# spell checker
set default_searchmeth(2,name) {Rechtschreibung}
set default_searchmeth(2,grepcmds) {hunspell aspell ispell}
set default_searchmeth(2,language1) "Deutsche Rechtschreibprfung"
set default_searchmeth(2,grepopts) "-B -d de_DE -a"
# dict - english ditionary
set default_searchmeth(3,name) {English}
set default_searchmeth(3,grepcmds) {dict}
set default_searchmeth(3,language1) "English Dictionary"
# Fortunes
set default_searchmeth(4,name) {Epigram}
set default_searchmeth(4,grepcmds) {/usr/bin/fortune}
set default_searchmeth(4,language1) "Random English adage/epigram"
set default_searchmeth(4,grepopts) ""
set default_searchmeth(4,minlength) 0
# check for these search commands
set default_grepcmds(tre-agrep) "-h"
set default_grepcmds(agrep) "-h"
set default_grepcmds(egrep) "-h -a"
set default_grepcmds(dict) ""
set default_grepcmds(hunspell) "-B -S -a"
set default_grepcmds(ispell) "-B -S -a"
set default_grepcmds(aspell) "-B -S -a"
set default_grepcmds(/usr/bin/fortune) ""
set default_grepcmds(internal_search) ""
set default_searchopts(minlength) 2
set default_searchopts(maxlength) 30
set default_searchopts(maxresults) 200
set default_searchopts(shapedresult) 1
set default_searchopts(foldedresult) 0
set default(maxhistory) 50
set default(autosave) 1
set default(hilite) 1
set default(raise) 0
set default(params_as_menu) 0
set default(show_menu) 1
set default(umlaut_buttons) 0
set default(show_result) 1
set default(show_status) 1
set default(bcolor) [expr {$param(isunix) ? [. cget -background] : "#C0C0C0"}]
set default(fcolor) "#000000"
set default(showBalloons) 1
set default(balloonDelay) 800
array set balloonHelp {}
set gparam(balloonBackground) LightGoldenrodYellow
set default(autosearch) 0
set default(autosearchDelay) 1000
# set default(automin) 0
set default(autominDelay) 8000
set default(search_prop) 0
set default(win_prop) 0
if {$param(isunix)} {
# set lfont "-*-Helvetica-Medium-R-Normal--*-100-*-*-*-*-*-*"
# set bfont "-*-Helvetica-Bold-R-Normal--*-100-*-*-*-*-*-*"
# set sfont "-*-Helvetica-Medium-R-Normal--*-100-*-*-*-*-*-*"
# set default_tfont "-*-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*"
set default(lfont) {helvetica 12 normal}
set param(bfont) {helvetica 12 bold}
set param(ifont) {helvetica 12 "" italic}
set param(sfont) {helvetica 10 normal}
set default(tfont) {fixed 14 normal}
set default(ipafont) {lucidatypewriter 14 normal}
# Font selection
# show all avail. font families
# set param(tfonts) {}
# or show only this subset:
set param(tfonts) {courier fixed lucida helvetica times terminal bitstream* dejavu* liberation* lucida* luxi* nimbus* urw*}
} else {
set default(lfont) {Arial 10 normal}
set param(bfont) {Arial 10 bold}
set param(ifont) {Arial 10 "" italic}
set param(sfont) {Arial 8 normal}
set default(tfont) {Arial 10 normal}
# set default(tfont) {Courier 10 normal}
# Font selection
# show all avail. font families
set param(tfonts) {}
# or show only this subset:
# set param(tfonts) {Arial System Times Courier Verdana}
}
set param(tfont) $default(tfont)
set param(lfont) $default(lfont)
set param(ipafont) $default(ipafont)
set opts(case) 0
set opts(word) 0
set opts(regex) 0
set opts(errors) 0
### don't change from here unless you know what you're doing .-)
# set defaults
set param(showBalloons) $default(showBalloons)
set param(balloonDelay) $default(balloonDelay)
set param(autosearch) $default(autosearch)
set param(autosearchDelay) $default(autosearchDelay)
set param(autosearch_active) 0
set param(autosearch_onchage_active) 0
# set param(automin) $default(automin)
set param(autominDelay) $default(autominDelay)
set param(autosave) $default(autosave)
set param(hilite) $default(hilite)
set param(raise) $default(raise)
set param(bcolor) $default(bcolor)
set param(fcolor) $default(fcolor)
set param(maxhistory) $default(maxhistory)
set param(params_as_menu) $default(params_as_menu)
set param(show_menu) $default(show_menu)
set param(umlaut_buttons) $default(umlaut_buttons)
set param(show_result) $default(show_result)
set param(show_status) $default(show_status)
set param(search_prop) $default(search_prop)
set param(win_prop) $default(win_prop)
set param(check_selection_active) 0
set curhistory 0
set inshistory 0
array set history_result {}
array set history_query {}
array set history_pos {}
array set history_fold {}
set pinfo(authormail) {frank.richter@hrz.tu-chemnitz.de}
set pinfo(author) "Frank Richter <$pinfo(authormail)>"
set pinfo(copyright) "Copyright (c) 1999 - 2020 $pinfo(author)"
set proc(pid) -1
set proc(pipe) {}
set proc(processlist) {}
set lines {}
set sigchld 0
# interface language settings
set languages(en) {English}
set languages(de) {Deutsch}
set default(language) {en}
set gparam(lang) $default(language)
set defaultcursor [. cget -cursor]
# Debug level
# 1 - main functions 2 - trace 4 - external process 8 - util
set param(debug) 0
# set param(debug) 15
# correction of height for some window managers
set param(add_geom_height) 0
# English messages
set s(en)(file) "File"
set s(en)(newwin) "New window"
set s(en)(quit) "Quit"
set s(en)(save) "Save"
set s(en)(saveall) "Save all"
set s(en)(mail) "Send corrections"
set s(en)(options) "Preferences"
set s(en)(params) "Search options"
set s(en)(soptions) "Search preferences..."
set s(en)(general) "General preferences..."
set s(en)(saveopts) "Save preferences"
set s(en)(help) "Help"
set s(en)(khelp) "Keys"
set s(en)(abbhelp) "Abbreviations"
set s(en)(cmdline) "Start options"
set s(en)(about) "About"
set s(en)(ctl) "Ctrl"
set s(en)(shift) "Shift"
set s(en)(space) "Space"
set s(en)(up) "Up"
set s(en)(down) "Down"
set s(en)(noback) "No previous search results."
set s(en)(noforw) "No more search results."
set s(en)(query) "Search word:"
set s(en)(searchmeth) "Search methods"
set s(en)(configured) "Configured"
set s(en)(search) "Search"
set s(en)(searchhelp) "Click left: Start search method\nClick middle: Search in result"
set s(en)(clear) "Clear"
set s(en)(clearhelp) "Erase search word, also with Esc key"
set s(en)(minimize) "Minimize window"
set s(en)(normalsize) "Show full window"
set s(en)(word)(0) "full words"
set s(en)(word)(1) "partial search"
set s(en)(case)(0) "ignore case"
set s(en)(case)(1) "exact case"
set s(en)(errors) "errors"
set s(en)(error) "error"
set s(en)(closestmatch) "best match"
set s(en)(regex)(0) "simple search"
set s(en)(regex)(1) "reg. expression"
set s(en)(cmd) "Search with"
set s(en)(bbhistory) "Previous results"
set s(en)(bfhistory) "Next results"
set s(en)(bwords) "Search for full words\nor partial matches?"
set s(en)(bcase) "Search case insensitive or sensitive?"
set s(en)(berrors) "Try error correction?"
set s(en)(bregex) "Simple patterns with *\nor regular expressions?"
set s(en)(color) "Select color"
set s(en)(results) "results"
set s(en)(result) "result"
set s(en)(noresults) "No results for"
set s(en)(notfound) "Search word not found"
set s(en)(correct) "Correctly spelled, no suggestions"
set s(en)(suggestion) "Suggestions"
set s(en)(nosuggestion) "Spelling is wrong or unknown, no suggestions"
set s(en)(root) "word root"
set s(en)(searcho) "Set search options"
set s(en)(searchm) "Set search methods"
set s(en)(apply) "Apply"
set s(en)(default) "Default"
set s(en)(cancel) "Cancel"
set s(en)(dictfile) "Dictionary file"
set s(en)(nodictfile) "No Dictionary file found! See Preferences | Search prefences ..."
set s(en)(new) "New"
set s(en)(edit) "Change"
set s(en)(delete) "Delete"
set s(en)(hilite) "Highlight text in result window when mouse over"
set s(en)(raise) "Bring window on top when search finished"
set s(en)(automin) "Minimize window automatically"
set s(en)(autosave) "Save options whenever changed"
set s(en)(lang) "Language"
set s(en)(sep) "Separator"
set s(en)(maxresults) "Max. number of results"
set s(en)(minlength) "Min. length of search word"
set s(en)(maxlength) "Max. length of search word"
set s(en)(params_as_menu) "Show search parameters"
set s(en)(show_menu) "Show menu bar"
set s(en)(show_menu_desc) "To bring menu back click with right mouse button"
set s(en)(hide_menu) "Hide menu bar"
set s(en)(umlaut_buttons) "Show umlaut buttons"
set s(en)(show_result) "Show search form only "
set s(en)(show_status) "Show status line"
set s(en)(hide_status) "Hide status line"
set s(en)(fg) "Foreground color..."
set s(en)(bg) "Background color..."
set s(en)(change) "Swap"
set s(en)(maxhistory) "Remember how many results"
set s(en)(balloon) "Show balloon help"
set s(en)(after) "after"
set s(en)(ms) "msec"
set s(en)(autosearch) "Start searching automatically"
set s(en)(mailtitle) "Send e-mail to"
set s(en)(send) "Send e-mail"
set s(en)(notext) "No text for your e-mail?\nNo message sent."
set s(en)(nomail) "Please send your suggestions with a mail program to"
set s(en)(notice) "Write a notice"
set s(en)(attachnotice) "Include notices"
set s(en)(nosave) "No search results to save!"
set s(en)(tooshort) "Search word too short!"
set s(en)(toolong) "Search word too long!"
set s(en)(more) "(found more, max limit reached)"
set s(en)(tfont) "Result font"
set s(en)(lfont) "Other font"
set s(en)(larger_font) "Increase font size"
set s(en)(smaller_font) "Decrease font size"
set s(en)(default_font) "Default font size"
set s(en)(defaultdict) "De <-> En"
set s(en)(shaped) "Results shaped"
set s(en)(folded) "Results folded"
set s(en)(name) "Name"
set s(en)(grepcmd) "Search command"
set s(en)(grepopts) "Options"
set s(en)(noagrep) "The \"agrep\" command wasn't found on your system.
Some functions won't be available for searching.\n
As a recommendation - install agrep.
You'll find it in a special agrep package or within the Glimpse package.\n
We will use for now: "
set s(en)(changes_later) "Some changes will come into effect after program restart."
set s(en)(kill) "Search process was stopped."
set s(en)(nokill) "Couldn't stop search process."
set s(en)(namerequired) "Please give a name to this search method."
set s(en)(props) "Search behaviour"
set s(en)(change_props) "Change search behaviour"
set s(en)(onrequest) "Search on input / middle mouse button"
set s(en)(onmouseover) "Search on mouse over"
set s(en)(onselection) "Search on new text selection"
set s(en)(min_none) "Don't minimize window automatically"
set s(en)(min_focus_delay) "Minimize window delayed"
set s(en)(min_focus) "Minimize window when mouse out"
set s(en)(clipboard_copy_line) "Copy current line to clipboard"
set s(en)(clipboard_copy_all) "Copy current result to clipboard"
# German messages
set s(de)(file) "Datei"
set s(de)(newwin) "Neues Fenster"
set s(de)(quit) "Beenden"
set s(de)(save) "Speichern"
set s(de)(saveall) "Alles speichern"
set s(de)(mail) "Korrektur senden"
set s(de)(options) "Einstellungen"
set s(de)(params) "Suchparameter"
set s(de)(soptions) "Suchmethoden..."
set s(de)(general) "Allgemein..."
set s(de)(saveopts) "Einstellungen speichern"
set s(de)(help) "Hilfe"
set s(de)(khelp) "Tastatur"
set s(de)(abbhelp) "Abkrzungen"
set s(de)(cmdline) "Startoptionen"
set s(de)(about) "Info"
set s(de)(ctl) "Strg"
set s(de)(shift) "Umschalt"
set s(de)(space) "Leer"
set s(de)(up) "Hoch"
set s(de)(down) "Runter"
set s(de)(noback) "Keine frheren Suchergebnisse."
set s(de)(noforw) "Keine weiteren Suchergebnisse."
set s(de)(query) "Suchwort:"
set s(de)(searchmeth) "Suchmethoden"
set s(de)(configured) "Eingestellte"
set s(de)(search) "Suche"
set s(de)(searchhelp) "Klick links: Suchmethode starten\nKlick mittel: Suche in Ergebnis"
set s(de)(clear) "Lschen"
set s(de)(clearhelp) "Lsche Suchwort, auch mit Esc-Taste"
set s(de)(minimize) "Fenster minimieren"
set s(de)(normalsize) "Volles Fenster anzeigen"
set s(de)(word)(0) "ganze Wrter"
set s(de)(word)(1) "Teilsuche"
set s(de)(case)(0) "Gro/klein egal"
set s(de)(case)(1) "Gro/klein exakt"
set s(de)(errors) "Fehler"
set s(de)(error) "Fehler"
set s(de)(closestmatch) "bis Treffer"
set s(de)(regex)(0) "einfache Suche"
set s(de)(regex)(1) "reg. Ausdrcke"
set s(de)(cmd) "Suche mit"
set s(de)(bbhistory) "Frhere Suchergebnisse"
set s(de)(bfhistory) "Weitere Suchergebnisse"
set s(de)(bwords) "Suche nach vollstndigen Wrtern\noder Muster in Wrtern?"
set s(de)(bcase) "Unterscheidung Gro-/Kleinschreibweise?"
set s(de)(berrors) "Versuche Fehlerkorrektur?"
set s(de)(bregex) "Einfache Muster mit * oder\nkomplexe regulre Ausdrcke?"
set s(de)(color) "Farbauswahl"
set s(de)(results) "Ergebnisse"
set s(de)(result) "Ergebnis"
set s(de)(noresults) "Kein Ergebnis fr"
set s(de)(notfound) "Suchbegriff nicht gefunden"
set s(de)(correct) "Richtige Schreibweise, keine Vorschlge"
set s(de)(suggestion) "Vorschlge"
set s(de)(nosuggestion) "Falsche oder unbekannte Schreibweise, keine Vorschlge"
set s(de)(root) "Wortstamm"
set s(de)(searcho) "Suchmethoden einstellen"
set s(de)(searchm) "Suchmethoden festlegen"
set s(de)(apply) "bernehmen"
set s(de)(default) "Standard"
set s(de)(cancel) "Abbrechen"
set s(de)(dictfile) "Wrterbuch-Datei"
set s(de)(nodictfile) "Keine Wrterbuch-Datei gefunden! Siehe Einstellungen | Suchmethoden"
set s(de)(new) "Neu"
set s(de)(edit) "ndern"
set s(de)(delete) "Entfernen"
set s(de)(lang) "Sprache"
set s(de)(sep) "Trennzeichen"
set s(de)(maxresults) "Maximalanzahl von Ergebnissen"
set s(de)(minlength) "Minimale Lnge des Suchwortes"
set s(de)(maxlength) "Maximale Lnge des Suchwortes"
set s(de)(params_as_menu) "Suchparameter anzeigen"
set s(de)(show_menu) "Menleiste anzeigen"
set s(de)(show_menu_desc) "Menleiste wiederherstellen mit rechter Maustaste"
set s(de)(hide_menu) "Menleiste verbergen"
set s(de)(umlaut_buttons) "Umlautknpfe anzeigen"
set s(de)(show_result) "Nur Suchmaske anzeigen"
set s(de)(show_status) "Statuszeile anzeigen"
set s(de)(hide_status) "Statuszeile verbergen"
set s(de)(fg) "Vordergrundfarbe..."
set s(de)(bg) "Hintergrundfarbe..."
set s(de)(change) "Vertauschen"
set s(de)(maxhistory) "Merken wievieler Ergebnisse"
set s(de)(balloon) "Hilfen anzeigen"
set s(de)(after) "nach"
set s(de)(ms) "ms"
set s(de)(autosearch) "Suche automatisch beginnen"
set s(de)(automin) "Fenster automatisch minimieren"
set s(de)(hilite) "Ergebniszeile unter Mauszeiger hervorheben"
set s(de)(raise) "Fenster in Vordergrund heben, wenn Suche fertig"
set s(de)(autosave) "Einstellungen bei nderung sofort speichern"
set s(de)(mailtitle) "Sende E-Mail an"
set s(de)(send) "E-Mail absenden"
set s(de)(notext) "Kein Text in der E-Mail?\nKeine Nachricht gesendet."
set s(de)(nomail) "Bitte senden Sie Ihre E-Mail mit einem Mail-Programm
an"
set s(de)(notice) "Notiz schreiben"
set s(de)(attachnotice) "Notizen einlesen"
set s(de)(nosave) "Noch keine Suchergebnisse zum Abspeichern."
set s(de)(tooshort) "Suchbegriff zu kurz!"
set s(de)(toolong) "Suchbegriff zu lang!"
set s(de)(more) "(weitere vorhanden, Suche abgebrochen)"
set s(de)(tfont) "Schriftart fr Resultat"
set s(de)(lfont) "Sonstige Schriftart"
set s(de)(larger_font) "Schrift vergrern"
set s(de)(smaller_font) "Schrift verkleinern"
set s(de)(default_font) "Standard-Schriftgre"
set s(de)(defaultdict) "De <-> En"
set s(de)(shaped) "Resultate farblich abgesetzt"
set s(de)(folded) "Resultate eingeklappt"
set s(de)(name) "Name"
set s(de)(grepcmd) "Such-Kommando"
set s(de)(grepopts) "Optionen"
set s(de)(noagrep) "Das Kommando \"agrep\" wurde in Ihrem System nicht gefunden.
Dadurch stehen einige Funktionen nicht zur Verfgung.\n
Empfehlung: agrep installieren!
Sie finden es in einem speziellen agrep-Paket oder im glimpse-Paket.\n
Jetzt wird verwendet: "
set s(de)(changes_later) "Einige nderungen werden erst nach Neustart des Programmes sichtbar."
set s(de)(kill) "Suchvorgang wurde gestoppt."
set s(de)(nokill) "Suchvorgang konnte nicht gestoppt werden."
set s(de)(namerequired) "Bitte dieser Suchmethode einen Namen geben."
set s(de)(props) "Suchverhalten"
set s(de)(change_props) "ndere Suchverhalten"
set s(de)(onrequest) "Suche erst nach Eingabe/mittl. Maustaste"
set s(de)(onmouseover) "Suche sobald Maus ber Fenster"
set s(de)(onselection) "Suche sofort bei neuer Textauswahl"
set s(de)(min_none) "Fenster nicht automatisch minimieren"
set s(de)(min_focus_delay) "Fenster verzgert minimieren"
set s(de)(min_focus) "Fenster sofort minimieren, wenn Fokus woanders"
set s(de)(clipboard_copy_line) "Aktuelle Zeile in Zwischenablage"
set s(de)(clipboard_copy_all) "Suchergebnis in Zwischenablage"
# Debug procedure
proc debug {level s} {
# levels:
# 1 - main function tracing (begin, parameters, end)
# 2 - minor function tracing
# 4 - communication with external programs
# 8 - others ...
global param
if [expr $param(debug) & $level] {
set time [clock format [clock seconds] -format "%T"]
puts stderr "$time $level $s"
}
}
if {$param(iswin) == 1} {
set l [registry get {HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\Language} Default]
if {$l == "0407"} { # DE
set default(language) "de"
set gparam(lang) "de"
}
} elseif {$param(isunix) == 1} {
# if Shell variable LANG set AND we've defined this language,
# set this as default
if [info exists env(LANG)] {
foreach l [array names languages] {
if [string match "$l*" $env(LANG)] {
set default(language) $l
set gparam(lang) $l
break
}
}
# check for UTF-8, as in "de_DE.UTF-8"
# regsub {\.UTF-8} $env(LANG) {} env(LANG)
# puts stderr "LANG is $env(LANG)"
}
}
proc errorBox {msg} {
tk_messageBox -message $msg -type ok -icon error
}
# for flag -remote: send a command to a running ding
proc remote {query} {
debug 1 "remote $query"
# my own application name
regsub { .*} [tk appname] {} myname
debug 8 " myname = $myname"
# find an alway running application ...
foreach i [lsort [winfo interps]] {
if [string match "${myname}*" $i] {
debug 4 " send $i querydictsearch $query"
set result [catch [list send $i [concat querydictsearch [list $query]]] msg]
if {$result != 0} {
# error - try next
debug 4 " returns: $result"
} else {
# ok
return 0
}
}
}
# error
return 1
}
############### main
# check command line parameters
set mini 0
set gparam(noconf) 0
set remote 0
set new 0
set query {}
set last_selection {}
for {set a 0} {$a < $argc} {incr a} {
set arg [lindex $argv $a]
if {([string compare $arg "--help"] == 0) ||
([string compare $arg "-h"] == 0)} {
Usage
exit
} elseif {([string compare $arg "--remote"] == 0) ||
([string compare $arg "-r"] == 0)} {
set remote 1
} elseif {([string compare $arg "--remote-new"] == 0) ||
([string compare $arg {-R}] == 0)} {
set remote 1
set new 1
} elseif {([string compare $arg {--selection}] == 0) ||
([string compare $arg {-x}] == 0)} {
# first search with current X selection
if {$param(isunix)} {
catch {set q [selection get]}
} else {
catch {set q [selection get -selection CLIPBOARD]}
}
if {[info exists q] && [string length $q] > 0} {
if {$opts(regex) == 0} { # replace regex characters
regsub -all {[*|\]\[]} $q {} q
}
if {[string length $q] > 0} {
set query $q
set last_selection $q
}
}
} elseif {([string compare $arg "--mini"] == 0) ||
([string compare $arg "-m"] == 0)} {
set mini 1
} elseif {([string compare $arg "--noconf"] == 0)} {
set gparam(noconf) 1
set param(autosave) 0
} elseif {([string compare $arg "--debug"] == 0) ||
([string compare $arg "-D"] == 0)} {
incr a
if {$a < $argc} {
set param(debug) [lindex $argv $a]
}
} elseif {! [string match {-*} $arg]} {
# argument is a search query
set query "$query $arg"
}
}
debug 1 "end of argument parsing: remote = $remote new = $new, query = $query, mini = $mini"
if {$remote} {
# send a command to a running ding
set ret 1
if [string length $query] {
set ret [remote $query]
}
debug 1 "remote exit $ret"
# if send was ok or no new window -> exit
if {($ret == 0) || (! $new)} {
exit $ret
}
}
# read user's config file if existing
if [file readable $param(rcfile)] {
set err [catch "source $param(rcfile)" errmsg]
if $err {
errorBox "Error in config file $param(rcfile):\n$errmsg"
exit
}
}
# check if we have tkTable extension
if {0} {
if {[string match {} [info commands table]] &&
[catch {package require Tktable} err] &&
[catch {load [file join [pwd] Tktable[info sharedlibextension]]} err]} {
debug 1 "No tkTable: $err"
set hastable 0
} else {
debug 1 "Tktable v[package provide Tktable] loaded"
set hastable 1
}
}
array set avail_cmds {}
proc cmd_avail {cmd} {
global env param avail_cmds
debug 2 "cmd_avail $cmd"
if [string match "internal_*" $cmd] {
return 1
} elseif {[llength [array get avail_cmds $cmd]] > 1} {
# found earlier
return 1
} elseif {$param(isunix)} {
if {[string index $cmd 0] == "/" && [file isfile $cmd] && [file executable $cmd]} {
debug 8 "Found $cmd"
set avail_cmds($cmd) 1
return 1
}
if {[llength [array get env PATH]] < 1} {
return 0
}
foreach p [split $env(PATH) :] {
if {[file isfile "$p/$cmd"] && [file executable "$p/$cmd"]} {
debug 8 "Found $p/$cmd"
set avail_cmds($cmd) 1
return 1
}
}
} else {
if {[file executable $cmd] || [file executable "$cmd.exe"]} {
# errorBox "Found $cmd.exe"
return 1
}
}
return 0
}
# check available search commands
set gparam(grepcmd) {}
foreach c [array names default_grepcmds] {
if [cmd_avail $c] {
if {$gparam(grepcmd) == ""} { # default search cmd
set gparam(grepcmd) $c
}
debug 2 "--- $c $default_grepcmds($c)"
set grepcmds($c) "$default_grepcmds($c)"
}
}
set cmds 0
# 1.0 options - no prog_version used
# do backward compatibility
if { ! [info exists ding_version]} {
# 1.0 options - no prog_version used
# or new user
set searchmeth(0,name) [set s(en)(defaultdict)]
set searchmeth(0,type) 0
foreach i [array names default_searchopts] {
set searchmeth(0,$i) $default_searchopts($i)
}
if [info exists dictfile] {
set searchmeth(0,dictfile) $dictfile
} else {
set searchmeth(0,dictfile) $default_searchmeth(0,dictfile)
}
set searchmeth(0,dictfiles) [glob -nocomplain $searchmeth(0,dictfile)]
if [info exists language1] {
set searchmeth(0,language1) $language1
} else {
set searchmeth(0,language1) $default_searchmeth(0,language1)
}
if [info exists language2] {
set searchmeth(0,language2) $language2
} else {
set searchmeth(0,language2) $default_searchmeth(0,language2)
}
if [info exists separator] {
set searchmeth(0,separator) $separator
} elseif [info exists default_searchmeth(0,separator)] {
set searchmeth(0,separator) $default_searchmeth(0,separator)
} else {
set searchmeth(0,separator) {}
}
if [info exists maxlength] {
set searchmeth(0,maxlength) $maxlength
} elseif [info exists default_searchmeth(0,maxlength)] {
set searchmeth(0,maxlength) $default_searchmeth(0,maxlength)
}
if [info exists maxresults] {
set searchmeth(0,maxresults) $maxresults
} elseif [info exists default_searchmeth(0,maxresults)] {
set searchmeth(0,maxresults) $default_searchmeth(0,maxresults)
}
if [info exists minlength] {
set searchmeth(0,minlength) $minlength
} elseif [info exists default_searchmeth(0,minlength)] {
set searchmeth(0,minlength) $default_searchmeth(0,minlength)
}
set searchmeth(0,shapedresult) $default_searchopts(shapedresult)
set searchmeth(0,foldedresult) $default_searchmeth(0,foldedresult)
if [info exists grepcmd] {
set searchmeth(0,grepcmd) $grepcmd
} else {
# evtl. spezifisches grep cmd
foreach c $default_searchmeth(0,grepcmds) {
if [info exists grepcmds($c)] {
set searchmeth(0,grepcmd) $c
break
}
}
}
if [info exists grepopts] {
set searchmeth(0,grepopts) $grepopts
} else {
set searchmeth(0,grepopts) "$grepcmds($searchmeth(0,grepcmd))"
}
set searchmeth(0,avail) 1
set searchmpos 0
# Enable other available search methods
for {set m 1} {[info exists default_searchmeth($m,name)]} {incr m} {
foreach c $default_searchmeth($m,grepcmds) {
if [info exists grepcmds($c)] {
set searchmeth($m,name) $default_searchmeth($m,name)
set searchmeth($m,type) $m
set searchmeth($m,grepcmd) $c
if [info exists default_searchmeth($m,grepopts)] {
set searchmeth($m,grepopts) $default_searchmeth($m,grepopts)
} else {
set searchmeth($m,grepopts) $grepcmds($c)
}
foreach i [array names default_searchopts] {
set searchmeth($m,$i) $default_searchopts($i)
}
if [info exists default_searchmeth($m,dictfile)] {
set searchmeth($m,dictfile) $default_searchmeth($m,dictfile)
} else {
set searchmeth($m,dictfile) {}
}
set searchmeth($m,dictfiles) [glob -nocomplain $searchmeth($m,dictfile)]
if [info exists default_searchmeth($m,language1)] {
set searchmeth($m,language1) $default_searchmeth($m,language1)
} else {
set searchmeth($m,language1) {}
}
if [info exists default_searchmeth($m,language2)] {
set searchmeth($m,language2) $default_searchmeth($m,language2)
} else {
set searchmeth($m,language2) {}
}
if [info exists default_searchmeth($m,separator)] {
set searchmeth($m,separator) $default_searchmeth($m,separator)
} else {
set searchmeth($m,separator) {}
}
if [info exists default_searchmeth($m,maxlength)] {
set searchmeth($m,maxlength) $default_searchmeth($m,maxlength)
}
if [info exists default_searchmeth($m,maxresults)] {
set searchmeth($m,maxresults) $default_searchmeth($m,maxresults)
}
if [info exists default_searchmeth($m,minlength)] {
set searchmeth($m,minlength) $default_searchmeth($m,minlength)
}
if [info exists default_searchmeth($m,shapedresult)] {
set searchmeth($m,shapedresult) $default_searchmeth($m,shapedresult)
}
if [info exists default_searchmeth($m,foldedresult)] {
set searchmeth($m,foldedresult) $default_searchmeth($m,foldedresult)
}
set searchmeth($m,avail) 1
lappend searchmpos $m
break
}
}
}
if [info exists maxhistory] {
set param(maxhistory) $maxhistory
}
if [info exists fcolor] {
set param(fcolor) $fcolor
}
if [info exists bcolor] {
set param(bcolor) $bcolor
}
if [info exists tfont] {
set param(tfont) $tfont
}
if [info exists lang] {
set gparam(lang) $lang
}
} else {
if {$searchmpos == ""} {
set searchmpos 0
}
foreach i $searchmpos {
if [cmd_avail $searchmeth($i,grepcmd)] {
incr cmds
set searchmeth($i,avail) 1
} else {
set searchmeth($i,avail) 0
}
if {! [info exists searchmeth($i,foldedresult)]} {
set fold [expr {[info exists default_searchmeth($i,foldedresult)] ? $default_searchmeth($i,foldedresult) : $default_searchopts(foldedresult)}]
debug 2 "set searchmeth($i,foldedresult) to $fold"
set searchmeth($i,foldedresult) $fold
}
# Change path of default ger-eng.txt when upgrading from version 1.1
if {$searchmeth($i,dictfile) == {/usr/dict/ger-eng.txt} &&
$ding_version == {1.1}} {
set searchmeth($i,dictfile) $default_searchmeth(0,dictfile)
debug 2 "New path and name of ger-eng.txt configured: $default_searchmeth(0,dictfile)"
} elseif {$searchmeth($i,dictfile) == {/usr/share/dict/ger-eng.txt}} {
set searchmeth($i,dictfile) $default_searchmeth(0,dictfile)
debug 2 "New name of ger-eng.txt configured: $default_searchmeth(0,dictfile)"
}
set df [glob -nocomplain $searchmeth($i,dictfile)]
set searchmeth($i,dictfiles) $df
}
}
if [expr $param(debug) & 8] {
debug 8 "Search methods:"
foreach m [lsort [array names searchmeth]] {
puts stderr " $m: $searchmeth($m)"
}
}
set param(cursearchmeth) 0
# set program colors
if {[string length $param(bcolor)] != 7 ||
[scan $param(bcolor) "#%2x%2x%2x" red green blue] != 3 ||
[string length $param(fcolor)] != 7 ||
[scan $param(fcolor) "#%2x%2x%2x" red green blue] != 3} {
set param(bcolor) $default(bcolor)
set param(fcolor) $default(fcolor)
}
tk_setPalette foreground $param(fcolor) background $param(bcolor)
if { ![string compare $gparam(grepcmd) ""] && $cmds < 1} {
# no search command found ...
errorBox "No grep commands like [array names default_grepcmds] found.
Check your PATH and/or install a grep command.
Exiting ..."
exit
}
# Define Font names
proc defFonts {} {
global param
# Pixel size for Unix - looks better
set pixel [expr {$param(isunix) ? "-" : ""}]
if [string length [lindex $param(lfont) 2]] {
set weight [lindex $param(lfont) 2]
} else {
set weight {normal}
}
font create lfont -family [lindex $param(lfont) 0] \
-size $pixel[lindex $param(lfont) 1] -weight $weight
if [string length [lindex $param(bfont) 2]] {
set weight [lindex $param(bfont) 2]
} else {
set weight {bold}
}
font create bfont -family [lindex $param(bfont) 0] \
-size $pixel[lindex $param(bfont) 1] -weight $weight
if [string length [lindex $param(ifont) 3]] {
set slant [lindex $param(ifont) 3]
} else {
set slant {italic}
}
font create ifont -family [lindex $param(ifont) 0] \
-size $pixel[lindex $param(ifont) 1] -slant $slant
if [string length [lindex $param(sfont) 2]] {
set weight [lindex $param(sfont) 2]
} else {
set weight {normal}
}
font create sfont -family [lindex $param(sfont) 0] \
-size $pixel[lindex $param(sfont) 1] -weight $weight
if [string length [lindex $param(tfont) 2]] {
set weight [lindex $param(tfont) 2]
} else {
set weight {normal}
}
font create tfont -family [lindex $param(tfont) 0] \
-size $pixel[lindex $param(tfont) 1] -weight $weight
if [string length [lindex $param(ipafont) 2]] {
set weight [lindex $param(ipafont) 2]
} else {
set weight {normal}
}
font create ipafont -family [lindex $param(ipafont) 0] \
-size $pixel[lindex $param(ipafont) 1] -weight $weight
# font create ipafont -family lucidatypewriter -size -14 -weight normal
}
# Change result font: how - 1 = bigger, -1 = smaller, 0 = default
proc change_font {how} {
global param default
if {$how == 0} { # default
set param(tfont) [list [lindex $param(tfont) 0] [lindex $default(tfont) 1] [lindex $param(tfont) 2]]
set param(ifont) [list [lindex $param(ifont) 0] [lindex $default(tfont) 1] [lindex $param(ifont) 2] [lindex $param(ifont) 3]]
set param(ipafont) [list [lindex $param(ipafont) 0] [lindex $default(ipafont) 1] [lindex $param(ipafont) 2]]
} else {
set fs [expr [lindex $param(tfont) 1] + $how]
if {$fs > 4} { # greater than minimum font size
set param(tfont) [list [lindex $param(tfont) 0] $fs [lindex $param(tfont) 2]]
set param(ifont) [list [lindex $param(ifont) 0] $fs [lindex $param(ifont) 2] [lindex $param(ifont) 3]]
set param(ipafont) [list [lindex $param(ipafont) 0] $fs [lindex $param(ipafont) 2]]
}
}
chFont tfont
chFont ifont
chFont ipafont
.statusBar.lab config -foreground $param(fcolor) -text "$param(tfont)"
}
proc chFont {font} {
global param
# Pixel size for Unix - looks better
set pixel [expr {$param(isunix) ? "-" : ""}]
if [string length [lindex $param($font) 2]] {
set weight [lindex $param($font) 2]
} else {
set weight {normal}
}
if {[string length [lindex $param($font) 3]] &&
[lindex $param($font) 3] == {italic}} {
set slant {italic}
} else {
set slant {roman}
}
font configure $font -family [lindex $param($font) 0] \
-size $pixel[lindex $param($font) 1] -weight $weight -slant $slant
}
defFonts
# if {![string compare $searchmeth($param(cursearchmeth),grepcmd) ""]} {
# } else {
# set default_searchopts(grepcmd) $searchmeth($param(cursearchmeth),grepcmd)
# }
if {[winfo depth .] > 1} { # Color display
set param(errcolor) red
} else {
set param(errcolor) black
}
#########################################################################
# Balloon help, by John Haxby <jch@pwd.hp.com>, with slight changes
# by Axel Boldt <boldt@math.ucsb.edu>.
proc BalloonInit {} {
global param
bind balloon <Enter> {
if { [info exists balloonHelp(%W)] && [%W cget -state] != "disabled"} {
set balloonHelp(%W,after) [after $param(balloonDelay) {showBalloonHelp %W}]
}
}
bind balloon <Leave> { unShowBalloonHelp %W }
bind balloon <Any-KeyPress> { unShowBalloonHelp %W }
bind balloon <Any-Button> { unShowBalloonHelp %W }
proc showBalloonHelp {w} {
global balloonHelp param gparam
if {![info exists balloonHelp($w)] || ! $param(showBalloons) } {
return
}
update idletasks
set curpos [winfo pointerxy $w]
set curwin [eval winfo containing $curpos]
if { $w == $curwin } {
if ![winfo exists .balloon] {
toplevel .balloon
wm overrideredirect .balloon true
pack [label .balloon.l -font lfont \
-foreground black \
-background $gparam(balloonBackground) \
-highlightthickness 1 \
-highlightbackground black]
wm withdraw .balloon
}
.balloon.l configure -text $balloonHelp($w)
set x [expr [lindex $curpos 0] - 14]
set y [expr [lindex $curpos 1] + 19]
wm geometry .balloon +$x+$y
# This update is important to have the geometry command take
# effect in all cases (A.B.)
update idletasks
raise .balloon
wm deiconify .balloon
}
}
proc unShowBalloonHelp {w} {
global balloonHelp
if [info exists balloonHelp($w,after)] {
after cancel $balloonHelp($w,after)
unset balloonHelp($w,after)
}
catch {wm withdraw .balloon}
}
# end of proc BalloonInit
}
BalloonInit
###############
# calculate other colors from given foreground and background colors
proc shadeColor {fcolor bcolor} {
debug 2 "shadeColor $fcolor $bcolor"
# the higher the following values
# the more different is the shaded/hilite color, max 127
set dc1 16
set dc2 32
if {[scan $bcolor "#%2x%2x%2x" red green blue] != 3} {
set rgb [winfo rgb . $bcolor]
set red [expr {[lindex $rgb 0]/0x100}]
set green [expr {[lindex $rgb 1]/0x100}]
set blue [expr {[lindex $rgb 2]/0x100}]
}
debug 8 " old bcolor = $red $green $blue"
set red [expr $red < (255 - $dc1) ? [expr $red + $dc1] : [expr $red - $dc1]]
set green [expr $green < (255 - $dc1) ? [expr $green + $dc1] : [expr $green - $dc1]]
set blue [expr $blue < (255 - $dc1) ? [expr $blue + $dc1] : [expr $blue - $dc1]]
set bc [format "#%02x%02x%02x" $red $green $blue]
set red [expr $red < (255 - $dc2) ? [expr $red + $dc2] : [expr $red - $dc2]]
set green [expr $green < (255 - $dc2) ? [expr $green + $dc2] : [expr $green - $dc2]]
set blue [expr $blue < (255 - $dc2) ? [expr $blue + $dc2] : [expr $blue - $dc2]]
set hc [format "#%02x%02x%02x" $red $green $blue]
set ec [format "#%02x%02x%02x" [expr $red < 128 ? 255 : $red] [expr $green < 128 ? 128 : 0] [expr $blue < 128 ? 128 : 0]]
# [expr 255 - $green] [expr 255 - $blue]]
if {[scan $fcolor "#%2x%2x%2x" red green blue] != 3} {
set rgb [winfo rgb . $fcolor]
set red [expr {[lindex $rgb 0]/0x100}]
set green [expr {[lindex $rgb 1]/0x100}]
set blue [expr {[lindex $rgb 2]/0x100}]
}
debug 8 " old fcolor = $red $green $blue"
# set red [expr $red < 128 ? 255 : 0]
# set green [expr $green < 128 ? 255 : 0]
set blue [expr $blue < 128 ? 255 : 0]
set fc [format "#%02x%02x%02x" $red $green $blue]
debug 8 " new colors = $bc $fc $ec $hc"
return [list $bc $fc $ec $hc]
}
proc setSearchBg {color} {
.search.s configure -background $color
.search.s.label.label configure -background $color
.search.l configure -background $color
.search.l.logo configure -background $color
.search configure -background $color
}
# updates the menu for search methods when changed
proc update_searchmeth_menu {} {
global searchmeth searchmpos param gparam s
debug 2 "update_searchmeth_menu"
set lang $gparam(lang)
variable i
.search.s.searchmeth.m delete 0 end
set n 0
foreach i $searchmpos {
if $searchmeth($i,avail) {
incr n
set cmd "
set param(cursearchmeth) $i
.search.s.searchmeth configure -text {$searchmeth($i,name)}
.statusBar.lab config -foreground $param(fcolor) \
-text {[set s($lang)(cmd)] $searchmeth($i,grepcmd)}
.statusBar.file config -foreground $param(fcolor) \
-text {$searchmeth($i,dictfile)}
set_opts_errors {$i}
after cancel dictsearchquery_onchange
after $param(autosearchDelay) dictsearchquery_onchange
"
if {$n < 10} {
bind .search.s.entry <Control-KeyPress-$n> "$cmd"
.search.s.searchmeth.m add command -font lfont \
-accelerator "[set s($lang)(ctl)]+$n" \
-label [set searchmeth($i,name)] -command $cmd \
} else {
.search.s.searchmeth.m add command -font lfont \
-label [set searchmeth($i,name)] -command $cmd
}
}
}
.search.s.searchmeth configure -text $searchmeth($param(cursearchmeth),name)
.statusBar.file config -foreground $param(fcolor) \
-text "$searchmeth($param(cursearchmeth),dictfile)"
}
# manipulates menu for opts(errors)
# - active only for search methods which support error correction
proc set_opts_errors {i} {
global searchmeth opts param
debug 2 "set_opts_errors"
if { ([string match "*grep*" $searchmeth($i,grepcmd)] && \
[string match "*agrep*" $searchmeth($i,grepcmd)]) ||
[string match "dict*" $searchmeth($i,grepcmd)]} {
# only agrep and dict (limited) have error correction
.search.opts.errors configure -state normal
.menuBar.params entryconfigure 8 -state normal
.menuBar.params entryconfigure 9 -state normal
.menuBar.params entryconfigure 10 -state normal
.menuBar.params entryconfigure 11 -state normal
.menuBar.params entryconfigure 12 -state normal
} else {
# save old state ???
set opts(errors) 0
.search.opts.errors configure -state disabled
.menuBar.params entryconfigure 8 -state disabled
.menuBar.params entryconfigure 9 -state disabled
.menuBar.params entryconfigure 10 -state disabled
.menuBar.params entryconfigure 11 -state disabled
.menuBar.params entryconfigure 12 -state disabled
}
}
# Escape: reset interface (kill search process, reset cursor, stop anim logo)
proc Reset {mini} {
global proc param gparam s
debug 2 "Reset"
set lang $gparam(lang)
if {$proc(pid) > 0} {
if {$param(isunix)} {
debug 4 " kill $proc(pid)"
if [catch {exec kill $proc(pid)} err] {
.statusBar.lab config -foreground $param(errcolor) -text "[set s($lang)(nokill)] $err"
} else {
set $proc(pid) -1
.statusBar.lab config -foreground $param(fcolor) -text [set s($lang)(kill)]
}
}
} elseif {$proc(pid) == 0} {
# internal search
debug 4 "Stopping internal"
set proc(pid) -1
}
interface_reset $mini
}
# Scrollbars when needed, http://mini.net/cgi-bin/wikit/BagOfTkAlgorithms
# scrollbars come and go as needed -- see Welch 8.0/347f.
proc yscroll {bar cmd offset size} {
# debug 8 "yscroll $bar \"$cmd\" $offset $size"
if {$offset == 0 && $size == 0} {
return
}
if {$offset != 0.0 || $size != 1.0} {
# grid configure .result.text -rowspan 1
eval $cmd
}
$bar set $offset $size
}
proc xscroll {bar cmd offset size} {
# debug 8 "xscroll $bar \"$cmd\" $offset $size"
if {$offset == 0 && $size == 0} {
return
}
if {$offset != 0.0 || $size != 1.0} {
grid configure .result.text -columnspan 1
eval $cmd
}
$bar set $offset $size
}
# show (full window) or hide (minimize window) the result frame
# type 0 = hide, 1 = show, -1 = toggle
proc hideResult {type} {
global param s lang balloonHelp
debug 2 "hideResult $type"
set x 0
set y 0
# update
set geo [wm geometry .]
scan $geo "%dx%d+%d+%d" w h x y
set where {}
set wx [winfo x .]
set wy [winfo y .]
if {$x == 0 && $y == 0} {
if {${wx} != 0 && ${wy} != 0} {
# set where "+${wx}+${wy}"
}
} else {
set where "+$x+$y"
}
debug 8 " toplevel geometry: $geo (= $w $h $x $y) winfo: $wx $wy -> $where"
set visible [winfo viewable .result]
# show
if {($type == 1 && ! $visible) || ($type == -1 && ! $visible)} {
pack .result -fill both -expand yes
debug 8 " show result"
set param(show_result) 1
hideMenuBar -1
hideStatusBar -1
if {[info exists param(width)] && [info exists param(height)]} {
set height [expr $param(height) + $param(add_geom_height)]
debug 8 " setting geometry: $param(width)x$height$where"
bind dlookup <Configure> {}
wm geometry . "$param(width)x$height$where"
update
debug 8 " after setting: [wm geometry .] [winfo height .] "
set wh [winfo height .]
if {$height != $wh} {
# correction of height for some window managers
debug 8 "Window manager sets false height: should $height, is $wh."
set param(add_geom_height) [expr $param(height) - $wh]
## should be: requested height + correction
set height [expr $param(height) + $param(add_geom_height)]
# for KDE this works: setting requested height again
set height $param(height)
debug 8 " setting geometry: $param(width)x$height$where"
wm geometry . "$param(width)x$height$where"
update
debug 8 " after setting: [wm geometry .] [winfo height .] "
}
bind dlookup <Configure> catch_resize
} else {
wm geometry . {}
}
set balloonHelp(.search.l.logo) [set s($lang)(minimize)]
.popup entryconfigure 7 -label [set s($lang)(minimize)]
return
}
# hide
if {($type == 0 && $visible) || ($type == -1 && $visible)} {
pack forget .result
debug 8 " hide result"
if {$param(do_automin) == 1 && $param(win_prop) == 2 && $param(autominDelay) > 0} {
debug 2 " cancelling automatically minimize <Enter>"
after cancel {hideResult 0}
}
set param(show_result) 0
hideMenuBar 0
hideStatusBar 0
if [info exists param(width)] {
set w $param(width)
} else {
set w [winfo width .search]
}
debug 8 " setting geometry: ${w}x[winfo height .search]$where"
wm geometry . "${w}x[winfo height .search]$where"
# wm geometry . {}
set balloonHelp(.search.l.logo) [set s($lang)(normalsize)]
.popup entryconfigure 7 -label [set s($lang)(normalsize)]
return
}
debug 2 "hideResult - status ok, nothing done"
}
# proc to show or hide the menu bar
# type 0 = hide, 1 = show, -1 = show if user wants to see
proc hideMenuBar {type} {
global param s lang
debug 8 "hideMenuBar $type"
# show
if {$type == 1} {
. configure -menu .menuBar
set param(show_menu) 1
.popup entryconfigure 8 -label [set s($lang)(hide_menu)]
debug 8 " show menu"
} elseif {$type == 0} {
# hide
. configure -menu .nomenuBar
# set param(show_menu) 0
.popup entryconfigure 8 -label [set s($lang)(show_menu)]
if {$param(show_result) == 1 && $param(show_status) == 1} {
.statusBar.lab config -foreground $param(fcolor) -text [set s($lang)(show_menu_desc)]
}
debug 8 " hide menu"
# type == -1
} elseif {$param(show_menu) == 1} {
. configure -menu .menuBar
.popup entryconfigure 8 -label [set s($lang)(hide_menu)]
debug 8 " show menu"
} else {
# hide
. configure -menu .nomenuBar
.popup entryconfigure 8 -label [set s($lang)(show_menu)]
debug 8 " hide menu"
}
}
# 0 - off, 1 = on, -1 = show if user wants to see
proc hideStatusBar {type} {
global param s lang
debug 8 "hideStatusBar $type"
# show
if {$type == 1} {
pack .statusBar -side bottom -fill x -pady 1 -padx 1 -before .result
set param(show_status) 1
.popup entryconfigure 9 -label [set s($lang)(hide_status)]
debug 8 " show status"
} elseif {$type == 0} {
# hide
pack forget .statusBar
# set param(show_status) 0
.popup entryconfigure 9 -label [set s($lang)(show_status)]
debug 8 " hide status"
} elseif {$param(show_status) == 1 && ![winfo viewable .statusBar]} {
pack .statusBar -side bottom -fill x -pady 1 -padx 1 -before .result
.popup entryconfigure 9 -label [set s($lang)(hide_status)]
debug 8 " show status"
} else {
# hide
pack forget .statusBar
.popup entryconfigure 9 -label [set s($lang)(show_status)]
debug 8 " hide status"
}
}
proc welcome {start} {
global param searchmpos searchmeth s lang pinfo
set t .result.text
set big {Helvetica 18 bold}
$t tag configure h1 -background $param(shadedcolor) -foreground $param(fcolor) -font $big -justify center
.result.text tag configure cmd -background $param(bcolor) \
-relief groove -borderwidth 1 -lmargin1 5 -spacing1 3 -spacing3 3 \
-font lfont
.result.text tag configure th -background $param(shadedcolor) -font bfont \
-relief groove -borderwidth 1 -lmargin1 5 -spacing1 3 -spacing3 3
$t tag configure c -justify center -font bfont -background $param(bcolor)
$t tag configure infolink -foreground $param(highcolor) -underline 1 \
-justify center -font bfont
$t tag bind infolink <ButtonRelease-1> { aboutBox }
$t tag bind infolink <Enter> " $t config -cursor hand2"
$t tag bind infolink <Leave> " $t config -cursor xterm"
$t configure -state normal
$t delete 0.0 end
if {$start} {
.result.text insert end "$pinfo(pname)\n" h1
.result.text insert end "\nVersion $pinfo(version) - " c
.result.text insert end "Info" infolink
.result.text insert end "\n\n" c
}
# compute tab stop
set width [winfo width $t]
if {$width < 200} {
set width 200
}
$t configure -tabs [expr round(($width / 2) - 2)]
.result.text insert end "[set s($lang)(configured)] [set s($lang)(searchmeth)]\t" th
.result.text insert end "[set s($lang)(grepcmd)] / [set s($lang)(dictfile)]\n" th
foreach i $searchmpos {
set what "$searchmeth($i,language1)"
if [string length $searchmeth($i,language2)] {
set what "$what $searchmeth($i,language2)"
}
if $searchmeth($i,avail) {
.result.text insert end [format "%s (%s)\t%s %s %s\n" \
$searchmeth($i,name) $what \
$searchmeth($i,grepcmd) \
$searchmeth($i,grepopts) \
$searchmeth($i,dictfile) ] cmd
}
}
.result.text configure -state disabled
.result.text tag raise sel
if {$start} {
animlogo .search.l.logo
after 1500 {
after cancel animlogo .search.l.logo
.search.l.logo configure -image "logo1"
}
}
}
# proc mainWindow {w} {
# global pinfo argv0 argv param gparam s lang
# global searchmeth opts defaultcursor
# global grepcmds
# now build the user interface
set logo {
R0lGODdhIAAgAMIAAMDAwAAAAP///4CAgPJ8Dv///////////ywAAAAAIAAgAAADxRi63P5N
yEmrvVIJwLv/YDhoYWl6Y7CdLJiubQy8ALR0tsLRKiYENd9vpyH0MDWAMECYFY+X5LL5Mv4C
g4EgK5Eustwf9SmU+phOlVWiBXeBE7dWnBaskfDzWA21mDFoVX0VXlhbYYFkV1hhfxeJfGV5
gHt2UHMTZmCYdIJxh3OOFpCWkkqHGQyVa5sUokFXq4Ouk29DpHdRtRs6NbI2vEo5siZAxsXE
xb0luDlMBEbDddDU1dRg1tmVMjIpm9/g4eLO5MAJADs=}
image create photo windowicon -data $logo
wm title . $pinfo(pname)
if {$tk_version >= 8.5} {
wm iconphoto . windowicon
}
wm iconname . $pinfo(pname)
wm command . [concat $argv0 $argv]
wm client . [info hostname]
# wm group . .
# wm focusmodel . active
set lang $gparam(lang)
menu .menuBar -font lfont -tearoff 0 -relief groove -bd 1
menu .menuBar.file -tearoff 0 -font lfont
.menuBar.file add command -label "[set s($lang)(newwin)]..." \
-underline 0 -accelerator "[set s($lang)(ctl)]+N" -command startNew
.menuBar.file add command -label "[set s($lang)(save)]..." -command {save 0} \
-underline 0 -accelerator "[set s($lang)(ctl)]+S"
.menuBar.file add command -label "[set s($lang)(saveall)]..." -command {save 1} \
-underline 0 -accelerator "[set s($lang)(ctl)]+L"
.menuBar.file add command -label "[set s($lang)(clipboard_copy_all)]" -command clipboard_copy_all \
-underline 0 -accelerator "[set s($lang)(ctl)]+C"
.menuBar.file add command -label "[set s($lang)(notice)]..." \
-command {notice $param(noticefile)} \
-underline 1 -accelerator "[set s($lang)(ctl)]+O"
.menuBar.file add command -label "[set s($lang)(mail)]..." -command sendMail \
-underline 0 -accelerator "[set s($lang)(ctl)]+M"
.menuBar.file add command -label [set s($lang)(quit)] -command {
if {$param(autosave) != 0} {
saveOptions
}
exit } \
-underline 0 -accelerator "[set s($lang)(ctl)]+Q"
.menuBar add cascade -menu .menuBar.file -label [set s($lang)(file)] -underline 0
menu .menuBar.opts -tearoff 0 -font lfont
.menuBar.opts add checkbutton -label [set s($lang)(show_menu)] \
-variable param(show_menu) -command {hideMenuBar $param(show_menu)} \
-accelerator "[set s($lang)(shift)]+[set s($lang)(ctl)]+[set s($lang)(space)]"
.menuBar.opts add checkbutton -label [set s($lang)(params_as_menu)] \
-variable param(params_as_menu) -command {
if $param(params_as_menu) {
pack .search.opts -pady 2
} else {
pack forget .search.opts
}
}
.menuBar.opts add checkbutton -label [set s($lang)(umlaut_buttons)] \
-variable param(umlaut_buttons) -command {
if $param(umlaut_buttons) {
pack .search.u -pady 2
} else {
pack forget .search.u
}
}
# .menuBar.opts add checkbutton -label [set s($lang)(show_result)] \
# -variable param(show_result) -command {hideResult $param(show_result)} \
# -accelerator "[set s($lang)(ctl)]+[set s($lang)(space)]"
.menuBar.opts add checkbutton -label [set s($lang)(show_status)] \
-variable param(show_status) -command \
{ hideStatusBar $param(show_status)}
.menuBar.opts add separator
.menuBar.opts add command -label [set s($lang)(larger_font)] -command "change_font 1" \
-accelerator "[set s($lang)(ctl)]++"
.menuBar.opts add command -label [set s($lang)(smaller_font)] -command "change_font -1" \
-accelerator "[set s($lang)(ctl)]+-"
.menuBar.opts add command -label [set s($lang)(default_font)] -command "change_font 0" \
-accelerator "[set s($lang)(ctl)]+0"
.menuBar.opts add separator
.menuBar.opts add command -label [set s($lang)(general)] -command "setGeneral" -underline 0
.menuBar.opts add command -label [set s($lang)(soptions)] -command "setSearch" -underline 0
.menuBar.opts add command -label [set s($lang)(saveopts)] -command "saveOptions" -underline 0
if {$gparam(noconf)} {
.menuBar.opts entryconfigure 11 -state disabled
}
.menuBar add cascade -menu .menuBar.opts -label [set s($lang)(options)] -underline 0
# Search parameters as menu?
menu .menuBar.params -tearoff 1 -font lfont
.menuBar.params add radiobutton -label [set s($lang)(word)(0)] \
-value 0 -variable opts(word)
.menuBar.params add radiobutton -label [set s($lang)(word)(1)] \
-value 1 -variable opts(word)
.menuBar.params add separator
.menuBar.params add radiobutton -label [set s($lang)(case)(0)] \
-value 0 -variable opts(case)
.menuBar.params add radiobutton -label [set s($lang)(case)(1)] \
-value 1 -variable opts(case)
.menuBar.params add separator
for {set x 0} {$x < 5} {incr x} {
set e [expr $x == 1 ? {[set s($lang)(error)]} : {[set s($lang)(errors)]}]
.menuBar.params add radiobutton -label "$x $e" \
-value $x -variable opts(errors)
}
.menuBar.params add radiobutton -label [set s($lang)(closestmatch)] \
-value -1 -variable opts(errors)
.menuBar.params add separator
.menuBar.params add radiobutton -label [set s($lang)(regex)(0)] \
-value 0 -variable opts(regex)
.menuBar.params add radiobutton -label [set s($lang)(regex)(1)] \
-value 1 -variable opts(regex)
.menuBar add cascade -menu .menuBar.params -label [set s($lang)(params)] \
-underline 0
# Program behavior menu
menu .menuBar.props -tearoff 1 -font lfont
.menuBar.props add radiobutton -label [set s($lang)(onrequest)] \
-value 0 -variable param(search_prop) \
-command {after cancel check_selection;
.search.s.label.mark configure -background green }
.menuBar.props add radiobutton -label [set s($lang)(onmouseover)] \
-value 1 -variable param(search_prop) \
-command {after cancel check_selection;
.search.s.label.mark configure -background yellow }
.menuBar.props add radiobutton -label [set s($lang)(onselection)] \
-value 2 -variable param(search_prop) \
-command { .search.s.label.mark configure -background red }
.menuBar.props add separator
.menuBar.props add radiobutton -label [set s($lang)(min_none)] \
-value 0 -variable param(win_prop)
.menuBar.props add radiobutton -label [set s($lang)(min_focus_delay)] \
-value 2 -variable param(win_prop)
.menuBar.props add radiobutton -label [set s($lang)(min_focus)] \
-value 1 -variable param(win_prop)
.menuBar.props add separator
.menuBar.props add checkbutton -label [set s($lang)(raise)] \
-onvalue 1 -offvalue 0 -variable param(raise)
.menuBar.props add checkbutton -label [set s($lang)(autosearch)] \
-onvalue 1 -offvalue 0 -variable param(autosearch)
.menuBar add cascade -menu .menuBar.props -label [set s($lang)(props)] \
-underline 1
menu .menuBar.help -tearoff 0 -font lfont
.menuBar.help add command -label [set s($lang)(help)] -command "helpGeneral" \
-underline 0 -accelerator "F1"
.menuBar.help add command -label [set s($lang)(khelp)] -command "helpKeys" \
-underline 0
.menuBar.help add command -label [set s($lang)(abbhelp)] -command "helpAbb" \
-underline 0
.menuBar.help add command -label [set s($lang)(cmdline)] \
-command "helpCmdline" -underline 0
.menuBar.help add command -label [set s($lang)(searchmeth)] -command "welcome 0" \
-underline 0
.menuBar.help add sep
.menuBar.help add command -label "Homepage" -command "urlOpen $pinfo(homepage)"
.menuBar.help add sep
.menuBar.help add command -label [set s($lang)(about)] -command "aboutBox" \
-underline 0
.menuBar add cascade -menu .menuBar.help -label [set s($lang)(help)] -underline 0
# the "no menu bar" - empty
menu .nomenuBar -bd 0
if {(! $mini) && $param(show_menu) == 1} {
. configure -menu .menuBar
} else {
. configure -menu .nomenuBar
}
# Pop up menu
menu .popup -tearoff 0 -font lfont
.popup add command -label [set s($lang)(bbhistory)] -command { history back } \
-accelerator "[set s($lang)(ctl)]+[set s($lang)(up)]" -state disabled
.popup add command -label [set s($lang)(bfhistory)] -command { history forward } \
-accelerator "[set s($lang)(ctl)]+[set s($lang)(down)]" -state disabled
.popup add separator
.popup add command -label [set s($lang)(save)] -command {save 0} \
-underline 0 -accelerator "[set s($lang)(ctl)]+S"
.popup add command -label [set s($lang)(clipboard_copy_line)] -command {
.result.text tag remove sel 1.0 end
#.result.text tag add sel [.result.text tag ranges hilite]
if {[string compare [.result.text index "@$tkPriv(x),$tkPriv(y) linestart"] "1.0"]} {
.result.text tag remove sel 1.0 end
.result.text tag add sel "@$tkPriv(x),$tkPriv(y) linestart" "@$tkPriv(x),$tkPriv(y) lineend"
}
if {$param(isunix)} {
catch {set last_selection [selection get]}
} else {
catch {set last_selection [selection get -selection CLIPBOARD]}
}
catch {clipboard clear}
catch {clipboard append $last_selection}
}
.popup add command -label [set s($lang)(clipboard_copy_all)] \
-accelerator "[set s($lang)(ctl)]+C" -command clipboard_copy_all
.popup add separator
.popup add command -label [set s($lang)(minimize)] -command { hideResult -1 } \
-accelerator "[set s($lang)(ctl)]+[set s($lang)(space)]"
.popup add command -label [if {$param(show_menu) == 1} \
{set s($lang)(hide_menu)} else {set s($lang)(show_menu)}] \
-command { debug 8 "$param(show_menu) $mini"
if {$param(show_menu) == 1 && $param(show_result) == 1} {set param(show_menu) 0} else {set param(show_menu) 1}
hideMenuBar $param(show_menu) } \
-accelerator "[set s($lang)(shift)]+[set s($lang)(ctl)]+[set s($lang)(space)]"
.popup add command -label [if {$param(show_status) == 1} \
{set s($lang)(hide_status)} else {set s($lang)(show_status)}] \
-command {
debug 8 "$param(show_status)"
if {$param(show_result) == 1} {
set param(show_status) [expr $param(show_status) == 0 ? 1 : 0]
hideStatusBar $param(show_status)
}
}
frame .search -background white
pack .search -side top -fill x -expand 0
frame .search.l
pack .search.l -side right -fill y -padx 2
image create photo logo1 -data $logo
image create photo logo2 -data {
R0lGODdhIAAgAMIAAMDAwAAAAP///4CAgPJ8Dv///////////ywAAAAAIAAgAAAD2Bi63P5N
yEmrvVIJwLv/nwIOGmiCgRCM5emmKpu6Jxx/5AwtnTY1nNzGdlkRB6pfUEMgWgCrCTKZIQCE
TYwECpBMqSorNqUYIM3bKAwZmAbETGeF67S9r3GpwDzl6sF3Y1pDXXs/bnApWVp+FCQ/iQKL
GHR6dpGLC3xphRRtVXiKchSNbpehkkdzUW6AmDZnaIQwOmiBeYxRVLphqIt8X4RKvLeig40q
vL2CuYUiFcWpO8I70U0vdC+vNDzavtVvBE3VmOLm5+J86OuRNO4mOcDy8/T14PfTCQA7}
image create photo logo3 -data {
R0lGODdhIAAgAMIAAMDAwAAAAP///4CAgPJ8Dv///////////ywAAAAAIAAgAAADzxi63P5N
yEmrvVIJwLv/QAB+gzaeytmVwaZ6rfiy7htmNh1CactCHF0LIxgWMTIawXjxHZsEgJJpCQwy
1Ex0WrReB9fnTwAOB7aaJfF4zWqlaeMXnJloquiWmuj0zt9cfGZIeQJ7SHaEcHpDC2V1XV2P
RYWHTUdulIuGTGF2MTd4m4dznkVBdGRtlZkZJQAVnmejQ2WmKRKpFLOBSAOwfKxrVsCKUzwb
IjwKrCrKryjNzinOrMsE2Mu8adjd3thl3+KFNuUkCrbp6uvs2u7ICQA7}
image create photo logo4 -data {
R0lGODdhIAAgAMIAAMDAwAAAAP///4CAgPJ8Dv///////////ywAAAAAIAAgAAAD2xi63P5N
yEmrvVIJwDsPXih6gzYCyqkCZbCNLriK7Su6gjx3NfpkHciC08NNUBOQ8SKrEZYbDRCTIbA0
zwoSB8owrc5YYDBAJgE5DXlQvbqyFDO7Sw2AsUZ2TVBCSyt2bgJwRzFTfGSIbWFaOHNodXdv
UD5nVDmSg1wphjl+aWuLeIBJnpeBjBQubFN/qpmEJROsdKGKqKNJtaYVrJiCcGuVj4i+SbCU
H4cYuJMXynTMyEJKfkLIKkM6N9jZKdnT1wRP1LDj5+jja+nsmTvvPApr8/T19vTU+fkCCQA7}
image create photo logo5 -data {
R0lGODdhIAAgAMIAAMDAwAAAAP///4CAgPJ8Dv///////////ywAAAAAIAAgAAAD3Ri63P5N
yEmrvVIJwLnqYCh2gxYGQjCuYYmeGSu7G4jG8kgD0fR5kN/uxktRVDeMCkAjEG9JHgCTITA1
TkmxIs1cAtYmCikYSMzdRXlgToWxT1R70KWCr6jsZkwpTTUWd2JaUBN1bGZsVXgCeltlhFN2
b3lPRpB1SpSNUIWRRgqIi4N7Pp+TjI5yFGlJR5uqZ4YqZ4prbqlJSW2ZE224pHSue1OiFYJw
rBpotKikhlu9gbBBL7TV1CxIUivIlTIL4NTYBE7YqeXp6uWI6+6bOfEtoYj19vf49dX7+wIJ
ADs=}
image create bitmap left -foreground $param(fcolor) -data {
#define l_width 9
#define l_height 13
static char l_bits[] = {
0x80,0x00,0xc0,0x00,0xe0,0x00,0x70,0x00,0x38,0x00,0x1c,0x00,0x0e,0x00,0x1c,
0x00,0x38,0x00,0x70,0x00,0xe0,0x00,0xc0,0x00,0x80,0x00};
}
image create bitmap right -foreground $param(fcolor) -data {
#define r_width 9
#define r_height 13
static char r_bits[] = {
0x02,0x00,0x06,0x00,0x0e,0x00,0x1c,0x00,0x38,0x00,0x70,0x00,0xe0,0x00,0x70,
0x00,0x38,0x00,0x1c,0x00,0x0e,0x00,0x06,0x00,0x02,0x00};
}
image create bitmap up -foreground $param(fcolor) -data {
#define u_width 13
#define u_height 9
static char u_bits[] = {
0x00,0x00,0x40,0x00,0xe0,0x00,0xf0,0x01,0xb8,0x03,0x1c,0x07,0x0e,0x0e,0x07,
0x1c,0x00,0x00};
}
image create bitmap down -foreground $param(fcolor) -data {
#define d_width 13
#define d_height 9
static char d_bits[] = {
0x00,0x00,0x07,0x1c,0x0e,0x0e,0x1c,0x07,0xb8,0x03,0xf0,0x01,0xe0,0x00,0x40,
0x00,0x00,0x00};
}
image create bitmap plus -foreground $param(bcolor) -background $param(fcolor) -data {
#define plus_width 8
#define plus_height 8
static unsigned char plus_bits[] = {
0x00, 0x18, 0x18, 0x7e, 0x7e, 0x18, 0x18, 0x00};
}
image create bitmap minus -foreground $param(bcolor) -background $param(fcolor) -data {
#define minus_width 8
#define minus_height 8
static unsigned char minus_bits[] = {
0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00};
}
button .search.l.logo -image logo1 -bd 1 -relief raised -command {Reset 1}
pack .search.l.logo -side right -expand 1 -anchor n
set balloonHelp(.search.l.logo) [set s($lang)(minimize)]
bindtags .search.l.logo [list balloon .search.l.logo Button all]
set logoanim 1
proc animlogo {t} {
global logoanim
# debug 2 "animlogo $t"
if ![winfo exists $t] {
after cancel animlogo $t
return
}
if {$logoanim >= 5} {
set logoanim 1
} else {
incr logoanim
}
$t configure -image "logo$logoanim"
after 100 "animlogo $t"
}
frame .search.s -background white
pack .search.s -side top -expand 1 -fill x -padx 5
if {$tk_version > 8.3} {
button .search.s.back -state disabled -height 15 -width 15 -image left \
-relief flat -overrelief raised -command { history back }
} else {
button .search.s.back -state disabled -height 15 -width 15 -image left \
-relief raised -command { history back }
}
set balloonHelp(.search.s.back) [set s($lang)(bbhistory)]
bindtags .search.s.back [list balloon .search.s.back Button all]
if {$tk_version > 8.3} {
button .search.s.forw -state disabled -height 15 -width 15 -image right \
-relief flat -overrelief raised -command { history forward }
} else {
button .search.s.forw -state disabled -height 15 -width 15 -image right \
-relief raised -command { history forward }
}
set balloonHelp(.search.s.forw) [set s($lang)(bfhistory)]
bindtags .search.s.forw [list balloon .search.s.forw Button all]
# fri: label -> button
# label .search.s.label -text " [set s($lang)(query)]" -font lfont
#frame .search.s.label -pady 0
#frame .search.s.label.mark -pady 1
frame .search.s.label
frame .search.s.label.mark
switch $param(search_prop) {
"0" { .search.s.label.mark configure -background green }
"1" { .search.s.label.mark configure -background yellow }
"2" { .search.s.label.mark configure -background red }
}
button .search.s.label.label -text " [set s($lang)(query)]" -font lfont \
-relief flat -command {
# toggle search property: onrequest, onmouseover, onselect
if {$param(search_prop) == 0} {
set param(search_prop) 1
.search.s.label.mark configure -background yellow
.statusBar.lab config -foreground $param(fcolor) -text \
"[set s($lang)(props)]: [set s($gparam(lang))(onmouseover)]"
} elseif {$param(search_prop) == 1} {
set param(search_prop) 2
.search.s.label.mark configure -background red
.statusBar.lab config -foreground $param(fcolor) -text \
"[set s($lang)(props)]: [set s($gparam(lang))(onselection)]"
} elseif {$param(search_prop) == 2} {
set param(search_prop) 0
.search.s.label.mark configure -background green
.statusBar.lab config -foreground $param(fcolor) -text \
"[set s($lang)(props)]: [set s($gparam(lang))(onrequest)]"
}
}
set balloonHelp(.search.s.label.label) [set s($lang)(change_props)]
bindtags .search.s.label.label [list balloon .search.s.label.label Button all]
entry .search.s.entry -width 17 -selectbackground $param(fcolor) -selectforeground $param(bcolor) \
-textvariable query -relief flat -font tfont -bd 3
if {$tk_version > 8.3} {
button .search.s.button -text [set s($lang)(search)] -font lfont \
-relief flat -overrelief raised -command "dictsearch \$query"
} else {
button .search.s.button -text [set s($lang)(search)] -font lfont \
-relief raised -command "dictsearch \$query"
}
bind .search.s.button <2> {
# internal search = search in result text
display $curhistory $query 0 ""
}
set balloonHelp(.search.s.button) [set s($lang)(searchhelp)]
bindtags .search.s.button [list balloon .search.s.button Button all]
menubutton .search.s.searchmeth -text $searchmeth($param(cursearchmeth),name) \
-menu .search.s.searchmeth.m -indicatoron 1 -anchor c \
-direction flush -font lfont -width 12 -relief raised
set balloonHelp(.search.s.searchmeth) [set s($lang)(searchmeth)]
bindtags .search.s.searchmeth [list balloon .search.s.searchmeth Menubutton all]
menu .search.s.searchmeth.m -font lfont -tearoff 0
# Wheel mouse bindings for easy scrolling through search methods:
proc next_searchmeth {nextprior} {
global param searchmeth searchmpos gparam s query
foreach i $searchmpos {
if {$nextprior == 1} { # next
if {$param(cursearchmeth) < [expr [llength $searchmpos] - 1]} {
incr param(cursearchmeth)
} else {
set param(cursearchmeth) 0
}
} else { # prior
if {$param(cursearchmeth) > 0} {
set param(cursearchmeth) [expr $param(cursearchmeth) - 1]
} else {
set param(cursearchmeth) [expr [llength $searchmpos] - 1]
}
}
if $searchmeth($param(cursearchmeth),avail) {
.search.s.searchmeth config -text $searchmeth($param(cursearchmeth),name)
.statusBar.lab config -foreground $param(fcolor) \
-text "[set s($gparam(lang))(cmd)] $searchmeth($param(cursearchmeth),grepcmd)"
.statusBar.file config -foreground $param(fcolor) \
-text $searchmeth($param(cursearchmeth),dictfile)
set_opts_errors $param(cursearchmeth)
# querydictsearch $query
after cancel dictsearchquery_onchange
after $param(autosearchDelay) dictsearchquery_onchange
break
}
}
}
if {$param(isunix) == 1} {
bind .search.s.searchmeth <Button-4> {
next_searchmeth -1
debug 8 "B4 in search.s.searchmeth: $param(cursearchmeth) [llength $searchmpos]"
}
bind .search.s.searchmeth <Button-5> {
next_searchmeth 1
debug 8 "B5 in search.s.searchmeth: $param(cursearchmeth) [llength $searchmpos]"
}
} else {
bind .search.s.searchmeth <MouseWheel> {
if {%D > 0} {
next_searchmeth 1
debug 8 "B5 in search.s.searchmeth: $param(cursearchmeth) [llength $searchmpos]"
} else {
next_searchmeth -1
debug 8 "B4 in search.s.searchmeth: $param(cursearchmeth) [llength $searchmpos]"
}
}
}
if {$tk_version > 8.3} {
button .search.s.clear -text [set s($lang)(clear)] -font lfont \
-relief flat -overrelief raised -command {set query ""}
} else {
button .search.s.clear -text [set s($lang)(clear)] -font lfont \
-relief raised -command {set query ""}
}
set balloonHelp(.search.s.clear) [set s($lang)(clearhelp)]
bindtags .search.s.clear [list balloon .search.s.clear Button all]
pack .search.s.back .search.s.forw -side left -pady 0 -padx 0
pack .search.s.label -side left
pack .search.s.label.label .search.s.label.mark -side top -pady 0 -padx 0 -fill x
pack .search.s.entry -side left -expand yes -fill x
pack .search.s.searchmeth -side left -pady 5 -padx 5
pack .search.s.button -side left -pady 5
pack .search.s.clear -side left -pady 5 -padx 5
# adjust size of history buttons
set h [expr [winfo reqheight .search.s.label.label] - 5]
if {$h > 0} {
debug 8 "new history button size: $h"
.search.s.back configure -height $h -width $h
.search.s.forw configure -height $h -width $h
}
# Umlaut buttons?
frame .search.u
button .search.u.aumlaut -text "" -font lfont -command {.search.s.entry insert insert ""}
button .search.u.oumlaut -text "" -font lfont -command {.search.s.entry insert insert ""}
button .search.u.uumlaut -text "" -font lfont -command {.search.s.entry insert insert ""}
button .search.u.bigaumlaut -text "" -font lfont -command {.search.s.entry insert insert ""}
button .search.u.bigoumlaut -text "" -font lfont -command {.search.s.entry insert insert ""}
button .search.u.biguumlaut -text "" -font lfont -command {.search.s.entry insert insert ""}
button .search.u.eszet -text "" -font lfont -command {.search.s.entry insert insert ""}
pack .search.u.aumlaut .search.u.oumlaut .search.u.uumlaut .search.u.bigaumlaut .search.u.bigoumlaut .search.u.biguumlaut .search.u.eszet -side left
if {$param(umlaut_buttons) == 1} {
pack .search.u -side top -pady 2
}
# Search parameters as multiple menus?
frame .search.opts
menubutton .search.opts.optword -textvariable wlabel -menu .search.opts.optword.menu \
-indicatoron 1 -relief raised -anchor c -direction flush -font lfont \
-width 11
set balloonHelp(.search.opts.optword) [set s($lang)(bwords)]
bindtags .search.opts.optword [list balloon .search.opts.optword Menubutton all]
menu .search.opts.optword.menu -font lfont -tearoff 0
.search.opts.optword.menu add command -label [set s($lang)(word)(0)] -font lfont -command \
{set opts(word) 0; set wlabel [set s($lang)(word)(0)]}
.search.opts.optword.menu add command -label [set s($lang)(word)(1)] -font lfont -command \
{set opts(word) 1; set wlabel [set s($lang)(word)(1)]}
set wlabel [set s($lang)(word)($opts(word))]
menubutton .search.opts.optcase -textvariable clabel -menu .search.opts.optcase.menu \
-indicatoron 1 -relief raised -anchor c -direction flush -font lfont \
-width 13
set balloonHelp(.search.opts.optcase) [set s($lang)(bcase)]
bindtags .search.opts.optcase [list balloon .search.opts.optcase Menubutton all]
menu .search.opts.optcase.menu -font lfont -tearoff 0
.search.opts.optcase.menu add command -label [set s($lang)(case)(0)] -font lfont \
-command {set opts(case) 0; set clabel [set s($lang)(case)(0)]}
.search.opts.optcase.menu add command -label [set s($lang)(case)(1)] -font lfont \
-command {set opts(case) 1; set clabel [set s($lang)(case)(1)]}
set clabel [set s($lang)(case)($opts(case))]
menubutton .search.opts.errors -textvariable elabel -menu .search.opts.errors.menu \
-indicatoron 1 -relief raised -anchor c -direction flush -font lfont \
-width 9
set balloonHelp(.search.opts.errors) [set s($lang)(berrors)]
bindtags .search.opts.errors [list balloon .search.opts.errors Menubutton all]
menu .search.opts.errors.menu -font lfont -tearoff 0
# set opts(errors) 0
if {[expr $opts(errors) == -1]} {
set elabel [set s($lang)(closestmatch)]
} else {
set elabel "$opts(errors) [expr $opts(errors) == 1 ? {[set s($lang)(error)]} : {[set s($lang)(errors)]}]"
}
for {set x 0} {$x < 5} {incr x} {
set e [expr $x == 1 ? {[set s($lang)(error)]} : {[set s($lang)(errors)]}]
.search.opts.errors.menu add command -label "$x $e" -font lfont \
-command "
set opts(errors) $x; set elabel \"$x $e\""
}
.search.opts.errors.menu add command -label [set s($lang)(closestmatch)] -font lfont \
-command {set opts(errors) -1; set elabel [set s($lang)(closestmatch)]}
menubutton .search.opts.regex -textvariable rlabel -menu .search.opts.regex.menu \
-indicatoron 1 -relief raised -anchor c -direction flush -font lfont \
-width 13
set balloonHelp(.search.opts.regex) [set s($lang)(bregex)]
bindtags .search.opts.regex [list balloon .search.opts.regex Menubutton all]
menu .search.opts.regex.menu -font lfont -tearoff 0
.search.opts.regex.menu add command -label [set s($lang)(regex)(0)] -font lfont -command \
{set opts(regex) 0; set rlabel [set s($lang)(regex)(0)]}
.search.opts.regex.menu add command -label [set s($lang)(regex)(1)] -font lfont -command \
{set opts(regex) 1; set rlabel [set s($lang)(regex)(1)]}
set rlabel [set s($lang)(regex)($opts(regex))]
pack .search.opts.optword .search.opts.optcase .search.opts.errors \
.search.opts.regex -side left -fill x -padx 2
if {$param(params_as_menu) == 1} {
pack .search.opts -side top -pady 2
}
####### Results
frame .result
if {! $mini} {
# pack .result -side top -fill both -expand yes -padx 0 -pady 0
}
text .result.text -bd 1 -state disabled -wrap none -relief groove \
-padx 2 -pady 2 -font tfont -width 76 -height 16 \
-yscrollcommand ".result.yscroll set" \
-xscrollcommand [list xscroll .result.xscroll \
[list grid .result.xscroll -in .result -row 1 -column 0 -sticky ew]]
# -yscrollcommand [list yscroll .result.yscroll
# [list grid .result.yscroll -in .result -row 0 -column 1 -sticky ns]]
scrollbar .result.yscroll -orient vertical -command { .result.text yview }
scrollbar .result.xscroll -orient horizontal -command { .result.text xview }
if {$param(isunix)} { # I like smaller scrollbars
.result.yscroll configure -width 10 -bd 1
.result.xscroll configure -width 10 -bd 1
}
grid .result.text -in .result -row 0 -column 0 -sticky news -padx 0 -pady 0 -ipadx 0 -ipady 0
grid .result.yscroll -in .result -row 0 -column 1 -sticky ns
# grid .result.xscroll -in .result -row 1 -column 0 -sticky we
# grid .result.yscroll -sticky news
# grid .result.xscroll -sticky news
grid rowconfig .result 0 -weight 1 -minsize 0
grid columnconfig .result 0 -weight 1 -minsize 0
# grid remove .result.xscroll
# grid remove .result.yscroll
# grid configure .result.text -columnspan 2
grid configure .result.text -rowspan 2
####### Status bar
frame .statusBar
label .statusBar.lab -width 46 -relief sunken -bd 1 -height 1 \
-text "[set s($lang)(cmd)] $searchmeth($param(cursearchmeth),grepcmd)" \
-font sfont -anchor w
label .statusBar.file -width 30 -relief sunken -bd 1 -height 1 \
-font sfont -anchor w -justify right \
-text $searchmeth($param(cursearchmeth),dictfile)
pack .statusBar.lab -side left -padx 1 -pady 1 -expand yes -fill x
pack .statusBar.file -side left -padx 1 -pady 1 -expand yes -fill x
# hideStatusBar $param(show_status)
update_searchmeth_menu
set_opts_errors $param(cursearchmeth)
# automatically minimize?
set param(do_automin) [expr {$param(win_prop) == 2 && $param(autominDelay) > 0}]
# Key bindings
set w .search.s.entry
set t .result.text
bind $w <Return> "dictsearch \$query"
bind $w <Shift-Return> {
after cancel dictsearchquery
display $curhistory $query 0 ""}
bind $w <Control-Up> {history back}
bind $w <Control-Down> {history forward}
bind $w <Escape> {set query ""; .search.s.entry configure -foreground $param(fcolor); Reset 0}
bind $w <Shift-Escape> {set query ""; Reset 1}
bind $w <Control-u> {set query ""; .search.s.entry configure -foreground $param(fcolor); Reset 0}
bind $w <Control-w> {%W selection clear; %W delete [tk::EntryPreviousWord %W insert] insert; .search.s.entry configure -foreground $param(fcolor); Reset 0}
bind $w <Control-BackSpace> {%W selection clear; %W delete [tk::EntryPreviousWord %W insert] insert; .search.s.entry configure -foreground $param(fcolor); Reset 0}
# for autosearch
foreach c {a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
adiaeresis odiaeresis udiaeresis ssharp
Adiaeresis Odiaeresis Udiaeresis} {
bind $w <KeyPress-$c> {
# problems mit KeyRelease an ^C/^L
# debug 8 "KeyPress-%K"
after cancel dictsearchquery;
after $param(autosearchDelay) dictsearchquery
}
}
bind $w <KeyRelease-asterisk> {
after cancel dictsearchquery;
after $param(autosearchDelay) dictsearchquery
}
# These key bindings look a bit strange: scroll result's text with key bindings
# to the entry. But the entry always has the focus...
# Settings for scrolling with a wheel mouse
# See http://www.inria.fr/koala/colas/mouse-wheel-scroll/
if {$param(isunix)} {
bind Text <Button-4> {%W yview scroll -1 units}
bind Text <Button-5> {%W yview scroll 1 units}
bind Text <Shift-Button-4> {%W yview scroll -5 units}
bind Text <Shift-Button-5> {%W yview scroll 5 units}
bind Text <Alt-Button-4> {%W yview scroll -1 pages}
bind Text <Alt-Button-5> {%W yview scroll 1 pages}
bind Text <Control-Button-4> {history back}
bind Text <Control-Button-5> {history forward}
} else {
# for windows
bind $w <MouseWheel> {$t yview scroll [expr {-(%D / 120)}] units}
bind $w <Shift-MouseWheel> {$t yview scroll [expr {-(%D /120 * 5)}] units}
bind $w <Alt-MouseWheel> {$t yview scroll [expr {-(%D / 120)}] pages}
bind $w <Control-MouseWheel> {if {%D > 0} {history back} else {history forward}}
}
bind $w <Up> {$t yview scroll -1 units}
bind $w <Down> {$t yview scroll 1 units}
bind $w <Shift-Up> {$t yview scroll -5 units}
bind $w <Shift-Down> {$t yview scroll 5 units}
bind $w <Prior> {$t yview scroll -1 pages}
bind $w <Next> {$t yview scroll 1 pages}
bind $w <Home> {$t yview moveto 0}
bind $w <End> {$t yview moveto 1.0}
bind $w <Shift-Left> {$t xview scroll -5 units}
bind $w <Shift-Right> {$t xview scroll 5 units}
bind $w <F1> helpGeneral
bind $w <Control-s> {save 0}
bind $w <Control-l> {save 1}
bind $w <Control-c> {clipboard_copy_all}
bind $w <Control-q> {
if {$param(autosave) != 0} { saveOptions }
exit
}
wm protocol . WM_DELETE_WINDOW {
if {$param(autosave) != 0} { saveOptions }
exit
}
wm protocol . WM_SAVE_YOURSELF {
if {$param(autosave) != 0} { saveOptions }
exit
}
bind $w <Control-m> sendMail
bind $w <Control-o> {notice $param(noticefile)}
bind $w <Control-n> startNew
bind $w <Control-space> {hideResult -1}
bind $w <Control-Shift-space> {
set param(show_menu) [expr $param(show_menu) == 1 ? 0 : 1]
hideMenuBar $param(show_menu) }
# change font on the fly
bind $w <Control-plus> { change_font 1}
bind $w <Control-minus> { change_font -1}
bind $w <Control-equal> { change_font 0}
bind $w <Control-0> { change_font 0}
bind Text <Double-1> {
global query tk_version
if {$tk_version < 8.4} {
set tkPriv(selectMode) word
tkTextSelectTo %W %x %y
} else {
set tk::Priv(selectMode) word
tk::TextSelectTo %W %x %y
}
catch {%W mark set insert sel.last}
catch {%W mark set anchor sel.first}
catch {set q [selection get -displayof %W]}
if {[string length $q] > 0 && [string compare $query $q]} {
set query $q
dictsearch $query
}
}
# mouse over text - highlight the line below the mouse pointer
bind dlookup <Motion> {
global param
set tkPriv(x) %x
set tkPriv(y) %y
if {$param(hilite)} {
.result.text tag remove hilite 1.0 end
if {[string compare [.result.text index "@%x, %y linestart"] "1.0"]} {
.result.text tag add hilite "@%x, %y linestart" "@%x, %y lineend"
}
}
}
bind . <<PasteSelection>> {
global query param
set tkPriv(x) %x
set tkPriv(y) %y
debug 8 " Event <<PasteSelection>>: "
if {$param(isunix)} {
catch {set q [selection get]}
} else {
catch {set q [selection get -selection CLIPBOARD]}
}
if {[info exists q] && [string length $q] > 0 && [string compare $query $q]} {
debug 8 " $q"
set query $q
dictsearch $query
}
}
# Shift + Mouse-2: search for dropped word in current results
bind . <Shift-2> {
global query param
set tkPriv(x) %x
set tkPriv(y) %y
debug 8 " Event Shift-Mouse 2: "
if {$param(isunix)} {
catch {set q [selection get]}
} else {
catch {set q [selection get -selection CLIPBOARD]}
}
if {[info exists q] && [string length $q] > 0 && [string compare $query $q]} {
debug 8 " $q"
set query $q
display $curhistory $query 0 ""
}
}
# right mouse button == popup menu
bind dlookup <3> {
debug 8 " Event <3>: .popup"
tk_popup .popup %X %Y
}
# fold/unfold all additional result entries
proc fold_result {} {
global history_fold curhistory
debug 8 " fold_result: $history_fold($curhistory)"
for {set i 1} {[info exists history_fold($curhistory)($i)]} {incr i} {
if {$history_fold($curhistory) == 1} {
set history_fold($curhistory)($i) 1
} else {
set history_fold($curhistory)($i) 0
}
catch {.result.text.fold$i invoke}
}
set history_fold($curhistory) [expr ! $history_fold($curhistory)]
}
bind Text <Control-1> fold_result
# Polling if global selection changes - for "search on text selection"
proc check_selection {} {
global query param last_selection check_selection_id opts
debug 16 "check_selection: [clock seconds]"
set param(check_selection_active) 1
if {$param(isunix)} {
catch {set q [selection get]}
} else {
catch {set q [selection get -selection CLIPBOARD]}
}
if {[info exists q] && [string length $q] > 0} {
set q_orig $q
if {$opts(regex) == 0} { # replace regex characters
regsub -all {[*|\]\[]} $q {} q
}
if {[string length $q] > 0 && \
[string compare $last_selection $q] && \
[string compare $last_selection $q_orig] && \
[string compare $query $q]} {
debug 2 "New selection: $q"
set last_selection $q
# substiture UTF-8 chars - should be done better
regsub -all {} $q {} q
regsub -all {} $q {} q
regsub -all {} $q {} q
regsub -all {} $q {} q
regsub -all {} $q {} q
regsub -all {} $q {} q
regsub -all {} $q {} q
regsub -all {} $q {} q
binary scan $q H* hex
regsub -all (..) $hex {\\x\1} hex
debug 2 "--> $hex"
set query $q
if {[llength [info procs dictsearch]]} {
catch [dictsearch $query]
# catch [dictsearch $last_selection]
}
}
}
set check_selection_id [after 500 check_selection]
debug 16 "restarting check_selection id = $check_selection_id"
}
bind . <Enter> {
global query param last_selection
debug 16 "Enter %W $param(win_prop) $param(do_automin) search_prop = $param(search_prop)"
if {[string compare %W "."] == 0} {
focus .search.s.entry
if {$param(search_prop) == 2} {
# fri: Why was that here?
# catch [check_selection]
debug 16 "cancelling check_selection [after info]"
set param(check_selection_active) 0
after cancel check_selection
}
if {$param(search_prop) == 1} {
# Search when we have Focus and a selection
if {$param(isunix)} {
catch {set q [selection get]}
} else {
catch {set q [selection get -selection CLIPBOARD]}
}
if {[info exists q] && [string length $q] > 0} {
if {$opts(regex) == 0} { # replace regex characters
regsub -all {[*|\]\[]} $q {} q
}
if {[string length $q] > 0 && \
[string compare $last_selection $q] && \
[string compare $query $q]} {
debug 8 " New selection entered: $q"
set last_selection $q
set query $q
catch {[dictsearch $last_selection]}
}
}
}
if {$param(win_prop) == 1 || $param(do_automin) == 1} {
# full window when focus in
hideResult 1
}
if {$param(do_automin) == 1 && $param(win_prop) == 2 && $param(autominDelay) > 0} {
debug 2 " cancelling automatically minimize <Enter>"
set param(do_automin) 0
after cancel {hideResult 0}
}
}
}
bind . <Leave> {
global param
debug 16 "Leave %W"
if {[string compare %W "."] == 0} {
# remove highlight from line
.result.text tag remove hilite 1.0 end
if {$param(search_prop) == 2} {
# poll selection
if {$param(check_selection_active) == 0} {
set check_selection_id [after 500 check_selection]
debug 16 "Leave .: Started check_selection, id = $check_selection_id"
}
}
}
}
bind . <FocusOut> {
global param
debug 16 "FocusOut %W"
if {[string compare %W "."] == 0} {
if {$param(win_prop) == 1} {
# mini window when focus out
hideResult 0
}
if {$param(win_prop) == 2 && $param(autominDelay) > 0 &&
$param(show_result) == 1} {
set param(do_automin) 1
debug 2 " automatically minimize after $param(autominDelay) ms (FocusOut)"
after $param(autominDelay) {hideResult 0}
}
}
}
proc catch_resize {} {
global param curhistory history_result
debug 8 "catch_resize"
# update
if { $curhistory > 0 && [string length $history_result($curhistory)] > 0} {
display $curhistory "" 2 ""
}
scan [wm geometry .] {%dx%d+} param(width) param(height)
debug 8 " catch_resize - new size: $param(width) x $param(height)"
}
# catch resize event to redisplay result text
bind dlookup <Configure> catch_resize
# bind .search.s.entry <Delete> {set query ""}
bindtags .search.s.entry [list .search.s.entry Entry all]
# set tags for result text
if {[winfo depth .] > 1} { # Color display
set cols [shadeColor $param(fcolor) $param(bcolor)]
set param(shadedcolor) [lindex $cols 0]
set param(highcolor) [lindex $cols 1]
set param(errcolor) [lindex $cols 2]
set param(hicolor) [lindex $cols 3]
.result.text configure -selectbackground $param(fcolor) -selectforeground $param(bcolor) -selectborderwidth 0
.result.text tag configure bg1 -background $param(shadedcolor)
.result.text tag configure matchfg -foreground $param(highcolor)
.result.text tag configure search -background $param(highcolor) -foreground $param(bcolor)
.result.text tag configure u -background $param(fcolor) -foreground $param(bcolor)
.result.text tag configure hilite -background $param(hicolor)
.result.text tag configure aux -font ifont
.result.text tag configure ipa -font ipafont
} else {
set param(shadedcolor) white
set param(highcolor) white
.result.text tag configure bg1 -background $param(shadedcolor) -foreground black
.result.text tag configure matchfg -background black -foreground white
.result.text tag configure search -background black -foreground white
.result.text tag configure u -underline 1
.result.text tag configure hilite -underline 1
.result.text tag configure aux -font ifont
}
if 0 {
# commented out
if {![info exists grepcmds(agrep)]} {
.result.text configure -state normal
.result.text insert end [set s($lang)(noagrep)]
.result.text insert end $gparam(grepcmd)
.result.text configure -state disabled
}
}
setSearchBg $param(shadedcolor)
if ($mini) {
wm geometry . {}
hideResult 0
set balloonHelp(.search.l.logo) [set s($lang)(normalsize)]
.popup entryconfigure 7 -label [set s($lang)(normalsize)]
update
if [info exists param(width)] {
set w $param(width)
} else {
set w [winfo width .search]
}
debug 8 " setting geometry: ${w}x[winfo height .search]"
wm geometry . "${w}x[winfo height .search]"
# wm geometry . {}
} else {
wm geometry . {}
update
hideResult 1
}
# automatically minimize?
if {$param(win_prop) == 2 && $param(autominDelay) > 0} {
debug 2 " automatically minimize after $param(autominDelay) ms (start)"
set param(do_automin) 1
after $param(autominDelay) {hideResult 0}
}
# Check selection?
if {$param(search_prop) == 2} {
# get current selection
if {$param(isunix)} {
catch {set q [selection get]}
} else {
catch {set q [selection get -selection CLIPBOARD]}
}
if {[info exists q] && [string length $q] > 0} {
set last_selection $q
}
# poll for new selection
if {$param(check_selection_active) == 0} {
after 500 check_selection
}
}
update
set geo [wm geometry .]
scan $geo {%dx%d+%d+%d} w h x y
debug 8 "toplevel geometry: $geo, winfo: [winfo width .] [winfo height .] [winfo x .] [winfo y .], correcting height: $param(add_geom_height)"
if {! $mini} {
set param(width) $w
set param(height) $h
}
if {[string length $query] == 0 && ! $mini} {
# welcome message if not started with search query and not mini size
welcome 1
}
bindtags .result.text {Text . all dlookup}
# Always the focus to the search entry:
focus .search.s.entry
# }
# mainWindow {}
#####################################
# Handling of external processes
proc ExecCmd {cmd stderr_to_stdout} {
global proc lines param
debug 1 "ExecCmd $cmd $stderr_to_stdout"
if {$proc(pid) > 0} {
.statusBar.lab config -foreground $param(errcolor) -text \
"Search process is still running. Wait or hit Escape."
return 1
}
if {$stderr_to_stdout == 1 && $param(iswin) == 0} {
set cmd [concat $cmd {2>@stdout}]
}
set lines {}
if [catch {set proc(pipe) [open "|$cmd" r+]} err] {
if [string match "child process exited abnormally" $err] {
.statusBar.lab config -foreground $param(errcolor) -text "[set s($lang)(noresults)] $query"
} else {
.statusBar.lab config -foreground $param(errcolor) -text $err
}
return 1
}
debug 4 "Pipe: $proc(pipe)"
set proc(pid) [pid $proc(pipe)]
set proc(processlist) [list $proc(pid) $cmd]
# fconfigure $proc(pipe) -buffering none -blocking 0
fileevent $proc(pipe) readable "CmdOut"
return 0
}
proc CmdOut {} {
global proc sigchld lines param searchmeth
debug 2 "CmdOut"
set r1 [catch {eof $proc(pipe)} res]
if {$r1 || $res} {
debug 4 " CmdOut: End of $proc(pipe): $proc(processlist)"
catch {close $proc(pipe)} err
debug 4 " CmdOut: Close pipe: $err"
set sigchld 1
# mark as finished
set proc(processlist) {}
set proc(pid) -1
return
}
# else read from the pipe
set line [read $proc(pipe)]
if {[llength $lines] > 10 * $searchmeth($param(cursearchmeth),maxresults)} {
# Reset
return
}
# if {$line != ""}i
foreach l [split $line "\n"] {
lappend lines $l
debug 4 " CmdOut: read [llength $lines] .$l."
if {[llength $lines] > 10 * $searchmeth($param(cursearchmeth),maxresults)} {
debug 4 " CmdOut: more than $searchmeth($param(cursearchmeth),maxresults) read, stopping"
Reset 0
break
}
}
}
# handle queries with umlauts - make queries to find also other spellings
proc umlautquery {query style} {
debug 8 "umlautquery $query"
if {[string length $query] < 1} {return ""}
set q $query
lappend Q $q
if {[regsub -all {ae} $q {} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {[regsub -all {oe} $q {} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {[regsub -all {ue} $q {} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {[regsub -all {A[Ee]} $q {} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {[regsub -all {O[Ee]} $q {} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {[regsub -all {U[Ee]} $q {} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {[regsub -all {ss} $q {} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {[regsub -all {} $q {ss} q] > 0 && [lsearch $Q $q] == -1} {lappend Q $q}
if {$style == "agrep"} {
set ret [join $Q {,}]
# new agrep ...
# set ret [join $Q {|}]
} else {
set ret [join $Q {|}]
if {[llength $Q] > 1} {set ret "($ret)"}
}
debug 8 " -> $ret"
return $ret
}
# Thanks to Holger Trapp <hot@hrz.tu-chemnitz.de>
# enforce loading the Tcl procedures "tcl_wordBreakBefore" and
# "tcl_wordBreakAfter" by calling them with senseless args.
# Now the global strings "tcl_nonwordchars" and "tcl_wordchars" are initialized
# and we can modify them as needed to specify the chars belonging or not
# belonging to words respectively
### No need on Unix for this:
# if {$param(iswin) == 1} {
tcl_wordBreakBefore "" 0
tcl_wordBreakAfter "" 0
# set tcl_wordchars {[a-zA-Z0-9_]}
# set tcl_nonwordchars {[^a-zA-Z0-9_]}
set tcl_wordchars "\\w"
set tcl_nonwordchars "\\W"
# }
### internal search - search in dict file without an external grep
# Thanks to Jens Poenisch <jens@ruessel.in-chemnitz.de>
array set internal_search_Dict {}
array set internal_search_init {}
proc internal_search {query dictfile max} {
global internal_search_init internal_search_Dict internal_search_dict
global param proc opts tcl_nonwordchars
debug 4 "internal_search $query $dictfile $max"
if {! [info exists internal_search_init($dictfile)]} {
set nr [array size internal_search_init]
incr nr
debug 4 "Initialising $dictfile ($nr) ..."
set s0 [clock seconds]
.statusBar.lab config -foreground $param(fcolor) \
-text "Initializing $dictfile ..."
update idletasks
set fd [open $dictfile r]
fconfigure $fd -buffersize 1024000
set Text [read $fd]
close $fd
# exact case
set internal_search_Dict($nr) [split $Text \n]
# lower case
set text [string tolower $Text]
set internal_search_dict($nr) [split $text \n]
set internal_search_init($dictfile) $nr
.statusBar.lab config -foreground $param(fcolor) \
-text "[expr [clock seconds] - $s0] sec"
debug 4 "done: [expr [clock seconds] - $s0] sec"
}
set f 0
set num 0
set result {}
set proc(pid) 0
set search {-regexp}
if {$opts(regex) == 0} { # simple query
regsub -all {\*} $query {.*} query
}
if {$opts(case) == 0} {
set query [string tolower $query]
}
if {$opts(word) == 0} {
set searchquery "(^|.*${tcl_nonwordchars})${query}(${tcl_nonwordchars}.*|$)"
} else {
set searchquery "${query}"
}
# case exact ?
set in $internal_search_init($dictfile)
if {$opts(case)} {
set d $internal_search_Dict($in)
} else {
set d $internal_search_dict($in)
}
debug 8 "searchquery = $searchquery in $in"
while {$proc(pid) == 0 && $num <= $max && \
[set i [lsearch -regexp [lrange $d $f end] $searchquery]] >= 0} {
update
lappend result [lindex $internal_search_Dict($in) [expr $f+$i]]
debug 4 "$num: [lindex $internal_search_Dict($in) [expr $f+$i]]"
set f [expr $f+$i+1]
incr num
}
debug 4 "internal_search ended - $num results"
return $result
}
proc querydictsearch {q} {
global query
debug 1 "querydictsearch $q"
if {[string length $q] > 0} {
set query $q
return [dictsearch $query]
}
return 0
}
proc dictsearch {query args} {
global param gparam searchmeth result opts
global curhistory inshistory
global history_result history_query history_searchm history_pos history_fold
global s logoanim defaultcursor lines sigchld
debug 1 "dictsearch $query"
set lang $gparam(lang)
# cancel autosearch
after cancel dictsearchquery
# disable auto minimize
if {$param(do_automin) == 1 && $param(win_prop) == 2 && $param(autominDelay) > 0} {
debug 2 " cancelling automatically minimize (dictsearch)"
# set param(do_automin) 0
after cancel {hideResult 0}
}
# starts with / -> internal search
if {[regexp {^/} $query]} {
regsub {^/} $query {} iquery
debug 2 " query starts with / -> internal search"
# .search.s.entry delete 0 end
# .search.s.entry insert 0 $query
# set history_pos($curhistory) [lindex [.result.text yview] 0]
set history_pos($curhistory) [.result.text index @0,0]
display $curhistory $iquery 0 ""
return 2
}
# search method specified
if [llength $args] {
set c [lindex $args 0]
if [info exists searchmeth($c,name)] {
set param(cursearchmeth) $c
.search.s.searchmeth configure -text $searchmeth($c,name)
set_opts_errors $c
}
}
set curr $param(cursearchmeth)
debug 1 " using search method $curr ($searchmeth($curr,name))"
if {[string length $searchmeth($curr,dictfiles)] <= 0} {
.statusBar.lab config -foreground $param(errcolor) -text [set s($lang)(nodictfile)]
return 2
}
# clean up query
# remove spaces and so at the beginning and the end
set orig_query $query
regsub -all "^\[ ,;:+'\n\t\]*" $query {} query
regsub -all "\[ ,:-;'\n\t\]*$" $query {} query
# remove duplicate spaces
regsub -all { *} $query { } query
# remove newline, tab, \
regsub -all "\[\n\r\t\]$" $query {} query
regsub -all "\[\n\r\t\]" $query { } query
regsub -all {\\$} $query {} query
if {$opts(regex) == 0} {
regsub -all {\.$} $query {} query
regsub -all {~} $query {} query
}
if {[string match "ispell" $searchmeth($curr,grepcmd)]} {
set squery $query
regsub -all {} $squery {a"} squery
regsub -all {} $squery {A"} squery
regsub -all {} $squery {o"} squery
regsub -all {} $squery {O"} squery
regsub -all {} $squery {u"} squery
regsub -all {} $squery {U"} squery
regsub -all {} $squery {s"} squery
} else {
regsub -all {"a} $query {} query
regsub -all {"A} $query {} query
regsub -all {"o} $query {} query
regsub -all {"O} $query {} query
regsub -all {"u} $query {} query
regsub -all {"U} $query {} query
regsub -all {"s} $query {} query
regsub -all {"} $query "" query
set squery $query
}
if {[string compare $orig_query $query]} {
# if query changed, display it
.search.s.entry delete 0 end
.search.s.entry insert 0 $query
}
if {[string length $squery] < $searchmeth($curr,minlength)} {
if {$param(autosearch_active) == 0} {
.statusBar.lab config -foreground $param(errcolor) \
-text [set s($lang)(tooshort)]
}
return 2
}
if {[string length $squery] > $searchmeth($curr,maxlength)} {
if {$param(autosearch_active) == 0} {
.statusBar.lab config -foreground $param(errcolor) -text \
"[set s($lang)(toolong)] ([string length $squery], max. $searchmeth($curr,maxlength))"
}
return 2
}
# escape shell meta chars -> \
regsub -all {([]\[\{\} `&$])} $squery {\\\1} squery
regsub -all {([<>|])} $squery {\\\\\1} squery
# evaluate options
set isgrep 0
set isspell 0
set isdict 0
set opt $searchmeth($curr,grepopts)
set internal 0
set q $query
set cmd {}
set stderr_to_stdout 1
if [string match "internal_*" $searchmeth($curr,grepcmd)] {
# internal search
set cmd [concat $searchmeth($curr,grepcmd) \"$query\" $searchmeth($curr,dictfiles) $searchmeth($curr,maxresults)]
set internal 1
# for sorting
set isgrep 1
} elseif {[string match "*grep" $searchmeth($curr,grepcmd)]} {
# grep family
set isgrep 1
if {$opts(word) == 0 && ![regexp {[.| ]} $squery]} {
# words only search - makes no sense if search string contains
# white space
set opt "$opt -w"
}
if {$opts(case) == 0} {
set opt "$opt -i"
}
if ($opts(errors)) {
if {$opts(errors) == -1} {
set opt "$opt -B -y"
} else {
set opt "$opt -$opts(errors)"
}
}
if {$opts(regex) == 0} {
if [string match "*agrep*" $searchmeth($curr,grepcmd)] {
# prepare simple pattern for agrep
regsub -all {\*} $squery "#" squery
# delete lonesome + at the end
regsub -all {\+$} $query "" query
regsub -all {\+$} $squery "" squery
# AND: + -> ;
regsub -all { *\+ *} $squery ";" squery
# Umlaut
set squery [umlautquery $squery "agrep"]
} else {
# prepare simple pattern for other grep cmd: * -> .*
regsub -all {\*} $squery ".*" squery
set squery [umlautquery $squery "egrep"]
}
# q is for priority sorting
regsub -all {[[\*+)(]} $query "" q
}
debug 8 " query = $query, squery = $squery"
set opt "$opt -e"
set cmd [concat "$searchmeth($curr,grepcmd) $opt \"$squery\" $searchmeth($curr,dictfiles)"]
} elseif {[string match "*spell" $searchmeth($curr,grepcmd)]} {
# spell family
set isspell 1
set cmd [concat "echo $squery | $searchmeth($curr,grepcmd) $opt"]
} elseif {[string match "*fortune" $searchmeth($curr,grepcmd)]} {
# fortune
set stderr_to_stdout 0
if {[string length $squery] > 0} {
# fortune with pattern
if {$opts(case) == 0} {
set opt "$opt -i"
}
if {$opts(word) == 0} {
# words only search - add a space after word...
set squery "$squery\[ !?.,\]"
}
set opt "$opt -m \"$squery\""
}
set cmd [concat "$searchmeth($curr,grepcmd) $opt"]
} else {
# this is for dict:
set isdict 1
set strategy {}
if {$opts(regex) == 1} {
set strategy "-s re"
} elseif {$opts(word) == 1 || [regexp { } $squery]} {
regsub -all {\*} $squery "" squery
set strategy "-s substring"
} elseif {[regsub -all {\*$} $squery "" squery]} {
set strategy "-s prefix"
}
# what to do with these?
# setting more than one search strategy is useless
if {$opts(errors) >= 1} {
set opt "$opt -s lev"
} elseif {$opts(errors) == -1} {
set opt "$opt -s soundex"
}
if {$strategy != ""} {
set opt "$opt $strategy"
}
set cmd [concat "$searchmeth($curr,grepcmd) $opt -- \"$squery\""]
}
set starttime [clock clicks -milliseconds]
.statusBar.lab config -foreground $param(fcolor) -text "$cmd"
. configure -cursor watch
.result.text configure -cursor watch
.search.s.entry configure -cursor watch
update
# Suche!
set res ""
set logoanim 1
animlogo .search.l.logo
debug 1 "dictsearch: Starting $cmd"
if ($internal) {
set lines [eval $cmd]
} else {
set sigchld 0
if {[ExecCmd $cmd $stderr_to_stdout] == 0} {
tkwait variable sigchld
} else {
# wait a bit - allow to see the error message
update idletasks
after 2000
}
}
# ok, read results
update idletasks
set resl {}
set c 0
foreach line $lines {
# foreach line [split $lines "\n"]
update idletasks
incr c
debug 2 "dictsearch: result $c: $line."
if {!$isspell && [regexp "^#" $line]} { # skip comments
continue
}
if {$isdict && [regexp "^No (definitions|matches) found for " $line]} {
continue
}
set p 0
# sorting of *grep
if {$isgrep} {
if {$line == ""} {continue}
if [string match "Grand Total*" $line] {
# get rid of Windows agrep's last line ...
continue
}
# find good matches (word at beginning, exact order etc.)
# remove alls (..) [..] {..}
regsub -all { \{[^.\}]*\}} $line "" pline
regsub -all { \([^.\)]*\)} $pline "" pline
regsub -all { \[[^\]]*\]} $pline "" pline
# debug 8 "$line\n$pline"
if {[regexp {[ +]} $query]} { # search words with spaces
set p [regexp -nocase -- $q $pline]
} else {
set ml [regexp -all {\|} $line]
if {$ml > 0} { # multiline result
set p 0
# Anfang + 100
if {[regexp -nocase ":: (to )?${q}(;.*| )\\|" $pline] ||
[regexp -nocase "^${q}(;| ).*\\|.* ::" $pline] } {
set p [expr $p + 100 + $ml]
# 1. Zeile
} elseif {[regexp -nocase ":: \[^|\]*${q}.*\\|" $pline] ||
[regexp -nocase "^\[^|\]*${q}.*\\|.* ::" $pline] } {
set p $ml
}
} else {
set p 2
# set p [expr [string length $pline] - [string first $q $pline]]
# Anfang + 100
if {[regexp -nocase ":: (to )?${q}(;|$)" $pline] ||
[regexp -nocase "^${q}(;| ::)" $pline]} {
set p [expr $p + 100]
} elseif {[regexp -nocase "; ${q}(;|$)" $pline]} {
# Einzelwort
set p [expr $p + 80]
}
# Abkrzung + 10
if {[regexp { : } $pline]} {set p [expr $p + 10]}
}
}
debug 8 "dictsearch: prio $p: $line"
}
lappend resl [list $p $line]
}
debug 8 "dictsearch: prio sorting ..."
set res {}
set first 1
foreach l [lsort -decreasing -integer -index 0 $resl] {
if {$first == 1} {set first 0} else {set res "$res\n"}
set res "$res[lindex $l 1]"
}
debug 8 "dictsearch: prio sorting done"
if [string length $res] {
# results found
.search.s.entry configure -foreground $param(fcolor)
if {$inshistory >= $param(maxhistory)} {
set inshistory 1
} else {
incr inshistory
}
.search.s.forw configure -state disabled
.popup entryconfigure 1 -state disabled
if {$curhistory != 0} {
.search.s.back configure -state normal
.popup entryconfigure 0 -state normal
# mark the current scroll position
#set history_pos($curhistory) [lindex [.result.text yview] 0]
set history_pos($curhistory) [.result.text index @0,0]
}
set curhistory $inshistory
set history_query($inshistory) $query
set history_searchm($inshistory) $curr
set history_result($inshistory) $res
set history_pos($inshistory) 0.0
set history_fold($inshistory) $searchmeth($curr,foldedresult)
set endtime [clock clicks -milliseconds]
display $inshistory "" 1 " [expr {$endtime - $starttime}] msec"
set ret 0
} else {
# no results found
# .search.s.entry delete 0 end
# .search.s.entry insert 0 $query
# .search.s.entry selection range 0 [string length $query]
.statusBar.lab config -foreground $param(errcolor) -text \
"[set s($lang)(noresults)] $query"
.search.s.entry configure -foreground $param(errcolor)
.result.text configure -state disabled
set ret 1
}
catch {close $in}
after 400 {
after cancel animlogo .search.l.logo
.search.l.logo configure -image "logo1"
}
. configure -cursor $defaultcursor
.result.text configure -cursor $defaultcursor
.search.s.entry configure -cursor $defaultcursor
return $ret
}
proc dictsearchquery {} {
global query param
debug 2 "dictsearchquery $query"
if {$param(autosearch) == 0} return
set param(autosearch_active) 1
# set r [dictsearch $query]
if {[dictsearch $query] == 1} {
# no result -> try appending *
debug 2 "dictsearchquery $query*"
dictsearch "$query*"
}
}
proc dictsearchquery_onchange {} {
global query param curhistory history_query history_searchm
debug 2 "dictsearchquery_onchange $query - $curhistory"
if {$param(autosearch) == 0} return
if {[string length $query] == 0} return
if {[info exists history_query($curhistory)] &&
$history_query($curhistory) == $query && $history_searchm($curhistory) == $param(cursearchmeth)} {
debug 2 "query and search method identical - returning"
return
}
set param(autosearch_onchage_active) 1
# set r [dictsearch $query]
if {[dictsearch $query] == 1} {
# no result -> try appending *
debug 2 "dictsearchquery_onchange $query*"
dictsearch "$query*"
}
}
# display: shows search results:
# num - show result for number in history
# search - highlight this string in result
# status - update status line, remove scrollbars?
# 1 = from new search, 2 = from history
# extra - some extra status info
proc display {num search status extra} {
global searchmeth maxresults param gparam s
global history_query history_searchm history_result history_pos history_fold
debug 1 "display num = $num search = $search status = $status extra = $extra"
# make result visible
hideResult 1
wm deiconify .
if ![info exists history_query($num)] {
return
}
if ![info exists history_pos($num)] {
set history_pos($num) 0.0
}
set history_spos $history_pos($num);
debug 4 "history_spos = $history_spos"
set lang $gparam(lang)
set count 0
set foldcount 0
set more ""
set shape 0
if {[string length $search] == 0 && $status != 1} {
.search.s.entry delete 0 end
.search.s.entry insert 0 $history_query($num)
}
# selection to the query in search entry when no other selection active
if {$param(isunix)} {
catch {set q [selection get]}
} else {
catch {set q [selection get -selection CLIPBOARD]}
}
if {$param(autosearch_active) == 0 &&
(![info exists q] ||
([string length $q] > 0 &&
[string compare $q $history_query($num)] == 0))} {
debug 2 "query selection exported: $history_query($num)"
# debug 2 "query selection exported: $q - $history_query($num)"
.search.s.entry configure -exportselection 1
.search.s.entry selection range 0 end
} else {
debug 2 "query selection NOT exported: $history_query($num)"
.search.s.entry configure -exportselection 0
.search.s.entry selection range 0 end
}
# search pattern for marking
regsub -all {[,+]} $history_query($num) "|" mquery
regsub -all {[[*+?)(|$]} $mquery "" mquery
regsub -all {^-} $mquery "" mquery
regsub -all { } $mquery " " mquery
debug 8 " query = $history_query($num), mquery = $mquery"
set t .result.text
$t configure -state normal
$t delete 0.0 end
# remove scrollbars
if {$status > 0} {
grid forget .result.xscroll
# grid forget .result.yscroll
# grid configure .result.text -columnspan 2
grid configure .result.text -rowspan 2
}
# compute tab stop in the middle
# set width [$t cget -width]
set width [winfo width $t]
set w [expr round(($width / 2) - 2)]
$t configure -tabs $w
if {[string compare $searchmeth($history_searchm($num),language1) ""] || \
[string compare $searchmeth($history_searchm($num),language2) ""]} {
$t insert end \
"$searchmeth($history_searchm($num),language1)\t $searchmeth($history_searchm($num),language2)\n" u
}
set isdict [expr [string compare $searchmeth($history_searchm($num),grepcmd) "dict"] ? 0 : 1]
set isfortune [string match "*fortune" $searchmeth($history_searchm($num),grepcmd)]
set isspell [string match "*spell" $searchmeth($history_searchm($num),grepcmd)]
if {$isspell} { ; # an empty line ...
$t insert end "\n"
}
set spell_version {}
set ftext 0
set ffirst 1
set xscroll 0
# for each line
foreach l [split $history_result($num) "\n"] {
if {!$isspell && [regexp "^#" $l]} { # skip comments
continue
}
if {$count >= $searchmeth($history_searchm($num),maxresults)} {
set more [set s($lang)(more)]
break
}
if {$isdict == 1} {
# dict - Find a "NUM definition found" l
if {[regexp {^([0-9]+) definitions? found} $l b c]} {
set count $c
continue
}
} elseif {$isfortune == 1} {
# fortune
if {! $ftext && [regexp {^$} $l]} {
continue
}
if {[regexp {^\(.*\)$} $l]} {
set ftext 0
continue
}
if {[regexp "^%$" $l]} {
set l ""
if {$searchmeth($history_searchm($num),shapedresult)} {
set shape [expr ! $shape]
}
if $ftext {
incr count
$t insert end "\n"
}
continue
} else {
# fortune text
# substitute tabs
if $ffirst {
incr count
set ffirst 0
$t insert end "\n"
}
set ftext 1
regsub "\t" $l " " l
}
} elseif {$isspell == 1} {
# ispell -a results:
# fist line: @(#) Version
# * ok
# + <root word>
# - <concatenation>,
# & <original> <count> <offset>: <miss>, <miss>, ..., <guess>, ...
# ? <original> 0 <offset>: <guess>, <guess>, ...
# # <original> <offset>
if {[regexp {^@\(#\) (.+)} $l b spell_version]} {
continue
} elseif {[regexp {^$} $l]} {
continue
} elseif {[regexp {^\*} $l]} {
set l [set s($lang)(correct)]
} elseif {[regexp {^\+} $l]} {
regsub {^\+} $l "[set s($lang)(root)]:" l
} elseif {[regexp {^\#} $l]} {
set l [set s($lang)(nosuggestion)]
} else {
regsub {.+: } $l "[set s($lang)(suggestion)]: \n" l
# wrap results
regsub -all {(.{40}[^,]*), } $l "\\1\n" l
regsub -all {\n} $l "\n " l
# regsub -all {, } $l "\t\n" l
}
regsub -all {a"} $l {} l
regsub -all {A"} $l {} l
regsub -all {o"} $l {} l
regsub -all {O"} $l {} l
regsub -all {u"} $l {} l
regsub -all {U"} $l {} l
regsub -all {s"} $l {} l
incr count
} else {
# not dict: 1 line == 1 match
incr count
# ignore <...> - old/wrong spelling
regsub -all {<[^>]*>} $l {} l
}
if {$searchmeth($history_searchm($num),shapedresult)} {
if {$isdict == 1} {
if {[regexp "^From " $l]} {
set shape 1
} else {
set shape 0
}
} elseif {! $isfortune} {
if {[expr $count % 2]} {
set shape 1
} else {
set shape 0
}
}
}
set bgtag [expr {$shape == 1 ? {bg1 } : {}}]
if {[string compare $searchmeth($history_searchm($num),separator) ""] && \
[regexp "$searchmeth($history_searchm($num),separator)" $l]} {
regsub "$searchmeth($history_searchm($num),separator).*" $l "" lang1
regsub ".*$searchmeth($history_searchm($num),separator)" $l "" lang2
if {[regexp {\|} "$lang1"]} {
# contains additional entries: separate on different lines
set l1 [split $lang1 |]
set l2 [split $lang2 |]
incr foldcount
set tag "vis$foldcount"
if {! [info exists history_fold($num)($foldcount)]} {
set history_fold($num)($foldcount) $history_fold($num)
}
$t tag configure $tag -elide [set history_fold($num)($foldcount)]
for {set i 0} {$i < [llength $l1]} {incr i} {
if {$i == 0} { # first = main entry
$t insert end "[lindex $l1 $i]\t" $bgtag
set cmd "$t tag configure $tag -elide \[expr \[set history_fold($num)($foldcount)\]\]"
checkbutton $t.fold$foldcount -image minus -selectimage plus \
-variable history_fold($num)($foldcount) -indicatoron 0 \
-bd 0 -width 8 -height 8 -command $cmd
$t window create end -window $t.fold$foldcount
$t insert end " [lindex $l2 $i]\n" $bgtag
# search word within main entry?
if {[string length $mquery] > 0 &&
([regexp -nocase "$mquery" [lindex $l1 $i]] ||
[regexp -nocase "$mquery" [lindex $l2 $i]])} {
set foundfirst 1
debug 8 "found $mquery first"
} else {
set foundfirst 0
debug 8 "NOT found $mquery first"
}
} elseif {(! $foundfirst) && [string length $mquery] > 0 &&
([regexp -nocase "$mquery" [lindex $l1 $i]] ||
[regexp -nocase "$mquery" [lindex $l2 $i]])} {
# search word in additional line
$t insert end "[lindex $l1 $i]\t [lindex $l2 $i]\n" $bgtag
} else { # additional entry
$t insert end "[lindex $l1 $i]\t [lindex $l2 $i]\n" "$bgtag $tag"
}
}
} else {
$t insert end "$lang1\t $lang2\n" $bgtag
}
} else {
$t insert end "$l\n" $bgtag
}
}
# selection colors wins over other tags colors
$t tag raise sel
if {$status > 0} {
set erg [expr $count == 1 ? {[set s($lang)(result)]} : {[set s($lang)(results)]}]
if {$isdict == 1 && $count == 0} {
set count "??"
}
.statusBar.lab config -foreground $param(fcolor) -text "$count $erg $more $extra"
if {$isspell == 1} {
.statusBar.file config -foreground $param(fcolor) -text $spell_version
}
}
# find and mark match pattern
if {[string length $mquery] > 0} {
debug 4 " find and mark match pattern: >$mquery<"
set cur 1.0
while 1 {
set cur [.result.text search -nocase -count length -regexp -- $mquery $cur end]
if {$cur == ""} {
break
}
.result.text tag add matchfg $cur "$cur + $length char"
set cur [.result.text index "$cur + $length char"]
}
}
# search pattern ?
if {[string length $search] > 0} {
debug 4 " find and mark search pattern: >$search<"
# remove special chars
regsub -all {\*} $search {} search
if {[string length $search] <= 0} {
return
}
if {$status > 0 || ![info exists history_spos] || $history_spos == 0} {
set history_spos 1.0
}
set found 0
set first {}
# mark search words
# start looking at current position
set now [expr $history_spos + 1.0]
set cur 1.0
while 1 {
set cur [.result.text search -nocase -count length -exact -- $search $cur end]
if {$cur == {}} {
break
}
if {$first == {}} {
set first $cur
}
.result.text tag add search $cur "$cur + $length char"
set new [.result.text index "$cur + $length char"]
if {$found == 0} {
if {$status == 0 && $history_spos != 1.0} {
if [.result.text compare $cur > $now] {
set history_spos $new
set found 1
}
} else {
set history_spos $new
set found 1
}
}
set cur $new
}
.statusBar.lab configure -foreground $param(fcolor) -text ""
if {$found == 0} {
# no next search results
if {$first != {}} {
# jump to the first
set history_spos $first
} else {
# no search result
.statusBar.lab configure -foreground $param(errcolor) \
-text "[set s($lang)(notfound)]"
}
}
set history_pos($num) $history_spos
}
if {$isdict == 1} {
# mark word in dict results - synonyms, antonyms etc.
set cur 1.0
set pattern {\{[^\}]*\}}
while 1 {
set cur [.result.text search -nocase -count length -regexp -- $pattern $cur end]
if {$cur == ""} {
break
}
set length [expr $length - 2]
.result.text delete $cur
.result.text delete "$cur + $length char"
.result.text tag add matchfg $cur "$cur + $length char"
set cur [.result.text index "$cur + $length char"]
}
} else {
debug 4 " find aux"
set cur 1.0
while 1 {
set cur [.result.text search -nocase -count length -regexp -- {(\[[^]]*\]|\{[^\}]*\})} $cur end]
if {$cur == ""} {
break
}
.result.text tag add aux $cur "$cur + $length char"
set cur [.result.text index "$cur + $length char"]
}
}
if {$history_pos($num)} {
#scroll
debug 4 "Move to position $history_pos($num)"
.result.text yview $history_pos($num)
}
.result.text configure -state disabled
focus .search.s.entry
# raise is slowly with KDE/Gnome :-/
if {$param(raise) == 1} {
debug 2 "raise top win"
raise .
}
# automatically minimize?
if {$param(do_automin) == 1 && $param(win_prop) == 2 && $param(autominDelay) > 0} {
debug 2 " automatically minimize after $param(autominDelay) ms (display)"
after $param(autominDelay) {hideResult 0}
}
set param(autosearch_active) 0
set param(autosearch_onchage_active) 0
debug 1 "display return"
}
#### main
# if query is set via command line - search it:
if {[string length $query] > 0} {
dictsearch $query
}
proc save {what} {
global inshistory history_result param gparam s
debug 2 "save $what"
set lang $gparam(lang)
if { $inshistory <= 0 || [string length $history_result($inshistory)] <= 0} {
tk_messageBox -icon info -type ok -parent . -message \
[set s($lang)(nosave)]
return
}
set f [tk_getSaveFile]
if {$f == ""} {
return
}
set err [catch "set fd \[open $f w\]"]
if $err {
tk_messageBox -icon error -type ok -parent . -message \
"Couldn't open $f for writing!"
return
}
if {$what == 0} { # current result
puts $fd $history_result($inshistory)
} else { # all results in history
for {set h [expr $inshistory + 1]} {$h <= [array size history_result]} {incr h} {
puts $fd "$history_result($h)"
}
for {set h 1} {$h <= $inshistory} {incr h} {
puts $fd "$history_result($h)"
}
}
catch {close $fd}
}
proc interface_reset {toggle_result} {
global defaultcursor
debug 2 "interface_reset"
after cancel animlogo .search.l.logo
.search.l.logo configure -image "logo1"
. configure -cursor $defaultcursor
.result.text configure -cursor $defaultcursor
.search.s.entry configure -cursor $defaultcursor
if {$toggle_result == 1} {
hideResult -1
}
}
proc clipboard_copy_all {} {
global last_selection param
debug 2 "clipboard_copy_all"
.result.text tag remove sel 1.0 end
.result.text tag add sel 1.0 end
if {$param(isunix)} {
catch {set last_selection [selection get]}
} else {
catch {set last_selection [selection get -selection CLIPBOARD]}
}
catch {clipboard clear}
catch {clipboard append $last_selection}
}
# places a window on the desktop
proc placeWin {win diff} {
debug 8 "placeWin $win $diff"
scan [wm geometry .] "%dx%d+%d+%d" w h x y
set x [expr $x + $diff]
set y [expr $y + $diff]
debug 8 " -> +$x+$y"
wm geometry $win +$x+$y
}
proc aboutBox {} {
global param gparam pinfo s defaultcursor
debug 2 "aboutBox"
set lang $gparam(lang)
# just in case ...
interface_reset 0
if ![winfo exists .about] {
toplevel .about
wm group .about .
wm title .about "$pinfo(pname) - [set s($lang)(about)]"
wm resizable .about 0 0
placeWin .about 50
text .about.text -font lfont -wrap word -width 60 -height 26 \
-relief groove -padx 8 -pady 8
button .about.ok -text "Ok" -width 8 -command {
after cancel animlogo .about.text.logo
destroy .about
}
pack .about.text -side top -expand 1 -fill x -fill y -ipady 10 -ipadx 10
pack .about.ok -side bottom -pady 8
label .about.text.logo -image logo1 -bd 1
animlogo .about.text.logo
after 1500 {
catch {after cancel animlogo .about.text.logo}
catch {.about.text.logo configure -image "logo1"}
}
.about.text tag configure center -justify center
.about.text tag configure bfont -font bfont -justify center
.about.text tag configure homepage -foreground $param(highcolor) -underline 1 \
-font bfont
.about.text tag bind homepage <ButtonRelease-1> { urlOpen $pinfo(homepage) }
.about.text tag bind homepage <Enter> { .about.text config -cursor hand2}
.about.text tag bind homepage <Leave> { .about.text config -cursor xterm}
.about.text insert end " " center
# .about.text image create end -image logo1 -pady 10 -align center
.about.text window create end -window .about.text.logo -pady 10 -align center
.about.text insert end " \n$pinfo(pname)\nVersion $pinfo(version)\n\n" bfont
.about.text insert end "$pinfo(copyright)\n\nOnline: " center
.about.text insert end "$pinfo(homepage)" homepage
if {$gparam(lang) == "de"} {
.about.text insert end "\nKommentare sind sehr willkommen!\n" center
.about.text insert end "
Dieses Programm ist freie Software. Sie knnen es unter \
den Bedingungen der GNU General Public License, wie von der \
Free Software Foundation verffentlicht, weitergeben und/oder \
modifizieren, entweder gem Version 2 der Lizenz oder (nach \
Ihrer Option) jeder spteren Version.
Die Verffentlichung dieses Programms erfolgt in der \
Hoffnung, dass es Ihnen von Nutzen sein wird, aber OHNE \
IRGENDEINE GARANTIE, sogar ohne die implizite Garantie \
der MARKTREIFE oder der VERWENDBARKEIT FR EINEN BESTIMMTEN ZWECK. \
Details finden Sie in der GNU General Public License.
Sie sollten ein Exemplar der GNU General Public License zusammen \
mit diesem Programm erhalten haben. Falls nicht, siehe \
<http://www.gnu.org/licenses/>.
"
} else {
.about.text insert end "\nComments are welcome!\n" center
.about.text insert end "
This program is free software; you can redistribute it and/or modify it \
under the terms of the GNU General Public License as published by the \
Free Software Foundation; either version 2 of the License, or (at your \
option) any later version.
This program is distributed in the hope that it will be useful, \
but WITHOUT ANY WARRANTY; without even the implied warranty of \
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \
GNU General Public License for more details.
You should have received a copy of the GNU General Public License \
along with this program. If not, see <http://www.gnu.org/licenses/>.
"
}
.about.text configure -state disabled
} else {
wm deiconify .about
raise .about
}
}
proc openHelpWindow {} {
global param gparam s pinfo
debug 2 "openHelpWindow"
set lang $gparam(lang)
if ![winfo exists .help] {
toplevel .help
wm group .help .
wm title .help "$pinfo(pname) - [set s($lang)(help)]"
# wm resizable .help 0 0
placeWin .help 50
text .help.text -font lfont -wrap word -width 80 -height 24 \
-relief groove -yscrollcommand ".help.yscroll set" \
-xscrollcommand ".help.xscroll set" \
-padx 4 -pady 4 -wrap none
scrollbar .help.yscroll -orient vertical \
-command { .help.text yview }
scrollbar .help.xscroll -orient horizontal \
-command { .help.text xview }
if {$param(isunix)} { # I like smaller scrollbars
.help.yscroll configure -width 10 -bd 1
.help.xscroll configure -width 10 -bd 1
}
button .help.ok -text "Ok" -width 8 -command {destroy .help}
pack .help.ok -side bottom -pady 8
pack .help.yscroll -side right -fill y
pack .help.xscroll -side bottom -fill x
pack .help.text -expand 1 -fill both
.help.text tag configure center -justify center
.help.text tag configure big -font bfont -justify center
.help.text tag configure bfont -font bfont
.help.text tag configure maillink -foreground $param(highcolor) -underline 1
.help.text tag bind maillink <ButtonRelease-1> { sendMail }
.help.text tag bind maillink <Enter> { .help.text config -cursor hand2}
.help.text tag bind maillink <Leave> { .help.text config -cursor xterm}
.help.text tag configure keylink -foreground $param(highcolor) -underline 1
.help.text tag bind keylink <ButtonRelease-1> { helpKeys }
.help.text tag bind keylink <Enter> { .help.text config -cursor hand2}
.help.text tag bind keylink <Leave> { .help.text config -cursor xterm}
.help.text tag configure flaglink -foreground $param(highcolor) -underline 1
.help.text tag bind flaglink <ButtonRelease-1> { helpCmdline }
.help.text tag bind flaglink <Enter> { .help.text config -cursor hand2}
.help.text tag bind flaglink <Leave> { .help.text config -cursor xterm}
.help.text tag configure abblink -foreground $param(highcolor) -underline 1
.help.text tag bind abblink <ButtonRelease-1> { helpAbb }
.help.text tag bind abblink <Enter> { .help.text config -cursor hand2}
.help.text tag bind abblink <Leave> { .help.text config -cursor xterm}
.help.text tag configure helplink -foreground $param(highcolor) -underline 1 -font bfont
.help.text tag bind helplink <ButtonRelease-1> { helpGeneral }
.help.text tag bind helplink <Enter> { .help.text config -cursor hand2}
.help.text tag bind helplink <Leave> { .help.text config -cursor xterm}
set w [expr round([winfo reqwidth .help.text] / 2) - 30]
.help.text configure -tabs $w
# mouse over text - highlight the line below the mouse pointer
.help.text tag configure hilite -background $param(hicolor)
bind .help.text <Motion> {
global param
if {$param(hilite)} {
.help.text tag remove hilite 1.0 end
if {[string compare [.help.text index "@%x, %y linestart"] "1.0"]} {
.help.text tag add hilite "@%x, %y linestart" "@%x, %y lineend"
}
}
}
} else {
wm deiconify .help
# raise .help
.help.text configure -state normal
.help.text delete 0.0 end
}
}
proc helpGeneral {} {
global s gparam pinfo
debug 2 "helpGeneral"
set lang $gparam(lang)
openHelpWindow
.help.text insert end "\n$pinfo(pname) - [set s($lang)(help)]\nVersion $pinfo(version)\n\n" big
if {$lang == "de"} {
.help.text insert end {Suche starten:} bfont
.help.text insert end {
* Suchwort eingeben, Suchmethode auswhlen, ENTER oder auf "Suche" drcken, oder
* Doppelklick mit linker Maustaste auf Wort in Ergebnisfenster, oder
* in anderem Fenser selektiertes Wort mit mittlerer Maustaste ber
Ergebnisfenster "fallenlassen"
* Suche im Ergebnis:
- Schrgstrich vor Suchwort: "/Suchwort" + ENTER oder
- Suchwort eingeben, Umschalt+ENTER oder
- mit mittlerer Maustaste auf "Suche" drcken oder
- Umschalt-Taste drcken und selektiertes Wort mit mittlerer Maustaste
ber Ergebnisfenster "fallenlassen"
}
.help.text insert end {
Suchworte angeben: } bfont
.help.text insert end {
* ein Suchwort oder
* eins aus mehreren Wrtern (ODER-Verknpfung): }
.help.text insert end {Wort1,Wort2} bfont
.help.text insert end {
* alle Wrter (UND-Verknpfung): }
.help.text insert end {Wort1+Wort2} bfont
.help.text insert end {
* exakte Wortfolge: }
.help.text insert end {Wort1 Wort2} bfont
.help.text insert end {
* }
.help.text insert end {Umlaute: } bfont
.help.text insert end {Falls Sie keine Umlaute auf der Tastatur haben, benutzen Sie:
}
.help.text insert end {"a = "A = "o = "O = "u = "U = "s = } bfont
.help.text insert end {
Suchparameter: } bfont
.help.text insert end {
* Suche nach vollstndigen Wrtern oder nach Muster in Wrtern?
* Gro-/Kleinschreibweise ignorieren oder exakt beachten?
* Korrekte Schreibweise oder, falls agrep benutzt wird, Fehlerkorrektur
versuchen?
* Einfache Suche (* als Platzhalter fr beliebige Zeichen) oder
regulre Ausdrcke zulassen?
}
.help.text insert end {
Andere Suchverhalten } bfont
.help.text insert end { sind ber das Men (oder durch Klick auf "Suchwort") einstellbar: }
.help.text insert end {
Suche, sobald Maus ber Fenster: } bfont
.help.text insert end {
* Selektieren Sie in einem anderen Fenster ein Wort (linke Maustaste)
* Sobald Sie mit der Maus ber das Ding-Fenster kommen, wird dieses
Wort mit aktueller Suchmethode gesucht.
}
.help.text insert end {
Suche sofort bei neuer Textauswahl: } bfont
.help.text insert end {
* Sobald Sie in einem anderen Fenster ein Wort selektieren
(linke Maustaste), wird dieses Wort mit aktueller Suchmethode gesucht.
}
.help.text insert end {
History-Funktion: } bfont
.help.text insert end {
* Frhere Suchergebnisse lassen sich wieder anzeigen (Knpfe "<" bzw. ">")
}
.help.text insert end {
Zur Funktionsweise: } bfont
.help.text insert end "
* \"$pinfo(pname)\" ist kein intelligentes Dolmetscherprogramm,
sondern letztlich nur ein Front-End zur Suche in Dateien.
* Die eigentliche Suche fhrt ein dafr existierendes Unix-Kommando aus der
\"grep\"-Famile durch. Hat man \"agrep\" installiert, kann man die Funktion
der \"fehlertoleranten Suche\" nutzen.
* Die Ergebnisse sind nur so gut, wie die zugrundeliegende Wrterbuch-Datei.
Zur Verbesserung dieser Datenbasis knnen Sie beitragen.
Senden Sie einfach "
.help.text insert end {eine E-Mail an den Autor.} maillink
.help.text insert end "\n\nWeitere Informationen:\n" bfont
.help.text insert end " * "
.help.text insert end "Hilfe zu Tastaturkrzeln" keylink
.help.text insert end "\n * "
.help.text insert end "Hilfe zu Startoptionen" flaglink
.help.text insert end "\n * "
.help.text insert end "Hilfe zu Abkrzungen" abblink
.help.text insert end "
* Unix-Manuals zu agrep, egrep, ispell, dict\n\n"
} else { # english
.help.text insert end {Start search:} bfont
.help.text insert end {
* Type in search word, select a search method,
then press ENTER or press the "Search" button, or
* Double click on a word in the result window with left mouse button 1, or
* Select a word in another X window, drop it by clicking with middle mouse
button 2 over the result window.
* Search in result:
- Type a slash, then the search word: "/word" + ENTER, or
- Type in search word, then press Shift+ENTER, or
- press the "Search" button with mouse middle button 2, or
- press Shift and drop word by clicking with middle mouse button 2
over the result window.
}
.help.text insert end {
Specify your search words: } bfont
.help.text insert end {
* Just one word, or
* Find one of many words: }
.help.text insert end {word1,word2} bfont
.help.text insert end {
* Find all words: }
.help.text insert end {word1+word2} bfont
.help.text insert end {
* Find exact phrase: }
.help.text insert end {word1 word2} bfont
.help.text insert end {
* }
.help.text insert end {Umlauts: } bfont
.help.text insert end {If you don't have umlaut keys on your keyboard, please use:
}
.help.text insert end {"a = "A = "o = "O = "u = "U = "s = } bfont
.help.text insert end {
Search options: } bfont
.help.text insert end {
* Search for full words or partial matches within words?
* Ignore case or search case sensitive?
* If agrep is used, try error correction if nothing is found?
* Simple search (* is wildcard for any character) or search with
regular expressions?
}
.help.text insert end {
Another search behavior } bfont
.help.text insert end { can be selected via the menu, or by clicking on "search word": }
.help.text insert end {
Search on mouse over: } bfont
.help.text insert end {
* Select a word in another window (left mouse button)
* As soon as you move the mouse over the Ding window
this word will be searched with the current search method.
}
.help.text insert end {
Search on new text selection: } bfont
.help.text insert end {
* As soon as you select a word in another window (left mouse button)
this word will be searched with the current search method.
}
.help.text insert end {
History function: } bfont
.help.text insert end {
* Previous search results could be displayed again ("<" and ">" buttons)
}
.help.text insert end {
How it works: } bfont
.help.text insert end "
* \"$pinfo(pname)\" is not an intelligent translator system, but \"only\"
a front-end to search quickly in files.
* The search itself is done by a dedicated Unix command ala \"grep\".
If you have installed \"agrep\" you are able to use the approximate
matching feature to correct spelling errors.
* Well, the results are as good as the dictionary wordlist.
You could contribute to improve this list!
Simply send "
.help.text insert end {an email to the author.} maillink
.help.text insert end "\n\nFurther information:\n" bfont
.help.text insert end " * "
.help.text insert end "Help on Keyboard shortcuts" keylink
.help.text insert end "\n * "
.help.text insert end "Help on start options" flaglink
.help.text insert end "\n * "
.help.text insert end "Help on abbreviations" abblink
.help.text insert end "
* Unix manual pages for agrep, egrep, ispell, dict \n\n"
}
.help.text configure -state disabled
}
proc helpKeys {} {
global s gparam pinfo
debug 2 "helpKeys"
set lang $gparam(lang)
openHelpWindow
.help.text insert end "\n$pinfo(pname) - [set s($lang)(help)]\nVersion $pinfo(version)\n\n" big
if {$lang == "de"} {
.help.text insert end {Viele Funktionen lassen sich einfach und schnell ber }
.help.text insert end {Tastaturkrzel} bfont
.help.text insert end " erreichen.\n\n"
.help.text insert end {Im Suchwort ndern:} bfont
.help.text insert end "
Kursur links (rechts)\tndern im Suchwort
Esc, Strg+u\tSuchwort lschen, evtl. Suche stoppen, Oberflche rcksetzen
Umschalt + Esc\tSuchwort lschen, evtl. Suche stoppen, Oberflche rcksetzen
\tFenster minimieren oder normale Gre
Strg+a\tan den Anfang des Suchwortes
Strg+e\tans Ende des Suchwortes
Strg+Zurck, Strg+w\tLscht ein Wort links von aktueller Position
Strg+k\tLschen von aktueller Position bis Ende\n\n"
.help.text insert end {Suchmethode ndern:} bfont
.help.text insert end "
Strg + 1\tSuche mit Methode 1, 2 usw.
Strg + 2 ...\t ... je nachdem, wieviele definiert\n\n"
.help.text insert end {Im Ergebnis blttern:} bfont
.help.text insert end "
Kursur hoch (runter) / Rollmaus\t1 Zeile hoch (runter)
Umschalt + Kursur hoch (runter) / Rollmaus\t5 Zeilen hoch (runter)
Bild hoch (runter) / Alt + Rollmaus\t1 Seite hoch (runter)
Pos 1\tan den Anfang
Ende\tans Ende
Umschalt + Kursur links (rechts)\tnach links (rechts) verschieben (bei langen Zeilen)
Strg + Kursur hoch (runter)\tin frheren Suchergebnissen
Strg + Rad der Rollmaus\tblttern (History)
\n"
.help.text insert end {Men-Funktionen:} bfont
.help.text insert end "
Strg + q\tProgramm beenden
Strg + n\tNeues Programmfenster starten
Strg + s\tAktuelles Ergebnis speichern
Strg + l\tAlle Ergebnisse speichern
Strg + c\tAktuelles Ergebnis in Zwischenablage
Strg + m\tE-Mail an den Autor senden (nur Unix)\n\n"
.help.text insert end {Sonstiges:} bfont
.help.text insert end "
F1\tHilfe
Strg + +\tSchrift vergrern
Strg + -\tSchrift verkleinern
Strg + = oder Strg + 0\tStandard-Schriftgre
Strg + Klick links\tErgebnisse ein- oder ausklappen (wenn verfgbar)
\n"
.help.text insert end "Allgemeine Hilfe" helplink
.help.text insert end "\n\n"
} else { # english
.help.text insert end {Many functions are easily available by }
.help.text insert end {Keyboard shortcuts} bfont
.help.text insert end ".\n\n"
.help.text insert end {To change the search word:} bfont
.help.text insert end "
Cursor left (right)\tEdit in the current word
Esc, Ctrl+u\tErase search word, Stop search, Reset interface
Shift + Esc\tErase search word, Stop search, Reset interface
\tminimize window or set normal size
Ctrl+a\tGo to the begin of the search word
Ctrl+e\tGo to end of the search word
Ctrl+Backspace, Ctrl+w\tErase one word left from current position
Ctrl+k\tErase from current position to the end\n\n"
.help.text insert end {To change the search method:} bfont
.help.text insert end "
Ctrl + 1\tSearch with method 1, 2 etc..
Ctrl + 2 ...\t ... if defined\n\n"
.help.text insert end {Scroll in the results:} bfont
.help.text insert end "
Cursor up (down) / wheel mouse\t1 line up (down)
Shift + Cursor up (down) / wheel mouse\t5 lines up (down)
Page up (down) / Alt + wheel mouse\t1 page up (down)
Pos 1\tto the beginning
End\tto the end
Shift + Cursor left (right)\tscroll left (right) (for long lines)
Ctrl + Cursur up (down)\tbrowse through previous
Ctrl + wheel of mouse\tsearch results (History)\n\n"
.help.text insert end {Menu functions:} bfont
.help.text insert end "
Ctrl + q\tQuit program
Ctrl + n\tStart new program window
Ctrl + s\tSave current result
Ctrl + l\tSave all results
Strg + c\tCopy current result to clipboard
Ctrl + m\tSend an e-mail to the author (Unix only)\n\n"
.help.text insert end {Others:} bfont
.help.text insert end "
F1\tHelp
Ctrl + +\tIncrease font size
Ctrl + -\tDecrease font size
Ctrl + = or Ctrl + 0\tStandard font size
Ctrl + click left\tFold or unfold search results (where available)
\n"
.help.text insert end {Umlauts: } bfont
.help.text insert end {If you don't have umlaut keys on your keyboard, please use:
}
.help.text insert end {"a = "A = "o = "O = "u = "U = "s =
} bfont
.help.text insert end "General help" helplink
.help.text insert end "\n\n"
}
.help.text configure -state disabled
}
proc helpCmdline {} {
global s gparam pinfo argv0 ding_usage
debug 2 "helpCmdline"
set lang $gparam(lang)
openHelpWindow
.help.text insert end "\n$pinfo(pname) - [set s($lang)(help)]\nVersion $pinfo(version)\n\n" big
if {$lang == "de"} {
.help.text insert end "Das Programm $argv0 kann mit verschiedenen Optionen (Flags) gestartet werden:\n"
.help.text insert end "$ding_usage(de)"
.help.text insert end "Allgemeine Hilfe" helplink
} else { # english
.help.text insert end "The program $argv0 may be started with different options (command line flags):\n"
.help.text insert end "$ding_usage(en)"
.help.text insert end "General help" helplink
}
.help.text insert end "\n\n"
.help.text configure -state disabled
}
# updates the list of search methods in configuration
proc update_searchmeth {num} {
global searchmeth searchmpos
debug 2 "update_searchmeth $num"
set sel [.ssearch.m.list curselection]
set size [.ssearch.m.list size]
.ssearch.m.list delete 0 $size
foreach i $searchmpos {
if {$searchmeth($i,name) != ""} {
.ssearch.m.list insert end $searchmeth($i,name)
}
}
if {$sel != ""} {
set s [expr $sel + $num]
if {($s <= $size && $s >= 0)} {
.ssearch.m.list selection set $s
}
}
# update
}
proc helpAbb {} {
global s gparam pinfo
debug 2 "helpAbb"
set lang $gparam(lang)
openHelpWindow
set w [expr round([winfo reqwidth .help.text] / 7)]
debug 4 "w = $w"
.help.text tag configure abbtab -tabs "$w [expr 4 * $w] [expr 7 * $w]"
.help.text tag configure abbtabb -tabs "$w [expr 4 * $w] [expr 7 * $w]" -font bfont
.help.text insert end "\n$pinfo(pname) - [set s($lang)(help)]\nVersion $pinfo(version)\n\n" big
if {$lang == "de"} {
.help.text insert end {Abkrzungen im Deutsch <> Englischen Wrterbuch} bfont
} else { # english
.help.text insert end {Used abbreviations in the German <> English Dictionary} bfont
}
.help.text insert end "\n\n\tWortart\tPart of speech\n" abbtabb
.help.text insert end "
{m}\tSubstantiv, mnnlich\tnoun, masculine
{f}\tSubstantiv, weiblich\tnoun, feminine
{n}\tSubstantiv, schlich\tnoun, neuter
{pl}\tSubstantiv, Plural\tnoun, plural
{vt}\tVerb, transitiv\tverb, transitive
{vi}\tVerb, intransitiv\tverb, intransitive
{vr}\tVerb, reflexiv\tverb, reflexive
{adj}\tAdjektiv\tadjective
{adv}\tAdverb\tadverb
{prp}\tPrposition\tpreposition
{num}\tNumeral, Zahlwort\tnumeral
{art}\tArtikel\tarticle
{ppron}\tPersonalpronomen\tpersonal pronoun
{conj}\tKonjunktion\tconjunction
{interj}\tInterjektion; Ausruf \tinterjection
etw. - sth.\tetwas\tsomething
jds. - sb.'s\tjemandes (Genitiv)\tsomebody's
jdm. - sb.\tjemandem (Dativ)\tsomebody
jdn. - sb.\tjemanden (Akkusativ)\tsomebody
usw. - etc.\tund so weiter\tet cetera; and so on
" abbtab
.help.text insert end "\n\tVerwendung\tUsage\n" abbtabb
.help.text insert end "
\[alt\]\talte deutsche Rechtschreibung\told German spelling
\[obs.\]\tveraltet; nicht mehr gebruchlich\tobsolete
\[Am.\]\tAmerikanisches Englisch\tAmerican English
\[Br.\]\tBritisches Englisch\tBritish English
\[Sc.\]\tSchottisches Englisch\tScottish English
\[Austr.\]\tAutralisches Englisch\tAustralian English
\[Sddt.\]\tSddeutsch\tSouthern German
\[s.\]\tsterreichisches Deutsch\tAustrian German
\[Schw.\]\tSchweizerisch\tSwiss German
\[ugs.\] \[coll.\]\tumgangssprachlich\tcolloquial
\[btr.\] \[fig.\]\tbertragen; bildlich\tfigurative
\[slang\]\tJargon, Slang; saloppe Umgangssprache\tslang
\[Sprw.\] \[prov.\]\tSprichwort\tproverb
\[tm\]\tHandelsmarke; Warenzeichen\ttrademark
" abbtab
.help.text insert end "\n\tFachgebiete\tSpecial branches\n" abbtabb
.help.text insert end "
\[anat.\]\tAnatomie\tanatomy
\[arch.\]\tArchitektur\tarchitecture
\[astron.\]\tAstronomie\tastronomy
\[auto\]\tAutos; Automobilindustrie\tcars; automotive industry
\[biochem.\]\tBiochemie\tbiochemistry
\[biol.\]\tBiologie\tbiology
\[bot.\]\tBotanik; Pflanzen\tbotany; plants
\[chem.\]\tChemie\tchemistry
\[comp.\]\tComputer\tcomputer
\[constr.\]\tBauwesen\tconstruction
\[econ.\]\tkonomie; Wirtschaft\teconomy
\[electr.\]\tElektrotechnik, Elektronik\telectrical engineering, electronics
\[cook.\]\tSpeisen; Kochen; Essen; Gastronomie\tdishes; cooking; eating; gastronomy
\[geogr.\]\tGeografie\tgeography
\[geol.\]\tGeologie\tgeology
\[gramm.\]\tGrammatik\tgrammar
\[jur.\]\tRecht, Jura\tlaw
\[math.\]\tMathematik\tmathematics
\[med.\]\tMedizin\tmedicine
\[mil.\]\tMilitr\tmilitary
\[min.\]\tMineralogie\tmineralogy
\[mus.\]\tMusik\tmusic
\[naut.\]\tNautik; Schifffahrtskunde\tnautical science; seafaring
\[ornith.\]\tOrnithologie; Vogelkunde\tornithology
\[pharm.\]\tPharmakologie; Arzneimittelkunde\tpharmacology
\[phil.\]\tPhilosophie\tphilosophy
\[phys.\]\tPhysik\tphysics
\[pol.\]\tPolitik\tpolitics
\[relig.\]\tReligion\treligion
\[sport\]\tSport\tsports
\[techn.\]\tTechnik\ttechnology; engineering
\[textil.\]\tTextilindustrie\ttextile industry
\[zool.\]\tZoologie; Tiere\tzoology; animals
" abbtab
if {$lang == "de"} {
.help.text insert end "\n\nAllgemeine Hilfe" helplink
} else {
.help.text insert end "\n\nGeneral help" helplink
}
.help.text insert end "\n\n"
.help.text configure -state disabled
}
proc setSearch {} {
global s pinfo default_searchmeth searchmeth searchmpos gparam param grepcmds
debug 2 "setSearch"
set lang $gparam(lang)
if ![winfo exists .ssearch] {
toplevel .ssearch
wm group .ssearch .
wm title .ssearch "$pinfo(pname): [set s($lang)(searchm)]"
wm iconname .ssearch "dict"
placeWin .ssearch 50
frame .ssearch.buttons
pack .ssearch.buttons -side bottom -fill x
button .ssearch.buttons.ok -text [set s($lang)(apply)] -command {
update_searchmeth_menu
if {$param(autosave) != 0} {
saveOptions
}
destroy .ssearch
}
button .ssearch.buttons.cancel -text [set s($lang)(cancel)] -command "destroy .ssearch"
pack .ssearch.buttons.ok .ssearch.buttons.cancel \
-side left -expand 1 -pady 8 -padx 8
# Methods
frame .ssearch.m -bd 2 -relief groove
pack .ssearch.m -side top -fill x -ipady 10
scrollbar .ssearch.m.scroll -command ".ssearch.m.list yview"
if {$param(isunix)} { # I like smaller scrollbars
.ssearch.m.scroll configure -width 10 -bd 1
}
listbox .ssearch.m.list -yscroll ".ssearch.m.scroll set" \
-setgrid 1 -height 4
menubutton .ssearch.m.new -text [set s($lang)(new)] -width 8 \
-menu .ssearch.m.new.menu -indicatoron 1 -relief raised \
-anchor c -direction flush
menu .ssearch.m.new.menu -font lfont -tearoff 0
for {set j 0} {[info exists default_searchmeth($j,name)]} {incr j} {
# check for available search cmds
set state "disabled"
foreach c $default_searchmeth($j,grepcmds) {
if [info exists grepcmds($c)] {
set state "active"
break
}
}
.ssearch.m.new.menu add command -label "$default_searchmeth($j,name)" \
-state $state -command "setSearchOptions {} $j"
}
.ssearch.m.new.menu add command -label "Generic" -command "setSearchOptions {} -1"
button .ssearch.m.edit -text [set s($lang)(edit)] -width 8 \
-state disabled -command {
if {[.ssearch.m.list curselection] != {}} {
setSearchOptions [lindex $searchmpos [.ssearch.m.list curselection]] {}
}
}
button .ssearch.m.delete -text [set s($lang)(delete)] -width 8 \
-state disabled -command {
if {[.ssearch.m.list curselection] != {}} {
set sel [.ssearch.m.list curselection]
set searchmeth([lindex $searchmpos $sel],name) ""
set searchmpos [lreplace $searchmpos $sel $sel]
update_searchmeth 0
}
}
button .ssearch.m.up -image up -state disabled -command {
if {[.ssearch.m.list curselection] != {}} {
set sel [.ssearch.m.list curselection]
if {$sel > 0} {
set pos [lindex $searchmpos $sel]
set searchmpos [lreplace $searchmpos $sel $sel]
set searchmpos [linsert $searchmpos [expr $sel - 1] $pos]
update_searchmeth -1
}
}
}
button .ssearch.m.down -image down -state disabled -command {
if {[.ssearch.m.list curselection] != {}} {
set sel [.ssearch.m.list curselection]
if {$sel < [expr [.ssearch.m.list size] - 1]} {
set pos [lindex $searchmpos $sel]
set searchmpos [lreplace $searchmpos $sel $sel]
set searchmpos [linsert $searchmpos [expr $sel + 1] $pos]
update_searchmeth 1
}
}
}
grid .ssearch.m.list -in .ssearch.m -row 0 -column 0 -rowspan 5 \
-sticky w,n,s -pady 4
grid .ssearch.m.scroll -in .ssearch.m -row 0 -column 1 -rowspan 5 \
-sticky w,n,s -pady 4
grid .ssearch.m.up -in .ssearch.m -row 1 -column 2 -rowspan 1 \
-padx 4 -sticky n
grid .ssearch.m.down -in .ssearch.m -row 1 -column 2 -rowspan 1 \
-padx 4 -sticky s
grid .ssearch.m.new -in .ssearch.m -row 0 -column 3 -rowspan 1 \
-padx 8 -pady 4
grid .ssearch.m.edit -in .ssearch.m -row 1 -column 3 -rowspan 1 \
-padx 8 -pady 4
grid .ssearch.m.delete -in .ssearch.m -row 2 -column 3 -rowspan 1 \
-padx 8 -pady 4
# grid .ssearch.m.down -in .ssearch.m -row 1 -column 2 -rowspan 1 \
# -padx 8 -pady 4
bind .ssearch.m.list <Double-1> {
setSearchOptions [lindex $searchmpos [.ssearch.m.list curselection]] {}
}
bind .ssearch.m.list <Return> {
setSearchOptions [lindex $searchmpos [.ssearch.m.list curselection]] {}
}
bind .ssearch.m.list <1> {
.ssearch.m.up configure -state normal
.ssearch.m.down configure -state normal
.ssearch.m.edit configure -state normal
.ssearch.m.delete configure -state normal
}
update_searchmeth 0
} else {
wm deiconify .ssearch
raise .ssearch
}
}
proc setSearchOptions {num type} {
global searchmeth default_searchmeth default_searchopts searchmpos grepcmds
global param gparam pinfo s
debug 1 "setSearchOptions $num $type"
set lang $gparam(lang)
variable smeth
if [array exists smeth] {
unset smeth
}
variable new 0
variable n $num
if {$num != ""} {
foreach i [array names searchmeth "$num,*"] {
regsub "$num," $i "" j
set smeth($j) $searchmeth($i)
}
} else {
set n 0
set new 1
array set smeth [array get default_searchopts]
foreach i [array names default_searchmeth "$type,*"] {
regsub "$type," $i "" j
set smeth($j) $default_searchmeth($i)
}
# set smeth(grepopts) $grepcmds($smeth(grepcmd))
# set smeth(name) ""
foreach i [array names searchmeth "*,name"] {
incr n
}
set smeth(type) $type
}
if [winfo exists .sopts] {
wm deiconify .sopts
raise .sopts
} else {
toplevel .sopts
wm group .sopts .
wm title .sopts "$pinfo(pname): [set s($lang)(searcho)]"
wm iconname .sopts "dict"
placeWin .sopts 70
frame .sopts.buttons
pack .sopts.buttons -side bottom -fill x
button .sopts.buttons.ok -text [set s($lang)(apply)] -command {
if {$smeth(name) == ""} {
tk_messageBox -icon info -type ok -parent .sopts \
-message [set s($lang)(namerequired)]
focus .sopts.c.n
return
}
set searchmeth($n,name) $smeth(name)
set searchmeth($n,type) $smeth(type)
set searchmeth($n,grepcmd) $smeth(grepcmd)
set searchmeth($n,grepopts) $smeth(grepopts)
set searchmeth($n,dictfile) $smeth(dictfile)
set df [glob -nocomplain $smeth(dictfile)]
set searchmeth($n,dictfiles) $df
set searchmeth($n,separator) $smeth(separator)
set searchmeth($n,language1) $smeth(language1)
set searchmeth($n,language2) $smeth(language2)
set searchmeth($n,minlength) $smeth(minlength)
set searchmeth($n,maxlength) $smeth(maxlength)
set searchmeth($n,maxresults) $smeth(maxresults)
set searchmeth($n,shapedresult) $smeth(shapedresult)
set searchmeth($n,foldedresult) $smeth(foldedresult)
set searchmeth($n,avail) 1
if {$new == 1} { # new
lappend searchmpos $n
}
update_searchmeth 0
unset smeth
destroy .sopts
}
button .sopts.buttons.st -text [set s($lang)(default)] -command {
if {$new == 1} { # new
array set smeth [array get default_searchopts]
} else {
foreach i [array names searchmeth "$n,*"] {
regsub "$n," $i "" j
set smeth($j) $searchmeth($i)
}
}
}
button .sopts.buttons.cancel -text [set s($lang)(cancel)] \
-command {
unset smeth
destroy .sopts
}
pack .sopts.buttons.ok .sopts.buttons.st .sopts.buttons.cancel \
-side left -expand 1 -pady 8
# Command
frame .sopts.c -bd 2 -relief groove
pack .sopts.c -side top -fill x -ipady 10
label .sopts.c.ln -text "[set s($lang)(name)]:" -font bfont
entry .sopts.c.n -textvariable smeth(name) -font bfont -width 15
label .sopts.c.l -text "[set s($lang)(grepcmd)]:" -font lfont
if {$type != -1} {
# pre-definded cmd
menubutton .sopts.c.m -textvariable smeth(grepcmd) -menu .sopts.c.m.m \
-indicatoron 1 -relief raised -anchor c -direction flush \
-font lfont -width 13
menu .sopts.c.m.m -font lfont -tearoff 0
foreach c $default_searchmeth($smeth(type),grepcmds) {
# all defined commands for this method
if {![info exists grepcmds($c)]} {
# not available in current system
continue
}
if {$smeth(grepcmd) == ""} { # no default command yet
set smeth(grepcmd) $c
if ![info exists smeth(grepopts)] {
# don't override specific options
set smeth(grepopts) "$grepcmds($c)"
}
}
if {$new == 1 || [string compare $c $searchmeth($n,grepcmd)] != 0} {
# no options set so far
if {[info exists default_searchmeth($smeth(type),grepopts)]} {
# special options for this method
set cmd "set smeth(grepopts) \"$default_searchmeth($smeth(type),grepopts)\""
} else {
# default options for this command
set cmd "set smeth(grepopts) \"$grepcmds($c)\""
}
} else {
# set default options
set cmd "set smeth(grepopts) \"$searchmeth($n,grepopts)\""
}
set cmd "$cmd; set smeth(grepcmd) $c"
.sopts.c.m.m add command -label $c -font lfont -command $cmd
}
} else {
# generic command - TODO!
entry .sopts.c.m
}
label .sopts.c.l2 -text "[set s($lang)(grepopts)]:" -font lfont
entry .sopts.c.o -textvariable smeth(grepopts) -font lfont -width 13
grid .sopts.c.ln -in .sopts.c -row 0 -column 0 -rowspan 1 -sticky e \
-padx 4 -pady 4
grid .sopts.c.n -in .sopts.c -row 0 -column 1 -rowspan 1 -sticky w \
-padx 4 -pady 4
grid .sopts.c.l -in .sopts.c -row 1 -column 0 -rowspan 1 -sticky e \
-padx 4 -pady 4
grid .sopts.c.m -in .sopts.c -row 1 -column 1 -rowspan 1 -sticky w \
-padx 4 -pady 4
grid .sopts.c.l2 -in .sopts.c -row 2 -column 0 -rowspan 1 -sticky e \
-padx 4 -pady 4
grid .sopts.c.o -in .sopts.c -row 2 -column 1 -rowspan 1 -sticky w \
-padx 4 -pady 4
# File
frame .sopts.file -bd 2 -relief groove
pack .sopts.file -side top -fill x -ipadx 10 -ipady 10 -pady 10
label .sopts.file.l -text "[set s($lang)(dictfile)]: " \
-font lfont
entry .sopts.file.e -width 36 -font lfont \
-textvariable smeth(dictfile)
variable types {
{"Text files" {.txt .vok .dic}}
{"All files" *}
}
button .sopts.file.b -font lfont -text "Browse ..." \
-command {
set f [tk_getOpenFile -initialdir [file dirname $smeth(dictfile)] \
-filetypes $types -parent .sopts]
if [string compare $f ""] {
set smeth(dictfile) $f
}
}
grid .sopts.file.l -in .sopts.file -row 0 -column 0 -columnspan 6
grid .sopts.file.e -in .sopts.file -row 1 -column 0 -columnspan 5 -sticky e
grid .sopts.file.b -in .sopts.file -row 1 -column 6
label .sopts.file.l1 -text "[set s($lang)(lang)] 1:" -font lfont
label .sopts.file.lt -text "[set s($lang)(sep)]:" -font lfont
label .sopts.file.l2 -text "[set s($lang)(lang)] 2:" -font lfont
entry .sopts.file.e1 -font lfont -textvariable smeth(language1) -width 10
entry .sopts.file.et -font lfont -textvariable smeth(separator) -width 5
entry .sopts.file.e2 -font lfont -textvariable smeth(language2) -width 10
grid .sopts.file.l1 -in .sopts.file -row 2 -column 0 -padx 4 -columnspan 2
grid .sopts.file.lt -in .sopts.file -row 2 -column 2 -padx 4 -columnspan 2
grid .sopts.file.l2 -in .sopts.file -row 2 -column 4 -padx 4 -columnspan 2
grid .sopts.file.e1 -in .sopts.file -row 3 -column 0 -padx 4 -columnspan 2
grid .sopts.file.et -in .sopts.file -row 3 -column 2 -padx 4 -columnspan 2
grid .sopts.file.e2 -in .sopts.file -row 3 -column 4 -padx 4 -columnspan 2
frame .sopts.search -bd 2 -relief groove
pack .sopts.search -side top -fill x -ipadx 10 -ipady 10
label .sopts.search.rl -text "[set s($lang)(maxresults)]:" -font lfont
entry .sopts.search.re -justify right -width 5 -font lfont -textvariable smeth(maxresults)
label .sopts.search.ll -text "[set s($lang)(minlength)]:" -font lfont
entry .sopts.search.le -justify right -width 5 -font lfont -textvariable smeth(minlength)
label .sopts.search.ml -text "[set s($lang)(maxlength)]:" -font lfont
entry .sopts.search.me -justify right -width 5 -font lfont -textvariable smeth(maxlength)
checkbutton .sopts.search.shaped -text [set s($lang)(shaped)] -font lfont \
-variable smeth(shapedresult)
checkbutton .sopts.search.folded -text [set s($lang)(folded)] -font lfont \
-variable smeth(foldedresult)
grid .sopts.search.rl -in .sopts.search -row 0 -column 0 -rowspan 1 -sticky e -padx 0
grid .sopts.search.re -in .sopts.search -row 0 -column 1 -rowspan 1 -sticky w -padx 0
grid .sopts.search.ll -in .sopts.search -row 1 -column 0 -rowspan 1 -sticky e -padx 0
grid .sopts.search.le -in .sopts.search -row 1 -column 1 -rowspan 1 -sticky w -padx 0
grid .sopts.search.ml -in .sopts.search -row 2 -column 0 -rowspan 1 -sticky e -padx 0
grid .sopts.search.me -in .sopts.search -row 2 -column 1 -rowspan 1 -sticky w -padx 0
grid .sopts.search.shaped -in .sopts.search -row 3 -column 0 -rowspan 1 -sticky w -padx 0
grid .sopts.search.folded -in .sopts.search -row 4 -column 0 -rowspan 1 -sticky w -padx 0
}
if {! [info exists default_searchmeth($smeth(type),dictfile)]} {
.sopts.file.e configure -state disabled
.sopts.file.b configure -state disabled
.sopts.file.l configure -foreground darkgray
}
if {! [info exists default_searchmeth($smeth(type),separator)]} {
.sopts.file.et configure -state disabled
.sopts.file.lt configure -foreground darkgray
}
if {! [info exists default_searchmeth($smeth(type),language2)]} {
.sopts.file.e2 configure -state disabled
.sopts.file.l2 configure -foreground darkgray
}
}
proc setGeneral {} {
global default
global pinfo s languages
global param gparam
debug 1 "setGeneral"
set lang $gparam(lang)
if ![winfo exists .general] {
toplevel .general
wm group .general .
wm title .general "$pinfo(pname): [set s($lang)(general)]"
wm iconname .general "ding"
placeWin .general 50
variable fc "$param(fcolor)"
variable bc "$param(bcolor)"
variable ll $lang
variable changes_restart 0
variable ffamily
variable fsize
variable fstyle
variable lffamily
variable lfsize
variable lfstyle
set ffamily [lindex $param(tfont) 0]
set fsize [lindex $param(tfont) 1]
set fstyle [lindex $param(tfont) 2]
set lffamily [lindex $param(lfont) 0]
set lfsize [lindex $param(lfont) 1]
set lfstyle [lindex $param(lfont) 2]
variable omaxhistory $param(maxhistory)
frame .general.buttons
pack .general.buttons -side bottom -fill x
button .general.buttons.ok -text [set s($lang)(apply)] -command {
if {$gparam(lang) != $ll} {
set gparam(lang) $ll
set lang $ll
set changes_restart 1
}
set tf [list $ffamily $fsize $fstyle]
if [string compare "$tf" "$param(tfont)"] {
set param(tfont) $tf
chFont tfont
set param(ifont) [list $ffamily $fsize normal italic]
chFont ifont
# .result.text configure -font $param(tfont)
# .search.s.entry configure -font $param(tfont)
}
set lf [list $lffamily $lfsize $lfstyle]
if [string compare "$lf" "$param(lfont)"] {
set param(lfont) $lf
set param(bfont) [list $lffamily $lfsize bold]
set param(sfont) [list $lffamily [expr $lfsize - 2] $lfstyle]
chFont lfont
chFont bfont
chFont sfont
}
if {[string compare $param(fcolor) $fc] || [string compare $param(bcolor) $bc]} {
# color change
set param(fcolor) "$fc"
set param(bcolor) "$bc"
tk_setPalette foreground "$fc" background "$bc"
left configure -foreground $param(fcolor)
right configure -foreground $param(fcolor)
up configure -foreground $param(fcolor)
down configure -foreground $param(fcolor)
plus configure -foreground $param(bcolor)
plus configure -background $param(fcolor)
minus configure -foreground $param(bcolor)
minus configure -background $param(fcolor)
if {[winfo depth .] > 1} { # Color display
# other background color for result text
set cols [shadeColor $param(fcolor) $param(bcolor)]
set param(shadedcolor) [lindex $cols 0]
set param(highcolor) [lindex $cols 1]
set param(errcolor) [lindex $cols 2]
set param(hicolor) [lindex $cols 3]
.result.text configure -selectbackground $param(fcolor) -selectforeground $param(bcolor)
.search.s.entry configure -selectbackground $param(fcolor) -selectforeground $param(bcolor)
.result.text tag configure bg1 -background $param(shadedcolor)
.result.text tag configure matchfg -foreground $param(highcolor)
.result.text tag configure search -background $param(highcolor) -foreground $param(bcolor)
.result.text tag configure u -background $param(fcolor) \
-foreground $param(bcolor)
.result.text tag configure hilite -background $param(hicolor)
setSearchBg $param(shadedcolor)
}
if {($curhistory <= 0) || ([string length $query] == 0 && ! $mini)} {
welcome 1
}
}
if {$param(win_prop) == 2 && $param(autominDelay) > 0} {
set param(do_automin) 1
}
if {$changes_restart == 1} {
tk_messageBox -icon info -type ok -parent .general -message \
[set s($lang)(changes_later)]
}
if {$param(autosave) != 0} {
saveOptions
}
destroy .general
}
button .general.buttons.st -text [set s($lang)(default)] -command {
set lang $default(language)
set llabel $languages($lang)
set fc $default(fcolor)
set bc $default(bcolor)
.general.c.fl configure -background $fc
.general.c.bl configure -background $bc
set ffamily [lindex $default(tfont) 0]
set fsize [lindex $default(tfont) 1]
set lffamily [lindex $default(lfont) 0]
set lfsize [lindex $default(lfont) 1]
set param(showBalloons) $default(showBalloons)
set param(balloonDelay) $default(balloonDelay)
set param(autosearch) $default(autosearch)
set param(autosearchDelay) $default(autosearchDelay)
set param(win_prop) $default(win_prop)
set param(autominDelay) $default(autominDelay)
set param(hilite) $default(hilite)
set param(raise) $default(raise)
set param(maxhistory) $default(maxhistory)
set param(autosave) $default(autosave)
}
button .general.buttons.cancel -text [set s($lang)(cancel)] \
-command "destroy .general"
pack .general.buttons.ok .general.buttons.st .general.buttons.cancel \
-side left -expand 1 -pady 8 -padx 8
# language
frame .general.l -bd 2 -relief groove
pack .general.l -side top -fill x -ipady 10
label .general.l.l -text "[set s($lang)(lang)]:" -font lfont
variable llabel
set llabel $languages($lang)
menubutton .general.l.m -textvariable llabel -menu .general.l.m.m \
-indicatoron 1 -relief raised -anchor c -direction flush \
-font lfont -width 13
menu .general.l.m.m -font lfont -tearoff 0
foreach i [array names languages] {
.general.l.m.m add command -label $languages($i) -font lfont \
-command "set ll $i; set llabel $languages($i)"
}
grid .general.l.l -in .general.l -row 0 -column 0 -rowspan 1 -sticky e \
-padx 4 -pady 4
grid .general.l.m -in .general.l -row 0 -column 1 -rowspan 1 -sticky w \
-padx 4 -pady 4
# colors
frame .general.c -bd 2 -relief groove
pack .general.c -side top -fill x -ipady 10 -pady 10
button .general.c.fb -text [set s($lang)(fg)] -width 18 -font lfont \
-command {
set fc [selectColor .general $fc fg]
raise .general
if [string compare $fc ""] {
.general.c.fl configure -background $fc
}
}
button .general.c.bb -text [set s($lang)(bg)] -width 18 -font lfont \
-command {
set bc [selectColor .general $bc bg]
raise .general
if [string compare $bc ""] {
.general.c.bl configure -background $bc
}
}
label .general.c.fl -background $fc -width 13 -relief groove
label .general.c.bl -background $bc -width 13 -relief groove
button .general.c.flip -text [set s($lang)(change)] -font lfont \
-command { set obc $bc; set bc $fc; set fc $obc;
.general.c.fl configure -background $fc
.general.c.bl configure -background $bc
}
grid .general.c.fb -in .general.c -row 0 -column 0 -sticky e \
-padx 4 -pady 4
grid .general.c.fl -in .general.c -row 0 -column 1 -sticky ew \
-padx 4 -pady 4
grid .general.c.bb -in .general.c -row 1 -column 0 -sticky e \
-padx 4 -pady 4
grid .general.c.bl -in .general.c -row 1 -column 1 -sticky ew \
-padx 4 -pady 4
grid .general.c.flip -in .general.c -row 0 -column 2 -rowspan 2 -sticky e \
-padx 4 -pady 4
# Fonts
# frame .general.f -bd 2 -relief groove
pack .general.c -side top -fill x -ipady 10 -pady 10
label .general.c.l -text "[set s($lang)(tfont)]: " -font lfont
label .general.c.l2 -text "[set s($lang)(lfont)]: " -font lfont
menubutton .general.c.f -textvariable ffamily -menu .general.c.f.m \
-indicatoron 1 -relief raised -anchor c -direction flush \
-font lfont -width 13
menu .general.c.f.m -font lfont -tearoff 0
menubutton .general.c.f2 -textvariable lffamily -menu .general.c.f2.m \
-indicatoron 1 -relief raised -anchor c -direction flush \
-font lfont -width 13
menu .general.c.f2.m -font lfont -tearoff 0
set allfams [lsort -unique [font families]]
set found_fonts 0
if {[llength $param(tfonts)] > 0} {
foreach i $param(tfonts) {
foreach f [lsearch -glob -all -inline $allfams $i] {
# if {[lsearch $allfams [string tolower $i]] != -1}
.general.c.f.m add command -label $f -font lfont \
-command "set ffamily {$f}"
.general.c.f2.m add command -label $f -font lfont \
-command "set lffamily {$f}"
incr found_fonts
debug 8 "adding font $f"
}
}
}
if {$found_fonts < 3} { # use all available fonts
foreach i $allfams {
.general.c.f.m add command -label $i -font lfont \
-command "set ffamily {$i}"
.general.c.f2.m add command -label $i -font lfont \
-command "set lffamily {$i}"
}
}
menubutton .general.c.s -textvariable fsize -menu .general.c.s.m \
-indicatoron 1 -relief raised -anchor c -direction flush \
-font lfont -width 4
menu .general.c.s.m -font lfont -tearoff 0
menubutton .general.c.s2 -textvariable lfsize -menu .general.c.s2.m \
-indicatoron 1 -relief raised -anchor c -direction flush \
-font lfont -width 4
menu .general.c.s2.m -font lfont -tearoff 0
foreach i {7 8 10 12 14 15 16 18 24} {
.general.c.s.m add command -label "$i" -font lfont \
-command "set fsize \"$i\""
.general.c.s2.m add command -label "$i" -font lfont \
-command "set lfsize \"$i\""
}
grid .general.c.l -in .general.c -row 2 -column 0 -sticky e \
-padx 4 -pady 4
grid .general.c.f -in .general.c -row 2 -column 1 -sticky w \
-padx 4 -pady 4
grid .general.c.s -in .general.c -row 2 -column 2 -sticky w \
-padx 4 -pady 4
grid .general.c.l2 -in .general.c -row 3 -column 0 -sticky e \
-padx 4 -pady 4
grid .general.c.f2 -in .general.c -row 3 -column 1 -sticky w \
-padx 4 -pady 4
grid .general.c.s2 -in .general.c -row 3 -column 2 -sticky w \
-padx 4 -pady 4
# History, Balloon help, search behavior, autosave
frame .general.b -bd 2 -relief groove
pack .general.b -side top -fill x -ipady 10
label .general.b.hl -text "[set s($lang)(maxhistory)]:" -font lfont
entry .general.b.he -justify right -width 5 -font lfont \
-textvariable param(maxhistory)
checkbutton .general.b.help -text [set s($lang)(balloon)] -font lfont \
-variable param(showBalloons) -command {
if {$param(showBalloons) == 1} {
.general.b.e configure -state normal
.general.b.l1 configure -state normal
.general.b.l2 configure -state normal
} else {
.general.b.e configure -state disabled
.general.b.l1 configure -state disabled
.general.b.l2 configure -state disabled
}
}
label .general.b.l1 -text [set s($lang)(after)] -font lfont
entry .general.b.e -width 5 -textvariable param(balloonDelay) \
-font lfont -justify right
label .general.b.l2 -text [set s($lang)(ms)] -font lfont
# Autosearch:
checkbutton .general.b.autosearch -text [set s($lang)(autosearch)] -font lfont \
-variable param(autosearch) -command {
if {$param(autosearch) == 1} {
.general.b.autosearche configure -state normal
.general.b.autosearchl1 configure -state normal
.general.b.autosearchl2 configure -state normal
} else {
.general.b.autosearche configure -state disabled
.general.b.autosearchl1 configure -state disabled
.general.b.autosearchl2 configure -state disabled
}
}
set state [expr {$param(autosearch) == 1 ? {normal} : {disabled}}]
label .general.b.autosearchl1 -text [set s($lang)(after)] -font lfont \
-state $state
entry .general.b.autosearche -width 5 -textvariable param(autosearchDelay) \
-font lfont -justify right -state $state
label .general.b.autosearchl2 -text [set s($lang)(ms)] -font lfont \
-state $state
# Autominimize:
checkbutton .general.b.automin -text [set s($lang)(automin)] -font lfont \
-variable param(win_prop) -onvalue 2 -offvalue 0 -command {
if {$param(win_prop) == 2} {
.general.b.automine configure -state normal
.general.b.autominl1 configure -state normal
.general.b.autominl2 configure -state normal
} else {
.general.b.automine configure -state disabled
.general.b.autominl1 configure -state disabled
.general.b.autominl2 configure -state disabled
}
}
set state [expr {$param(win_prop) == 2 ? {normal} : {disabled}}]
label .general.b.autominl1 -text [set s($lang)(after)] -font lfont \
-state $state
entry .general.b.automine -width 5 -textvariable param(autominDelay) \
-font lfont -justify right -state $state
label .general.b.autominl2 -text [set s($lang)(ms)] -font lfont \
-state $state
# Raise window when search done
checkbutton .general.b.raise -text [set s($lang)(raise)] -font lfont \
-variable param(raise)
# Highlight text line when mouse over
checkbutton .general.b.hilite -text [set s($lang)(hilite)] -font lfont \
-variable param(hilite)
# Autosave options
checkbutton .general.b.as -text [set s($lang)(autosave)] -font lfont \
-variable param(autosave)
grid .general.b.hl -in .general.b -row 0 -column 0 -columnspan 2 \
-sticky w -padx 4 -pady 4
grid .general.b.he -in .general.b -row 0 -column 2 \
-sticky e -padx 4 -pady 4
grid .general.b.help -in .general.b -row 1 -column 0 \
-sticky w -padx 4 -pady 4
grid .general.b.l1 -in .general.b -row 1 -column 1 \
-sticky w -padx 4 -pady 4
grid .general.b.e -in .general.b -row 1 -column 2 \
-sticky e -padx 4 -pady 4
grid .general.b.l2 -in .general.b -row 1 -column 3 \
-sticky w -padx 4 -pady 4
grid .general.b.autosearch -in .general.b -row 2 -column 0 \
-sticky w -padx 4 -pady 4
grid .general.b.autosearchl1 -in .general.b -row 2 -column 1 \
-sticky w -padx 4 -pady 4
grid .general.b.autosearche -in .general.b -row 2 -column 2 \
-sticky e -padx 4 -pady 4
grid .general.b.autosearchl2 -in .general.b -row 2 -column 3 \
-sticky w -padx 4 -pady 4
grid .general.b.automin -in .general.b -row 3 -column 0 \
-sticky w -padx 4 -pady 4
grid .general.b.autominl1 -in .general.b -row 3 -column 1 \
-sticky w -padx 4 -pady 4
grid .general.b.automine -in .general.b -row 3 -column 2 \
-sticky e -padx 4 -pady 4
grid .general.b.autominl2 -in .general.b -row 3 -column 3 \
-sticky w -padx 4 -pady 4
grid .general.b.raise -in .general.b -row 4 -column 0 -columnspan 3 \
-sticky w -padx 4 -pady 4
grid .general.b.hilite -in .general.b -row 5 -column 0 -columnspan 3 \
-sticky w -padx 4 -pady 4
grid .general.b.as -in .general.b -row 6 -column 0 -columnspan 3 \
-sticky w -padx 4 -pady 4
} else {
wm deiconify .general
raise .general
}
}
proc selectColor {w color name} {
global s gparam
debug 2 "selectColor $color $name"
set lang $gparam(lang)
grab $w
set color [tk_chooseColor -parent $w -title "[set s($lang)(color)] [set s($lang)($name)]" \
-initialcolor $color]
grab release $w
if [string compare $color ""] {
return $color
}
}
# Save options
proc saveOptions {} {
global opts pinfo
global param gparam
global pinfo env s searchmeth searchmpos
debug 1 "saveOptions"
if {$gparam(noconf) == 1} {
return
}
set lang $gparam(lang)
if {[file readable $param(rcfile)] &&
![file isfile $param(rcfile)]} {
errorBox "$param(rcfile) isn't a regular file!"
return
}
set err [catch "set fd \[open $param(rcfile) w\]"]
if $err {
errorBox "Couldn't open $param(rcfile) for writing!"
return
}
puts $fd "# Options for $pinfo(pname) - do not edit!"
puts $fd "# General options"
puts $fd "set ding_version {$pinfo(version)}"
puts $fd "set param(autosave) {$param(autosave)}"
puts $fd "set param(hilite) {$param(hilite)}"
puts $fd "set param(raise) {$param(raise)}"
puts $fd "set gparam(lang) {$lang}"
puts $fd "set param(showBalloons) {$param(showBalloons)}"
puts $fd "set param(balloonDelay) {$param(balloonDelay)}"
puts $fd "set param(autosearch) {$param(autosearch)}"
puts $fd "set param(autosearchDelay) {$param(autosearchDelay)}"
# puts $fd "set param(automin) {$param(automin)}"
puts $fd "set param(autominDelay) {$param(autominDelay)}"
puts $fd "set param(params_as_menu) {$param(params_as_menu)}"
puts $fd "set param(show_menu) {$param(show_menu)}"
puts $fd "set param(umlaut_buttons) {$param(umlaut_buttons)}"
puts $fd "set param(show_result) {$param(show_result)}"
puts $fd "set param(show_status) {$param(show_status)}"
puts $fd "set param(fcolor) {$param(fcolor)}"
puts $fd "set param(bcolor) {$param(bcolor)}"
puts $fd "set param(lfont) {$param(lfont)}"
puts $fd "set param(bfont) {$param(bfont)}"
puts $fd "set param(sfont) {$param(sfont)}"
puts $fd "set param(tfont) {$param(tfont)}"
puts $fd "set param(ifont) {$param(ifont)}"
puts $fd "set param(maxhistory) {$param(maxhistory)}"
puts $fd "set param(width) {$param(width)}"
puts $fd "set param(height) {$param(height)}"
puts $fd "set param(search_prop) {$param(search_prop)}"
puts $fd "set param(win_prop) {$param(win_prop)}"
puts $fd "set opts(word) {$opts(word)}"
puts $fd "set opts(case) {$opts(case)}"
puts $fd "set opts(errors) {$opts(errors)}"
puts $fd "set opts(regex) {$opts(regex)}"
puts $fd "\n# Dictionaries and search methods"
set n 0
set so ""
foreach i $searchmpos {
set so "$so $n"
incr n
}
puts $fd "set searchmpos {$so}"
set n 0
foreach i $searchmpos {
puts $fd "set searchmeth($n,name) {$searchmeth($i,name)}"
puts $fd "set searchmeth($n,type) {$searchmeth($i,type)}"
puts $fd "set searchmeth($n,dictfile) {$searchmeth($i,dictfile)}"
puts $fd "set searchmeth($n,separator) {$searchmeth($i,separator)}"
puts $fd "set searchmeth($n,language1) {$searchmeth($i,language1)}"
puts $fd "set searchmeth($n,language2) {$searchmeth($i,language2)}"
puts $fd "set searchmeth($n,grepcmd) {$searchmeth($i,grepcmd)}"
puts $fd "set searchmeth($n,grepopts) {$searchmeth($i,grepopts)}"
puts $fd "set searchmeth($n,maxlength) {$searchmeth($i,maxlength)}"
puts $fd "set searchmeth($n,maxresults) {$searchmeth($i,maxresults)}"
puts $fd "set searchmeth($n,minlength) {$searchmeth($i,minlength)}"
puts $fd "set searchmeth($n,shapedresult) {$searchmeth($i,shapedresult)}"
puts $fd "set searchmeth($n,foldedresult) {$searchmeth($i,foldedresult)}"
incr n
}
catch {close $fd}
.statusBar.lab configure -foreground $param(fcolor) -text "[set s($lang)(saveopts)] ok"
}
# History function
proc history {where} {
global curhistory inshistory history_query history_result history_pos
global param gparam s
debug 1 "history $where"
set lang $gparam(lang)
set len [array size history_result]
if ![string compare $where "back"] { # back
if {$curhistory == 0} {
set curhistory $inshistory
}
debug 8 "history: back: max $param(maxhistory) cur $curhistory ins $inshistory len $len"
if {($curhistory <= 0) ||
($curhistory == 1 && $len < $param(maxhistory)) ||
($curhistory == 1 && $inshistory == $param(maxhistory)) ||
($curhistory == [expr $inshistory + 1])} {
# no more history entries
.statusBar.lab config -foreground $param(fcolor) \
-text [set s($lang)(noback)]
return
}
# mark the current scroll position
#set history_pos($curhistory) [lindex [.result.text yview] 0]
set history_pos($curhistory) [.result.text index @0,0]
if {$curhistory == 1} {
set curhistory $param(maxhistory)
} else {
set curhistory [expr $curhistory - 1]
}
display $curhistory "" 2 ""
if {($curhistory == 1 && ($len < $param(maxhistory) || $inshistory == $param(maxhistory))) ||
($inshistory == [expr $curhistory - 1])} {
.search.s.back configure -state disabled
.popup entryconfigure 0 -state disabled
}
.search.s.forw configure -state normal
.popup entryconfigure 1 -state normal
} else { # forward
debug 8 "history: forw: max $param(maxhistory) cur $curhistory ins $inshistory len $len"
if {($curhistory <= 0) || ($len < $curhistory) ||
($len == $curhistory && $len < $param(maxhistory)) ||
($curhistory == $inshistory)} {
# no more history entries
.statusBar.lab config -foreground $param(fcolor) \
-text [set s($lang)(noforw)]
return
}
# mark the current scroll position
#set history_pos($curhistory) [lindex [.result.text yview] 0]
set history_pos($curhistory) [.result.text index @0,0]
if {$curhistory == $param(maxhistory)} {
set curhistory 1
} else {
incr curhistory
}
display $curhistory "" 2 ""
if {($curhistory >= $param(maxhistory) && $param(maxhistory) < $len) ||
$curhistory == $inshistory} {
.search.s.forw configure -state disabled
.popup entryconfigure 1 -state disabled
}
.search.s.back configure -state normal
.popup entryconfigure 0 -state normal
}
}
proc sendMail {} {
global param gparam pinfo s
debug 1 "sendMail"
set lang $gparam(lang)
variable subject "$pinfo(pname) $pinfo(version): "
variable nf $param(noticefile)
if {! $param(isunix)} {
# don't know how to send mail on Non-Unix ...
tk_messageBox -icon error -type ok -parent . -message \
"[set s($lang)(nomail)] $pinfo(author)"
return
}
if ![winfo exists .mail] {
toplevel .mail
wm group .mail .
wm title .mail "[set s($lang)(mailtitle)] $pinfo(author)"
wm resizable .mail 0 0
placeWin .mail 50
frame .mail.buttons
button .mail.buttons.ok -text [set s($lang)(send)] -width 15 -command {
set text [.mail.t.text get 1.0 end]
if {[string length $text] <= 3} {
tk_messageBox -icon warning -type ok -parent .mail -message \
[set s($lang)(notext)]
return
}
catch {set fd [open "|mail -s \"$subject\" $pinfo(authormail)" w]} em
if ![info exists fd] {
catch {set fd [open "|mail $pinfo(authormail)" w]} em
}
if ![info exists fd] {
tk_messageBox -icon error -type ok -parent .mail -message \
[set s($lang)(notext)]
} else {
puts -nonewline $fd $text
close $fd
.statusBar.lab config -foreground $param(fcolor) \
-text "[set s($lang)(send)] ok."
}
destroy .mail
}
button .mail.buttons.cancel -text [set s($lang)(cancel)] -width 15 \
-command {destroy .mail}
pack .mail.buttons -side bottom -expand 1 -padx 8 -pady 8
pack .mail.buttons.ok .mail.buttons.cancel -side left -padx 8
frame .mail.s
label .mail.s.label -text "Subject: " -font bfont
entry .mail.s.subject -bg $param(shadedcolor) -textvariable subject \
-relief flat -font lfont
label .mail.s.flabel -text "[set s($lang)(file)]: " -font bfont
entry .mail.s.fname -bg $param(shadedcolor) -font lfont \
-textvariable nf -relief flat
variable types {
{"Text files" {.txt .vok .dic}}
{"All files" *}
}
button .mail.s.fb -font lfont -text "[set s($lang)(attachnotice)] ..." \
-relief raised -command {
if [string compare $nf ""] {
set err [catch "set fd \[open $nf r\]"]
if {! $err} {
.mail.t.text insert end [read $fd]
close $fd
}
}
}
pack .mail.s -side top -fill x -expand 1 -padx 8 -pady 8
grid columnconfig .mail.s 1 -weight 1
grid .mail.s.label -row 0 -column 0 -sticky e
grid .mail.s.subject -row 0 -column 1 -sticky news
# grid x -in .mail.s
grid .mail.s.flabel -row 1 -column 0 -sticky e
grid .mail.s.fname -row 1 -column 1 -sticky news
grid .mail.s.fb -in .mail.s -row 1 -column 2 -sticky w -padx 4
# pack .mail.s.label -side left
# pack .mail.s.subject -side left -fill x -expand 1
frame .mail.t
text .mail.t.text -wrap word -width 70 -height 15 \
-relief flat -bg $param(shadedcolor) \
-yscrollcommand ".mail.t.yscroll set"
scrollbar .mail.t.yscroll -orient vertical \
-command { .mail.t.text yview }
if {$param(isunix)} { # I like smaller scrollbars
.mail.t.yscroll configure -width 10 -bd 1
}
pack .mail.t -fill x -expand 1 -padx 8 -pady 8
pack .mail.t.text .mail.t.yscroll -side left -fill both -expand 1
} else {
wm deiconify .mail
raise .mail
}
}
proc notice {file} {
global param gparam s
debug 1 "notice file"
set lang $gparam(lang)
if ![winfo exists .notice] {
toplevel .notice
wm group .notice .
wm title .notice "[set s($lang)(notice)]"
wm resizable .notice 0 0
placeWin .notice 50
variable nf $file
frame .notice.buttons
button .notice.buttons.ok -text [set s($lang)(save)] -width 15 -command {
set text [.notice.t.text get 1.0 end]
if {[string length $text] <= 0} {
tk_messageBox -icon warning -type ok -parent .notice -message \
[set s($lang)(notext)]
return
}
set err [catch "set fd \[open $nf w\]"]
if $err {
tk_messageBox -icon error -type ok -parent . -message \
"Couldn't open $nf for writing!"
return
} else {
puts -nonewline $fd $text
close $fd
}
set $param(noticefile) $nf
.statusBar.lab config -foreground $param(fcolor) \
-text "[set s($lang)(save)] ok."
destroy .notice
}
button .notice.buttons.cancel -text [set s($lang)(cancel)] -width 15 \
-command {destroy .notice}
pack .notice.buttons -side bottom -expand 1 -padx 8 -pady 8
pack .notice.buttons.ok .notice.buttons.cancel -side left -padx 8
frame .notice.f
label .notice.f.label -text "[set s($lang)(file)]:"
entry .notice.f.name -bg $param(shadedcolor) -font lfont \
-textvariable nf -relief flat
variable types {
{"Text files" {.txt .vok .dic}}
{"All files" *}
}
button .notice.f.b -font lfont -text "Browse ..." \
-command {
set f [tk_getSaveFile -initialdir [file dirname $nf] \
-filetypes $types -parent .notice]
if [string compare $f ""] {
set nf $f
}
}
pack .notice.f -side top -fill x -expand 1 -padx 8 -pady 8
pack .notice.f.label -side left
pack .notice.f.name -side left -fill x -expand 1
pack .notice.f.b -side left
frame .notice.t
text .notice.t.text -wrap word -width 70 -height 15 \
-relief flat -bg $param(shadedcolor) \
-yscrollcommand ".notice.t.yscroll set"
scrollbar .notice.t.yscroll -orient vertical \
-command { .notice.t.text yview }
if {$param(isunix)} { # I like smaller scrollbars
.notice.t.yscroll configure -width 10 -bd 1
}
pack .notice.t -fill x -expand 1 -padx 8 -pady 8
pack .notice.t.text .notice.t.yscroll -side left -fill both -expand 1
set err [catch "set fd \[open $nf r\]"]
if {! $err} {
.notice.t.text insert end [read $fd]
close $fd
}
} else {
wm deiconify .notice
raise .notice
}
focus .notice.t.text
}
proc startNew {} {
global param gparam argv0
set prog "$argv0 --noconf"
debug 1 "new win: $prog"
if [catch {exec $argv0 --noconf &} err] {
.statusBar.lab config -foreground $param(errcolor) -text \
"Error starting $prog: $err"
} else {
.statusBar.lab config -foreground $param(fcolor) -text "$prog started"
}
}
# Invoking browsers
# http://mini.net/cgi-bin/wikit/InvokingBrowsers
proc urlOpen {url} {
global param
switch $::tcl_platform(platform) {
"unix" {
set asciibrowser 0
if {0 == [info exists ::env(BROWSER)]} {
if {[string length [auto_execok firefox]] } {
set ::env(BROWSER) [auto_execok firefox]
} elseif {[string length [auto_execok mozilla]] } {
set ::env(BROWSER) [auto_execok mozilla]
} elseif {[string length [auto_execok opera]] } {
set ::env(BROWSER) [auto_execok opera]
} elseif {[string length [auto_execok galeon]] } {
set ::env(BROWSER) [auto_execok galeon]
} elseif {[string length [auto_execok konqueror]] } {
set ::env(BROWSER) [auto_execok konqueror]
} elseif {[string length [auto_execok netscape]] } {
set ::env(BROWSER) [auto_execok netscape]
} elseif { [ string length [ auto_execok light ] ] } {
set ::env(BROWSER) [ auto_execok light ]
} elseif { [ string length [ auto_execok skipstone ] ] } {
set ::env(BROWSER) [ auto_execok skipstone ]
} elseif { [ string length [ auto_execok dillo ] ] } {
set ::env(BROWSER) [ auto_execok dillo ]
} elseif { [ string length [ auto_execok chimera2 ] ] } {
set ::env(BROWSER) [ auto_execok chimera2 ]
} elseif {[info exists ::env(NETSCAPE)]} {
# Some of us use this envvar instead... - DKF
set ::env(BROWSER) $::env(NETSCAPE)
} elseif {[string length [auto_execok x-terminal-emulator]]} {
set asciibrowser 1
if {[string length [auto_execok w3m]]} {
set ::env(BROWSER) [auto_execok w3m]
} elseif {[string length [auto_execok links]]} {
set ::env(BROWSER) [auto_execok links]
} elseif {[string length [auto_execok lynx]]} {
set ::env(BROWSER) [auto_execok lynx]
}
}
}
if { [info exists ::env(BROWSER)] } {
if {$asciibrowser} {
debug 4 "Invoking [auto_execok x-terminal-emulator] -c $::env(BROWSER) $url"
.statusBar.lab config -foreground $param(fcolor) \
-text "[auto_execok x-terminal-emulator] -c $::env(BROWSER) $url ..."
catch { exec [auto_execok x-terminal-emulator] -c $::env(BROWSER) $url &}
} else {
debug 4 "Invoking $::env(BROWSER) $url"
.statusBar.lab config -foreground $param(fcolor) \
-text "$::env(BROWSER) $url ..."
catch {exec $::env(BROWSER) $url &}
}
} else {
error "No web browser found\n"
}
}
"windows" {
if {$::tcl_platform(os) == "Windows NT"} {
set rc [catch {exec $::env(COMSPEC) /c start $url &} emsg]
} else {
# Windows 95/98
set rc [catch {exec start $url} emsg]
}
if {$rc} {
error "Error displaying $url in browser\n$emsg"
}
}
"macintosh" {
# AppleScript should be able to provide the default browser,
# but I'm not enough of an AppleScript hacker to figure out.
# Help!
if {0 == [info exists ::env(BROWSER)]} {
error "Couldn't find a usable browser. Set env(BROWSER) in your application's preferences file."
}
if {[catch {
AppleScript execute "tell application \"$::env(BROWSER)\"
open url \"$url\"
end tell
"} emsg]
} then {
error "Error displaying $url in browser\n$emsg"
}
}
} ;## end of switch
}
|