My favorites | Sign in
Project Home Issues Source
Checkout   Browse   Changes  
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
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
using System;
using System.Collections;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using ScintillaNet.Configuration;
using System.Drawing.Printing;
using PluginCore.FRService;
using PluginCore.Utilities;
using PluginCore.Managers;
using System.Drawing;
using System.Text;

namespace ScintillaNet
{
public class ScintillaControl : Control
{
private bool saveBOM;
private Encoding encoding;
private int directPointer;
private IntPtr hwndScintilla;
private bool hasHighlights = false;
private bool ignoreAllKeys = false;
private bool isBraceMatching = true;
private bool isHiliteSelected = true;
private bool useHighlightGuides = true;
private static Scintilla sciConfiguration = null;
private Enums.SmartIndent smartIndent = Enums.SmartIndent.CPP;
private Hashtable ignoredKeys = new Hashtable();
private string configLanguage = String.Empty;
private string fileName = String.Empty;

#region Scintilla Main

public ScintillaControl() : this("SciLexer.dll")
{
DragAcceptFiles(this.Handle, 1);
}

public ScintillaControl(string fullpath)
{
try
{
IntPtr lib = WinAPI.LoadLibrary(fullpath);
hwndScintilla = WinAPI.CreateWindowEx(0, "Scintilla", "", WS_CHILD_VISIBLE_TABSTOP, 0, 0, this.Width, this.Height, this.Handle, 0, new IntPtr(0), null);
directPointer = (int)SlowPerform(2185, 0, 0);
UpdateUI += new UpdateUIHandler(OnBraceMatch);
UpdateUI += new UpdateUIHandler(OnCancelHighlight);
DoubleClick += new DoubleClickHandler(OnBlockSelect);
DoubleClick += new DoubleClickHandler(OnSelectHighlight);
CharAdded += new CharAddedHandler(OnSmartIndent);
Resize += new EventHandler(OnResize);
directPointer = DirectPointer;
}
catch (Exception ex)
{
throw ex;
}
}

public void OnResize(object sender, EventArgs e)
{
SetWindowPos(this.hwndScintilla, 0, this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width, this.ClientRectangle.Height, 0);
}

public override bool PreProcessMessage(ref Message m)
{
switch (m.Msg)
{
case WM_KEYDOWN:
{
if (!IsFocus || ignoreAllKeys || ignoredKeys.ContainsKey((Int32)Control.ModifierKeys + (Int32)m.WParam))
{
if (base.PreProcessMessage(ref m)) return true;
}
if (((Control.ModifierKeys & Keys.Control) != 0) && ((Control.ModifierKeys & Keys.Alt) == 0))
{
Int32 code = (Int32)m.WParam;
if ((code >= 65) && (code <= 90)) return true; // Eat non-writable characters
else if ((code == 9) || (code == 33) || (code == 34)) // Transmit Ctrl with Tab, PageUp/PageDown
{
return base.PreProcessMessage(ref m);
}
}
break;
}
case WM_SYSKEYDOWN:
{
return base.PreProcessMessage(ref m);
}
case WM_SYSCHAR:
{
return base.PreProcessMessage(ref m);
}
}
return false;
}

#endregion

#region Scintilla Event Members

public event KeyHandler Key;
public event ZoomHandler Zoom;
public event FocusHandler FocusChanged;
public event StyleNeededHandler StyleNeeded;
public event CharAddedHandler CharAdded;
public event SavePointReachedHandler SavePointReached;
public event SavePointLeftHandler SavePointLeft;
public event ModifyAttemptROHandler ModifyAttemptRO;
public event UpdateUIHandler UpdateUI;
public event ModifiedHandler Modified;
public event MacroRecordHandler MacroRecord;
public event MarginClickHandler MarginClick;
public event NeedShownHandler NeedShown;
public event PaintedHandler Painted;
public event UserListSelectionHandler UserListSelection;
public event URIDroppedHandler URIDropped;
public event DwellStartHandler DwellStart;
public event DwellEndHandler DwellEnd;
public event HotSpotClickHandler HotSpotClick;
public event HotSpotDoubleClickHandler HotSpotDoubleClick;
public event CallTipClickHandler CallTipClick;
public event AutoCSelectionHandler AutoCSelection;
public event TextInsertedHandler TextInserted;
public event TextDeletedHandler TextDeleted;
public event FoldChangedHandler FoldChanged;
public event UserPerformedHandler UserPerformed;
public event UndoPerformedHandler UndoPerformed;
public event RedoPerformedHandler RedoPerformed;
public event LastStepInUndoRedoHandler LastStepInUndoRedo;
public event MarkerChangedHandler MarkerChanged;
public event BeforeInsertHandler BeforeInsert;
public event BeforeDeleteHandler BeforeDelete;
public event SmartIndentHandler SmartIndent;
public new event StyleChangedHandler StyleChanged;
public new event DoubleClickHandler DoubleClick;
public event IndicatorClickHandler IndicatorClick;
public event IndicatorReleaseHandler IndicatorRelease;
public event AutoCCancelledHandler AutoCCancelled;
public event AutoCCharDeletedHandler AutoCCharDeleted;

#endregion

#region Scintilla Properties

/// <summary>
/// Current used configuration
/// </summary>
static public Scintilla Configuration
{
get
{
return sciConfiguration;
}
set
{
sciConfiguration = value;
}
}

/// <summary>
/// Current configuration language
/// </summary>
public string ConfigurationLanguage
{
get
{
return this.configLanguage;
}
set
{
if (value == null || value.Equals("")) return;
Language lang = sciConfiguration.GetLanguage(value);
if (lang == null) return;
StyleClearAll();
try
{
lang.lexer.key = (int)Enum.Parse(typeof(Enums.Lexer), lang.lexer.name, true);
}
catch { /* If not found, uses the lang.lexer.key directly. */ }
this.configLanguage = value;
Lexer = lang.lexer.key;
if (lang.lexer.stylebits > 0) StyleBits = lang.lexer.stylebits;
if (lang.editorstyle != null)
{
EdgeColour = lang.editorstyle.PrintMarginColor;
CaretFore = lang.editorstyle.CaretForegroundColor;
CaretLineBack = lang.editorstyle.CaretLineBackgroundColor;
SetSelBack(true, lang.editorstyle.SelectionBackgroundColor);
SetSelFore(true, lang.editorstyle.SelectionForegroundColor);
SetFoldMarginHiColour(true, lang.editorstyle.MarginForegroundColor);
SetFoldMarginColour(true, lang.editorstyle.MarginBackgroundColor);
Int32 markerForegroundColor = lang.editorstyle.MarkerForegroundColor;
Int32 markerBackgroundColor = lang.editorstyle.MarkerBackgroundColor;
MarkerSetBack((Int32)ScintillaNet.Enums.MarkerOutline.Folder, markerBackgroundColor);
MarkerSetFore((Int32)ScintillaNet.Enums.MarkerOutline.Folder, markerForegroundColor);
MarkerSetBack((Int32)ScintillaNet.Enums.MarkerOutline.FolderOpen, markerBackgroundColor);
MarkerSetFore((Int32)ScintillaNet.Enums.MarkerOutline.FolderOpen, markerForegroundColor);
MarkerSetBack((Int32)ScintillaNet.Enums.MarkerOutline.FolderSub, markerBackgroundColor);
MarkerSetFore((Int32)ScintillaNet.Enums.MarkerOutline.FolderSub, markerForegroundColor);
MarkerSetBack((Int32)ScintillaNet.Enums.MarkerOutline.FolderTail, markerBackgroundColor);
MarkerSetFore((Int32)ScintillaNet.Enums.MarkerOutline.FolderTail, markerForegroundColor);
MarkerSetBack((Int32)ScintillaNet.Enums.MarkerOutline.FolderEnd, markerBackgroundColor);
MarkerSetFore((Int32)ScintillaNet.Enums.MarkerOutline.FolderEnd, markerForegroundColor);
MarkerSetBack((Int32)ScintillaNet.Enums.MarkerOutline.FolderOpenMid, markerBackgroundColor);
MarkerSetFore((Int32)ScintillaNet.Enums.MarkerOutline.FolderOpenMid, markerForegroundColor);
MarkerSetBack((Int32)ScintillaNet.Enums.MarkerOutline.FolderMidTail, markerBackgroundColor);
MarkerSetFore((Int32)ScintillaNet.Enums.MarkerOutline.FolderMidTail, markerForegroundColor);
MarkerSetBack(0, lang.editorstyle.BookmarkLineColor);
MarkerSetBack(2, lang.editorstyle.ModifiedLineColor);
}
if (lang.characterclass != null)
{
WordChars(lang.characterclass.Characters);
}
for (int j = 0; j < lang.usestyles.Length; j++)
{
UseStyle usestyle = lang.usestyles[j];
if (usestyle.key == 0)
{
System.Type theType = null;
switch ((Enums.Lexer)lang.lexer.key)
{
case Enums.Lexer.PYTHON:
theType = typeof(Lexers.PYTHON);
break;
case Enums.Lexer.CPP:
theType = typeof(Lexers.CPP);
break;
case Enums.Lexer.HTML:
theType = typeof(Lexers.HTML);
break;
case Enums.Lexer.XML:
theType = typeof(Lexers.XML);
break;
case Enums.Lexer.PERL:
theType = typeof(Lexers.PERL);
break;
case Enums.Lexer.SQL:
theType = typeof(Lexers.SQL);
break;
case Enums.Lexer.VB:
theType = typeof(Lexers.VB);
break;
case Enums.Lexer.PROPERTIES:
theType = typeof(Lexers.PROPERTIES);
break;
case Enums.Lexer.ERRORLIST:
theType = typeof(Lexers.ERRORLIST);
break;
case Enums.Lexer.MAKEFILE:
theType = typeof(Lexers.MAKEFILE);
break;
case Enums.Lexer.BATCH:
theType = typeof(Lexers.BATCH);
break;
case Enums.Lexer.LATEX:
theType = typeof(Lexers.LATEX);
break;
case Enums.Lexer.LUA:
theType = typeof(Lexers.LUA);
break;
case Enums.Lexer.DIFF:
theType = typeof(Lexers.DIFF);
break;
case Enums.Lexer.CONF:
theType = typeof(Lexers.CONF);
break;
case Enums.Lexer.PASCAL:
theType = typeof(Lexers.PASCAL);
break;
case Enums.Lexer.AVE:
theType = typeof(Lexers.AVE);
break;
case Enums.Lexer.ADA:
theType = typeof(Lexers.ADA);
break;
case Enums.Lexer.LISP:
theType = typeof(Lexers.LISP);
break;
case Enums.Lexer.RUBY:
theType = typeof(Lexers.RUBY);
break;
case Enums.Lexer.EIFFEL:
theType = typeof(Lexers.EIFFEL);
break;
case Enums.Lexer.EIFFELKW:
theType = typeof(Lexers.EIFFELKW);
break;
case Enums.Lexer.TCL:
theType = typeof(Lexers.TCL);
break;
case Enums.Lexer.NNCRONTAB:
theType = typeof(Lexers.NNCRONTAB);
break;
case Enums.Lexer.BULLANT:
theType = typeof(Lexers.BULLANT);
break;
case Enums.Lexer.VBSCRIPT:
theType = typeof(Lexers.VBSCRIPT);
break;
case Enums.Lexer.BAAN:
theType = typeof(Lexers.BAAN);
break;
case Enums.Lexer.MATLAB:
theType = typeof(Lexers.MATLAB);
break;
case Enums.Lexer.SCRIPTOL:
theType = typeof(Lexers.SCRIPTOL);
break;
case Enums.Lexer.ASM:
theType = typeof(Lexers.ASM);
break;
case Enums.Lexer.FORTRAN:
theType = typeof(Lexers.FORTRAN);
break;
case Enums.Lexer.F77:
theType = typeof(Lexers.F77);
break;
case Enums.Lexer.CSS:
theType = typeof(Lexers.CSS);
break;
case Enums.Lexer.POV:
theType = typeof(Lexers.POV);
break;
case Enums.Lexer.LOUT:
theType = typeof(Lexers.LOUT);
break;
case Enums.Lexer.ESCRIPT:
theType = typeof(Lexers.ESCRIPT);
break;
case Enums.Lexer.PS:
theType = typeof(Lexers.PS);
break;
case Enums.Lexer.NSIS:
theType = typeof(Lexers.NSIS);
break;
case Enums.Lexer.MMIXAL:
theType = typeof(Lexers.MMIXAL);
break;
case Enums.Lexer.LOT:
theType = typeof(Lexers.LOT);
break;
case Enums.Lexer.YAML:
theType = typeof(Lexers.YAML);
break;
case Enums.Lexer.TEX:
theType = typeof(Lexers.TEX);
break;
case Enums.Lexer.METAPOST:
theType = typeof(Lexers.METAPOST);
break;
case Enums.Lexer.POWERBASIC:
theType = typeof(Lexers.POWERBASIC);
break;
case Enums.Lexer.FORTH:
theType = typeof(Lexers.FORTH);
break;
case Enums.Lexer.ERLANG:
theType = typeof(Lexers.ERLANG);
break;
case Enums.Lexer.OCTAVE:
theType = typeof(Lexers.OCTAVE);
break;
case Enums.Lexer.MSSQL:
theType = typeof(Lexers.MSSQL);
break;
case Enums.Lexer.VERILOG:
theType = typeof(Lexers.VERILOG);
break;
case Enums.Lexer.KIX:
theType = typeof(Lexers.KIX);
break;
case Enums.Lexer.GUI4CLI:
theType = typeof(Lexers.GUI4CLI);
break;
case Enums.Lexer.SPECMAN:
theType = typeof(Lexers.SPECMAN);
break;
case Enums.Lexer.AU3:
theType = typeof(Lexers.AU3);
break;
case Enums.Lexer.APDL:
theType = typeof(Lexers.APDL);
break;
case Enums.Lexer.BASH:
theType = typeof(Lexers.BASH);
break;
case Enums.Lexer.ASN1:
theType = typeof(Lexers.ASN1);
break;
case Enums.Lexer.VHDL:
theType = typeof(Lexers.VHDL);
break;
case Enums.Lexer.CAML:
theType = typeof(Lexers.CAML);
break;
case Enums.Lexer.HASKELL:
theType = typeof(Lexers.HASKELL);
break;
case Enums.Lexer.TADS3:
theType = typeof(Lexers.TADS3);
break;
case Enums.Lexer.REBOL:
theType = typeof(Lexers.REBOL);
break;
case Enums.Lexer.SMALLTALK:
theType = typeof(Lexers.SMALLTALK);
break;
case Enums.Lexer.FLAGSHIP:
theType = typeof(Lexers.FLAGSHIP);
break;
case Enums.Lexer.CSOUND:
theType = typeof(Lexers.CSOUND);
break;
case Enums.Lexer.INNOSETUP:
theType = typeof(Lexers.INNOSETUP);
break;
case Enums.Lexer.OPAL:
theType = typeof(Lexers.OPAL);
break;
case Enums.Lexer.SPICE:
theType = typeof(Lexers.SPICE);
break;
case Enums.Lexer.D:
theType = typeof(Lexers.D);
break;
case Enums.Lexer.CMAKE:
theType = typeof(Lexers.CMAKE);
break;
case Enums.Lexer.GAP:
theType = typeof(Lexers.GAP);
break;
case Enums.Lexer.PLM:
theType = typeof(Lexers.PLM);
break;
case Enums.Lexer.PROGRESS:
theType = typeof(Lexers.PROGRESS);
break;
case Enums.Lexer.ABAQUS:
theType = typeof(Lexers.ABAQUS);
break;
case Enums.Lexer.ASYMPTOTE:
theType = typeof(Lexers.ASYMPTOTE);
break;
case Enums.Lexer.R:
theType = typeof(Lexers.R);
break;
case Enums.Lexer.MAGIK:
theType = typeof(Lexers.MAGIK);
break;
case Enums.Lexer.POWERSHELL:
theType = typeof(Lexers.POWERSHELL);
break;
case Enums.Lexer.MYSQL:
theType = typeof(Lexers.MYSQL);
break;
case Enums.Lexer.PO:
theType = typeof(Lexers.PO);
break;
case Enums.Lexer.SORCUS:
theType = typeof(Lexers.SORCUS);
break;
case Enums.Lexer.POWERPRO:
theType = typeof(Lexers.POWERPRO);
break;
case Enums.Lexer.NIMROD:
theType = typeof(Lexers.NIMROD);
break;
case Enums.Lexer.SML:
theType = typeof(Lexers.SML);
break;
}
try
{
usestyle.key = (int)Enum.Parse(theType, usestyle.name, true);
}
catch (Exception ex)
{
String info;
if (theType == null)
{
info = String.Format("Lexer '{0}' ({1}) unknown.", lang.lexer.name, lang.lexer.key);
ErrorManager.ShowWarning(info, ex);
break;
}
else
{
info = String.Format("Style '{0}' in syntax file is not used by lexer '{1}'.", usestyle.name, theType.Name);
ErrorManager.ShowWarning(info, ex);
}
}
}
if (usestyle.HasForegroundColor) StyleSetFore(usestyle.key, usestyle.ForegroundColor);
if (usestyle.HasBackgroundColor) StyleSetBack(usestyle.key, usestyle.BackgroundColor);
if (usestyle.HasFontName) StyleSetFont(usestyle.key, usestyle.FontName);
if (usestyle.HasFontSize) StyleSetSize(usestyle.key, usestyle.FontSize);
if (usestyle.HasBold) StyleSetBold(usestyle.key, usestyle.IsBold);
if (usestyle.HasItalics) StyleSetItalic(usestyle.key, usestyle.IsItalics);
if (usestyle.HasEolFilled) StyleSetEOLFilled(usestyle.key, usestyle.IsEolFilled);
}
// Clear the keywords lists
for (int j = 0; j < 9; j++) KeyWords(j, "");
for (int j = 0; j < lang.usekeywords.Length; j++)
{
UseKeyword usekeyword = lang.usekeywords[j];
KeywordClass kc = sciConfiguration.GetKeywordClass(usekeyword.cls);
if (kc != null) KeyWords(usekeyword.key, kc.val);
}
}
}

/// <summary>
/// Texts in the control
/// </summary>
public override string Text
{
get
{
return GetText(Length);
}
set
{
SetText(value);
}
}

/// <summary>
/// Filename of the editable document
/// </summary>
public string FileName
{
get
{
return fileName;
}
set
{
fileName = value;
}
}

/// <summary>
/// Is the control focused?
/// </summary>
public override bool Focused
{
get
{
return IsFocus;
}
}

/// <summary>
/// Should we ignore recieved keys?
/// </summary>
public bool IgnoreAllKeys
{
get
{
return ignoreAllKeys;
}
set
{
ignoreAllKeys = value;
}
}

/// <summary>
/// Enables the selected word highlighting.
/// </summary>
public bool IsHiliteSelected
{
get
{
return isHiliteSelected;
}
set
{
isHiliteSelected = value;
}
}

/// <summary>
/// Enables the brace matching from current position.
/// </summary>
public bool IsBraceMatching
{
get
{
return isBraceMatching;
}
set
{
isBraceMatching = value;
}
}

/// <summary>
/// Enables the highlight guides from current position.
/// </summary>
public bool UseHighlightGuides
{
get
{
return useHighlightGuides;
}
set
{
useHighlightGuides = value;
}
}

/// <summary>
/// Enables the Smart Indenter so that On enter, it indents the next line.
/// </summary>
public Enums.SmartIndent SmartIndentType
{
get
{
return smartIndent;
}
set
{
smartIndent = value;
}
}

/// <summary>
/// Are white space characters currently visible?
/// Returns one of Enums.WhiteSpace constants.
/// </summary>
public Enums.WhiteSpace ViewWhitespace
{
get
{
return (Enums.WhiteSpace)ViewWS;
}
set
{
ViewWS = (int)value;
}
}

/// <summary>
/// Get or sets the background alpha of the caret line.
/// </summary>
public int CaretLineBackAlpha
{
get
{
return (int)SPerform(2471, 0, 0);
}
set
{
SPerform(2470, (uint)value, 0);
}
}

/// <summary>
/// Get or sets the background alpha of the caret line.
/// </summary>
public int CaretStyle
{
get
{
return (int)SPerform(2513, 0, 0);
}
set
{
SPerform(2512, (uint)value, 0);
}
}

/// <summary>
/// Sets or gets the indicator used for IndicatorFillRange and IndicatorClearRange
/// </summary>
public int CurrentIndicator
{
get
{
return (int)SPerform(2501, 0, 0);
}
set
{
SPerform(2500, (uint)value, 0);
}
}

/// <summary>
/// Gets or sets the number of entries in position cache.
/// </summary>
public int PositionCache
{
get
{
return (int)SPerform(2515, 0, 0);
}
set
{
SPerform(2514, (uint)value, 0);
}
}

/// <summary>
/// Get the current indicator value or sets the value used for IndicatorFillRange.
/// </summary>
public int IndicatorValue
{
get
{
return (int)SPerform(2503, 0, 0);
}
set
{
SPerform(2502, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the current end of line mode - one of CRLF, CR, or LF.
/// </summary>
public Enums.EndOfLine EndOfLineMode
{
get
{
return (Enums.EndOfLine)EOLMode;
}
set
{
EOLMode = (int)value;
}
}

/// <summary>
/// Length Method for : Retrieve the text of the line containing the caret.
/// Returns the index of the caret on the line.
/// </summary>
public int CurLineSize
{
get
{
return (int)SPerform(2027, 0 , 0);
}
}

/// <summary>
/// Length Method for : Retrieve the contents of a line.
/// Returns the length of the line.
/// </summary>
public int LineSize
{
get
{
return (int)SPerform(2153, 0, 0);
}
}

/// <summary>
/// Length Method for : Retrieve the selected text.
/// Return the length of the text.
/// </summary>
public int SelTextSize
{
get
{
return (int)SPerform(2161, 0, 0);
}
}

/// <summary>
/// Length Method for : Retrieve all the text in the document.
/// Returns number of characters retrieved.
/// </summary>
public int TextSize
{
get
{
return (int)SPerform(2182, 0, 0);
}
}

/// <summary>
/// Are there any redoable actions in the undo history?
/// </summary>
public bool CanRedo
{
get
{
return SPerform(2016, 0, 0) != 0;
}
}

/// <summary>
/// Is there an auto-completion list visible?
/// </summary>
public bool IsAutoCActive
{
get
{
return SPerform(2102, 0, 0) != 0;
}
}

/// <summary>
/// Retrieve the position of the caret when the auto-completion list was displayed.
/// </summary>
public int AutoCPosStart
{
get
{
return (int)SPerform(2103, 0, 0);
}
}

/// <summary>
/// Will a paste succeed?
/// </summary>
public bool CanPaste
{
get
{
return SPerform(2173, 0, 0) != 0;
}
}

/// <summary>
/// Are there any undoable actions in the undo history?
/// </summary>
public bool CanUndo
{
get
{
return SPerform(2174, 0, 0) != 0;
}
}

/// <summary>
/// Is there an active call tip?
/// </summary>
public bool IsCallTipActive
{
get
{
return SPerform(2202, 0, 0) != 0;
}
}

/// <summary>
/// Retrieve the position where the caret was before displaying the call tip.
/// </summary>
public int CallTipPosStart
{
get
{
return (int)SPerform(2203, 0, 0);
}
}

/// <summary>
/// Create a new document object.
/// Starts with reference count of 1 and not selected into editor.
/// </summary>
public int CreateDocument
{
get
{
return (int)SPerform(2375, 0, 0);
}
}

/// <summary>
/// Get currently selected item position in the auto-completion list
/// </summary>
public int AutoCGetCurrent
{
get
{
return (int)SPerform(2445, 0, 0);
}
}

/// <summary>
/// Returns the number of characters in the document.
/// </summary>
public int Length
{
get
{
return (int)SPerform(2006, 0, 0);
}
}

/// <summary>
/// Enable/Disable convert-on-paste for line endings
/// </summary>
public bool PasteConvertEndings
{
get
{
return SPerform(2468, 0, 0) != 0;
}
set
{
SPerform(2467, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Returns the position of the caret.
/// </summary>
public int CurrentPos
{
get
{
return (int)SPerform(2008, 0, 0);
}
set
{
SPerform(2141, (uint)value , 0);
}
}

/// <summary>
/// Returns the position of the opposite end of the selection to the caret.
/// </summary>
public int AnchorPosition
{
get
{
return (int)SPerform(2009, 0, 0);
}
set
{
SPerform(2026, (uint)value , 0);
}
}

/// <summary>
/// Is undo history being collected?
/// </summary>
public bool IsUndoCollection
{
get
{
return SPerform(2019, 0, 0)!=0;
}
set
{
SPerform(2012 , (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Are white space characters currently visible?
/// Returns one of SCWS_/// constants.
/// </summary>
public int ViewWS
{
get
{
return (int)SPerform(2020, 0, 0);
}
set
{
SPerform(2021, (uint)value , 0);
}
}

/// <summary>
/// Retrieve the position of the last correctly styled character.
/// </summary>
public int EndStyled
{
get
{
return (int)SPerform(2028, 0, 0);
}
}

/// <summary>
/// Retrieve the current end of line mode - one of CRLF, CR, or LF.
/// </summary>
public int EOLMode
{
get
{
return (int)SPerform(2030, 0, 0);
}
set
{
SPerform(2031, (uint)value , 0);
}
}

/// <summary>
/// Is drawing done first into a buffer or direct to the screen?
/// </summary>
public bool IsBufferedDraw
{
get
{
return SPerform(2034, 0, 0)!=0;
}
set
{
SPerform(2035 , (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve the visible size of a tab.
/// </summary>
public int TabWidth
{
get
{
return (int)SPerform(2121, 0, 0);
}
set
{
SPerform(2036, (uint)value, 0);
}
}

/// <summary>
/// Get the time in milliseconds that the caret is on and off.
/// </summary>
public int CaretPeriod
{
get
{
return (int)SPerform(2075, 0, 0);
}
set
{
SPerform(2076, (uint)value, 0);
}
}

/// <summary>
/// Retrieve number of bits in style bytes used to hold the lexical state.
/// </summary>
public int StyleBits
{
get
{
return (int)SPerform(2091, 0, 0);
}
set
{
SPerform(2090, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the last line number that has line state.
/// </summary>
public int MaxLineState
{
get
{
return (int)SPerform(2094, 0, 0);
}
}

/// <summary>
/// Is the background of the line containing the caret in a different colour?
/// </summary>
public bool IsCaretLineVisible
{
get
{
return SPerform(2095, 0, 0) != 0;
}
set
{
SPerform(2096, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Get the colour of the background of the line containing the caret.
/// </summary>
public int CaretLineBack
{
get
{
return (int)SPerform(2097, 0, 0);
}
set
{
SPerform(2098, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the auto-completion list separator character.
/// </summary>
public int AutoCSeparator
{
get
{
return (int)SPerform(2107, 0, 0);
}
set
{
SPerform(2106, (uint)value, 0);
}
}

/// <summary>
/// Retrieve whether auto-completion cancelled by backspacing before start.
/// </summary>
public bool IsAutoCGetCancelAtStart
{
get
{
return SPerform(2111, 0, 0) != 0;
}
set
{
SPerform(2110 , (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve whether a single item auto-completion list automatically choose the item.
/// </summary>
public bool IsAutoCGetChooseSingle
{
get
{
return SPerform(2114, 0, 0) != 0;
}
set
{
SPerform(2113, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve state of ignore case flag.
/// </summary>
public bool IsAutoCGetIgnoreCase
{
get
{
return SPerform(2116, 0, 0) != 0;
}
set
{
SPerform(2115, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve whether or not autocompletion is hidden automatically when nothing matches.
/// </summary>
public bool IsAutoCGetAutoHide
{
get
{
return SPerform(2119, 0, 0) != 0;
}
set
{
SPerform(2118, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve whether or not autocompletion deletes any word characters
/// after the inserted text upon completion.
/// </summary>
public bool IsAutoCGetDropRestOfWord
{
get
{
return SPerform(2271, 0, 0) != 0;
}
set
{
SPerform(2270, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve the auto-completion list type-separator character.
/// </summary>
public int AutoCTypeSeparator
{
get
{
return (int)SPerform(2285, 0, 0);
}
set
{
SPerform(2286, (uint)value, 0);
}
}

/// <summary>
/// Retrieve indentation size.
/// </summary>
public int Indent
{
get
{
return (int)SPerform(2123, 0, 0);
}
set
{
SPerform(2122, (uint)value, 0);
}
}

/// <summary>
/// Retrieve whether tabs will be used in indentation.
/// </summary>
public bool IsUseTabs
{
get
{
return SPerform(2125, 0, 0) != 0;
}
set
{
SPerform(2124 , (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Is the horizontal scroll bar visible?
/// </summary>
public bool IsHScrollBar
{
get
{
return SPerform(2131, 0, 0) != 0;
}
set
{
SPerform(2130, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Are the indentation guides visible?
/// </summary>
public bool IsIndentationGuides
{
get
{
return SPerform(2133, 0, 0) != 0;
}
set
{
SPerform(2132, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Get the highlighted indentation guide column.
/// </summary>
public int HighlightGuide
{
get
{
return (int)SPerform(2135, 0, 0);
}
set
{
SPerform(2134, (uint)value, 0);
}
}

/// <summary>
/// Get the code page used to interpret the bytes of the document as characters.
/// </summary>
public int CodePage
{
get
{
return (int)SPerform(2137, 0, 0);
}
set
{
SPerform(2037, (uint)value, 0);
}
}

/// <summary>
/// Get the foreground colour of the caret.
/// </summary>
public int CaretFore
{
get
{
return (int)SPerform(2138, 0, 0);
}
set
{
SPerform(2069, (uint)value, 0);
}
}

/// <summary>
/// In palette mode?
/// </summary>
public bool IsUsePalette
{
get
{
return SPerform(2139, 0, 0) != 0;
}
set
{
SPerform(2039, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// In read-only mode?
/// </summary>
public bool IsReadOnly
{
get
{
return SPerform(2140, 0, 0) != 0;
}
set
{
SPerform(2171, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Returns the position at the start of the selection.
/// </summary>
public int SelectionStart
{
get
{
return (int)SPerform(2143, 0, 0);
}
set
{
SPerform(2142, (uint)value, 0);
}
}

/// <summary>
/// Returns the position at the end of the selection.
/// </summary>
public int SelectionEnd
{
get
{
return (int)SPerform(2145, 0, 0);
}
set
{
SPerform(2144, (uint)value, 0);
}
}

/// <summary>
/// Returns true if the selection extends over more than one line.
/// </summary>
public bool IsSelectionMultiline
{
get
{
return LineFromPosition(SelectionStart) != LineFromPosition(SelectionEnd);
}
}

/// <summary>
/// Returns the print magnification.
/// </summary>
public int PrintMagnification
{
get
{
return (int)SPerform(2147, 0, 0);
}
set
{
SPerform(2146, (uint)value, 0);
}
}

/// <summary>
/// Returns the print colour mode.
/// </summary>
public int PrintColourMode
{
get
{
return (int)SPerform(2149, 0, 0);
}
set
{
SPerform(2148, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the display line at the top of the display.
/// </summary>
public int FirstVisibleLine
{
get
{
return (int)SPerform(2152, 0, 0);
}
}

/// <summary>
/// Returns the number of lines in the document. There is always at least one.
/// </summary>
public int LineCount
{
get
{
return (int)SPerform(2154, 0, 0);
}
}

/// <summary>
/// Returns the size in pixels of the left margin.
/// </summary>
public int MarginLeft
{
get
{
return (int)SPerform(2156, 0, 0);
}
set
{
SPerform(2155, 0, (uint)value);
}
}

/// <summary>
/// Returns the size in pixels of the right margin.
/// </summary>
public int MarginRight
{
get
{
return (int)SPerform(2158, 0, 0);
}
set
{
SPerform(2157, 0, (uint)value);
}
}

/// <summary>
/// Is the document different from when it was last saved?
/// </summary>
public bool IsModify
{
get
{
return SPerform(2159, 0, 0) != 0;
}
}

/// <summary>
/// Retrieve the number of characters in the document.
/// </summary>
public int TextLength
{
get
{
return (int)SPerform(2183, 0, 0);
}
}

/// <summary>
/// Retrieve a pointer to a function that processes messages for this Scintilla.
/// </summary>
public int DirectFunction
{
get
{
return (int)SPerform(2184, 0, 0);
}
}

/// <summary>
/// Retrieve a pointer value to use as the first argument when calling
/// the function returned by GetDirectFunction.
/// </summary>
public int DirectPointer
{
get
{
return (int)SPerform(2185, 0, 0);
}
}

/// <summary>
/// Returns true if overtype mode is active otherwise false is returned.
/// </summary>
public bool IsOvertype
{
get
{
return SPerform(2187, 0, 0) != 0;
}
set
{
SPerform(2186 , (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Returns the width of the insert mode caret.
/// </summary>
public int CaretWidth
{
get
{
return (int)SPerform(2189, 0, 0);
}
set
{
SPerform(2188, (uint)value, 0);
}
}

/// <summary>
/// Get the position that starts the target.
/// </summary>
public int TargetStart
{
get
{
return (int)SPerform(2191, 0, 0);
}
set
{
SPerform(2190, (uint)value , 0);
}
}

/// <summary>
/// Get the position that ends the target.
/// </summary>
public int TargetEnd
{
get
{
return (int)SPerform(2193, 0, 0);
}
set
{
SPerform(2192, (uint)value , 0);
}
}

/// <summary>
/// Get the search flags used by SearchInTarget.
/// </summary>
public int SearchFlags
{
get
{
return (int)SPerform(2199, 0, 0);
}
set
{
SPerform(2198, (uint)value, 0);
}
}

/// <summary>
/// Is a line visible?
/// </summary>
public bool IsLineVisible
{
get
{
return SPerform(2228, 0, 0) != 0;
}
}

/// <summary>
/// Does a tab pressed when caret is within indentation indent?
/// </summary>
public bool IsTabIndents
{
get
{
return SPerform(2261, 0, 0) != 0;
}
set
{
SPerform(2260, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Does a backspace pressed when caret is within indentation unindent?
/// </summary>
public bool IsBackSpaceUnIndents
{
get
{
return SPerform(2263, 0, 0) != 0;
}
set
{
SPerform(2262, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve the time the mouse must sit still to generate a mouse dwell event.
/// </summary>
public int MouseDwellTime
{
get
{
return (int)SPerform(2265, 0, 0);
}
set
{
SPerform(2264, (uint)value, 0);
}
}

/// <summary>
/// Retrieve whether text is word wrapped.
/// </summary>
public int WrapMode
{
get
{
return (int)SPerform(2269, 0, 0);
}
set
{
SPerform(2268, (uint)value, 0);
}
}

/// <summary>
/// Retrive the display mode of visual flags for wrapped lines.
/// </summary>
public int WrapVisualFlags
{
get
{
return (int)SPerform(2461, 0, 0);
}
set
{
SPerform(2460, (uint)value , 0);
}
}

/// <summary>
/// Retrive the location of visual flags for wrapped lines.
/// </summary>
public int WrapVisualFlagsLocation
{
get
{
return (int)SPerform(2463, 0, 0);
}
set
{
SPerform(2462, (uint)value, 0);
}
}

/// <summary>
/// Retrive the start indent for wrapped lines.
/// </summary>
public int WrapStartIndent
{
get
{
return (int)SPerform(2465, 0, 0);
}
set
{
SPerform(2464, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the degree of caching of layout information.
/// </summary>
public int LayoutCache
{
get
{
return (int)SPerform(2273, 0, 0);
}
set
{
SPerform(2272, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the document width assumed for scrolling.
/// </summary>
public int ScrollWidth
{
get
{
return (int)SPerform(2275, 0, 0);
}
set
{
SPerform(2274, (uint)value, 0);
}
}

/// <summary>
/// Retrieve whether the maximum scroll position has the last
/// line at the bottom of the view.
/// </summary>
public int EndAtLastLine
{
get
{
return (int)SPerform(2278, 0, 0);
}
set
{
SPerform(2277, (uint)value , 0);
}
}

/// <summary>
/// Is the vertical scroll bar visible?
/// </summary>
public bool IsVScrollBar
{
get
{
return SPerform(2281, 0, 0) != 0;
}
set
{
SPerform(2280, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Is drawing done in two phases with backgrounds drawn before faoregrounds?
/// </summary>
public bool IsTwoPhaseDraw
{
get
{
return SPerform(2283, 0, 0)!=0;
}
set
{
SPerform(2284, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Are the end of line characters visible?
/// </summary>
public bool IsViewEOL
{
get
{
return SPerform(2355, 0, 0) != 0;
}
set
{
SPerform(2356, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Retrieve a pointer to the document object.
/// </summary>
public int DocPointer
{
get
{
return (int)SPerform(2357, 0, 0);
}
set
{
SPerform(2358, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the column number which text should be kept within.
/// </summary>
public int EdgeColumn
{
get
{
return (int)SPerform(2360, 0, 0);
}
set
{
SPerform(2361, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the edge highlight mode.
/// </summary>
public int EdgeMode
{
get
{
return (int)SPerform(2362, 0, 0);
}
set
{
SPerform(2363, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the colour used in edge indication.
/// </summary>
public int EdgeColour
{
get
{
return (int)SPerform(2364, 0, 0);
}
set
{
SPerform(2365, (uint)value, 0);
}
}

/// <summary>
/// Retrieves the number of lines completely visible.
/// </summary>
public int LinesOnScreen
{
get
{
return (int)SPerform(2370, 0, 0);
}
}

/// <summary>
/// Is the selection rectangular? The alternative is the more common stream selection.
/// </summary>
public bool IsSelectionRectangle
{
get
{
return SPerform(2372, 0, 0) != 0;
}
}

/// <summary>
/// Set the zoom level. This number of points is added to the size of all fonts.
/// It may be positive to magnify or negative to reduce. Retrieve the zoom level.
/// </summary>
public int ZoomLevel
{
get
{
return (int)SPerform(2374, 0, 0);
}
set
{
SPerform(2373, (uint)value, 0);
}
}

/// <summary>
/// Get which document modification events are sent to the container.
/// </summary>
public int ModEventMask
{
get
{
return (int)SPerform(2378, 0, 0);
}
set
{
SPerform(2359, (uint)value, 0);
}
}

/// <summary>
/// Change internal focus flag. Get internal focus flag.
/// </summary>
public bool IsFocus
{
get
{
return SPerform(2381, 0, 0) != 0;
}
set
{
SPerform(2380 , (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Change error status - 0 = OK. Get error status.
/// </summary>
public int Status
{
get
{
return (int)SPerform(2383, 0, 0);
}
set
{
SPerform(2382, (uint)value, 0);
}
}

/// <summary>
/// Set whether the mouse is captured when its button is pressed. Get whether mouse gets captured.
/// </summary>
public bool IsMouseDownCaptures
{
get
{
return SPerform(2385, 0, 0) != 0;
}
set
{
SPerform(2384 , (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Sets the cursor to one of the SC_CURSOR/// values. Get cursor type.
/// </summary>
public int CursorType
{
get
{
return (int)SPerform(2387, 0, 0);
}
set
{
SPerform(2386, (uint)value, 0);
}
}

/// <summary>
/// Change the way control characters are displayed:
/// If symbol is < 32, keep the drawn way, else, use the given character.
/// Get the way control characters are displayed.
/// </summary>
public int ControlCharSymbol
{
get
{
return (int)SPerform(2389, 0, 0);
}
set
{
SPerform(2388, (uint)value, 0);
}
}

/// <summary>
/// Get and Set the xOffset (ie, horizonal scroll position).
/// </summary>
public int XOffset
{
get
{
return (int)SPerform(2398, 0, 0);
}
set
{
SPerform(2397, (uint)value, 0);
}
}

/// <summary>
/// Is printing line wrapped?
/// </summary>
public int PrintWrapMode
{
get
{
return (int)SPerform(2407, 0, 0);
}
set
{
SPerform(2406, (uint)value, 0);
}
}

/// <summary>
/// Get the mode of the current selection.
/// </summary>
public int SelectionMode
{
get
{
return (int)SPerform(2423, 0, 0);
}
set
{
SPerform(2422, (uint)value, 0);
}
}

/// <summary>
/// Retrieve the lexing language of the document.
/// </summary>
public int Lexer
{
get
{
return (int)SPerform(4002, 0, 0);
}
set
{
SPerform(4001, (uint)value, 0);
}
}

/// <summary>
/// Gets the EOL marker
/// </summary>
public string NewLineMarker
{
get
{
if (EOLMode == 1) return "\r";
else if (EOLMode == 2) return "\n";
else return "\r\n";
}
}

/// <summary>
/// Compact the document buffer and return a read-only pointer to the characters in the document.
/// </summary>
public int CharacterPointer
{
get
{
return (int)SPerform(2520, 0, 0);
}
}

/// <summary>
/// Always interpret keyboard input as Unicode
/// </summary>
public bool UnicodeKeys
{
get
{
return SPerform(2522, 0, 0) != 0;
}
set
{
SPerform(2521, (uint)(value ? 1 : 0), 0);
}
}

/// <summary>
/// Set extra ascent for each line
/// </summary>
public int ExtraAscent
{
get
{
return (int)SPerform(2526, 0, 0);
}
set
{
SPerform(2525, (uint)value, 0);
}
}

/// <summary>
/// Set extra descent for each line
/// </summary>
public int ExtraDescent
{
get
{
return (int)SPerform(2528, 0, 0);
}
set
{
SPerform(2527, (uint)value, 0);
}
}

/// <summary>
/// Get the start of the range of style numbers used for margin text
/// </summary>
public int MarginStyleOffset
{
get
{
return (int)SPerform(2538, 0, 0);
}
set
{
SPerform(2537, (uint)value, 0);
}
}

/// <summary>
/// Get the start of the range of style numbers used for annotations
/// </summary>
public int AnnotationStyleOffset
{
get
{
return (int)SPerform(2551, 0, 0);
}
set
{
SPerform(2550, (uint)value, 0);
}
}

/// <summary>
/// Get the start of the range of style numbers used for annotations
/// </summary>
public bool AnnotationVisible
{
get
{
return SPerform(2549, 0, 0) != 0;
}
set
{
SPerform(2548, (uint)(value ? 1 : 0), 0);
}
}

#endregion

#region Scintilla Methods

/// <summary>
/// Adds a new keys to ignore
/// </summary>
public virtual void AddIgnoredKeys(Keys keys)
{
ignoredKeys.Add((int)keys, (int)keys);
}

/// <summary>
/// Removes the ignored keys
/// </summary>
public virtual void RemoveIgnoredKeys(Keys keys)
{
ignoredKeys.Remove((int)keys);
}

/// <summary>
/// Does the container have keys?
/// </summary>
public virtual bool ContainsIgnoredKeys(Keys keys)
{
return ignoredKeys.ContainsKey((int)keys);
}

/// <summary>
/// Clears the ignored keys container
/// </summary>
public virtual void ClearIgnoredKeys()
{
ignoredKeys.Clear();
}

/// <summary>
/// Sets the focud to the control
/// </summary>
public new bool Focus()
{
return WinAPI.SetFocus(hwndScintilla) != IntPtr.Zero;
}

/// <summary>
/// Duplicate the selection.
/// If selection empty duplicate the line containing the caret.
/// </summary>
public void SelectionDuplicate()
{
SPerform(2469, 0, 0);
}

/// <summary>
/// Can the caret preferred x position only be changed by explicit movement commands?
/// </summary>
public bool GetCaretSticky()
{
return SPerform(2457, 0, 0) != 0;
}

/// <summary>
/// Stop the caret preferred x position changing when the user types.
/// </summary>
public void SetCaretSticky(bool useSetting)
{
SPerform(2458, (uint)(useSetting ? 1 : 0), 0);
}

/// <summary>
/// Switch between sticky and non-sticky: meant to be bound to a key.
/// </summary>
public void ToggleCaretSticky()
{
SPerform(2459, 0, 0);
}

/// <summary>
/// Retrieve the fold level of a line.
/// </summary>
public int GetFoldLevel(int line)
{
return (int)SPerform(2223, (uint)line, 0);
}

/// <summary>
/// Set the fold level of a line.
/// This encodes an integer level along with flags indicating whether the
/// line is a header and whether it is effectively white space.
/// </summary>
public void SetFoldLevel(int line, int level)
{
SPerform(2222, (uint)line, (uint)level);
}

/// <summary>
/// Find the last child line of a header line.
/// </summary>
public int LastChild(int line, int level)
{
return (int)SPerform(2224, (uint)line, (uint)level);
}

/// <summary>
/// Find the last child line of a header line.
/// </summary>
public int LastChild(int line)
{
return (int)SPerform(2224, (uint)line, 0);
}

/// <summary>
/// Find the parent line of a child line.
/// </summary>
public int FoldParent(int line)
{
return (int)SPerform(2225, (uint)line, 0);
}

/// <summary>
/// Is a header line expanded?
/// </summary>
public bool FoldExpanded(int line)
{
return SPerform(2230, (uint)line, 0) != 0;
}

/// <summary>
/// Show the children of a header line.
/// </summary>
public void FoldExpanded(int line, bool expanded)
{
SPerform(2229, (uint)line, (uint)(expanded ? 1 : 0));
}

/// <summary>
/// Clear all the styles and make equivalent to the global default style.
/// </summary>
public void StyleClearAll()
{
SPerform(2050, 0, 0);
}

/// <summary>
/// Set the foreground colour of a style.
/// </summary>
public void StyleSetFore(int style, int fore)
{
SPerform(2051, (uint)style, (uint)fore);
}

/// <summary>
/// Set the background colour of a style.
/// </summary>
public void StyleSetBack(int style, int back)
{
SPerform(2052, (uint)style, (uint)back);
}

/// <summary>
/// Set a style to be bold or not.
/// </summary>
public void StyleSetBold(int style, bool bold)
{
SPerform(2053, (uint)style, (uint)(bold ? 1 : 0));
}

/// <summary>
/// Set a style to be italic or not.
/// </summary>
public void StyleSetItalic(int style, bool italic)
{
SPerform(2054, (uint)style, (uint)(italic ? 1 : 0));
}

/// <summary>
/// Set the size of characters of a style.
/// </summary>
public void StyleSetSize(int style, int sizePoints)
{
SPerform(2055, (uint)style, (uint)sizePoints);
}

/// <summary>
/// Set the font of a style.
/// </summary>
unsafe public void StyleSetFont(int style, string fontName)
{
if (fontName == null || fontName.Equals("")) fontName = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(fontName))
{
SPerform(2056,(uint)style, (uint)b );
}
}

/// <summary>
/// Set a style to have its end of line filled or not.
/// </summary>
public void StyleSetEOLFilled(int style, bool filled)
{
SPerform(2057, (uint)style, (uint)(filled ? 1 : 0));
}

/// <summary>
/// Set a style to be underlined or not.
/// </summary>
public void StyleSetUnderline(int style, bool underline )
{
SPerform(2059, (uint)style, (uint)(underline?1:0) );
}

/// <summary>
/// Set a style to be mixed case, or to force upper or lower case.
/// </summary>
public void StyleSetCase(int style, int caseForce)
{
SPerform(2060, (uint)style, (uint)caseForce);
}

/// <summary>
/// Set the character set of the font in a style.
/// </summary>
public void StyleSetCharacterSet(int style, int characterSet )
{
SPerform(2066, (uint)style, (uint)characterSet);
}

/// <summary>
/// Set a style to be a hotspot or not.
/// </summary>
public void StyleSetHotSpot(int style, bool hotspot)
{
SPerform(2409, (uint)style, (uint)(hotspot ? 1 : 0));
}

/// <summary>
/// Set a style to be visible or not.
/// </summary>
public void StyleSetVisible(int style, bool visible)
{
SPerform(2074, (uint)style, (uint)(visible ? 1 : 0));
}

/// <summary>
/// Set the set of characters making up words for when moving or selecting by word.
/// First sets deaults like SetCharsDefault.
/// </summary>
unsafe public void WordChars(string characters)
{
if (characters == null || characters.Equals("")) characters = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(characters))
{
SPerform(2077, 0, (uint)b);
}
}

/// <summary>
/// Set a style to be changeable or not (read only).
/// Experimental feature, currently buggy.
/// </summary>
public void StyleSetChangeable(int style, bool changeable )
{
SPerform(2099, (uint)style, (uint)(changeable?1:0) );
}

/// <summary>
/// Define a set of characters that when typed will cause the autocompletion to
/// choose the selected item.
/// </summary>
unsafe public void AutoCSetFillUps(string characterSet )
{
if (characterSet == null || characterSet.Equals("")) characterSet = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(characterSet))
{
SPerform(2112, 0, (uint)b);
}
}

/// <summary>
/// Enable / Disable underlining active hotspots.
/// </summary>
public void HotspotActiveUnderline(bool useSetting)
{
SPerform(2412, (uint)(useSetting ? 1 : 0), 0);
}

/// <summary>
/// Limit hotspots to single line so hotspots on two lines don't merge.
/// </summary>
public void HotspotSingleLine(bool useSetting)
{
SPerform(2421, (uint)(useSetting ? 1 : 0), 0);
}

/// <summary>
/// Set a fore colour for active hotspots.
/// </summary>
public void HotspotActiveFore(bool useSetting, int fore)
{
SPerform(2410, (uint)(useSetting ? 1 : 0), (uint)fore);
}

/// <summary>
/// Set a back colour for active hotspots.
/// </summary>
public void HotspotActiveBack(bool useSetting, int back)
{
SPerform(2411, (uint)(useSetting ? 1 : 0), (uint)back);
}

/// <summary>
/// Retrieve the number of bits the current lexer needs for styling.
/// </summary>
public int GetStyleBitsNeeded()
{
return (int)SPerform(4011, 0, 0);
}

/// <summary>
/// Set up a value that may be used by a lexer for some optional feature.
/// </summary>
unsafe public void SetProperty(string key, string val)
{
if (key == null || key.Equals("")) key = "\0\0";
if (val == null || val.Equals("")) val = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(val))
{
fixed (byte* b2 = Encoding.GetEncoding(this.CodePage).GetBytes(key))
{
SPerform(4004, (uint)b2, (uint)b);
}
}
}

/// <summary>
/// Retrieve a "property" value previously set with SetProperty,
/// interpreted as an int AFTER any "$()" variable replacement.
/// </summary>
unsafe public int GetPropertyInt(string key)
{
if (key == null || key.Equals("")) key = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(key))
{
return (int)SPerform(4010, (uint)b, 0);
}
}

/// <summary>
/// Set up the key words used by the lexer.
/// </summary>
unsafe public void KeyWords(int keywordSet, string keyWords)
{
if (keyWords == null || keyWords.Equals("")) keyWords = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(keyWords))
{
SPerform(4005, (uint)keywordSet, (uint)b);
}
}

/// <summary>
/// Set the lexing language of the document based on string name.
/// </summary>
unsafe public void LexerLanguage(string language)
{
if (language == null || language.Equals("")) language = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(language))
{
SPerform(4006, 0, (uint)b);
}
}

/// <summary>
/// Retrieve the extra styling information for a line.
/// </summary>
public int GetLineState(int line)
{
return (int)SPerform(2093,(uint)line, 0);
}

/// <summary>
/// Used to hold extra styling information for each line.
/// </summary>
public void SetLineState(int line, int state)
{
SPerform(2092, (uint)line, (uint)state);
}

/// <summary>
/// Retrieve the number of columns that a line is indented.
/// </summary>
public int GetLineIndentation(int line)
{
return (int)SPerform(2127, (uint)line, 0);
}

/// <summary>
/// Change the indentation of a line to a number of columns.
/// </summary>
public void SetLineIndentation(int line, int indentSize)
{
SPerform(2126, (uint)line, (uint)indentSize);
}

/// <summary>
/// Retrieve the position before the first non indentation character on a line.
/// </summary>
public int LineIndentPosition(int line)
{
return (int)SPerform(2128, (uint)line, 0);
}

/// <summary>
/// Retrieve the column number of a position, taking tab width into account.
/// </summary>
public int Column(int pos)
{
return (int)SPerform(2129, (uint)pos, 0);
}

/// <summary>
/// Get the position after the last visible characters on a line.
/// </summary>
public int LineEndPosition(int line)
{
return (int)SPerform(2136, (uint)line, 0);
}

/// <summary>
/// Returns the character byte at the position.
/// </summary>
public int CharAt(int pos)
{
return (int)SPerform(2007, (uint)pos, 0);
}

/// <summary>
/// Returns the style byte at the position.
/// </summary>
public int StyleAt(int pos)
{
return (int)SPerform(2010, (uint)pos, 0);
}

/// <summary>
/// Retrieve the type of a margin.
/// </summary>
public int GetMarginTypeN(int margin)
{
return (int)SPerform(2241, (uint)margin, 0);
}

/// <summary>
/// Set a margin to be either numeric or symbolic.
/// </summary>
public void SetMarginTypeN(int margin, int marginType)
{
SPerform(2240, (uint)margin, (uint)marginType);
}

/// <summary>
/// Retrieve the width of a margin in pixels.
/// </summary>
public int GetMarginWidthN(int margin)
{
return (int)SPerform(2243,(uint)margin, 0);
}

/// <summary>
/// Set the width of a margin to a width expressed in pixels.
/// </summary>
public void SetMarginWidthN(int margin, int pixelWidth)
{
SPerform(2242, (uint)margin, (uint)pixelWidth);
}

/// <summary>
/// Retrieve the marker mask of a margin.
/// </summary>
public int GetMarginMaskN(int margin)
{
return (int)SPerform(2245, (uint)margin, 0);
}

/// <summary>
/// Set a mask that determines which markers are displayed in a margin.
/// </summary>
public void SetMarginMaskN(int margin, int mask)
{
SPerform(2244, (uint)margin, (uint)mask);
}

/// <summary>
/// Retrieve the mouse click sensitivity of a margin.
/// </summary>
public bool MarginSensitiveN(int margin)
{
return SPerform(2247, (uint)margin, 0) != 0;
}

/// <summary>
/// Make a margin sensitive or insensitive to mouse clicks.
/// </summary>
public void MarginSensitiveN(int margin, bool sensitive)
{
SPerform(2246, (uint)margin, (uint)(sensitive ? 1 : 0));
}

/// <summary>
/// Retrieve the style of an indicator.
/// </summary>
public int GetIndicStyle(int indic)
{
return (int)SPerform(2081, (uint)indic, 0);
}

/// <summary>
/// Set an indicator to plain, squiggle or TT.
/// </summary>
public void SetIndicStyle(int indic, int style)
{
SPerform(2080, (uint)indic , (uint)style);
}

/// <summary>
/// Retrieve the foreground colour of an indicator.
/// </summary>
public int GetIndicFore(int indic)
{
return (int)SPerform(2083,(uint)indic, 0);
}

/// <summary>
/// Set the foreground colour of an indicator.
/// </summary>
public void SetIndicFore(int indic, int fore)
{
SPerform(2082, (uint)indic, (uint)fore);
}

/// <summary>
/// Add text to the document at current position.
/// </summary>
unsafe public void AddText(int length, string text )
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2001,(uint)length, (uint)b);
}
}

/// <summary>
/// Insert string at a position.
/// </summary>
unsafe public void InsertText(int pos, string text )
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2003, (uint)pos, (uint)b);
}
}

/// <summary>
/// Convert all line endings in the document to one mode.
/// </summary>
public void ConvertEOLs(Enums.EndOfLine eolMode)
{
ConvertEOLs((int)eolMode);
}

/// <summary>
/// Set the symbol used for a particular marker number.
/// </summary>
public void MarkerDefine(int markerNumber, Enums.MarkerSymbol markerSymbol)
{
MarkerDefine(markerNumber, (int)markerSymbol);
}

/// <summary>
/// Set the character set of the font in a style.
/// </summary>
public void StyleSetCharacterSet(int style, Enums.CharacterSet characterSet)
{
StyleSetCharacterSet(style, (int)characterSet);
}

/// <summary>
/// Set a style to be mixed case, or to force upper or lower case.
/// </summary>
public void StyleSetCase(int style, Enums.CaseVisible caseForce)
{
StyleSetCase(style, (int)caseForce);
}

/// <summary>
/// Delete all text in the document.
/// </summary>
public void ClearAll()
{
SPerform(2004, 0, 0);
}


/// <summary>
/// Set all style bytes to 0, remove all folding information.
/// </summary>
public void ClearDocumentStyle()
{
SPerform(2005, 0, 0);
}

/// <summary>
/// Redoes the next action on the undo history.
/// </summary>
public void Redo()
{
SPerform(2011, 0, 0);
}

/// <summary>
/// Select all the text in the document.
/// </summary>
public void SelectAll()
{
SPerform(2013, 0, 0);
}

/// <summary>
/// Remember the current position in the undo history as the position
/// at which the document was saved.
/// </summary>
public void SetSavePoint()
{
SPerform(2014, 0, 0);
}

/// <summary>
/// Retrieve the line number at which a particular marker is located.
/// </summary>
public int MarkerLineFromHandle(int handle)
{
return (int)SPerform(2017, (uint)handle, 0);
}

/// <summary>
/// Delete a marker.
/// </summary>
public void MarkerDeleteHandle(int handle)
{
SPerform(2018, (uint)handle, 0);
}

/// <summary>
/// Find the position from a point within the window.
/// </summary>
public int PositionFromPoint(int x, int y)
{
return (int)SPerform(2022, (uint)x, (uint)y);
}

/// <summary>
/// Find the position from a point within the window but return
/// INVALID_POSITION if not close to text.
/// </summary>
public int PositionFromPointClose(int x, int y)
{
return (int)SPerform(2023, (uint)x, (uint)y);
}

/// <summary>
/// Set caret to start of a line and ensure it is visible.
/// </summary>
public void GotoLine(int line)
{
SPerform(2024, (uint)line, 0);
}

/// <summary>
/// Set caret to a position and ensure it is visible.
/// </summary>
public void GotoPos(int pos)
{
SPerform(2025, (uint)pos, 0);
}

/// <summary>
/// Retrieve the text of the line containing the caret.
/// Returns the index of the caret on the line.
/// </summary>
unsafe public string GetCurLine(int length)
{
int sz = (int)SPerform(2027, (uint)length, 0);
byte[] buffer = new byte[sz+1];
fixed (byte* b = buffer) SPerform(2027, (uint)length+1, (uint)b);
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz-1);
}

/// <summary>
/// Convert all line endings in the document to one mode.
/// </summary>
public void ConvertEOLs(int eolMode)
{
SPerform(2029, (uint)eolMode, 0);
}

/// <summary>
/// Set the current styling position to pos and the styling mask to mask.
/// The styling mask can be used to protect some bits in each styling byte from modification.
/// </summary>
public void StartStyling(int pos, int mask)
{
SPerform(2032, (uint)pos, (uint)mask);
}

/// <summary>
/// Change style from current styling position for length characters to a style
/// and move the current styling position to after this newly styled segment.
/// </summary>
public void SetStyling(int length, int style)
{
SPerform(2033, (uint)length, (uint)style);
}

/// <summary>
/// Set the symbol used for a particular marker number.
/// </summary>
public void MarkerDefine(int markerNumber, int markerSymbol)
{
SPerform(2040, (uint)markerNumber, (uint)markerSymbol);
}

/// <summary>
/// Set the foreground colour used for a particular marker number.
/// </summary>
public void MarkerSetFore(int markerNumber, int fore)
{
SPerform(2041, (uint)markerNumber, (uint)fore);
}

/// <summary>
/// Set the background colour used for a particular marker number.
/// </summary>
public void MarkerSetBack(int markerNumber, int back)
{
SPerform(2042, (uint)markerNumber, (uint)back);
}

/// <summary>
/// Add a marker to a line, returning an ID which can be used to find or delete the marker.
/// </summary>
public int MarkerAdd(int line, int markerNumber)
{
return (int)SPerform(2043, (uint)line, (uint)markerNumber);
}

/// <summary>
/// Delete a marker from a line.
/// </summary>
public void MarkerDelete(int line, int markerNumber)
{
SPerform(2044, (uint)line, (uint)markerNumber);
}

/// <summary>
/// Delete all markers with a particular number from all lines.
/// </summary>
public void MarkerDeleteAll(int markerNumber)
{
SPerform(2045, (uint)markerNumber, 0);
}

/// <summary>
/// Get a bit mask of all the markers set on a line.
/// </summary>
public int MarkerGet(int line)
{
return (int)SPerform(2046, (uint)line, 0);
}

/// <summary>
/// Find the next line after lineStart that includes a marker in mask.
/// </summary>
public int MarkerNext(int lineStart, int markerMask)
{
return (int)SPerform(2047, (uint)lineStart, (uint)markerMask);
}

/// <summary>
/// Find the previous line before lineStart that includes a marker in mask.
/// </summary>
public int MarkerPrevious(int lineStart, int markerMask)
{
return (int)SPerform(2048, (uint)lineStart, (uint)markerMask);
}

/// <summary>
/// Define a marker from a pixmap.
/// </summary>
unsafe public void MarkerDefinePixmap(int markerNumber, string pixmap )
{
if (pixmap == null || pixmap.Equals("")) pixmap = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(pixmap))
{
SPerform(2049, (uint)markerNumber, (uint)b);
}
}

/// <summary>
/// Reset the default style to its state at startup
/// </summary>
public void StyleResetDefault()
{
SPerform(2058, 0, 0);
}

/// <summary>
/// Set the foreground colour of the selection and whether to use this setting.
/// </summary>
public void SetSelFore(bool useSetting, int fore)
{
SPerform(2067,(uint)(useSetting ? 1 : 0), (uint)fore);
}

/// <summary>
/// Set the background colour of the selection and whether to use this setting.
/// </summary>
public void SetSelBack(bool useSetting, int back)
{
SPerform(2068, (uint)(useSetting ? 1 : 0), (uint)back);
}

/// <summary>
/// When key+modifier combination km is pressed perform msg.
/// </summary>
public void AssignCmdKey(int km, int msg)
{
SPerform(2070, (uint)km, (uint)msg);
}

/// <summary>
/// When key+modifier combination km is pressed do nothing.
/// </summary>
public void ClearCmdKey(int km)
{
SPerform(2071, (uint)km, 0);
}

/// <summary>
/// Drop all key mappings.
/// </summary>
public void ClearAllCmdKeys()
{
SPerform(2072, 0, 0);
}

/// <summary>
/// Set the styles for a segment of the document.
/// </summary>
unsafe public void SetStylingEx(int length, string styles)
{
if (styles == null || styles.Equals("")) styles = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(styles))
{
SPerform(2073,(uint)length, (uint)b);
}
}

/// <summary>
/// Start a sequence of actions that is undone and redone as a unit.
/// May be nested.
/// </summary>
public void BeginUndoAction()
{
SPerform(2078, 0, 0);
}

/// <summary>
/// End a sequence of actions that is undone and redone as a unit.
/// </summary>
public void EndUndoAction()
{
SPerform(2079, 0, 0);
}

/// <summary>
/// Set the foreground colour of all whitespace and whether to use this setting.
/// </summary>
public void SetWhitespaceFore(bool useSetting, int fore)
{
SPerform(2084, (uint)(useSetting ? 1 : 0), (uint)fore);
}

/// <summary>
/// Set the background colour of all whitespace and whether to use this setting.
/// </summary>
public void SetWhitespaceBack(bool useSetting, int back)
{
SPerform(2085, (uint)(useSetting ? 1 : 0), (uint)back);
}

/// <summary>
/// Display a auto-completion list.
/// The lenEntered parameter indicates how many characters before
/// the caret should be used to provide context.
/// </summary>
unsafe public void AutoCShow(int lenEntered, string itemList)
{
if (itemList == null || itemList.Equals("")) itemList = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(itemList))
{
SPerform(2100, (uint)lenEntered, (uint)b);
}
}

/// <summary>
/// Remove the auto-completion list from the screen.
/// </summary>
public void AutoCCancel()
{
SPerform(2101, 0, 0);
}

/// <summary>
/// User has selected an item so remove the list and insert the selection.
/// </summary>
public void AutoCComplete()
{
SPerform(2104, 0, 0);
}

/// <summary>
/// Define a set of character that when typed cancel the auto-completion list.
/// </summary>
unsafe public void AutoCStops(string characterSet)
{
if (characterSet == null || characterSet.Equals("")) characterSet = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(characterSet))
{
SPerform(2105, 0, (uint)b);
}
}

/// <summary>
/// Select the item in the auto-completion list that starts with a string.
/// </summary>
unsafe public void AutoCSelect(string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2108, 0, (uint)b);
}
}

/// <summary>
/// Display a list of strings and send notification when user chooses one.
/// </summary>
unsafe public void UserListShow(int listType, string itemList)
{
if (itemList == null || itemList.Equals("")) itemList = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(itemList))
{
SPerform(2117, (uint)listType, (uint)b);
}
}

/// <summary>
/// Register an XPM image for use in autocompletion lists.
/// </summary>
unsafe public void RegisterImage(int type, string xpmData)
{
if (xpmData == null || xpmData.Equals("")) xpmData = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(xpmData))
{
SPerform(2405,(uint)type, (uint)b);
}
}

/// <summary>
/// Clear all the registered XPM images.
/// </summary>
public void ClearRegisteredImages()
{
SPerform(2408, 0, 0);
}

/// <summary>
/// Retrieve the contents of a line.
/// </summary>
unsafe public string GetLine(int line)
{
try
{
int sz = (int)SPerform(2153, (uint)line, 0);
byte[] buffer = new byte[sz + 1];
fixed (byte* b = buffer) SPerform(2153, (uint)line, (uint)b);
if (buffer[sz - 1] == 10) sz--;
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz);
}
catch
{
return "";
}
}

/// <summary>
/// Select a range of text.
/// </summary>
public void SetSel(int start, int end)
{
SPerform(2160, (uint)start, (uint)end);
}

/// <summary>
/// Retrieve the selected text.
/// Return the length of the text.
/// </summary>
unsafe public string SelText
{
get
{
int sz = (int)SPerform(2161,0 ,0);
byte[] buffer = new byte[sz+1];
fixed (byte* b = buffer)
{
SPerform(2161, (UInt32)sz + 1, (uint)b);
}
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz-1);
}
}

/// <summary>
/// Draw the selection in normal style or with selection highlighted.
/// </summary>
public void HideSelection(bool normal)
{
SPerform(2163, (uint)(normal ? 1 : 0), 0);
}

/// <summary>
/// Retrieve the x value of the point in the window where a position is displayed.
/// </summary>
public int PointXFromPosition(int pos)
{
return (int) SPerform(2164, 0, (uint)pos);
}

/// <summary>
/// Retrieve the y value of the point in the window where a position is displayed.
/// </summary>
public int PointYFromPosition(int pos)
{
return (int) SPerform(2165, 0, (uint)pos);
}

/// <summary>
/// Retrieve the line containing a position.
/// </summary>
public int LineFromPosition(int pos)
{
return (int) SPerform(2166, (uint)pos, 0);
}

/// <summary>
/// Retrieve the position at the start of a line.
/// </summary>
public int PositionFromLine(int line)
{
return (int) SPerform(2167, (uint)line, 0);
}

/// <summary>
/// Scroll horizontally and vertically.
/// </summary>
public void LineScroll(int columns, int lines)
{
SPerform(2168, (uint)columns, (uint)lines);
}

/// <summary>
/// Ensure the caret is visible.
/// </summary>
public void ScrollCaret()
{
SPerform(2169, 0, 0);
}

/// <summary>
/// Replace the selected text with the argument text.
/// </summary>
unsafe public void ReplaceSel(string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2170,0 , (uint)b);
}
}

/// <summary>
/// Null operation.
/// </summary>
public void Null()
{
SPerform(2172, 0, 0);
}

/// <summary>
/// Delete the undo history.
/// </summary>
public void EmptyUndoBuffer()
{
SPerform(2175, 0, 0);
}

/// <summary>
/// Undo one action in the undo history.
/// </summary>
public void Undo()
{
SPerform(2176, 0, 0);
}

/// <summary>
/// Cut the selection to the clipboard.
/// </summary>
public void Cut()
{
SPerform(2177, 0, 0);
}

/// <summary>
/// Copy the selection to the clipboard.
/// </summary>
public void Copy()
{
SPerform(2178, 0, 0);
}

/// <summary>
/// Copy the selection to the clipboard as RTF.
/// </summary>
public void CopyRTF()
{
Language language = ScintillaControl.Configuration.GetLanguage(this.configLanguage);
String conversion = RTF.GetConversion(language, this, this.SelectionStart, this.SelectionEnd);
Clipboard.SetText(conversion, TextDataFormat.Rtf);
}

/// <summary>
/// Paste the contents of the clipboard into the document replacing the selection.
/// </summary>
public void Paste()
{
SPerform(2179, 0, 0);
}

/// <summary>
/// Clear the selection.
/// </summary>
public void Clear()
{
SPerform(2180, 0, 0);
}

/// <summary>
/// Replace the contents of the document with the argument text.
/// </summary>
unsafe public void SetText(string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2181, 0, (uint)b);
}
}

/// <summary>
/// Retrieve all the text in the document. Returns number of characters retrieved.
/// </summary>
unsafe public string GetText(int length)
{
int sz = (int)SPerform(2182, (uint)length, 0);
byte[] buffer = new byte[sz+1];
fixed (byte* b = buffer)SPerform(2182, (uint)length+1, (uint)b);
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz-1);
}

/// <summary>
/// Replace the target text with the argument text.
/// Text is counted so it can contain NULs.
/// Returns the length of the replacement text.
/// </summary>
unsafe public int ReplaceTarget(int length, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
return (int)SPerform(2194, (uint)length, (uint)b);
}
}

/// <summary>
/// Replace the target text with the argument text after \d processing.
/// Text is counted so it can contain NULs.
/// Looks for \d where d is between 1 and 9 and replaces these with the strings
/// matched in the last search operation which were surrounded by \( and \).
/// Returns the length of the replacement text including any change
/// caused by processing the \d patterns.
/// </summary>
unsafe public int ReplaceTargetRE(int length, string text )
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
return (int) SPerform(2195, (uint)length, (uint)b);
}
}

/// <summary>
/// Search for a counted string in the target and set the target to the found
/// range. Text is counted so it can contain NULs.
/// Returns length of range or -1 for failure in which case target is not moved.
/// </summary>
unsafe public int SearchInTarget(int length, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
return (int) SPerform(2197, (uint)length, (uint)b);
}
}

/// <summary>
/// Show a call tip containing a definition near position pos.
/// </summary>
unsafe public void CallTipShow(int pos, string definition)
{
if (definition == null || definition.Equals("")) definition = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(definition))
{
SPerform(2200, (uint)pos, (uint)b);
}
}

/// <summary>
/// Remove the call tip from the screen.
/// </summary>
public void CallTipCancel()
{
SPerform(2201, 0, 0);
}

/// <summary>
/// Highlight a segment of the definition.
/// </summary>
public void CallTipSetHlt(int start, int end)
{
SPerform(2204, (uint)start, (uint)end);
}

/// <summary>
/// Set the background colour for the call tip.
/// </summary>
public void CallTipSetBack(int color)
{
SPerform(2205, (uint)color, 0);
}

/// <summary>
/// Set the foreground colour for the call tip.
/// </summary>
public void CallTipSetFore(int color)
{
SPerform(2206, (uint)color, 0);
}

/// <summary>
/// Set the foreground colour for the highlighted part of the call tip.
/// </summary>
public void CallTipSetForeHlt(int color)
{
SPerform(2207, (uint)color, 0);
}

/// <summary>
/// Find the display line of a document line taking hidden lines into account.
/// </summary>
public int VisibleFromDocLine(int line)
{
return (int) SPerform(2220, (uint)line, 0);
}

/// <summary>
/// Find the document line of a display line taking hidden lines into account.
/// </summary>
public int DocLineFromVisible(int lineDisplay)
{
return (int) SPerform(2221, (uint)lineDisplay, 0);
}

/// <summary>
/// Make a range of lines visible.
/// </summary>
public void ShowLines(int lineStart, int lineEnd)
{
SPerform(2226, (uint)lineStart, (uint)lineEnd);
}

/// <summary>
/// Make a range of lines invisible.
/// </summary>
public void HideLines(int lineStart, int lineEnd)
{
SPerform(2227, (uint)lineStart, (uint)lineEnd);
}

/// <summary>
/// Switch a header line between expanded and contracted.
/// </summary>
public void ToggleFold(int line)
{
SPerform(2231, (uint)line, 0);
}

/// <summary>
/// Ensure a particular line is visible by expanding any header line hiding it.
/// </summary>
public void EnsureVisible(int line)
{
SPerform(2232, (uint)line, 0);
}

/// <summary>
/// Set some style options for folding.
/// </summary>
public void SetFoldFlags(int flags)
{
SPerform(2233, (uint)flags, 0);
}

/// <summary>
/// Ensure a particular line is visible by expanding any header line hiding it.
/// Use the currently set visibility policy to determine which range to display.
/// </summary>
public void EnsureVisibleEnforcePolicy(int line)
{
SPerform(2234, (uint)line, 0);
}

/// <summary>
/// Get position of start of word.
/// </summary>
public int WordStartPosition(int pos, bool onlyWordCharacters)
{
return (int) SPerform(2266, (uint)pos, (uint)(onlyWordCharacters ? 1 : 0));
}

/// <summary>
/// Get position of end of word.
/// </summary>
public int WordEndPosition(int pos, bool onlyWordCharacters)
{
return (int) SPerform(2267, (uint)pos, (uint)(onlyWordCharacters ? 1 : 0));
}

/// <summary>
/// Measure the pixel width of some text in a particular style.
/// NUL terminated text argument.
/// Does not handle tab or control characters.
/// </summary>
unsafe public int TextWidth(int style, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
return (int) SPerform(2276, (uint)style, (uint)b);
}
}

/// <summary>
/// Retrieve the height of a particular line of text in pixels.
/// </summary>
public int TextHeight(int line)
{
return (int) SPerform(2279, (uint)line, 0);
}

/// <summary>
/// Append a string to the end of the document without changing the selection.
/// </summary>
unsafe public void AppendText(int length, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2282, (uint)length, (uint)b);
}
}

/// <summary>
/// Make the target range start and end be the same as the selection range start and end.
/// </summary>
public void TargetFromSelection()
{
SPerform(2287, 0, 0);
}

/// <summary>
/// Join the lines in the target.
/// </summary>
public void LinesJoin()
{
SPerform(2288, 0, 0);
}

/// <summary>
/// Split the lines in the target into lines that are less wide than pixelWidth
/// where possible.
/// </summary>
public void LinesSplit(int pixelWidth)
{
SPerform(2289, (uint)pixelWidth, 0);
}

/// <summary>
/// Set the colours used as a chequerboard pattern in the fold margin
/// </summary>
public void SetFoldMarginColour(bool useSetting, int back)
{
SPerform(2290,(uint)(useSetting ? 1 : 0), (uint)back);
}

/// <summary>
/// Set the colours used as a chequerboard pattern in the fold margin
/// </summary>
public void SetFoldMarginHiColour(bool useSetting, int fore)
{
SPerform(2291,(uint)(useSetting ? 1 : 0), (uint)fore);
}

/// <summary>
/// Move caret down one line.
/// </summary>
public void LineDown()
{
SPerform(2300, 0, 0);
}

/// <summary>
/// Move caret down one line extending selection to new caret position.
/// </summary>
public void LineDownExtend()
{
SPerform(2301, 0, 0);
}

/// <summary>
/// Move caret up one line.
/// </summary>
public void LineUp()
{
SPerform(2302, 0, 0);
}

/// <summary>
/// Move caret up one line extending selection to new caret position.
/// </summary>
public void LineUpExtend()
{
SPerform(2303, 0, 0);
}

/// <summary>
/// Move caret left one character.
/// </summary>
public void CharLeft()
{
SPerform(2304, 0, 0);
}

/// <summary>
/// Move caret left one character extending selection to new caret position.
/// </summary>
public void CharLeftExtend()
{
SPerform(2305, 0, 0);
}

/// <summary>
/// Move caret right one character.
/// </summary>
public void CharRight()
{
SPerform(2306, 0, 0);
}

/// <summary>
/// Move caret right one character extending selection to new caret position.
/// </summary>
public void CharRightExtend()
{
SPerform(2307, 0, 0);
}

/// <summary>
/// Move caret left one word.
/// </summary>
public void WordLeft()
{
SPerform(2308, 0, 0);
}

/// <summary>
/// Move caret left one word extending selection to new caret position.
/// </summary>
public void WordLeftExtend()
{
SPerform(2309, 0, 0);
}

/// <summary>
/// Move caret right one word.
/// </summary>
public void WordRight()
{
SPerform(2310, 0, 0);
}

/// <summary>
/// Move caret right one word extending selection to new caret position.
/// </summary>
public void WordRightExtend()
{
SPerform(2311, 0, 0);
}

/// <summary>
/// Move caret to first position on line.
/// </summary>
public void Home()
{
SPerform(2312, 0, 0);
}

/// <summary>
/// Move caret to first position on line extending selection to new caret position.
/// </summary>
public void HomeExtend()
{
SPerform(2313, 0, 0);
}

/// <summary>
/// Move caret to last position on line.
/// </summary>
public void LineEnd()
{
SPerform(2314, 0, 0);
}

/// <summary>
/// Move caret to last position on line extending selection to new caret position.
/// </summary>
public void LineEndExtend()
{
SPerform(2315, 0, 0);
}

/// <summary>
/// Move caret to first position in document.
/// </summary>
public void DocumentStart()
{
SPerform(2316, 0, 0);
}

/// <summary>
/// Move caret to first position in document extending selection to new caret position.
/// </summary>
public void DocumentStartExtend()
{
SPerform(2317, 0, 0);
}

/// <summary>
/// Move caret to last position in document.
/// </summary>
public void DocumentEnd()
{
SPerform(2318, 0, 0);
}

/// <summary>
/// Move caret to last position in document extending selection to new caret position.
/// </summary>
public void DocumentEndExtend()
{
SPerform(2319, 0, 0);
}

/// <summary>
/// Move caret one page up.
/// </summary>
public void PageUp()
{
SPerform(2320, 0, 0);
}

/// <summary>
/// Move caret one page up extending selection to new caret position.
/// </summary>
public void PageUpExtend()
{
SPerform(2321, 0, 0);
}

/// <summary>
/// Move caret one page down.
/// </summary>
public void PageDown()
{
SPerform(2322, 0, 0);
}

/// <summary>
/// Move caret one page down extending selection to new caret position.
/// </summary>
public void PageDownExtend()
{
SPerform(2323, 0, 0);
}

/// <summary>
/// Switch from insert to overtype mode or the reverse.
/// </summary>
public void EditToggleOvertype()
{
SPerform(2324, 0, 0);
}

/// <summary>
/// Cancel any modes such as call tip or auto-completion list display.
/// </summary>
public void Cancel()
{
SPerform(2325, 0, 0);
}

/// <summary>
/// Delete the selection or if no selection, the character before the caret.
/// </summary>
public void DeleteBack()
{
SPerform(2326, 0, 0);
}

/// <summary>
/// If selection is empty or all on one line replace the selection with a tab character.
/// If more than one line selected, indent the lines.
/// </summary>
public void Tab()
{
SPerform(2327, 0, 0);
}

/// <summary>
/// Dedent the selected lines.
/// </summary>
public void BackTab()
{
SPerform(2328, 0, 0);
}

/// <summary>
/// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
/// </summary>
public void NewLine()
{
SPerform(2329, 0, 0);
}

/// <summary>
/// Insert a Form Feed character.
/// </summary>
public void FormFeed()
{
SPerform(2330, 0, 0);
}

/// <summary>
/// Move caret to before first visible character on line.
/// If already there move to first character on line.
/// </summary>
public void VCHome()
{
SPerform(2331, 0, 0);
}

/// <summary>
/// Like VCHome but extending selection to new caret position.
/// </summary>
public void VCHomeExtend()
{
SPerform(2332, 0, 0);
}

/// <summary>
/// Magnify the displayed text by increasing the sizes by 1 point.
/// </summary>
public void ZoomIn()
{
SPerform(2333, 0, 0);
}

/// <summary>
/// Make the displayed text smaller by decreasing the sizes by 1 point.
/// </summary>
public void ZoomOut()
{
SPerform(2334, 0, 0);
}

/// <summary>
/// Delete the word to the left of the caret.
/// </summary>
public void DelWordLeft()
{
SPerform(2335, 0, 0);
}

/// <summary>
/// Delete the word to the right of the caret.
/// </summary>
public void DelWordRight()
{
SPerform(2336, 0, 0);
}

/// <summary>
/// Cut the line containing the caret.
/// </summary>
public void LineCut()
{
SPerform(2337, 0, 0);
}

/// <summary>
/// Delete the line containing the caret.
/// </summary>
public void LineDelete()
{
SPerform(2338, 0, 0);
}

/// <summary>
/// Switch the current line with the previous.
/// </summary>
public void LineTranspose()
{
SPerform(2339, 0, 0);
}

/// <summary>
/// Duplicate the current line.
/// </summary>
public void LineDuplicate()
{
SPerform(2404, 0, 0);
}

/// <summary>
/// Transform the selection to lower case.
/// </summary>
public void LowerCase()
{
this.ReplaceSel(this.SelText.ToLower());
}

/// <summary>
/// Transform the selection to upper case.
/// </summary>
public void UpperCase()
{
this.ReplaceSel(this.SelText.ToUpper());
}

/// <summary>
/// Scroll the document down, keeping the caret visible.
/// </summary>
public void LineScrollDown()
{
SPerform(2342, 0, 0);
}

/// <summary>
/// Scroll the document up, keeping the caret visible.
/// </summary>
public void LineScrollUp()
{
SPerform(2343, 0, 0);
}

/// <summary>
/// Delete the selection or if no selection, the character before the caret.
/// Will not delete the character before at the start of a line.
/// </summary>
public void DeleteBackNotLine()
{
SPerform(2344, 0, 0);
}

/// <summary>
/// Move caret to first position on display line.
/// </summary>
public void HomeDisplay()
{
SPerform(2345, 0, 0);
}

/// <summary>
/// Move caret to first position on display line extending selection to
/// new caret position.
/// </summary>
public void HomeDisplayExtend()
{
SPerform(2346, 0, 0);
}

/// <summary>
/// Move caret to last position on display line.
/// </summary>
public void LineEndDisplay()
{
SPerform(2347, 0, 0);
}

/// <summary>
/// Move caret to last position on display line extending selection to new
/// caret position.
/// </summary>
public void LineEndDisplayExtend()
{
SPerform(2348, 0, 0);
}

/// <summary>
/// </summary>
public void HomeWrap()
{
SPerform(2349, 0, 0);
}

/// <summary>
/// </summary>
public void HomeWrapExtend()
{
SPerform(2450, 0, 0);
}

/// <summary>
/// </summary>
public void LineEndWrap()
{
SPerform(2451, 0, 0);
}

/// <summary>
/// </summary>
public void LineEndWrapExtend()
{
SPerform(2452, 0, 0);
}

/// <summary>
/// </summary>
public void VCHomeWrap()
{
SPerform(2453, 0, 0);
}

/// <summary>
/// </summary>
public void VCHomeWrapExtend()
{
SPerform(2454, 0, 0);
}

/// <summary>
/// Copy the line containing the caret.
/// </summary>
public void LineCopy()
{
SPerform(2455, 0, 0);
}

/// <summary>
/// Move the caret inside current view if it's not there already.
/// </summary>
public void MoveCaretInsideView()
{
SPerform(2401, 0, 0);
}

/// <summary>
/// How many characters are on a line, not including end of line characters?
/// </summary>
public int LineLength(int line)
{
return (int) SPerform(2350, (uint)line, 0);
}

/// <summary>
/// Highlight the characters at two positions.
/// </summary>
public void BraceHighlight(int pos1, int pos2)
{
SPerform(2351, (uint)pos1, (uint)pos2);
}

/// <summary>
/// Highlight the character at a position indicating there is no matching brace.
/// </summary>
public void BraceBadLight(int pos)
{
SPerform(2352, (uint)pos, 0);
}

/// <summary>
/// Find the position of a matching brace or INVALID_POSITION if no match.
/// </summary>
public int BraceMatch(int pos)
{
return (int) SPerform(2353, (uint)pos, 0);
}

/// <summary>
/// Sets the current caret position to be the search anchor.
/// </summary>
public void SearchAnchor()
{
SPerform(2366, 0, 0);
}

/// <summary>
/// Find some text starting at the search anchor.
/// Does not ensure the selection is visible.
/// </summary>
unsafe public int SearchNext(int flags, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
return (int)SPerform(2367, (uint)flags, (uint)b);
}
}

/// <summary>
/// Find some text starting at the search anchor and moving backwards.
/// Does not ensure the selection is visible.
/// </summary>
unsafe public int SearchPrev(int flags, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
return (int)SPerform(2368,(uint)flags, (uint)b);
}
}

/// <summary>
/// Set whether a pop up menu is displayed automatically when the user presses
/// the wrong mouse button.
/// </summary>
public void UsePopUp(bool allowPopUp)
{
SPerform(2371, (uint)(allowPopUp ? 1 : 0), 0);
}

/// <summary>
/// Create a new document object.
/// Starts with reference count of 1 and not selected into editor.
/// Extend life of document.
/// </summary>
public void AddRefDocument(int doc)
{
SPerform(2376, 0, (uint)doc );
}

/// <summary>
/// Release a reference to the document, deleting document if it fades to black.
/// </summary>
public void ReleaseDocument(int doc)
{
SPerform(2377, 0, (uint)doc );
}

/// <summary>
/// Move to the previous change in capitalisation.
/// </summary>
public void WordPartLeft()
{
SPerform(2390, 0, 0);
}

/// <summary>
/// Move to the previous change in capitalisation extending selection
/// to new caret position.
/// </summary>
public void WordPartLeftExtend()
{
SPerform(2391, 0, 0);
}

/// <summary>
/// Move to the change next in capitalisation.
/// </summary>
public void WordPartRight()
{
SPerform(2392, 0, 0);
}

/// <summary>
/// Move to the next change in capitalisation extending selection
/// to new caret position.
/// </summary>
public void WordPartRightExtend()
{
SPerform(2393, 0, 0);
}

/// <summary>
/// Constants for use with SetVisiblePolicy, similar to SetCaretPolicy.
/// Set the way the display area is determined when a particular line
/// is to be moved to by Find, FindNext, GotoLine, etc.
/// </summary>
public void SetVisiblePolicy(int visiblePolicy, int visibleSlop)
{
SPerform(2394, (uint)visiblePolicy, (uint)visibleSlop);
}

/// <summary>
/// Delete back from the current position to the start of the line.
/// </summary>
public void DelLineLeft()
{
SPerform(2395, 0, 0);
}

/// <summary>
/// Delete forwards from the current position to the end of the line.
/// </summary>
public void DelLineRight()
{
SPerform(2396, 0, 0);
}

/// <summary>
/// Set the last x chosen value to be the caret x position.
/// </summary>
public void ChooseCaretX()
{
SPerform(2399, 0, 0);
}

/// <summary>
/// Set the focus to this Scintilla widget.
/// GTK+ Specific.
/// </summary>
public void GrabFocus()
{
SPerform(2400, 0, 0);
}

/// <summary>
/// Set the way the caret is kept visible when going sideway.
/// The exclusion zone is given in pixels.
/// </summary>
public void SetXCaretPolicy(int caretPolicy, int caretSlop)
{
SPerform(2402, (uint)caretPolicy, (uint)caretSlop);
}

/// <summary>
/// Set the way the line the caret is on is kept visible.
/// The exclusion zone is given in lines.
/// </summary>
public void SetYCaretPolicy(int caretPolicy, int caretSlop)
{
SPerform(2403, (uint)caretPolicy, (uint)caretSlop);
}

/// <summary>
/// Move caret between paragraphs (delimited by empty lines).
/// </summary>
public void ParaDown()
{
SPerform(2413, 0, 0);
}

/// <summary>
/// Move caret between paragraphs (delimited by empty lines).
/// </summary>
public void ParaDownExtend()
{
SPerform(2414, 0, 0);
}

/// <summary>
/// Move caret between paragraphs (delimited by empty lines).
/// </summary>
public void ParaUp()
{
SPerform(2415, 0, 0);
}

/// <summary>
/// Move caret between paragraphs (delimited by empty lines).
/// </summary>
public void ParaUpExtend()
{
SPerform(2416, 0, 0);
}

/// <summary>
/// Given a valid document position, return the previous position taking code
/// page into account. Returns 0 if passed 0.
/// </summary>
public int PositionBefore(int pos)
{
return (int)SPerform(2417, (uint)pos, 0);
}

/// <summary>
/// Given a valid document position, return the next position taking code
/// page into account. Maximum value returned is the last position in the document.
/// </summary>
public int PositionAfter(int pos)
{
return (int)SPerform(2418, (uint)pos, 0);
}

/// <summary>
/// Copy a range of text to the clipboard. Positions are clipped into the document.
/// </summary>
public void CopyRange(int start, int end)
{
SPerform(2419, (uint)start, (uint)end);
}

/// <summary>
/// Copy argument text to the clipboard.
/// </summary>
unsafe public void CopyText(int length, string text)
{
if (text == null || text.Equals(""))text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2420,(uint)length, (uint)b);
}
}

/// <summary>
/// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
/// </summary>
public int GetLineSelStartPosition(int line)
{
return (int)SPerform(2424, (uint)line, 0);
}

/// <summary>
/// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
/// </summary>
public int GetLineSelEndPosition(int line)
{
return (int)SPerform(2425, (uint)line, 0);
}

/// <summary>
/// Move caret down one line, extending rectangular selection to new caret position.
/// </summary>
public void LineDownRectExtend()
{
SPerform(2426, 0, 0);
}

/// <summary>
/// Move caret up one line, extending rectangular selection to new caret position.
/// </summary>
public void LineUpRectExtend()
{
SPerform(2427, 0, 0);
}

/// <summary>
/// Move caret left one character, extending rectangular selection to new caret position.
/// </summary>
public void CharLeftRectExtend()
{
SPerform(2428, 0, 0);
}

/// <summary>
/// Move caret right one character, extending rectangular selection to new caret position.
/// </summary>
public void CharRightRectExtend()
{
SPerform(2429, 0, 0);
}

/// <summary>
/// Move caret to first position on line, extending rectangular selection to new caret position.
/// </summary>
public void HomeRectExtend()
{
SPerform(2430, 0, 0);
}

/// <summary>
/// Move caret to before first visible character on line.
/// If already there move to first character on line.
/// In either case, extend rectangular selection to new caret position.
/// </summary>
public void VCHomeRectExtend()
{
SPerform(2431, 0, 0);
}

/// <summary>
/// Move caret to last position on line, extending rectangular selection to new caret position.
/// </summary>
public void LineEndRectExtend()
{
SPerform(2432, 0, 0);
}

/// <summary>
/// Move caret one page up, extending rectangular selection to new caret position.
/// </summary>
public void PageUpRectExtend()
{
SPerform(2433, 0, 0);
}

/// <summary>
/// Move caret one page down, extending rectangular selection to new caret position.
/// </summary>
public void PageDownRectExtend()
{
SPerform(2434, 0, 0);
}

/// <summary>
/// Move caret to top of page, or one page up if already at top of page.
/// </summary>
public void StutteredPageUp()
{
SPerform(2435, 0, 0);
}

/// <summary>
/// Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
/// </summary>
public void StutteredPageUpExtend()
{
SPerform(2436, 0, 0);
}

/// <summary>
/// Move caret to bottom of page, or one page down if already at bottom of page.
/// </summary>
public void StutteredPageDown()
{
SPerform(2437, 0, 0);
}

/// <summary>
/// Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
/// </summary>
public void StutteredPageDownExtend()
{
SPerform(2438, 0, 0);
}

/// <summary>
/// Move caret left one word, position cursor at end of word.
/// </summary>
public void WordLeftEnd()
{
SPerform(2439, 0, 0);
}

/// <summary>
/// Move caret left one word, position cursor at end of word, extending selection to new caret position.
/// </summary>
public void WordLeftEndExtend()
{
SPerform(2440, 0, 0);
}

/// <summary>
/// Move caret right one word, position cursor at end of word.
/// </summary>
public void WordRightEnd()
{
SPerform(2441, 0, 0);
}

/// <summary>
/// Move caret right one word, position cursor at end of word, extending selection to new caret position.
/// </summary>
public void WordRightEndExtend()
{
SPerform(2442, 0, 0);
}

/// <summary>
/// Set the set of characters making up whitespace for when moving or selecting by word. Should be called after WordChars.
/// </summary>
unsafe public void WhitespaceChars(string characters)
{
if (characters == null || characters.Equals("")) characters = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(characters))
{
SPerform(2443, 0, (uint)b);
}
}

/// <summary>
/// Reset the set of characters for whitespace and word characters to the defaults.
/// </summary>
public void SetCharsDefault()
{
SPerform(2444, 0, 0);
}

/// <summary>
/// Enlarge the document to a particular size of text bytes.
/// </summary>
public void Allocate(int bytes)
{
SPerform(2446, (uint)bytes, 0);
}

/// <summary>
/// Start notifying the container of all key presses and commands.
/// </summary>
public void StartRecord()
{
SPerform(3001, 0, 0);
}

/// <summary>
/// Stop notifying the container of all key presses and commands.
/// </summary>
public void StopRecord()
{
SPerform(3002, 0, 0);
}

/// <summary>
/// Colourise a segment of the document using the current lexing language.
/// </summary>
public void Colourise(int start, int end)
{
SPerform(4003, (uint)start, (uint)end);
}

/// <summary>
/// Load a lexer library (dll / so).
/// </summary>
unsafe public void LoadLexerLibrary(string path)
{
if (path == null || path.Equals("")) path = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(path))
{
SPerform(4007, 0, (uint)b);
}
}

/// <summary>
/// Find the position of a column on a line taking into account tabs and
/// multi-byte characters. If beyond end of line, return line end position.
/// </summary>
public int FindColumn(int line, int column)
{
return (int)SPerform(2456, (uint)line, (uint)column);
}

/// <summary>
/// Turn a indicator on over a range.
/// </summary>
public void IndicatorFillRange(int position, int fillLength)
{
SPerform(2504, (uint)position, (uint)fillLength);
}

/// <summary>
/// Turn a indicator off over a range.
/// </summary>
public void IndicatorClearRange(int position, int clearLength)
{
SPerform(2505, (uint)position, (uint)clearLength);
}

/// <summary>
/// Are any indicators present at position?
/// </summary>
public int IndicatorAllOnFor(int position)
{
return (int)SPerform(2506, (uint)position, 0);
}

/// <summary>
/// What value does a particular indicator have at at a position?
/// </summary>
public int IndicatorValueAt(int indicator, int position)
{
return (int)SPerform(2507, (uint)indicator, (uint)position);
}

/// <summary>
/// Where does a particular indicator start?
/// </summary>
public int IndicatorStart(int indicator, int position)
{
return (int)SPerform(2508, (uint)indicator, (uint)position);
}

/// <summary>
/// Where does a particular indicator end?
/// </summary>
public int IndicatorEnd(int indicator, int position)
{
return (int)SPerform(2509, (uint)indicator, (uint)position);
}

/// <summary>
/// Copy the selection, if selection empty copy the line with the caret
/// </summary>
public void CopyAllowLine()
{
SPerform(2519, 0, 0);
}

/// <summary>
/// Set the alpha fill colour of the given indicator.
/// </summary>
public void SetIndicSetAlpha(int indicator, int alpha)
{
SPerform(2523, (uint)indicator, (uint)alpha);
}

/// <summary>
/// Set the alpha fill colour of the given indicator.
/// </summary>
public void GetIndicSetAlpha(int indicator)
{
SPerform(2524, (uint)indicator, 0);
}

/// <summary>
/// Which symbol was defined for markerNumber with MarkerDefine
/// </summary>
public int GetMarkerSymbolDefined(int markerNumber)
{
return (int)SPerform(2529, (uint)markerNumber, 0);
}

/// <summary>
/// Set the text in the text margin for a line
/// </summary>
public void SetMarginStyle(int line, int style)
{
SPerform(2532, (uint)line, (uint)style);
}

/// <summary>
/// Get the style number for the text margin for a line
/// </summary>
public int GetMarginStyle(int line)
{
return (int)SPerform(2533, (uint)line, 0);
}

/// <summary>
/// Clear the margin text on all lines
/// </summary>
public void MarginTextClearAll()
{
SPerform(2536, 0, 0);
}

/// <summary>
/// Find the position of a character from a point within the window.
/// </summary>
public int GetCharPositionFromPoint(int x, int y)
{
return (int)SPerform(2561, (uint)x, (uint)y);
}

/// <summary>
/// Find the position of a character from a point within the window. Return INVALID_POSITION if not close to text.
/// </summary>
public int GetCharPositionFromPointClose(int x, int y)
{
return (int)SPerform(2562, (uint)x, (uint)y);
}

/// <summary>
/// Add a container action to the undo stack
/// </summary>
public void AddUndoAction(int token, int flags)
{
SPerform(2560, (uint)token, (uint)flags);
}

/// <summary>
/// Set the style number for the annotations for a line
/// </summary>
public void SetAnnotationStyle(int line, int style)
{
SPerform(2542, (uint)line, (uint)style);
}

/// <summary>
/// Get the style number for the annotations for a line
/// </summary>
public int GetAnnotationStyle(int line)
{
return (int)SPerform(2543, (uint)line, 0);
}

/// <summary>
/// Clear the annotations from all lines
/// </summary>
public void AnnotatioClearAll()
{
SPerform(2547, 0, 0);
}

/// <summary>
/// Get the number of annotation lines for a line
/// </summary>
public int GetAnnotationLines(int line)
{
return (int)SPerform(2546, (uint)line, 0);
}

/// <summary>
/// Set the text in the text margin for a line
/// </summary>
unsafe public void SetMarginText(int line, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2530, (uint)line, (uint)b);
}
}

/// <summary>
/// Set the style in the text margin for a line
/// </summary>
unsafe public void SetMarginStyles(int line, string styles)
{
if (styles == null || styles.Equals("")) styles = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(styles))
{
SPerform(2534, (uint)line, (uint)b);
}
}

/// <summary>
/// Set the annotation text for a line
/// </summary>
unsafe public void SetAnnotationText(int line, string text)
{
if (text == null || text.Equals("")) text = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(text))
{
SPerform(2540, (uint)line, (uint)b);
}
}

/// <summary>
/// Set the annotation styles for a line
/// </summary>
unsafe public void SetAnnotationStyles(int line, string styles)
{
if (styles == null || styles.Equals("")) styles = "\0\0";
fixed (byte* b = Encoding.GetEncoding(this.CodePage).GetBytes(styles))
{
SPerform(2544, (uint)line, (uint)b);
}
}

/// <summary>
/// Get the text in the text margin for a line
/// </summary>
unsafe public string GetMarginText(int line)
{
int sz = (int)SPerform(2531, (uint)line, 0);
byte[] buffer = new byte[sz + 1];
fixed (byte* b = buffer) SPerform(2531, (uint)line + 1, (uint)b);
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz - 1);
}

/// <summary>
/// Get the styles in the text margin for a line
/// </summary>
unsafe public string GetMarginStyles(int line)
{
int sz = (int)SPerform(2535, (uint)line, 0);
byte[] buffer = new byte[sz + 1];
fixed (byte* b = buffer) SPerform(2535, (uint)line + 1, (uint)b);
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz - 1);
}

/// <summary>
/// Get the annotation text for a line
/// </summary>
unsafe public string GetAnnotationText(int line)
{
int sz = (int)SPerform(2541, (uint)line, 0);
byte[] buffer = new byte[sz + 1];
fixed (byte* b = buffer) SPerform(2541, (uint)line + 1, (uint)b);
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz - 1);
}

/// <summary>
/// Get the annotation styles for a line
/// </summary>
unsafe public string GetAnnotationStyles(int line)
{
int sz = (int)SPerform(2545, (uint)line, 0);
byte[] buffer = new byte[sz + 1];
fixed (byte* b = buffer) SPerform(2545, (uint)line + 1, (uint)b);
return Encoding.GetEncoding(this.CodePage).GetString(buffer, 0, sz - 1);
}

#endregion

#region Scintilla Constants

private const int WM_NOTIFY = 0x004e;
private const int WM_SYSCHAR = 0x106;
private const int WM_COMMAND = 0x0111;
private const int WM_KEYDOWN = 0x0100;
private const int WM_SYSKEYDOWN = 0x0104;
private const int WM_DROPFILES = 0x0233;
private const uint WS_CHILD = (uint)0x40000000L;
private const uint WS_VISIBLE = (uint)0x10000000L;
private const uint WS_TABSTOP = (uint)0x00010000L;
private const uint WS_CHILD_VISIBLE_TABSTOP = WS_CHILD|WS_VISIBLE|WS_TABSTOP;
public const int MAXDWELLTIME = 10000000;
private const int PATH_LEN = 1024;

#endregion

#region Scintilla External

[DllImport("gdi32.dll")]
public static extern int GetDeviceCaps(IntPtr hdc, Int32 capindex);

[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);

[DllImport("user32.dll")]
public static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);

[DllImport("shell32.dll")]
public static extern int DragQueryFileA(IntPtr hDrop, uint idx, IntPtr buff, int sz);

[DllImport("shell32.dll")]
public static extern int DragFinish(IntPtr hDrop);

[DllImport("shell32.dll")]
public static extern void DragAcceptFiles(IntPtr hwnd, int accept);

[DllImport("scilexer.dll", EntryPoint = "Scintilla_DirectFunction")]
public static extern int Perform(int directPointer, UInt32 message, UInt32 wParam, UInt32 lParam);

public UInt32 SlowPerform(UInt32 message, UInt32 wParam, UInt32 lParam)
{
return (UInt32)SendMessage((int)hwndScintilla, message, (int)wParam, (int)lParam);
}

public UInt32 FastPerform(UInt32 message, UInt32 wParam, UInt32 lParam)
{
return (UInt32)Perform(directPointer, message, wParam, lParam);
}

public UInt32 SPerform(UInt32 message, UInt32 wParam, UInt32 lParam)
{
return (UInt32)Perform(directPointer, message, wParam, lParam);
}

protected override void WndProc(ref System.Windows.Forms.Message m )
{
if (m.Msg == WM_COMMAND)
{
Int32 message = (m.WParam.ToInt32() >> 16) & 0xffff;
if (message == (int)Enums.Command.SetFocus || message == (int)Enums.Command.KillFocus)
{
if (FocusChanged != null) FocusChanged(this);
}
}
else if (m.Msg == WM_NOTIFY)
{
SCNotification scn = (SCNotification)Marshal.PtrToStructure(m.LParam, typeof(SCNotification));
if (scn.nmhdr.hwndFrom == hwndScintilla)
{
switch (scn.nmhdr.code)
{
case (uint)Enums.ScintillaEvents.StyleNeeded:
if (StyleNeeded != null) StyleNeeded(this, scn.position);
break;

case (uint)Enums.ScintillaEvents.CharAdded:
if (CharAdded != null) CharAdded(this, scn.ch);
break;

case (uint)Enums.ScintillaEvents.SavePointReached:
if (SavePointReached != null) SavePointReached(this);
break;

case (uint)Enums.ScintillaEvents.SavePointLeft:
if (SavePointLeft != null) SavePointLeft(this);
break;

case (uint)Enums.ScintillaEvents.ModifyAttemptRO:
if (ModifyAttemptRO != null) ModifyAttemptRO(this);
break;

case (uint)Enums.ScintillaEvents.Key:
if (Key != null) Key(this, scn.ch, scn.modifiers);
break;

case (uint)Enums.ScintillaEvents.DoubleClick:
if (DoubleClick != null) DoubleClick(this);
break;

case (uint)Enums.ScintillaEvents.UpdateUI:
if (UpdateUI != null) UpdateUI(this);
break;

case (uint)Enums.ScintillaEvents.MacroRecord:
if (MacroRecord != null) MacroRecord(this, scn.message, scn.wParam, scn.lParam);
break;

case (uint)Enums.ScintillaEvents.MarginClick:
if (MarginClick != null) MarginClick(this, scn.modifiers, scn.position, scn.margin);
break;

case (uint)Enums.ScintillaEvents.NeedShown:
if (NeedShown != null) NeedShown(this, scn.position, scn.length);
break;

case (uint)Enums.ScintillaEvents.Painted:
if (Painted != null) Painted(this);
break;

case (uint)Enums.ScintillaEvents.UserListSelection:
if (UserListSelection != null) UserListSelection(this, scn.listType, MarshalStr(scn.text));
break;

case (uint)Enums.ScintillaEvents.URIDropped:
if (URIDropped != null) URIDropped(this, MarshalStr(scn.text));
break;

case (uint)Enums.ScintillaEvents.DwellStart:
if (DwellStart != null) DwellStart(this, scn.position);
break;

case (uint)Enums.ScintillaEvents.DwellEnd:
if (DwellEnd != null) DwellEnd(this, scn.position);
break;

case (uint)Enums.ScintillaEvents.Zoom:
if (Zoom != null) Zoom(this);
break;

case (uint)Enums.ScintillaEvents.HotspotClick:
if (HotSpotClick != null) HotSpotClick(this, scn.modifiers, scn.position);
break;

case (uint)Enums.ScintillaEvents.HotspotDoubleClick:
if (HotSpotDoubleClick != null) HotSpotDoubleClick(this, scn.modifiers, scn.position);
break;

case (uint)Enums.ScintillaEvents.CalltipClick:
if (CallTipClick != null) CallTipClick(this, scn.position);
break;

case (uint)Enums.ScintillaEvents.AutoCSelection:
if (AutoCSelection != null) AutoCSelection(this, MarshalStr(scn.text));
break;

case (uint)Enums.ScintillaEvents.IndicatorClick:
if (IndicatorClick != null) IndicatorClick(this, scn.position);
break;

case (uint)Enums.ScintillaEvents.IndicatorRelease:
if (IndicatorRelease != null) IndicatorRelease(this, scn.position);
break;

case (uint)Enums.ScintillaEvents.AutoCCharDeleted:
if (AutoCCharDeleted != null) AutoCCharDeleted(this);
break;

case (uint)Enums.ScintillaEvents.AutoCCancelled:
if (AutoCCancelled != null) AutoCCancelled(this);
break;

case (uint)Enums.ScintillaEvents.Modified:
bool notify = false;
if ((scn.modificationType & (uint)Enums.ModificationFlags.InsertText)>0)
{
if (TextInserted != null) TextInserted(this, scn.position, scn.length, scn.linesAdded);
notify = true;
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.DeleteText)>0)
{
if (TextDeleted != null) TextDeleted(this, scn.position, scn.length, scn.linesAdded);
notify = true;
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.ChangeStyle)>0)
{
if (StyleChanged != null) StyleChanged(this, scn.position, scn.length);
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.ChangeFold)>0)
{
if (FoldChanged != null ) FoldChanged(this, scn.line, scn.foldLevelNow, scn.foldLevelPrev);
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.UserPerformed)>0)
{
if (UserPerformed != null ) UserPerformed(this);
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.UndoPerformed)>0)
{
if (UndoPerformed != null ) UndoPerformed(this);
notify = true;
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.RedoPerformed)>0)
{
if (RedoPerformed != null ) RedoPerformed(this);
notify = true;
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.LastStepInUndoRedo)>0)
{
if (LastStepInUndoRedo != null ) LastStepInUndoRedo(this);
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.ChangeMarker)>0)
{
if (MarkerChanged != null ) MarkerChanged(this, scn.line);
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.BeforeInsert)>0)
{
if (BeforeInsert != null ) BeforeInsert(this, scn.position, scn.length);
notify = false;
}
if ((scn.modificationType & (uint)Enums.ModificationFlags.BeforeDelete)>0)
{
if (BeforeDelete != null ) BeforeDelete(this, scn.position, scn.length);
notify = false;
}
if (notify && Modified != null && scn.text != null)
{
try
{
string text = MarshalStr(scn.text, scn.length);
Modified(this, scn.position, scn.modificationType, text, scn.length, scn.linesAdded, scn.line, scn.foldLevelNow, scn.foldLevelPrev);
}
catch {}
}
break;
}
}
}
else if (m.Msg == WM_DROPFILES)
{
HandleFileDrop(m.WParam);
}
else
{
base.WndProc(ref m);
}
}

unsafe string MarshalStr(IntPtr p)
{
sbyte* b = (sbyte*)p;
int len = 0;
while (b[len] != 0) ++len;
return new string(b,0,len);
}

unsafe string MarshalStr(IntPtr p, int len)
{
sbyte* b = (sbyte*)p;
return new string(b,0,len);
}

#endregion

#region Automated Features

/// <summary>
/// Provides basic highlighting of selected text
/// </summary>
private void OnSelectHighlight(ScintillaControl sci)
{
sci.RemoveHighlights();
if (Control.ModifierKeys == Keys.Control && sci.SelText.Length != 0)
{
Language language = Configuration.GetLanguage(sci.ConfigurationLanguage);
Int32 color = language.editorstyle.HighlightBackColor;
String pattern = sci.SelText.Trim();
FRSearch search = new FRSearch(pattern);
search.WholeWord = true; search.NoCase = false;
search.Filter = SearchFilter.None; // Everywhere
sci.AddHighlights(search.Matches(sci.Text), color);
sci.hasHighlights = true;
}
}
private void OnCancelHighlight(ScintillaControl sci)
{
if (sci.isHiliteSelected && sci.hasHighlights && sci.SelText.Length == 0)
{
sci.RemoveHighlights();
sci.hasHighlights = false;
}
}

/// <summary>
/// Provides the support for code block selection
/// </summary>
private void OnBlockSelect(ScintillaControl sci)
{
int position = CurrentPos - 1;
char character = (char)CharAt(position);
if (character == '{' || character == '(' || character == '[')
{
if (!this.PositionIsOnComment(position))
{
int bracePosStart = position;
int bracePosEnd = BraceMatch(position);
if (bracePosEnd != -1) SetSel(bracePosStart, bracePosEnd + 1);
}
}
}

/// <summary>
/// Provides the support for brace matching
/// </summary>
private void OnBraceMatch(ScintillaControl sci)
{
if (isBraceMatching && sci.SelText.Length == 0)
{
int position = CurrentPos-1;
char character = (char)CharAt(position);
if (character != '{' && character != '}' && character != '(' && character != ')' && character != '[' && character != ']')
{
position = CurrentPos;
character = (char)CharAt(position);
}
if (character == '{' || character == '}' || character == '(' || character == ')' || character == '[' || character == ']')
{
if (!this.PositionIsOnComment(position))
{
int bracePosStart = position;
int bracePosEnd = BraceMatch(position);
if (bracePosEnd != -1) BraceHighlight(bracePosStart, bracePosEnd);
if (useHighlightGuides)
{
int line = LineFromPosition(position);
HighlightGuide = GetLineIndentation(line);
}
}
else
{
BraceHighlight(-1, -1);
HighlightGuide = 0;
}
}
else
{
BraceHighlight(-1, -1);
HighlightGuide = 0;
}
}
}

/// <summary>
/// Provides support for smart indenting
/// </summary>
///
private void OnSmartIndent(ScintillaControl ctrl, int ch)
{
char newline = (EOLMode == 1) ? '\r' : '\n';
switch (SmartIndentType)
{
case Enums.SmartIndent.None:
return;
case Enums.SmartIndent.Simple:
if (ch == newline)
{
this.BeginUndoAction();
try
{
int curLine = LineFromPosition(CurrentPos);
int previousIndent = GetLineIndentation(curLine - 1);
IndentLine(curLine, previousIndent);
int position = LineIndentPosition(curLine);
SetSel(position, position);
}
finally
{
this.EndUndoAction();
}
}
break;
case Enums.SmartIndent.CPP:
if (ch == newline)
{
this.BeginUndoAction();
try
{
int curLine = LineFromPosition(CurrentPos);
int tempLine = curLine;
int previousIndent;
string tempText;
do
{
previousIndent = GetLineIndentation(tempLine - 1);
tempText = GetLine(tempLine - 1).Trim();
if (tempText.Length == 0) previousIndent = -1;
tempLine--;
}
while ((tempLine > 0) && (previousIndent < 0));
if (tempText.IndexOf("//") > 0) // remove comment at end of line
{
int slashes = this.MBSafeTextLength(tempText.Substring(0, tempText.IndexOf("//") + 1));
if (this.PositionIsOnComment(slashes))
tempText = tempText.Substring(0, tempText.IndexOf("//")).Trim();
}
if (tempText.EndsWith("{"))
{
int bracePos = CurrentPos - 1;
while (bracePos > 0 && CharAt(bracePos) != '{') bracePos--;
if (bracePos >= 0 && CharAt(bracePos) == '{' && BaseStyleAt(bracePos) == 10)
previousIndent += TabWidth;
}
IndentLine(curLine, previousIndent);
int position = LineIndentPosition(curLine);
SetSel(position, position);
if (Control.ModifierKeys == Keys.Shift)
{
int endPos = LineEndPosition(curLine - 1);
int style = BaseStyleAt(endPos - 1);
if (style == 12 || style == 7)
{
string quote = (style == 7) ? "'" : "\"";
InsertText(endPos, quote);
InsertText(position + 1, "+ " + quote);
GotoPos(position + 4);
if (Regex.IsMatch(GetLine(curLine - 1), "=[\\s]*" + quote))
{
SetLineIndentation(curLine, GetLineIndentation(curLine - 1) + TabWidth);
}
}
}
}
finally
{
this.EndUndoAction();
}
}
else if (ch == '}')
{
this.BeginUndoAction();
try
{
int position = CurrentPos;
int curLine = LineFromPosition(position);
int previousIndent = GetLineIndentation(curLine - 1);
int match = SafeBraceMatch(position - 1);
if (match != -1)
{
previousIndent = GetLineIndentation(LineFromPosition(match));
IndentLine(curLine, previousIndent);
}
}
finally
{
this.EndUndoAction();
}
}
break;
case Enums.SmartIndent.Custom:
if (ch == newline)
{
if (SmartIndent != null) SmartIndent(this);
}
break;
}
}

#endregion

#region Misc Custom Stuff

/// <summary>
/// Render the contents for printing
/// </summary>
public int FormatRange(bool measureOnly, PrintPageEventArgs e, int charFrom, int charTo)
{
IntPtr hdc = e.Graphics.GetHdc();
int wParam = (measureOnly ? 0 : 1);
RangeToFormat frPrint = this.GetRangeToFormat(hdc, charFrom, charTo);
IntPtr lParam = Marshal.AllocCoTaskMem(Marshal.SizeOf(frPrint));
Marshal.StructureToPtr(frPrint, lParam, false);
int res = (int)this.SPerform(2151, (uint)wParam, (uint)lParam);
Marshal.FreeCoTaskMem(lParam);
e.Graphics.ReleaseHdc(hdc);
return res;
}

/// <summary>
/// Populates the RangeToFormat struct
/// </summary>
private RangeToFormat GetRangeToFormat(IntPtr hdc, int charFrom, int charTo)
{
RangeToFormat frPrint;
int pageWidth = (int)GetDeviceCaps(hdc, 110);
int pageHeight = (int)GetDeviceCaps(hdc, 111);
frPrint.hdcTarget = hdc;
frPrint.hdc = hdc;
frPrint.rcPage.Left = 0;
frPrint.rcPage.Top = 0;
frPrint.rcPage.Right = pageWidth;
frPrint.rcPage.Bottom = pageHeight;
frPrint.rc.Left = Convert.ToInt32(pageWidth*0.02);
frPrint.rc.Top = Convert.ToInt32(pageHeight*0.03);
frPrint.rc.Right = Convert.ToInt32(pageWidth*0.975);
frPrint.rc.Bottom = Convert.ToInt32(pageHeight*0.95);
frPrint.chrg.cpMin = charFrom;
frPrint.chrg.cpMax = charTo;
return frPrint;
}

/// <summary>
/// Free cached data from the control after printing
/// </summary>
public void FormatRangeDone()
{
this.SPerform(2151, 0, 0);
}

/// <summary>
/// This holds the actual encoding of the document
/// </summary>
public Encoding Encoding
{
set { this.encoding = value; }
get { return this.encoding; }
}

/// <summary>
/// Indicate that BOM characters should be written when saving
/// </summary>
public bool SaveBOM
{
set { this.saveBOM = value; }
get { return this.saveBOM; }
}

/// <summary>
/// Adds a line end marker to the end of the document
/// </summary>
public void AddLastLineEnd()
{
string eolMarker = "\r\n";
if (this.EOLMode == 1) eolMarker = "\r";
else if (this.EOLMode == 2) eolMarker = "\n";
if (!this.Text.EndsWith(eolMarker))
{
this.TargetStart = this.TargetEnd = this.TextLength;
this.ReplaceTarget(eolMarker.Length, eolMarker);
}
}

/// <summary>
/// Removes trailing spaces from each line
/// </summary>
public void StripTrailingSpaces()
{
this.BeginUndoAction();
try
{
int maxLines = this.LineCount;
for (int line = 0; line < maxLines; line++)
{
int lineStart = this.PositionFromLine(line);
int lineEnd = this.LineEndPosition(line);
int i = lineEnd - 1;
char ch = (char)this.CharAt(i);
while ((i >= lineStart) && ((ch == ' ') || (ch == '\t')))
{
i--;
ch = (char)this.CharAt(i);
}
if (i == lineStart - 1)
{
ch = (char)this.CharAt(i + 1);
while (i < lineEnd && ch == '\t')
{
i++;
ch = (char)this.CharAt(i + 1);
}
}
if (i < (lineEnd - 1))
{
this.TargetStart = i + 1;
this.TargetEnd = lineEnd;
this.ReplaceTarget(0, "");
}
}
}
finally
{
this.EndUndoAction();
}
}

/// <summary>
/// Checks that if the specified position is on comment.
/// NOTE: You may need to manually update coloring: "sci.Colourise(0, -1);"
/// </summary>
public bool PositionIsOnComment(int position)
{
return PositionIsOnComment(position, this.Lexer);
}
public bool PositionIsOnComment(int position, int lexer)
{
int style = BaseStyleAt(position);
if ((lexer == 3 || lexer == 18 || lexer == 25 || lexer == 27)
&& style == 1
|| style == 2
|| style == 3
|| style == 15
|| style == 17
|| style == 18)
{
return true; // cpp, tcl, bullant or pascal
}
else if ((lexer == 4 || lexer == 5)
&& style == 9
|| style == 20
|| style == 29
|| style == 30
|| style == 42
|| style == 43
|| style == 44
|| style == 57
|| style == 58
|| style == 59
|| style == 72
|| style == 82
|| style == 92
|| style == 107
|| style == 124
|| style == 125)
{
return true; // html or xml
}
else if ((lexer == 2 || lexer == 21)
&& style == 1
|| style == 12)
{
return true; // python or lisp
}
else if ((lexer == 6 || lexer == 22 || lexer == 45 || lexer == 62)
&& style == 2)
{
return true; // perl, bash, clarion/clw or ruby
}
else if ((lexer == 7)
&& style == 1
|| style == 2
|| style == 3
|| style == 13
|| style == 15
|| style == 17
|| style == 18)
{
return true; // sql
}
else if ((lexer == 8 || lexer == 9 || lexer == 11 || lexer == 12 || lexer == 16 || lexer == 17 || lexer == 19 || lexer == 23 || lexer == 24 || lexer == 26 || lexer == 28 || lexer == 32 || lexer == 36 || lexer == 37 || lexer == 40 || lexer == 44 || lexer == 48 || lexer == 51 || lexer == 53 || lexer == 54 || lexer == 57 || lexer == 63)
&& style == 1)
{
return true; // asn1, vb, diff, batch, makefile, avenue, eiffel, eiffelkw, vbscript, matlab, crontab, fortran, f77, lout, mmixal, yaml, powerbasic, erlang, octave, kix or properties
}
else if ((lexer == 14)
&& style == 4)
{
return true; // latex
}
else if ((lexer == 15 || lexer == 41 || lexer == 56)
&& style == 1
|| style == 2
|| style == 3)
{
return true; // lua, verilog or escript
}
else if ((lexer == 20)
&& style == 10)
{
return true; // ada
}
else if ((lexer == 31 || lexer == 39 || lexer == 42 || lexer == 52 || lexer == 55 || lexer == 58 || lexer == 60 || lexer == 61 || lexer == 64 || lexer == 71)
&& style == 1
|| style == 2)
{
return true; // au3, apdl, baan, ps, mssql, rebol, forth, gui4cli, vhdl or pov
}
else if ((lexer == 34)
&& style == 1
|| style == 11)
{
return true; // asm
}
else if ((lexer == 43)
&& style == 1
|| style == 18)
{
return true; // nsis
}
else if ((lexer == 59)
&& style == 2
|| style == 3)
{
return true; // specman
}
else if ((lexer == 70)
&& style == 3
|| style == 4)
{
return true; // tads3
}
else if ((lexer == 74)
&& style == 1
|| style == 9)
{
return true; // csound
}
else if ((lexer == 65)
&& style == 12
|| style == 13
|| style == 14
|| style == 15)
{
return true; // caml
}
else if ((lexer == 68)
&& style == 13
|| style == 14
|| style == 15
|| style == 16)
{
return true; // haskell
}
else if ((lexer == 73)
&& style == 1
|| style == 2
|| style == 3
|| style == 4
|| style == 5
|| style == 6)
{
return true; // flagship
}
else if ((lexer == 72)
&& style == 3)
{
return true; // smalltalk
}
else if ((lexer == 38)
&& style == 9)
{
return true; // css
}
return false;
}

/// <summary>
/// Indents the specified line
/// </summary>
protected void IndentLine(int line, int indent)
{
if (indent < 0) return;
int selStart = SelectionStart;
int selEnd = SelectionEnd;
int posBefore = LineIndentPosition(line);
SetLineIndentation(line, indent);
int posAfter = LineIndentPosition(line);
int posDifference = posAfter - posBefore;
if (posAfter > posBefore)
{
if (selStart >= posBefore) selStart += posDifference;
if (selEnd >= posBefore) selEnd += posDifference;
}
else if (posAfter < posBefore)
{
if (selStart >= posAfter)
{
if (selStart >= posBefore) selStart += posDifference;
else selStart = posAfter;
}
if (selEnd >= posAfter)
{
if (selEnd >= posBefore) selEnd += posDifference;
else selEnd = posAfter;
}
}
SetSel(selStart, selEnd);
}

/// <summary>
/// Expands all folds
/// </summary>
public void ExpandAllFolds()
{
for (int i = 0; i<LineCount; i++)
{
FoldExpanded(i, true);
ShowLines(i+1, i+1);
}
}

/// <summary>
/// Collapses all folds
/// </summary>
public void CollapseAllFolds()
{
for (int i = 0; i<LineCount; i++)
{
int maxSubOrd = LastChild(i, -1);
FoldExpanded(i, false);
HideLines(i+1, maxSubOrd);
}
}

/// <summary>
/// Only folds functions keeping the blocks within it open
/// </summary>
public void CollapseFunctions()
{
for (int i = 0; i < LineCount; i++)
{
// Determine if function block
string line = GetLine(i);
bool collapse = (line.Contains("function") && line.Contains("(") && line.Contains(")"));

if (collapse)
{
// Get the function opening brace
int maxSubOrd = LastChild(i, -1);
// Get brace if on the next line
if (maxSubOrd == i)
{
i++;
maxSubOrd = LastChild(i, -1);
}

FoldExpanded(i, false);

HideLines(i + 1, maxSubOrd);
i = maxSubOrd;
}
else
{
FoldExpanded(i, true);
ShowLines(i + 1, i + 1);
}
}
}

/// <summary>
/// Selects the specified text, starting from the caret position
/// </summary>
public int SelectText(string text)
{
int pos = this.Text.IndexOf(text, MBSafeCharPosition(this.CurrentPos));
if (pos >= 0) this.MBSafeSetSel(pos, text);
return pos;
}

/// <summary>
/// Selects the specified text, starting from the given position
/// </summary>
public int SelectText(string text, int startPos)
{
int pos = this.Text.IndexOf(text, startPos);
if (pos >= 0) this.MBSafeSetSel(pos, text);
return pos;
}

/// <summary>
/// Gets a word from the specified position
/// </summary>
public string GetWordFromPosition(int position)
{
try
{
int startPosition = this.MBSafeCharPosition(this.WordStartPosition(position, true));
int endPosition = this.MBSafeCharPosition(this.WordEndPosition(position, true));
string keyword = this.Text.Substring(startPosition, endPosition - startPosition);
if (keyword == "" || keyword == " ") return null;
return keyword.Trim();
}
catch
{
return null;
}
}

/// <summary>
/// Insert text with wide-char to byte position conversion
/// </summary>
public void MBSafeInsertText(int position, string text)
{
if (this.CodePage != 65001)
{
this.InsertText(position, text);
}
else
{
int mbpos = this.MBSafePosition(position);
this.InsertText(mbpos, text);
}
}

/// <summary>
/// Set cursor position with wide-char to byte position conversion
/// </summary>
public void MBSafeGotoPos(int position)
{
if (this.CodePage != 65001)
{
this.GotoPos(position);
}
else
{
int mbpos = this.MBSafePosition(position);
this.GotoPos(mbpos);
}
}

/// <summary>
/// Select text using wide-char to byte indexes conversion
/// </summary>
public void MBSafeSetSel(int start, int end)
{
if (this.CodePage != 65001)
{
this.SetSel(start, end);
}
else
{
string count = this.Text.Substring(start, end-start);
start = this.MBSafePosition(start);
end = start+this.MBSafeTextLength(count);
this.SetSel(start, end);
}
}

/// <summary>
/// Select text using wide-char to byte index & text conversion
/// </summary>
public void MBSafeSetSel(int start, string text)
{
if (this.CodePage != 65001)
{
this.SetSel(start, start+text.Length);
}
else
{
int mbpos = this.MBSafePosition(start);
this.SetSel(mbpos, mbpos+this.MBSafeTextLength(text));
}
}

/// <summary>
/// Wide-char to byte position in the editor text
/// </summary>
public int MBSafePosition(int position)
{
if (this.CodePage != 65001)
{
return position;
}
else if (position < 0) return position;
else
{
string count = this.Text.Substring(0, position);
int mbpos = Encoding.UTF8.GetByteCount(count);
return mbpos;
}
}

/// <summary>
/// Byte to wide-char position in the editor text
/// </summary>
public int MBSafeCharPosition(int bytePosition)
{
if (this.CodePage != 65001)
{
return bytePosition;
}
else if (bytePosition < 0) return bytePosition;
else
{
byte[] bytes = Encoding.UTF8.GetBytes(this.Text);
int chrpos = Encoding.UTF8.GetCharCount(bytes, 0, bytePosition);
return chrpos;
}
}

/// <summary>
/// Counts byte length of wide-char text
/// </summary>
public int MBSafeTextLength(string text)
{
if (this.CodePage != 65001)
{
return text.Length;
}
else
{
int mblenght = Encoding.UTF8.GetByteCount(text);
return mblenght;
}
}

/// <summary>
/// Converts bytes count to text length
/// </summary>
/// <param name="txt">Reference text</param>
/// <param name="bytes">Bytes count</param>
/// <returns>Multi-byte chars length</returns>
public int MBSafeLengthFromBytes(string txt, int bytes)
{
if (this.CodePage != 65001) return bytes;

byte[] raw = Encoding.UTF8.GetBytes(txt);
return Encoding.UTF8.GetString(raw, 0, Math.Min(raw.Length, bytes)).Length;
}

/// <summary>
/// Custom way to find the matching brace when BraceMatch() does not work
/// </summary>
public int SafeBraceMatch(int position)
{
int match = this.CharAt(position);
int toMatch = 0;
int length = TextLength;
int ch;
int sub = 0;
int lexer = Lexer;
Colourise(0, -1);
bool comment = PositionIsOnComment(position, lexer);
switch (match)
{
case '{':
toMatch = '}';
goto down;
case '(':
toMatch = ')';
goto down;
case '[':
toMatch = ']';
goto down;
case '}':
toMatch = '{';
goto up;
case ')':
toMatch = '(';
goto up;
case ']':
toMatch = '[';
goto up;
}
return -1;
// search up
up:
while (position >= 0)
{
position--;
ch = CharAt(position);
if (ch == match)
{
if (comment == PositionIsOnComment(position, lexer)) sub++;
}
else if (ch == toMatch && comment == PositionIsOnComment(position, lexer))
{
sub--;
if (sub < 0) return position;
}
}
return -1;
// search down
down:
while (position < length)
{
position++;
ch = CharAt(position);
if (ch == match)
{
if (comment == PositionIsOnComment(position, lexer)) sub++;
}
else if (ch == toMatch && comment == PositionIsOnComment(position, lexer))
{
sub--;
if (sub < 0) return position;
}
}
return -1;
}

/// <summary>
/// File dropped on the control, fire URIDropped event
/// </summary>
unsafe void HandleFileDrop(IntPtr hDrop)
{
int nfiles = DragQueryFileA(hDrop, 0xffffffff, (IntPtr)null, 0);
string files = "";
byte[] buffer = new byte[PATH_LEN];
for (uint i = 0; i<nfiles; i++)
{
fixed (byte* b = buffer)
{
DragQueryFileA(hDrop, i, (IntPtr)b, PATH_LEN);
if (files.Length > 0) files += ' ';
files += '"'+MarshalStr((IntPtr)b) + '"';
}
}
DragFinish(hDrop);
if (URIDropped != null) URIDropped(this, files);
}


/// <summary>
/// Returns the base style (without indicators) byte at the position.
/// </summary>
public int BaseStyleAt(int pos)
{
return (int)(SPerform(2010, (uint)pos, 0) & ((1 << this.StyleBits) - 1));
}

/// <summary>
/// Adds the specified highlights to the control
/// </summary>
public void AddHighlights(List<SearchMatch> matches, Int32 highlightColor)
{
if (matches == null) return;
foreach (SearchMatch match in matches)
{
Int32 start = this.MBSafePosition(match.Index);
Int32 end = start + this.MBSafeTextLength(match.Value);
Int32 line = this.LineFromPosition(start);
Int32 position = start; Int32 mask = 1 << this.StyleBits;
this.SetIndicStyle(0, (Int32)ScintillaNet.Enums.IndicatorStyle.RoundBox);
this.SetIndicFore(0, highlightColor);
this.StartStyling(position, mask);
this.SetStyling(end - start, mask);
this.StartStyling(this.EndStyled, mask - 1);
}
}

/// <summary>
/// Removes the highlights from the control
/// </summary>
public void RemoveHighlights()
{
Int32 mask = (1 << this.StyleBits);
this.StartStyling(0, mask);
this.SetStyling(this.TextLength, 0);
this.StartStyling(this.EndStyled, mask - 1);
}

#endregion

}

}

Change log

r1550 by meychi on Nov 22, 2010   Diff
Control+DoubleClick now highlights all
selected words...
Go to: 

Older revisions

r1548 by meychi on Nov 22, 2010   Diff
Added basic selection highlighting to
ScintillaControl...
r1487 by meychi on Oct 29, 2010   Diff
Started FD4.
All revisions of this file

File info

Size: 163572 bytes, 5951 lines
Powered by Google Project Hosting