File: idecommands.pas

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (2494 lines) | stat: -rw-r--r-- 98,298 bytes parent folder | download
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
{
 *****************************************************************************
  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************

 Abstract:
   Interface unit for IDE commands.
   IDE commands are functions like open file, save, build, ... .
   
   Every command can have up to two shortcuts. For example:
     ecCopy: two shortcuts: Ctrl+C and Ctrl+Insert
     ecDeleteChar: one shortcut: Delete
     ecInsertDateTime: no shortcut
   
   Commands are sorted into categories. For example:
     ecCopy is in the category 'Selection'.
     This is only to help the user find commands.
     
   Scopes:
     A command can work globally or only in some IDE windows.
     For example: When the user presses a key in the source editor, the IDE
       first searches in all commands with the Scope IDECmdScopeSrcEdit.
       Then it will search in all commands without scope.
}
unit IDECommands;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,
  // LCL
  LCLProc, LCLType, LCLIntf, Forms, Menus,
  // LazUtils
  LazLoggerBase, LazTracer, LazMethodList, LazUtilities,
  // IdeIntf
  IDEImagesIntf;
  
const
  { editor commands constants. see syneditkeycmds.pp for more

   These values can change from version to version, so DO NOT save them to file!

   To add one static key do the following:
     1. Add a constant with a unique value in the list below.
     2. Update IDEEditorCommandStrs to define a name (used for configs)
     3. Add it to GetDefaultKeyForCommand to define the default keys+shiftstates
     4. Add it to EditorCommandToDescriptionString to define the description
     5. Add it to TKeyCommandRelationList.DefineCommandCategories to define the category.
  }
  ecNone                    = 0;
  
  ecFirstLazarus            = 1001;  // syneditkeycmds.ecUserFirst = 1001;

  // search
  ecFind                    = ecFirstLazarus + 1;
  ecFindAgain               = ecFirstLazarus + 2;
  ecFindNext                = ecFindAgain;
  ecFindPrevious            = ecFirstLazarus + 3;
  ecReplace                 = ecFirstLazarus + 4;
  ecIncrementalFind         = ecFirstLazarus + 5;
  ecFindProcedureDefinition = ecFirstLazarus + 6;
  ecFindProcedureMethod     = ecFirstLazarus + 7;
  ecGotoLineNumber          = ecFirstLazarus + 8;
  ecFindNextWordOccurrence  = ecFirstLazarus + 9;
  ecFindPrevWordOccurrence  = ecFirstLazarus + 10;
  ecFindInFiles             = ecFirstLazarus + 11;
  ecJumpBack                = ecFirstLazarus + 12;
  ecJumpForward             = ecFirstLazarus + 13;
  ecAddJumpPoint            = ecFirstLazarus + 14;
  ecViewJumpHistory         = ecFirstLazarus + 15;
  ecJumpToNextError         = ecFirstLazarus + 16;
  ecJumpToPrevError         = ecFirstLazarus + 17;
  ecProcedureList           = ecFirstLazarus + 18;

  // search code
  ecFindDeclaration         = ecFirstLazarus + 20;
  ecFindBlockOtherEnd       = ecFirstLazarus + 21;
  ecFindBlockStart          = ecFirstLazarus + 22;
  ecOpenFileAtCursor        = ecFirstLazarus + 23;
  ecGotoIncludeDirective    = ecFirstLazarus + 24;
  ecJumpToSection           = ecFirstLazarus + 25;
  ecJumpToInterface         = ecFirstLazarus + 26;
  ecJumpToInterfaceUses     = ecFirstLazarus + 27;
  ecJumpToImplementation    = ecFirstLazarus + 28;
  ecJumpToImplementationUses= ecFirstLazarus + 29;
  ecJumpToInitialization    = ecFirstLazarus + 30;
  ecJumpToProcedureHeader   = ecFirstLazarus + 31;
  ecJumpToProcedureBegin    = ecFirstLazarus + 32;

  // edit selection
  ecSelectionUpperCase      = ecFirstLazarus + 50;
  ecSelectionLowerCase      = ecFirstLazarus + 51;
  ecSelectionSwapCase       = ecFirstLazarus + 52;
  ecSelectionTabs2Spaces    = ecFirstLazarus + 53;
  ecSelectionEnclose        = ecFirstLazarus + 54;
  ecSelectionComment        = ecFirstLazarus + 55;
  ecSelectionUncomment      = ecFirstLazarus + 56;
  ecSelectionSort           = ecFirstLazarus + 57;
  ecSelectionBreakLines     = ecFirstLazarus + 58;
  ecSelectToBrace           = ecFirstLazarus + 59;
  ecSelectCodeBlock         = ecFirstLazarus + 60;
  ecSelectWord              = ecFirstLazarus + 61;
  ecSelectLine              = ecFirstLazarus + 62;
  ecSelectParagraph         = ecFirstLazarus + 63;
  ecSelectionEncloseIFDEF   = ecFirstLazarus + 64;
  ecToggleComment           = ecFirstLazarus + 65;

  // insert text
  ecInsertCharacter         = ecFirstLazarus + 70;  // not used, moved to external package
  ecInsertGUID              = ecFirstLazarus + 71;
  ecInsertFilename          = ecFirstLazarus + 72;
  ecInsertUserName          = ecFirstLazarus + 73;
  ecInsertDateTime          = ecFirstLazarus + 74;
  ecInsertChangeLogEntry    = ecFirstLazarus + 75;
  ecInsertCVSAuthor         = ecFirstLazarus + 76;
  ecInsertCVSDate           = ecFirstLazarus + 77;
  ecInsertCVSHeader         = ecFirstLazarus + 78;
  ecInsertCVSID             = ecFirstLazarus + 79;
  ecInsertCVSLog            = ecFirstLazarus + 80;
  ecInsertCVSName           = ecFirstLazarus + 81;
  ecInsertCVSRevision       = ecFirstLazarus + 82;
  ecInsertCVSSource         = ecFirstLazarus + 83;
  ecInsertGPLNotice         = ecFirstLazarus + 84;
  ecInsertGPLNoticeTranslated = ecFirstLazarus + 85;
  ecInsertLGPLNotice        = ecFirstLazarus + 86;
  ecInsertLGPLNoticeTranslated = ecFirstLazarus + 87;
  ecInsertModifiedLGPLNotice= ecFirstLazarus + 88;
  ecInsertModifiedLGPLNoticeTranslated = ecFirstLazarus + 89;
  ecInsertMITNotice         = ecFirstLazarus + 90;
  ecInsertMITNoticeTranslated = ecFirstLazarus + 91;

  // source tools
  ecWordCompletion          = ecFirstLazarus + 100;
  ecCompleteCode            = ecFirstLazarus + 101;
  ecIdentCompletion         = ecFirstLazarus + 102;
  ecSyntaxCheck             = ecFirstLazarus + 103;
  ecGuessUnclosedBlock      = ecFirstLazarus + 104;
  ecGuessMisplacedIFDEF     = ecFirstLazarus + 105;
  ecConvertDFM2LFM          = ecFirstLazarus + 106;
  ecCheckLFM                = ecFirstLazarus + 107;
  ecConvertDelphiUnit       = ecFirstLazarus + 108;
  ecConvertDelphiProject    = ecFirstLazarus + 109;
  ecConvertDelphiPackage    = ecFirstLazarus + 110;
  ecConvertEncoding         = ecFirstLazarus + 111;
  ecMakeResourceString      = ecFirstLazarus + 112;
  ecDiff                    = ecFirstLazarus + 113;
  ecExtractProc             = ecFirstLazarus + 114;
  ecFindIdentifierRefs      = ecFirstLazarus + 115;
  ecRenameIdentifier        = ecFirstLazarus + 116;
  ecInvertAssignment        = ecFirstLazarus + 117;
  ecShowCodeContext         = ecFirstLazarus + 118;
  ecShowAbstractMethods     = ecFirstLazarus + 119;
  ecRemoveEmptyMethods      = ecFirstLazarus + 120;
  ecRemoveUnusedUnits       = ecFirstLazarus + 121;
  ecUseUnit                 = ecFirstLazarus + 122;
  ecFindOverloads           = ecFirstLazarus + 123;
  ecFindUsedUnitRefs        = ecFirstLazarus + 124;
  ecCompleteCodeInteractive = ecFirstLazarus + 125;

  // file menu
  ecNew                     = ecFirstLazarus + 201;
  ecNewUnit                 = ecFirstLazarus + 202;
  ecNewForm                 = ecFirstLazarus + 203;
  ecOpen                    = ecFirstLazarus + 205;
  ecRevert                  = ecFirstLazarus + 206;
  ecSave                    = ecFirstLazarus + 207;
  ecSaveAs                  = ecFirstLazarus + 208;
  ecSaveAll                 = ecFirstLazarus + 209;
  ecClose                   = ecFirstLazarus + 210;
  ecCleanDirectory          = ecFirstLazarus + 212;
  ecRestart                 = ecFirstLazarus + 213;
  ecQuit                    = ecFirstLazarus + 214;
  ecOpenUnit                = ecFirstLazarus + 215;
  ecOpenRecent              = ecFirstLazarus + 216;
  ecCloseOtherTabs          = ecFirstLazarus + 217;
  ecCloseRightTabs          = ecFirstLazarus + 218;

  // edit menu
  ecMultiPaste              = ecFirstLazarus + 230;

  // IDE navigation
  ecToggleFormUnit          = ecFirstLazarus + 301;
  ecToggleObjectInsp        = ecFirstLazarus + 302;
  ecToggleSourceEditor      = ecFirstLazarus + 303;
  ecToggleCodeExpl          = ecFirstLazarus + 304;
  ecToggleFPDocEditor       = ecFirstLazarus + 305;
  ecToggleMessages          = ecFirstLazarus + 306;
  ecToggleWatches           = ecFirstLazarus + 307;
  ecToggleBreakPoints       = ecFirstLazarus + 308;
  ecToggleDebuggerOut       = ecFirstLazarus + 309;
  ecViewUnitDependencies    = ecFirstLazarus + 312;
  ecViewUnitInfo            = ecFirstLazarus + 313;
  ecToggleLocals            = ecFirstLazarus + 314;
  ecToggleCallStack         = ecFirstLazarus + 315;
  ecToggleSearchResults     = ecFirstLazarus + 316;
  ecViewAnchorEditor        = ecFirstLazarus + 317;
  ecViewTabOrder            = ecFirstLazarus + 318;
  ecToggleCodeBrowser       = ecFirstLazarus + 319;
  ecToggleCompPalette       = ecFirstLazarus + 320;
  ecToggleIDESpeedBtns      = ecFirstLazarus + 321;
  ecViewComponents          = ecFirstLazarus + 322;
  ecToggleRestrictionBrowser= ecFirstLazarus + 323;
  ecViewTodoList            = ecFirstLazarus + 324;
  ecToggleRegisters         = ecFirstLazarus + 325;
  ecToggleAssembler         = ecFirstLazarus + 326;
  ecToggleDebugEvents       = ecFirstLazarus + 327;
  ecViewPseudoTerminal      = ecFirstLazarus + 328;
  ecViewThreads             = ecFirstLazarus + 329;
  ecViewHistory             = ecFirstLazarus + 460;
  ecViewMacroList           = ecFirstLazarus + 461;
  ecToggleMemViewer         = ecFirstLazarus + 462;

  // sourcenotebook commands
  ecNextEditor              = ecFirstLazarus + 330;
  ecPrevEditor              = ecFirstLazarus + 331;
  ecMoveEditorLeft          = ecFirstLazarus + 332;
  ecMoveEditorRight         = ecFirstLazarus + 333;
  ecMoveEditorLeftmost      = ecFirstLazarus + 336;
  ecMoveEditorRightmost     = ecFirstLazarus + 337;

  ecNextSharedEditor        = ecFirstLazarus + 338;
  ecPrevSharedEditor        = ecFirstLazarus + 339;

  ecNextWindow              = ecFirstLazarus + 340;
  ecPrevWindow              = ecFirstLazarus + 341;
  ecMoveEditorNextWindow    = ecFirstLazarus + 342;
  ecMoveEditorPrevWindow    = ecFirstLazarus + 343;
  ecMoveEditorNewWindow     = ecFirstLazarus + 344;
  ecCopyEditorNextWindow    = ecFirstLazarus + 345;
  ecCopyEditorPrevWindow    = ecFirstLazarus + 346;
  ecCopyEditorNewWindow     = ecFirstLazarus + 347;
  ecPrevEditorInHistory     = ecFirstLazarus + 348;
  ecNextEditorInHistory     = ecFirstLazarus + 349;

  ecGotoEditor1             = ecFirstLazarus + 350;
  ecGotoEditor2             = ecGotoEditor1 + 1;
  ecGotoEditor3             = ecGotoEditor2 + 1;
  ecGotoEditor4             = ecGotoEditor3 + 1;
  ecGotoEditor5             = ecGotoEditor4 + 1;
  ecGotoEditor6             = ecGotoEditor5 + 1;
  ecGotoEditor7             = ecGotoEditor6 + 1;
  ecGotoEditor8             = ecGotoEditor7 + 1;
  ecGotoEditor9             = ecGotoEditor8 + 1;
  ecGotoEditor0             = ecGotoEditor9 + 1;

  ecLockEditor              = ecFirstLazarus + 370;

  // marker
  ecSetFreeBookmark         = ecFirstLazarus + 381;
  ecPrevBookmark            = ecFirstLazarus + 382;
  ecNextBookmark            = ecFirstLazarus + 383;
  ecClearBookmarkForFile    = ecFirstLazarus + 384;
  ecClearAllBookmark        = ecFirstLazarus + 385;

  ecGotoBookmarks           = ecFirstLazarus + 386;
  ecToggleBookmarks         = ecFirstLazarus + 387;

  // Macro
  ecSynMacroRecord          = ecFirstLazarus + 390;
  ecSynMacroPlay            = ecFirstLazarus + 391;

  // run menu
  ecCompile                 = ecFirstLazarus + 400;
  ecBuild                   = ecFirstLazarus + 401;
  ecQuickCompile            = ecFirstLazarus + 402;
  ecCleanUpAndBuild         = ecFirstLazarus + 403;
  ecBuildManyModes          = ecFirstLazarus + 404;
  ecAbortBuild              = ecFirstLazarus + 405;
  ecRunWithoutDebugging     = ecFirstLazarus + 409;
  ecRun                     = ecFirstLazarus + 410;
  ecPause                   = ecFirstLazarus + 411;
  ecStepInto                = ecFirstLazarus + 412;
  ecStepOver                = ecFirstLazarus + 413;
  ecStepToCursor             = ecFirstLazarus + 414;
  ecStopProgram             = ecFirstLazarus + 415;
  ecResetDebugger           = ecFirstLazarus + 416;
  ecRunParameters           = ecFirstLazarus + 417;
  ecRunToCursor             = ecFirstLazarus + 418;
  ecRunWithDebugging        = ecFirstLazarus + 419;

  ecBuildFile               = ecFirstLazarus + 431;
  ecRunFile                 = ecFirstLazarus + 432;
  ecConfigBuildFile         = ecFirstLazarus + 433;
  ecInspect                 = ecFirstLazarus + 440;
  ecEvaluate                = ecFirstLazarus + 441;
  ecAddWatch                = ecFirstLazarus + 442;
  ecShowExecutionPoint      = ecFirstLazarus + 443;
  ecStepOut                 = ecFirstLazarus + 444;
  ecStepIntoInstr           = ecFirstLazarus + 445;
  ecStepOverInstr           = ecFirstLazarus + 446;
  ecStepIntoContext         = ecFirstLazarus + 447;
  ecStepOverContext         = ecFirstLazarus + 448;
  ecAddBpSource             = ecFirstLazarus + 449;
  ecAddBpAddress            = ecFirstLazarus + 450;
  ecAddBpDataWatch          = ecFirstLazarus + 451;
  ecAttach                  = ecFirstLazarus + 452;
  ecDetach                  = ecFirstLazarus + 453;

  // 460++ : used for ecViewHistory (debugger) / ecViewMacroList

  ecToggleBreakPoint        = ecFirstLazarus + 470;
  ecRemoveBreakPoint        = ecFirstLazarus + 471;
  ecToggleBreakPointEnabled = ecFirstLazarus + 472;
  ecBreakPointProperties    = ecFirstLazarus + 473;


  // project menu
  ecNewProject              = ecFirstLazarus + 500;
  ecNewProjectFromFile      = ecFirstLazarus + 501;
  ecOpenProject             = ecFirstLazarus + 502;
  ecOpenRecentProject       = ecFirstLazarus + 503;
  ecCloseProject            = ecFirstLazarus + 504;
  ecSaveProject             = ecFirstLazarus + 505;
  ecSaveProjectAs           = ecFirstLazarus + 506;
  ecPublishProject          = ecFirstLazarus + 507;
  ecProjectInspector        = ecFirstLazarus + 508;
  ecAddCurUnitToProj        = ecFirstLazarus + 509;
  ecRemoveFromProj          = ecFirstLazarus + 510;
  ecViewProjectUnits        = ecFirstLazarus + 511;
  ecViewProjectForms        = ecFirstLazarus + 512;
  ecViewProjectSource       = ecFirstLazarus + 513;
  ecProjectOptions          = ecFirstLazarus + 514;
  ecProjectChangeBuildMode  = ecFirstLazarus + 515;
  ecProjectResaveFormsWithI18n = ecFirstLazarus + 516;

  // package menu
  ecOpenPackage             = ecFirstLazarus + 600;
  ecOpenPackageFile         = ecFirstLazarus + 601;
  ecOpenPackageOfCurUnit    = ecFirstLazarus + 602;
  ecOpenRecentPackage       = ecFirstLazarus + 603;
  ecAddCurFileToPkg         = ecFirstLazarus + 604;
  ecNewPkgComponent         = ecFirstLazarus + 605;
  ecPackageGraph            = ecFirstLazarus + 606;
  ecPackageLinks            = ecFirstLazarus + 607;
  ecEditInstallPkgs         = ecFirstLazarus + 608;
  ecConfigCustomComps       = ecFirstLazarus + 609;
  ecNewPackage              = ecFirstLazarus + 610;

  // custom tools menu
  ecExtToolFirst            = ecFirstLazarus + 700;
  ecExtToolLast             = ecFirstLazarus + 799;

  // tools menu
  ecEnvironmentOptions      = ecFirstLazarus + 820;
  ecRescanFPCSrcDir         = ecFirstLazarus + 821;
  ecEditCodeTemplates       = ecFirstLazarus + 822;
  ecCodeToolsDefinesEd      = ecFirstLazarus + 823;

  ecExtToolSettings         = ecFirstLazarus + 824;
  ecManageDesktops          = ecFirstLazarus + 825;
  // ecManageExamples          = ecFirstLazarus + 826;
  ecConfigBuildLazarus      = ecFirstLazarus + 830;
  ecBuildLazarus            = ecFirstLazarus + 831;
  ecBuildAdvancedLazarus    = ecFirstLazarus + 832;

  // window menu
  ecManageSourceEditors     = ecFirstLazarus + 840;

  // help menu
  ecAboutLazarus            = ecFirstLazarus + 900;
  ecOnlineHelp              = ecFirstLazarus + 901;
  ecContextHelp             = ecFirstLazarus + 903;
  ecEditContextHelp         = ecFirstLazarus + 904;
  ecReportingBug            = ecFirstLazarus + 905;
  ecFocusHint               = ecFirstLazarus + 906;
  ecSmartHint               = ecFirstLazarus + 907;

  // designer
  ecDesignerCopy            = ecFirstLazarus + 1000;
  ecDesignerCut             = ecFirstLazarus + 1001;
  ecDesignerPaste           = ecFirstLazarus + 1002;
  ecDesignerSelectParent    = ecFirstLazarus + 1003;
  ecDesignerMoveToFront     = ecFirstLazarus + 1004;
  ecDesignerMoveToBack      = ecFirstLazarus + 1005;
  ecDesignerForwardOne      = ecFirstLazarus + 1006;
  ecDesignerBackOne         = ecFirstLazarus + 1007;
  ecDesignerToggleNonVisComps= ecFirstLazarus + 1008;


  (* SynEdit Plugins
     Define fixed values for the IDE. Must be mapped to plugincommands,
     when assigned to KeyMap.
     Offsets are defined in KeyMapping
     See: TKeyCommandRelationList.AssignTo
  *)
  ecFirstPlugin = ecFirstLazarus +  5000; // 6001
  ecLastPlugin = ecFirstLazarus +  6000; // 6001
  // custom commands
  ecLazarusLast             = ecLastPlugin;

  // TSynPluginTemplateEdit - In cell
  ecIdePTmplEdNextCell           = ecFirstPlugin +  0;
  ecIdePTmplEdNextCellSel        = ecFirstPlugin +  1;
  ecIdePTmplEdNextCellRotate     = ecFirstPlugin +  2;
  ecIdePTmplEdNextCellSelRotate  = ecFirstPlugin +  3;
  ecIdePTmplEdPrevCell           = ecFirstPlugin +  4;
  ecIdePTmplEdPrevCellSel        = ecFirstPlugin +  5;
  ecIdePTmplEdCellHome           = ecFirstPlugin +  6;
  ecIdePTmplEdCellEnd            = ecFirstPlugin +  7;
  ecIdePTmplEdCellSelect         = ecFirstPlugin +  8;
  ecIdePTmplEdFinish             = ecFirstPlugin +  9;
  ecIdePTmplEdEscape             = ecFirstPlugin + 10;
  ecIdePTmplEdNextFirstCell           = ecFirstPlugin + 11;
  ecIdePTmplEdNextFirstCellSel        = ecFirstPlugin + 12;
  ecIdePTmplEdNextFirstCellRotate     = ecFirstPlugin + 13;
  ecIdePTmplEdNextFirstCellSelRotate  = ecFirstPlugin + 14;
  ecIdePTmplEdPrevFirstCell           = ecFirstPlugin + 15;
  ecIdePTmplEdPrevFirstCellSel        = ecFirstPlugin + 16;

  // TSynPluginTemplateEdit - Out off Cell
  ecIdePTmplEdOutNextCell           = ecFirstPlugin +  20;
  ecIdePTmplEdOutNextCellSel        = ecFirstPlugin +  21;
  ecIdePTmplEdOutNextCellRotate     = ecFirstPlugin +  22;
  ecIdePTmplEdOutNextCellSelRotate  = ecFirstPlugin +  23;
  ecIdePTmplEdOutPrevCell           = ecFirstPlugin +  24;
  ecIdePTmplEdOutPrevCellSel        = ecFirstPlugin +  25;
  ecIdePTmplEdOutCellHome           = ecFirstPlugin +  26;
  ecIdePTmplEdOutCellEnd            = ecFirstPlugin +  27;
  ecIdePTmplEdOutCellSelect         = ecFirstPlugin +  28;
  ecIdePTmplEdOutFinish             = ecFirstPlugin +  29;
  ecIdePTmplEdOutEscape             = ecFirstPlugin +  30;
  ecIdePTmplEdOutNextFirstCell           = ecFirstPlugin + 31;
  ecIdePTmplEdOutNextFirstCellSel        = ecFirstPlugin + 32;
  ecIdePTmplEdOutNextFirstCellRotate     = ecFirstPlugin + 33;
  ecIdePTmplEdOutNextFirstCellSelRotate  = ecFirstPlugin + 34;
  ecIdePTmplEdOutPrevFirstCell           = ecFirstPlugin + 35;
  ecIdePTmplEdOutPrevFirstCellSel        = ecFirstPlugin + 36;

  // TSynPluginSyncroEdit - in celll
  ecIdePSyncroEdNextCell           = ecFirstPlugin +  50;
  ecIdePSyncroEdNextCellSel        = ecFirstPlugin +  51;
  ecIdePSyncroEdPrevCell           = ecFirstPlugin +  52;
  ecIdePSyncroEdPrevCellSel        = ecFirstPlugin +  53;
  ecIdePSyncroEdCellHome           = ecFirstPlugin +  54;
  ecIdePSyncroEdCellEnd            = ecFirstPlugin +  55;
  ecIdePSyncroEdCellSelect         = ecFirstPlugin +  56;
  ecIdePSyncroEdEscape             = ecFirstPlugin +  57;
  ecIdePSyncroEdNextFirstCell      = ecFirstPlugin +  58;
  ecIdePSyncroEdNextFirstCellSel   = ecFirstPlugin +  59;
  ecIdePSyncroEdPrevFirstCell      = ecFirstPlugin +  60;
  ecIdePSyncroEdPrevFirstCellSel   = ecFirstPlugin +  61;
  ecIdePSyncroEdGrowCellLeft       = ecFirstPlugin +  62;
  ecIdePSyncroEdShrinkCellLeft     = ecFirstPlugin +  63;
  ecIdePSyncroEdGrowCellRight      = ecFirstPlugin +  64;
  ecIdePSyncroEdShrinkCellRight    = ecFirstPlugin +  65;
  ecIdePSyncroEdAddCell            = ecFirstPlugin +  66;
  ecIdePSyncroEdAddCellCase        = ecFirstPlugin +  67;
  ecIdePSyncroEdAddCellCtx         = ecFirstPlugin +  68;
  ecIdePSyncroEdAddCellCtxCase     = ecFirstPlugin +  69;
  ecIdePSyncroEdDelCell            = ecFirstPlugin +  70;

  // TSynPluginSyncroEdit - Out off cell
  ecIdePSyncroEdOutNextCell           = ecFirstPlugin +  80;
  ecIdePSyncroEdOutNextCellSel        = ecFirstPlugin +  81;
  ecIdePSyncroEdOutPrevCell           = ecFirstPlugin +  82;
  ecIdePSyncroEdOutPrevCellSel        = ecFirstPlugin +  83;
  ecIdePSyncroEdOutCellHome           = ecFirstPlugin +  84;
  ecIdePSyncroEdOutCellEnd            = ecFirstPlugin +  85;
  ecIdePSyncroEdOutCellSelect         = ecFirstPlugin +  86;
  ecIdePSyncroEdOutEscape             = ecFirstPlugin +  87;
  ecIdePSyncroEdOutNextFirstCell      = ecFirstPlugin +  88;
  ecIdePSyncroEdOutNextFirstCellSel   = ecFirstPlugin +  89;
  ecIdePSyncroEdOutPrevFirstCell      = ecFirstPlugin +  90;
  ecIdePSyncroEdOutPrevFirstCellSel   = ecFirstPlugin +  91;
  // grow/shrink 92..95 (reserved)
  ecIdePSyncroEdOutAddCell            = ecFirstPlugin +  96;
  ecIdePSyncroEdOutAddCellCase        = ecFirstPlugin +  97;
  ecIdePSyncroEdOutAddCellCtx         = ecFirstPlugin +  98;
  ecIdePSyncroEdOutAddCellCtxCase     = ecFirstPlugin +  99;
  // del 100 (reserved)

  // TSynPluginSyncroEdit - selecting
  ecIdePSyncroEdSelStart              = ecFirstPlugin + 110;
  ecIdePSyncroEdSelStartCase          = ecFirstPlugin + 111;
  ecIdePSyncroEdSelStartCtx           = ecFirstPlugin + 112;
  ecIdePSyncroEdSelStartCtxCase       = ecFirstPlugin + 113;

const
  // Mouse command offsets
  emcOffsetToggleBreakPoint        = 0;
  emcOffsetToggleBreakPointEnabled = 1;
  emcOffsetBreakPointProperties    = 2;

var
  emcToggleBreakPoint,
  emcToggleBreakPointEnabled,
  emcBreakPointProperties : integer;

const
  emcIdeMouseCommandsCount = 3;

type
  TIDECommand = class;
  TIDECommandCategory = class;
  TIDESpecialCommand = class;
  TIDESpecialCommands = class;

  TNotifyProcedure = procedure(Sender: TObject);

  { TIDECommandScope
    A TIDECommandScope defines a set of IDE windows that will share the same
    IDE commands. An IDE command can be valid in several scopes at the same
    time. }
    
  { TIDECommandScope }

  TIDECommandScope = class(TPersistent)
  private
    FName: string;
    FIDEWindowClasses: TFPList;// list of TCustomFormClass
    FCategories: TFPList;
    function GetCategories(Index: integer): TIDECommandCategory;
    function GetIDEWindowClasses(Index: integer): TCustomFormClass;
  public
    constructor Create(const TheName: string);
    destructor Destroy; override;
    procedure AddWindowClass(AWindowClass: TCustomFormClass);
    procedure RemoveWindowClass(AWindowClass: TCustomFormClass);
    function IDEWindowClassCount: integer;
    function CategoryCount: integer;
    function HasIDEWindowClass(AWindowClass: TCustomFormClass): boolean;
    function Intersects(AScope: TIDECommandScope): boolean;
    procedure WriteDebugReport;
  public
    property Name: string read FName;
    property IDEWindowClasses[Index: integer]: TCustomFormClass read GetIDEWindowClasses;
    property Categories[Index: integer]: TIDECommandCategory read GetCategories;
  end;

  { TIDECommandScopes }

  TIDECommandScopes = class(TPersistent)
  private
    FItems: TFPList;
    function GetItems(Index: integer): TIDECommandScope;
  public
    constructor Create;
    destructor Destroy; override;
    procedure Clear;
    procedure Add(NewItem: TIDECommandScope);
    function IndexOf(AnItem: TIDECommandScope): Integer;
    function IndexByName(const AName: string): Integer;
    function FindByName(const AName: string): TIDECommandScope;
    function CreateUniqueName(const AName: string): string;
    function Count: integer;
  public
    property Items[Index: integer]: TIDECommandScope read GetItems;
  end;
  

  { TIDEShortCut }

  TIDEShortCut = record
    Key1: word;
    Shift1: TShiftState;
    Key2: word;
    Shift2: TShiftState;
  end;
  PIDEShortCut = ^TIDEShortCut;

  { TIDECommandCategory - list of TKeyCommandRelation/TIDECommand
    TIDECommandCategory is used to divide the commands in handy packets }
    
  TIDECommandCategory = class(TList)
  private
    procedure SetDescription(const AValue: string);
  protected
    FDescription: string;
    FName: string;
    FParent: TIDECommandCategory;
    FScope: TIDECommandScope;
    procedure SetScope(const AValue: TIDECommandScope);
  public
    destructor Destroy; override;
    function ScopeIntersects(AScope: TIDECommandScope): boolean;
    procedure WriteScopeDebugReport;
    procedure DoOnUpdate;
  public
    property Name: string read FName;
    property Description: string read FDescription write SetDescription;
    property Parent: TIDECommandCategory read FParent;
    procedure Delete(Index: Integer); virtual;
    property Scope: TIDECommandScope read FScope write SetScope;
  end;
  
  
  { TIDECommand }
  { class for storing the keys of a single command (shortcut-command relationship) }
  TIDECommand = class
  private
    FCategory: TIDECommandCategory;
    FCommand: word;
    FLocalizedName: string;
    FName: String;
    FOnExecute: TNotifyEvent;
    FOnExecuteProc: TNotifyProcedure;
    FShortcutA: TIDEShortCut;
    FShortcutB: TIDEShortCut;
    FOnUpdateMethod: TNotifyEvent;
    FOnUpdateProc: TNotifyProcedure;
    FUsers: TIDESpecialCommands;

    function GetEnabled: Boolean;
    function GetUser(Index: Integer): TIDESpecialCommand;
    function GetUserCount: Integer;
    procedure SetOnExecute(const aOnExecute: TNotifyEvent);
    procedure SetOnExecuteProc(const aOnExecuteProc: TNotifyProcedure);
    procedure SetEnabled(const AEnabled: Boolean);
    procedure SetCaption(const ACaption: string);
    procedure SetHint(const AHint: string);
  protected
    function GetLocalizedName: string; virtual;
    procedure SetLocalizedName(const AValue: string); virtual;
    procedure SetCategory(const AValue: TIDECommandCategory); virtual;
    procedure SetShortcutA(const AValue: TIDEShortCut); virtual;
    procedure SetShortcutB(const AValue: TIDEShortCut); virtual;
    procedure Change;
    procedure Init; virtual;
  public
    function AsShortCut: TShortCut; virtual;
    constructor Create(TheCategory: TIDECommandCategory;
              const TheName, TheLocalizedName: String; TheCommand: word;
              const TheShortcutA, TheShortcutB: TIDEShortCut;
              const ExecuteMethod: TNotifyEvent; const ExecuteProc: TNotifyProcedure);
    constructor Create(TheCategory: TIDECommandCategory;
              const TheName, TheLocalizedName: String; TheCommand: word);
    constructor Create(ACommand: TIDECommand; ACategory: TIDECommandCategory);
    destructor Destroy; override;
    procedure Assign(ACommand: TIDECommand);
    function IsEqual(ACommand: TIDECommand): boolean;
  public
    DefaultShortcutA: TIDEShortCut;
    DefaultShortcutB: TIDEShortCut;
    procedure ClearShortcutA;
    procedure ClearShortcutB;
    function GetCategoryAndName: string;
    function Execute(Sender: TObject): boolean;
    procedure UserAdded(const aUser: TIDESpecialCommand);
    procedure UserRemoved(const aUser: TIDESpecialCommand);
    procedure DoOnUpdate; overload;
    procedure DoOnUpdate(Sender: TObject); overload;
  public
    property Enabled: Boolean read GetEnabled write SetEnabled;
    property Caption: string write SetCaption; // set Caption of all "Users" TIDESpecialCommand, use Users to read
    property Hint: string write SetHint; // set Hint of all "Users" TIDESpecialCommand, use Users to read
    // don't add Visible property here - it is not generic. Tool buttons should never be hidden programmatically
  public
    property Name: String read FName;
    property Command: word read FCommand;// see the ecXXX constants above
    property LocalizedName: string read GetLocalizedName write SetLocalizedName;
    property Category: TIDECommandCategory read FCategory write SetCategory;
    property ShortcutA: TIDEShortCut read FShortcutA write SetShortcutA;
    property ShortcutB: TIDEShortCut read FShortcutB write SetShortcutB;
    property OnExecute: TNotifyEvent read FOnExecute write SetOnExecute;
    property OnExecuteProc: TNotifyProcedure read FOnExecuteProc write SetOnExecuteProc;
    property OnUpdate: TNotifyEvent read FOnUpdateMethod write FOnUpdateMethod;
    property OnUpdateProc: TNotifyProcedure read FOnUpdateProc write FOnUpdateProc;

    property Users[Index: Integer]: TIDESpecialCommand read GetUser;
    property UserCount: Integer read GetUserCount;
  end;


  { TIDECommands }

  TIDECommands = class
  private
    FCustomUpdateEvents: TMethodList;
    FDontExecuteUpdateEventsUntil: QWord;

    procedure ApplicationOnIdle({%H-}Sender: TObject; var {%H-}Done: Boolean);
  protected
    function GetCategory(Index: integer): TIDECommandCategory; virtual; abstract;
  public
    constructor Create;
    destructor Destroy; override;

    function FindIDECommand(ACommand: word): TIDECommand; virtual; abstract;
    function CreateCategory(Parent: TIDECommandCategory;
                            const Name, Description: string;
                            Scope: TIDECommandScope = nil): TIDECommandCategory; virtual; abstract;
    function CreateCommand(Category: TIDECommandCategory;
                           const Name, Description: string;
                           const TheShortcutA, TheShortcutB: TIDEShortCut;
                           const OnExecuteMethod: TNotifyEvent = nil;
                           const OnExecuteProc: TNotifyProcedure = nil
                           ): TIDECommand; virtual; abstract;
    function FindCategoryByName(const CategoryName: string): TIDECommandCategory; virtual; abstract;
    function FindCommandByName(const CommandName: string): TIDECommand; virtual; abstract;
    function FindCommandsByShortCut(const ShortCutMask: TIDEShortCut;
            IDEWindowClass: TCustomFormClass = nil): TFPList; virtual; abstract; // list of TIDECommand
    function RemoveShortCut(ShortCutMask: TIDEShortCut;
            IDEWindowClass: TCustomFormClass = nil): Integer; virtual; abstract;
    function CategoryCount: integer; virtual; abstract;
  public
    procedure StartUpdateEvents;
    procedure StopUpdateEvents;

    procedure ExecuteUpdateEvents;
    procedure CancelPostponeUpdateEvents;
    procedure PostponeUpdateEvents;

    procedure AddCustomUpdateEvent(const aEvent: TNotifyEvent);
    procedure RemoveCustomUpdateEvent(const aEvent: TNotifyEvent);
  public
    property Categories[Index: integer]: TIDECommandCategory read GetCategory;
  end;

  // MenuItem and ButtonCommand inherit from SpecialCommand.

  TGetHintCaptionEvent = procedure(Sender: TObject; var ACaption, AHint: string) of object;

  TIDESpecialCommand = class(TPersistent)
  private
    FCommand: TIDECommand;
    FName: string;
    FCaption: string;
    FEnabled: Boolean;
    FChecked: Boolean;
    FHint: string;
    FImageIndex: Integer;
    FOnClickMethod: TNotifyEvent;
    FOnClickProc: TNotifyProcedure;
    FOnRequestCaption: TGetHintCaptionEvent;
    FSyncProperties: Boolean;
    FBlockSync: Integer;
  protected
    function SyncAvailable: Boolean; virtual;
    function GetCaption: string; virtual;
    procedure SetCommand(const AValue: TIDECommand); virtual;
    procedure SetName(const aName: string); virtual;
    procedure SetCaption(aCaption: string); virtual;
    procedure SetEnabled(const aEnabled: Boolean); virtual;
    procedure SetChecked(const aChecked: Boolean); virtual;
    procedure SetHint(const aHint: string); virtual;
    procedure SetImageIndex(const aImageIndex: Integer); virtual;
    procedure SetOnClickMethod(const aOnClick: TNotifyEvent); virtual;
    procedure SetOnClickProc(const aOnClickProc: TNotifyProcedure); virtual;
    procedure SetOnRequestCaption(
      const aOnRequestCaptionHint: TGetHintCaptionEvent); virtual;
    procedure SetResourceName(const aResourceName: string); virtual;
    procedure ShortCutsUpdated(const {%H-}aShortCut, {%H-}aShortCutKey2: TShortCut); virtual;
  public
    constructor Create(const aName: string); virtual;
    destructor Destroy; override;
  public
    procedure DoOnClick; overload;
    procedure DoOnClick(Sender: TObject); virtual; overload;
    function DoOnRequestCaption(Sender: TObject): Boolean; virtual;

    procedure BlockSync;
    procedure UnblockSync;
  public
    function GetCaptionWithShortCut: String; virtual;
    function GetHintOrCaptionWithShortCut: String; virtual;
    function GetShortcut: String; virtual;

    property Command: TIDECommand read FCommand write SetCommand;
    property SyncProperties: Boolean read FSyncProperties write FSyncProperties;
    property Name: string read FName write SetName;
    property Caption: string read GetCaption write SetCaption;
    property Hint: string read FHint write SetHint;
    property Enabled: Boolean read FEnabled write SetEnabled;
    property Checked: Boolean read FChecked write SetChecked;
    property ImageIndex: Integer read FImageIndex write SetImageIndex;
    property ResourceName: string write SetResourceName;
    // don't add Visible property here - it is not generic. Tool buttons should never be hidden programmatically

    property OnClick: TNotifyEvent read FOnClickMethod write SetOnClickMethod;
    property OnClickProc: TNotifyProcedure read FOnClickProc write SetOnClickProc;
    property OnRequestCaptionHint: TGetHintCaptionEvent read FOnRequestCaption write SetOnRequestCaption;
  end;

  TIDESpecialCommandEnumerator = class
  private
    FList: TIDESpecialCommands;
    FPosition: Integer;
  public
    constructor Create(AButtons: TIDESpecialCommands);
    function GetCurrent: TIDESpecialCommand;
    function MoveNext: Boolean;
    property Current: TIDESpecialCommand read GetCurrent;
  end;

  TIDESpecialCommands = class
  private
    FList: TFPList;
    function GetCount: Integer;
    function GetItems(Index: Integer): TIDESpecialCommand;
  public
    constructor Create;
    destructor Destroy; override;
  public
    function GetEnumerator: TIDESpecialCommandEnumerator;
    procedure Add(const aUser: TIDESpecialCommand);
    procedure Remove(const aUser: TIDESpecialCommand);

    property Count: Integer read GetCount;
    property Items[Index: Integer]: TIDESpecialCommand read GetItems; default;
  end;



const
  CleanIDEShortCut: TIDEShortCut =
    (Key1: VK_UNKNOWN; Shift1: []; Key2: VK_UNKNOWN; Shift2: []);

function IDEShortCut(Key1: word; Shift1: TShiftState;
  Key2: word = VK_UNKNOWN; Shift2: TShiftState = []): TIDEShortCut;


type
  TExecuteIDEShortCut =
    procedure(Sender: TObject; var Key: word; Shift: TShiftState;
              IDEWindowClass: TCustomFormClass) of object;
  TExecuteIDECommand = function(Sender: TObject; Command: word): boolean of object;

var
  OnExecuteIDEShortCut: TExecuteIDEShortCut;
  OnExecuteIDECommand: TExecuteIDECommand;

procedure ExecuteIDEShortCut(Sender: TObject; var Key: word; Shift: TShiftState;
  IDEWindowClass: TCustomFormClass);
procedure ExecuteIDEShortCut(Sender: TObject; var Key: word; Shift: TShiftState);
function ExecuteIDECommand(Sender: TObject; Command: word): boolean;
function IsValidIDECommandKey(Key: word): boolean;

var
  // will be set by the IDE
  IDECommandList: TIDECommands;
  IDECommandScopes: TIDECommandScopes = nil;
var
  IDECmdScopeSrcEdit: TIDECommandScope;
  IDECmdScopeSrcEditOnly: TIDECommandScope;
  IDECmdScopeSrcEditOnlyMultiCaret: TIDECommandScope;
  IDECmdScopeSrcEditOnlyTmplEdit: TIDECommandScope;
  IDECmdScopeSrcEditOnlyTmplEditOff: TIDECommandScope;
  IDECmdScopeSrcEditOnlySyncroEditSel: TIDECommandScope;
  IDECmdScopeSrcEditOnlySyncroEdit: TIDECommandScope;
  IDECmdScopeSrcEditOnlySyncroEditOff: TIDECommandScope;
  IDECmdScopeDesignerOnly: TIDECommandScope;
  IDECmdScopeObjectInspectorOnly: TIDECommandScope;

const
  CommandCategoryToolMenuName = 'ToolMenu';
  CommandCategoryCustomName = 'Custom';
  CommandCategoryTextEditingName = 'text editing commands';
  CommandCategoryViewName = 'ViewMenu';
  CommandCategoryCodeTools = 'CodeTools';

// register a new IDE command category (i.e. set of commands)
function RegisterIDECommandCategory(Parent: TIDECommandCategory;
                          const Name, Description: string): TIDECommandCategory;

// register a new IDE command (i.e. a shortcut, IDE function)
function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string;
  const OnExecuteMethod: TNotifyEvent = nil;
  const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string; Key1: word; Shift1: TShiftState;
  const OnExecuteMethod: TNotifyEvent = nil;
  const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string; const ShortCut1: TIDEShortCut;
  const OnExecuteMethod: TNotifyEvent = nil;
  const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string;
  const ShortCut1, ShortCut2: TIDEShortCut;
  const OnExecuteMethod: TNotifyEvent = nil;
  const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;

// register a new IDE command scope (i.e. a set of windows)
function RegisterIDECommandScope(const Name: string): TIDECommandScope;

procedure CreateStandardIDECommandScopes;


function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String;
function KeyValuesToCaptionStr(const ShortcutA, ShortcutB: TIDEShortCut; Brackets: Char = '['): String;

function CompareIDEShortCuts(Data1, Data2: Pointer): integer;
function CompareIDEShortCutKey1s(Data1, Data2: Pointer): integer;
function IdentToIDECommand(const Ident: string; var Cmd: longint): boolean;
function IDECommandToIdent(Cmd: longint; var Ident: string): boolean;
function IDECommandToIdent(Cmd: longint): string;
procedure GetIDEEditorCommandValues(Proc: TGetStrProc);

procedure SetIdeMouseCommandOffset(AStartNum: Integer);
function  GetIdeMouseCommandOffset: Integer;
function  IdentToIDEMouseCommand(const Ident: string; var Cmd: longint): boolean;
function  IDEMouseCommandToIdent(Cmd: longint; var Ident: string): boolean;
procedure GetIdeMouseCommandValues(Proc: TGetStrProc);

property  emcIdeMouseCommandOffset: integer read GetIdeMouseCommandOffset write SetIdeMouseCommandOffset;

implementation

function IDEShortCut(Key1: word; Shift1: TShiftState;
  Key2: word; Shift2: TShiftState): TIDEShortCut;
begin
  Result.Key1:=Key1;
  Result.Shift1:=Shift1;
  Result.Key2:=Key2;
  Result.Shift2:=Shift2;
end;

procedure ExecuteIDEShortCut(Sender: TObject; var Key: word; Shift: TShiftState;
  IDEWindowClass: TCustomFormClass);
begin
  if (OnExecuteIDECommand<>nil) and (Key<>VK_UNKNOWN) then
    OnExecuteIDEShortCut(Sender,Key,Shift,IDEWindowClass);
end;

procedure ExecuteIDEShortCut(Sender: TObject; var Key: word;
  Shift: TShiftState);
begin
  OnExecuteIDEShortCut(Sender,Key,Shift,nil);
end;

function ExecuteIDECommand(Sender: TObject; Command: word): boolean;
begin
  if (OnExecuteIDECommand<>nil) and (Command<>0) then
    Result:=OnExecuteIDECommand(Sender,Command)
  else
    Result:=false;
end;

function IsValidIDECommandKey(Key: word): boolean;
begin
  case Key of
  VK_UNDEFINED,VK_UNKNOWN,
  VK_CONTROL,VK_LCONTROL,VK_RCONTROL,
  VK_SHIFT,VK_LSHIFT,VK_RSHIFT,
  VK_LBUTTON,VK_MBUTTON,VK_RBUTTON,
  VK_LWIN,VK_RWIN:
    exit(false);
  end;
  Result:=true;
end;

procedure CreateStandardIDECommandScopes;
begin
  IDECommandScopes:=TIDECommandScopes.Create;
  IDECmdScopeSrcEdit:=RegisterIDECommandScope('SourceEditor');
  IDECmdScopeSrcEditOnly:=RegisterIDECommandScope('SourceEditorOnly');
  IDECmdScopeSrcEditOnlyMultiCaret:=RegisterIDECommandScope('IDECmdScopeSrcEditOnlyMultiCaret');
  IDECmdScopeSrcEditOnlyTmplEdit:=RegisterIDECommandScope('SourceEditorOnlyTemplateEdit');
  IDECmdScopeSrcEditOnlyTmplEditOff:=RegisterIDECommandScope('SourceEditorOnlyTemplateEditOff');
  IDECmdScopeSrcEditOnlySyncroEditSel:=RegisterIDECommandScope('SourceEditorOnlySyncroEditSel');
  IDECmdScopeSrcEditOnlySyncroEdit:=RegisterIDECommandScope('SourceEditorOnlySyncroEdit');
  IDECmdScopeSrcEditOnlySyncroEditOff:=RegisterIDECommandScope('SourceEditorOnlySyncroEdit');
  IDECmdScopeDesignerOnly:=RegisterIDECommandScope('DesignerOnly');
  IDECmdScopeObjectInspectorOnly:=RegisterIDECommandScope('ObjectInspectorOnly');
end;

function KeyAndShiftStateToEditorKeyString(const Key: TIDEShortCut): String;
begin
  Result := KeyAndShiftStateToKeyString(Key.Key1, Key.Shift1);
  if Key.Key2 <> VK_UNKNOWN then
    Result := Result + ', ' + KeyAndShiftStateToKeyString(Key.Key2, Key.Shift2);
end;

function KeyValuesToCaptionStr(const ShortcutA, ShortcutB: TIDEShortCut; Brackets: Char): String;
  function AddBrakets(S: String): String;
  begin
    if Brackets = '[' then
      Result := '[' + S + ']'
    else if Brackets = '(' then
      Result := '(' + S + ')'
    else if Brackets > #0 then
      Result := Brackets + S + Brackets
    else
      Result := S;
  end;
begin
  Result := '';
  if (ShortcutA.Key1 = VK_UNKNOWN) and (ShortcutB.Key1 = VK_UNKNOWN) then
    Result := Result{ + lisNone2 }
  else
  if (ShortcutA.Key1 = VK_UNKNOWN) then
    Result := Result + AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutB))
  else
  if (ShortcutB.Key1 = VK_UNKNOWN) then
    Result := Result + AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutA))
  else
    Result := Result + AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutA))
                     + ' / ' +
                       AddBrakets(KeyAndShiftStateToEditorKeyString(ShortcutB));
end;

type
// in fpc 2.3.1 TShiftState is declared with {$packset 1}
{$IF sizeof(TShiftState)=2}
  TShiftStateInt = word;
{$ELSE}
  TShiftStateInt = integer;
{$ENDIF}

function CompareIDEShortCuts(Data1, Data2: Pointer): integer;
var
  ShortCut1: PIDEShortCut absolute Data1;
  ShortCut2: PIDEShortCut absolute Data2;
begin
  if ShortCut1^.Key1>ShortCut2^.Key1 then
    Result:=1
  else if ShortCut1^.Key1<ShortCut2^.Key1 then
    Result:=-1
  else if TShiftStateInt(ShortCut1^.Shift1)>TShiftStateInt(ShortCut2^.Shift1) then
    Result:=1
  else if TShiftStateInt(ShortCut1^.Shift1)<TShiftStateInt(ShortCut2^.Shift1) then
    Result:=-1
  else if ShortCut1^.Key2>ShortCut2^.Key2 then
    Result:=1
  else if ShortCut1^.Key2<ShortCut2^.Key2 then
    Result:=-1
  else if TShiftStateInt(ShortCut1^.Shift2)>TShiftStateInt(ShortCut2^.Shift2) then
    Result:=1
  else if TShiftStateInt(ShortCut1^.Shift2)<TShiftStateInt(ShortCut2^.Shift2) then
    Result:=-1
  else
    Result:=0;
end;

function CompareIDEShortCutKey1s(Data1, Data2: Pointer): integer;
var
  ShortCut1: PIDEShortCut;
  ShortCut2: PIDEShortCut;
begin
  ShortCut1:=PIDEShortCut(Data1);
  ShortCut2:=PIDEShortCut(Data2);
  if ShortCut1^.Key1>ShortCut2^.Key1 then
    Result:=1
  else if ShortCut1^.Key1<ShortCut2^.Key1 then
    Result:=-1
  else if TShiftStateInt(ShortCut1^.Shift1)>TShiftStateInt(ShortCut2^.Shift1) then
    Result:=1
  else if TShiftStateInt(ShortCut1^.Shift1)<TShiftStateInt(ShortCut2^.Shift1) then
    Result:=-1
  else
    Result:=0;
end;

function RegisterIDECommandCategory(Parent: TIDECommandCategory;
  const Name, Description: string): TIDECommandCategory;
begin
  Result:=IDECommandList.CreateCategory(Parent,Name,Description);
end;

function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string;
  const OnExecuteMethod: TNotifyEvent = nil;
  const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
begin
  Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(VK_UNKNOWN,[]),
                             OnExecuteMethod,OnExecuteProc);
end;

function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string;
  Key1: word; Shift1: TShiftState;
  const OnExecuteMethod: TNotifyEvent;
  const OnExecuteProc: TNotifyProcedure): TIDECommand;
begin
  Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(Key1,Shift1),
                             OnExecuteMethod,OnExecuteProc);
end;

function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string;  const ShortCut1: TIDEShortCut;
  const OnExecuteMethod: TNotifyEvent;
  const OnExecuteProc: TNotifyProcedure): TIDECommand;
begin
  Result:=RegisterIDECommand(Category,Name,Description,
                             ShortCut1,IDEShortCut(VK_UNKNOWN,[]),
                             OnExecuteMethod,OnExecuteProc);
end;

function RegisterIDECommand(Category: TIDECommandCategory;
  const Name, Description: string;
  const ShortCut1, ShortCut2: TIDEShortCut;
  const OnExecuteMethod: TNotifyEvent;
  const OnExecuteProc: TNotifyProcedure): TIDECommand;
begin
  Result:=IDECommandList.CreateCommand(Category,Name,Description,
                                       ShortCut1,ShortCut2,OnExecuteMethod,
                                       OnExecuteProc);
end;

function RegisterIDECommandScope(const Name: string): TIDECommandScope;
begin
  Result:=TIDECommandScope.Create(Name);
  IDECommandScopes.Add(Result);
end;

{ TIDECommandScope }

function TIDECommandScope.GetCategories(Index: integer): TIDECommandCategory;
begin
  Result:=TIDECommandCategory(FCategories[Index]);
end;

function TIDECommandScope.GetIDEWindowClasses(Index: integer): TCustomFormClass;
begin
  Result:=TCustomFormClass(FIDEWindowClasses[Index]);
end;

constructor TIDECommandScope.Create(const TheName: string);
begin
  FName:=TheName;
  FIDEWindowClasses:=TFPList.Create;
  FCategories:=TFPList.Create;
end;

destructor TIDECommandScope.Destroy;
var
  i: Integer;
begin
  for i:=FCategories.Count-1 downto 0 do
    Categories[i].Scope:=nil;
  FreeAndNil(FIDEWindowClasses);
  FreeAndNil(FCategories);
  inherited Destroy;
end;

procedure TIDECommandScope.AddWindowClass(AWindowClass: TCustomFormClass);
begin
  if FIDEWindowClasses.IndexOf(AWindowClass)>=0 then
    RaiseGDBException('TIDECommandScope.AddWindowClass');
  FIDEWindowClasses.Add(AWindowClass);
end;

procedure TIDECommandScope.RemoveWindowClass(AWindowClass: TCustomFormClass);
begin
  FIDEWindowClasses.Remove(AWindowClass);
end;

function TIDECommandScope.IDEWindowClassCount: integer;
begin
  Result:=FIDEWindowClasses.Count;
end;

function TIDECommandScope.CategoryCount: integer;
begin
  Result:=FCategories.Count;
end;

function TIDECommandScope.HasIDEWindowClass(AWindowClass: TCustomFormClass): boolean;
var
  i: Integer;
begin
  if AWindowClass<>nil then begin
    for i:=0 to FIDEWindowClasses.Count-1 do begin
      if (FIDEWindowClasses[i]=nil)
      or AWindowClass.InheritsFrom(TCustomFormClass(FIDEWindowClasses[i])) then
        exit(true);
    end;
  end else begin
    if FIDEWindowClasses.IndexOf(nil)>=0 then
      exit(true);
  end;
  Result:=false;
end;

function TIDECommandScope.Intersects(AScope: TIDECommandScope): boolean;
var
  i: Integer;
  CurClass: TCustomFormClass;
begin
  if AScope=nil then
    Result:=true
  else begin
    for i:=0 to FIDEWindowClasses.Count-1 do begin
      CurClass:=TCustomFormClass(FIDEWindowClasses[i]);
      if (CurClass=nil)
      or (AScope.FIDEWindowClasses.IndexOf(FIDEWindowClasses[i])>=0) then
        exit(true);
    end;
    Result:=false;
  end;
end;

procedure TIDECommandScope.WriteDebugReport;
var
  i: Integer;
begin
  debugln('TIDECommandScope.WriteDebugReport ',Name);
  for i:=0 to FIDEWindowClasses.Count-1 do begin
    if FIDEWindowClasses[i]=nil then
      debugln('  ',dbgs(i),'/',dbgs(FIDEWindowClasses.Count),' nil')
    else
      debugln('  ',dbgs(i),'/',dbgs(FIDEWindowClasses.Count),' ',TClass(FIDEWindowClasses[i]).ClassName);
  end;
end;

{ TIDECommandScopes }

function TIDECommandScopes.GetItems(Index: integer): TIDECommandScope;
begin
  Result:=TIDECommandScope(FItems[Index]);
end;

constructor TIDECommandScopes.Create;
begin
  FItems:=TFPList.Create;
end;

destructor TIDECommandScopes.Destroy;
begin
  Clear;
  FItems.Free;
  inherited Destroy;
end;

procedure TIDECommandScopes.Clear;
var
  i: Integer;
begin
  for i:=0 to FItems.Count-1 do Items[i].Free;
  FItems.Clear;
end;

procedure TIDECommandScopes.Add(NewItem: TIDECommandScope);
begin
  NewItem.fName:=CreateUniqueName(NewItem.Name);
  FItems.Add(NewItem);
end;

function TIDECommandScopes.IndexOf(AnItem: TIDECommandScope): Integer;
begin
  Result:=FItems.IndexOf(AnItem);
end;

function TIDECommandScopes.IndexByName(const AName: string): Integer;
begin
  Result:=Count-1;
  while (Result>=0) and (CompareText(AName,Items[Result].Name)<>0) do
    dec(Result);
end;

function TIDECommandScopes.FindByName(const AName: string): TIDECommandScope;
var
  i: LongInt;
begin
  i:=IndexByName(AName);
  if i>=0 then
    Result:=Items[i]
  else
    Result:=nil;
end;

function TIDECommandScopes.CreateUniqueName(const AName: string): string;
begin
  Result:=AName;
  if IndexByName(Result)<0 then exit;
  Result:=CreateFirstIdentifier(Result);
  while IndexByName(Result)>=0 do
    Result:=CreateNextIdentifier(Result);
end;

function TIDECommandScopes.Count: integer;
begin
  Result:=FItems.Count;
end;

{ TIDECommandCategory }

procedure TIDECommandCategory.SetDescription(const AValue: string);
begin
  if FDescription=AValue then exit;
  FDescription:=AValue;
end;

procedure TIDECommandCategory.SetScope(const AValue: TIDECommandScope);
begin
  if FScope=AValue then exit;
  if FScope<>nil then
    FScope.FCategories.Remove(Self);
  FScope:=AValue;
  if FScope<>nil then
    FScope.FCategories.Add(Self);
end;

destructor TIDECommandCategory.Destroy;
begin
  Scope:=nil;
  inherited Destroy;
end;

procedure TIDECommandCategory.DoOnUpdate;
var
  i: Integer;
begin
  for i := 0 to Count-1 do
    TIDECommand(Items[i]).DoOnUpdate;
end;

function TIDECommandCategory.ScopeIntersects(AScope: TIDECommandScope): boolean;
begin
  if (Scope=nil) or (AScope=nil) then
    Result:=true
  else
    Result:=Scope.Intersects(AScope);
end;

procedure TIDECommandCategory.WriteScopeDebugReport;
begin
  debugln('TIDECommandCategory.WriteScopeDebugReport ',Name,'=',Description);
  if Scope<>nil then
    Scope.WriteDebugReport
  else
    debugln('  Scope=nil');
end;

procedure TIDECommandCategory.Delete(Index: Integer);
begin
  inherited Delete(Index);
end;

{ TIDECommand }

procedure TIDECommand.SetShortcutA(const AValue: TIDEShortCut);
begin
  if CompareIDEShortCuts(@FShortcutA,@AValue)=0 then exit;
  FShortcutA:=AValue;
  //DebugLn('TIDECommand.SetShortcutA ',dbgs(Assigned(OnChange)),' ',Name);
  Change;
end;

procedure TIDECommand.SetShortcutB(const AValue: TIDEShortCut);
begin
  if CompareIDEShortCuts(@FShortcutB,@AValue)=0 then exit;
  FShortcutB:=AValue;
  //DebugLn('TIDECommand.SetShortcutB ',dbgs(Assigned(OnChange)),' ',Name);
  Change;
end;

procedure TIDECommand.UserAdded(const aUser: TIDESpecialCommand);
begin
  FUsers.Add(aUser);
end;

procedure TIDECommand.UserRemoved(const aUser: TIDESpecialCommand);
begin
  FUsers.Remove(aUser);
end;

procedure TIDECommand.Change;
var
  xUser: TIDESpecialCommand;
begin
  for xUser in FUsers do
  begin
    xUser.ShortCutsUpdated(KeyToShortCut(ShortcutA.Key1,ShortcutA.Shift1),
                           KeyToShortCut(ShortcutA.Key2,ShortcutA.Shift2));
  end;
end;

procedure TIDECommand.Init;
begin
  //
end;

function TIDECommand.GetLocalizedName: string;
begin
  if FLocalizedName<>'' then
    Result:=FLocalizedName
  else
    Result:=Name;
end;

function TIDECommand.GetUser(Index: Integer): TIDESpecialCommand;
begin
  Result := FUsers[Index];
end;

function TIDECommand.GetEnabled: Boolean;
begin
  if FUsers.Count > 0 then
    Result := FUsers[0].Enabled
  else
    Result := True;   // A command without SpecialCommands is enabled.
end;

function TIDECommand.GetUserCount: Integer;
begin
  Result := FUsers.Count;
end;

procedure TIDECommand.SetLocalizedName(const AValue: string);
begin
  if FLocalizedName=AValue then exit;
  FLocalizedName:=AValue;
  //DebugLn('TIDECommand.SetLocalizedName ',dbgs(Assigned(OnChange)),' ',Name);
  Change;
end;

procedure TIDECommand.SetOnExecute(const aOnExecute: TNotifyEvent);
var
  xUser: TIDESpecialCommand;
begin
  if SameMethod(TMethod(FOnExecute), TMethod(aOnExecute)) then Exit;
  FOnExecute := aOnExecute;
  for xUser in FUsers do
    if xUser.SyncProperties then
    begin
      xUser.BlockSync;
      try
        xUser.OnClick := aOnExecute;
      finally
        xUser.UnblockSync;
      end;
    end;
end;

procedure TIDECommand.SetOnExecuteProc(const aOnExecuteProc: TNotifyProcedure);
var
  xUser: TIDESpecialCommand;
begin
  if FOnExecuteProc = aOnExecuteProc then Exit;
  FOnExecuteProc := aOnExecuteProc;
  for xUser in FUsers do
    if xUser.SyncProperties then
    begin
      xUser.BlockSync;
      try
        xUser.OnClickProc := aOnExecuteProc;
      finally
        xUser.UnblockSync;
      end;
    end;
end;

procedure TIDECommand.SetCategory(const AValue: TIDECommandCategory);
begin
  if FCategory=AValue then exit;
  // unbind
  if Category<>nil then
    Category.Remove(Self);
  // bind
  fCategory:=AValue;
  if Category<>nil then
    Category.Add(Self);
  //DebugLn('TIDECommand.SetCategory ',dbgs(Assigned(OnChange)),' ',Name);
  Change;
end;

procedure TIDECommand.SetEnabled(const AEnabled: Boolean);
var
  xUser: TIDESpecialCommand;
begin
  for xUser in FUsers do
    if xUser.SyncProperties then
    begin
      xUser.BlockSync;
      try
        xUser.Enabled := AEnabled;
      finally
        xUser.UnblockSync;
      end;
    end;
end;

procedure TIDECommand.SetHint(const AHint: string);
var
  xUser: TIDESpecialCommand;
begin
  for xUser in FUsers do
    if xUser.SyncProperties then
    begin
      xUser.BlockSync;
      try
        xUser.Hint := AHint;
      finally
        xUser.UnblockSync;
      end;
    end;
end;

function TIDECommand.AsShortCut: TShortCut;
var
  CurKey: TIDEShortCut;
begin
  if (ShortcutA.Key1<>VK_UNKNOWN) and (ShortcutA.Key2=VK_UNKNOWN) then
    CurKey:=ShortcutA
  else if (ShortcutB.Key1<>VK_UNKNOWN) and (ShortcutB.Key2=VK_UNKNOWN) then
    CurKey:=ShortcutB
  else
    CurKey:=CleanIDEShortCut;
  Result:=CurKey.Key1;
  if ssCtrl in CurKey.Shift1 then
    Result:=Result+scCtrl;
  if ssShift in CurKey.Shift1 then
    Result:=Result+scShift;
  if ssAlt in CurKey.Shift1 then
    Result:=Result+scAlt;
end;

constructor TIDECommand.Create(TheCategory: TIDECommandCategory;
  const TheName, TheLocalizedName: String; TheCommand: word;
  const TheShortcutA, TheShortcutB: TIDEShortCut;
  const ExecuteMethod: TNotifyEvent;
  const ExecuteProc: TNotifyProcedure);
begin
  FUsers:=TIDESpecialCommands.Create;
  fCommand:=TheCommand;
  fName:=TheName;
  FLocalizedName:=TheLocalizedName;
  fShortcutA:=TheShortcutA;
  fShortcutB:=TheShortcutB;
  DefaultShortcutA:=ShortcutA;
  DefaultShortcutB:=ShortcutB;
  Category:=TheCategory;
  FOnExecute:=ExecuteMethod;
  FOnExecuteProc:=ExecuteProc;
  //DebugLn('TIDECommand.Create Name=',Name,' ',ShortCutToText(AsShortCut),' ',dbgs(Pointer(Self)));
  Init;
end;

constructor TIDECommand.Create(TheCategory: TIDECommandCategory;
  const TheName, TheLocalizedName: String; TheCommand: word);
begin
  Create(TheCategory, TheName, TheLocalizedName, TheCommand,
         CleanIDEShortCut, CleanIDEShortCut, Nil, Nil);
end;

constructor TIDECommand.Create(ACommand: TIDECommand; ACategory: TIDECommandCategory);
begin
  Create(ACategory, ACommand.Name, ACommand.LocalizedName, ACommand.Command,
    ACommand.ShortcutA, ACommand.ShortcutB, ACommand.OnExecute, ACommand.OnExecuteProc);
end;

destructor TIDECommand.Destroy;
begin
  if Category <> nil then
    Category := nil;
  FUsers.Free;
  inherited Destroy;
end;

procedure TIDECommand.DoOnUpdate(Sender: TObject);
begin
  if Assigned(FOnUpdateProc) then
    FOnUpdateProc(Sender);
  if Assigned(FOnUpdateMethod) then
    FOnUpdateMethod(Sender);
end;

procedure TIDECommand.DoOnUpdate;
begin
  DoOnUpdate(Self);
end;

procedure TIDECommand.Assign(ACommand: TIDECommand);
begin
  if IsEqual(ACommand) then exit;
  //DebugLn('TIDECommand.Assign ',dbgs(Assigned(OnChange)),' ',Name,' ');
  FShortcutA:=ACommand.FShortcutA;
  FShortcutB:=ACommand.FShortcutB;
  Change;
end;

function TIDECommand.IsEqual(ACommand: TIDECommand): boolean;
begin
  Result:=(CompareIDEShortCuts(@FShortcutA,@ACommand.FShortcutA)=0)
          and (CompareIDEShortCuts(@FShortcutB,@ACommand.FShortcutB)=0);
end;

procedure TIDECommand.SetCaption(const ACaption: string);
var
  xUser: TIDESpecialCommand;
begin
  for xUser in FUsers do
    if xUser.SyncProperties then
    begin
      xUser.BlockSync;
      try
        xUser.Caption := ACaption;
      finally
        xUser.UnblockSync;
      end;
    end;
end;

procedure TIDECommand.ClearShortcutA;
begin
  ShortcutA:=CleanIDEShortCut;
end;

procedure TIDECommand.ClearShortcutB;
begin
  ShortcutB:=CleanIDEShortCut;
end;

function TIDECommand.GetCategoryAndName: string;
begin
  Result:='"'+GetLocalizedName+'"';
  if Category<>nil then
    Result:='"'+Category.Description+'" -> '+Result;
end;

function TIDECommand.Execute(Sender: TObject): boolean;
begin
  Result:=false;
  if Assigned(OnExecute) then begin
    Result:=true;
    OnExecute(Sender);
  end else
  if Assigned(OnExecuteProc) then begin
    Result:=true;
    OnExecuteProc(Sender);
  end;
end;

{ TIDECommands }

procedure TIDECommands.AddCustomUpdateEvent(const aEvent: TNotifyEvent);
begin
  FCustomUpdateEvents.Add(TMethod(aEvent));
end;

procedure TIDECommands.ApplicationOnIdle(Sender: TObject; var Done: Boolean);
begin
  if (FDontExecuteUpdateEventsUntil > 0) and (GetTickCount64 < FDontExecuteUpdateEventsUntil) then
    Exit;

  ExecuteUpdateEvents;
  FDontExecuteUpdateEventsUntil := 0;
end;

constructor TIDECommands.Create;
begin
  inherited Create;

  FCustomUpdateEvents := TMethodList.Create;
end;

destructor TIDECommands.Destroy;
begin
  FCustomUpdateEvents.Free;
  inherited Destroy;
end;

procedure TIDECommands.ExecuteUpdateEvents;
var
  i: Integer;
begin
  if not Application.Active or
     (ActivePopupMenu <> nil) or//no popup menus
     (Application.ModalLevel > 0) or//no modal windows
     not IsWindowEnabled(Application.MainForm.Handle)//main IDE must be enabled
  then
    Exit;

  FCustomUpdateEvents.CallNotifyEvents(Self);
  for i := 0 to CategoryCount-1 do
    Categories[i].DoOnUpdate;
end;

procedure TIDECommands.CancelPostponeUpdateEvents;
begin
  FDontExecuteUpdateEventsUntil := 0;
end;

procedure TIDECommands.PostponeUpdateEvents;
begin
  FDontExecuteUpdateEventsUntil := GetTickCount64 + 500;
end;

procedure TIDECommands.RemoveCustomUpdateEvent(const aEvent: TNotifyEvent);
begin
  FCustomUpdateEvents.Remove(TMethod(aEvent));
end;

procedure TIDECommands.StartUpdateEvents;
begin
  Application.AddOnIdleHandler(@ApplicationOnIdle, False);
end;

procedure TIDECommands.StopUpdateEvents;
begin
  Application.RemoveOnIdleHandler(@ApplicationOnIdle);
end;

{ TIDESpecialCommand }

constructor TIDESpecialCommand.Create(const aName: string);
begin
  inherited Create;

  FSyncProperties:=true;
  FName := aName;
  FEnabled:=true;
  FImageIndex:=-1;
end;

procedure TIDESpecialCommand.BlockSync;
begin
  Inc(FBlockSync);
end;

destructor TIDESpecialCommand.Destroy;
begin
  if Assigned(FCommand) then
    FCommand.UserRemoved(Self);
  inherited Destroy;
end;

procedure TIDESpecialCommand.DoOnClick(Sender: TObject);
begin
  if Assigned(FOnClickProc) then
    FOnClickProc(Sender)
  else
  if Assigned(FOnClickMethod) then
    FOnClickMethod(Sender);
end;

procedure TIDESpecialCommand.DoOnClick;
begin
  DoOnClick(Self);
end;

function TIDESpecialCommand.DoOnRequestCaption(Sender: TObject): Boolean;
var
  xCaption, xHint: string;
begin
  Result := Assigned(FOnRequestCaption);
  if Result then
  begin
    xCaption := Caption;
    xHint := Hint;
    FOnRequestCaption(Sender, xCaption, xHint);
    Caption := xCaption;
    Hint := xHint;
  end;
end;

function TIDESpecialCommand.GetCaption: string;
begin
  if FCaption<>'' then
    Result:=FCaption
  else if (FCommand<>nil) and (FCommand.LocalizedName<>'') then
    Result:=FCommand.LocalizedName
  else
    Result:=FName;
end;

function TIDESpecialCommand.GetCaptionWithShortCut: String;
begin
  Result := Caption;
  DeleteAmpersands(Result);
  Result := Result + GetShortcut;
end;

function TIDESpecialCommand.GetHintOrCaptionWithShortCut: String;
begin
  if Hint <> '' then
    Result := Hint
  else
    Result := Caption;
  DeleteAmpersands(Result);
  Result := Result + GetShortcut;
end;

function TIDESpecialCommand.GetShortcut: String;
begin
  Result := '';
  if Assigned(FCommand) then
    Result := KeyValuesToCaptionStr(FCommand.ShortcutA, FCommand.ShortcutB);
  if Result <> '' then
    Result := ' ' + Result;
end;

procedure TIDESpecialCommand.SetCaption(aCaption: string);
var
  xUser: TIDESpecialCommand;
begin
  if FCaption=aCaption then Exit;
  FCaption := aCaption;
  if (FCommand<> nil) and SyncAvailable then
    for xUser in FCommand.FUsers do
      if (xUser <> Self) and xUser.SyncProperties then
      begin
        xUser.BlockSync;
        try
          xUser.Caption:=aCaption;
        finally
          xUser.UnblockSync;
        end;
      end;
end;

procedure TIDESpecialCommand.SetChecked(const aChecked: Boolean);
var
  xUser: TIDESpecialCommand;
begin
  if FChecked=aChecked then Exit;
  FChecked := aChecked;
  if (FCommand<> nil) and SyncAvailable then
    for xUser in FCommand.FUsers do
      if (xUser <> Self) and xUser.SyncProperties then
      begin
        xUser.BlockSync;
        try
          xUser.Checked:=aChecked;
        finally
          xUser.UnblockSync;
        end;
      end;
end;

procedure TIDESpecialCommand.SetCommand(const AValue: TIDECommand);
begin
  if FCommand = AValue then
    Exit;
  FCommand := AValue;
  if FCommand <> nil then
  begin
    if (FCommand.OnExecute=nil) and (OnClick<>nil) then
      FCommand.OnExecute := OnClick
    else
    if (OnClick=nil) and (FCommand.OnExecute<>nil) then
      OnClick := FCommand.OnExecute;

    if (FCommand.OnExecuteProc=nil) and (OnClickProc<>nil) then
      FCommand.OnExecuteProc := OnClickProc
    else
    if (OnClickProc=nil) and (FCommand.OnExecuteProc<>nil) then
      OnClickProc := FCommand.OnExecuteProc;

    FCommand.UserAdded(Self);
    FCommand.Change;
  end;
end;

procedure TIDESpecialCommand.SetEnabled(const aEnabled: Boolean);
var
  xUser: TIDESpecialCommand;
begin
  if FEnabled=aEnabled then Exit;
  FEnabled := aEnabled;
  if (FCommand<> nil) and SyncAvailable then
    for xUser in FCommand.FUsers do
      if (xUser <> Self) and xUser.SyncProperties then
      begin
        xUser.BlockSync;
        try
          xUser.Enabled:=aEnabled;
        finally
          xUser.UnblockSync;
        end;
      end;
end;

procedure TIDESpecialCommand.SetHint(const aHint: string);
var
  xUser: TIDESpecialCommand;
begin
  if FHint=aHint then Exit;
  FHint := aHint;
  if (FCommand<> nil) and SyncAvailable then
    for xUser in FCommand.FUsers do
      if (xUser <> Self) and xUser.SyncProperties then
      begin
        xUser.BlockSync;
        try
          xUser.Hint:=aHint;
        finally
          xUser.UnblockSync;
        end;
      end;
end;

procedure TIDESpecialCommand.SetImageIndex(const aImageIndex: Integer);
var
  xUser: TIDESpecialCommand;
begin
  if FImageIndex=aImageIndex then Exit;
  FImageIndex := aImageIndex;
  if (FCommand<> nil) and SyncAvailable then
    for xUser in FCommand.FUsers do
      if (xUser <> Self) and xUser.SyncProperties then
      begin
        xUser.BlockSync;
        try
          xUser.ImageIndex:=aImageIndex;
        finally
          xUser.UnblockSync;
        end;
      end;
end;

procedure TIDESpecialCommand.SetName(const aName: string);
begin
  FName := aName;
end;

procedure TIDESpecialCommand.SetOnClickMethod(const aOnClick: TNotifyEvent);
begin
  if SameMethod(TMethod(FOnClickMethod), TMethod(aOnClick)) then Exit;
  FOnClickMethod := aOnClick;
  if (FCommand<>nil) and SyncAvailable then
    FCommand.OnExecute:=aOnClick;
end;

procedure TIDESpecialCommand.SetOnClickProc(const aOnClickProc: TNotifyProcedure);
begin
  if FOnClickProc = aOnClickProc then Exit;
  FOnClickProc := aOnClickProc;
  if (FCommand<> nil) and SyncAvailable then
    FCommand.OnExecuteProc:=aOnClickProc;
end;

procedure TIDESpecialCommand.SetOnRequestCaption(
  const aOnRequestCaptionHint: TGetHintCaptionEvent);
var
  xUser: TIDESpecialCommand;
begin
  if FOnRequestCaption = aOnRequestCaptionHint then Exit;
  FOnRequestCaption := aOnRequestCaptionHint;
  if (FCommand<> nil) and SyncAvailable then
    for xUser in FCommand.FUsers do
      if (xUser <> Self) and xUser.SyncProperties then
      begin
        xUser.BlockSync;
        try
          xUser.OnRequestCaptionHint:=aOnRequestCaptionHint;
        finally
          xUser.UnblockSync;
        end;
      end;
end;

procedure TIDESpecialCommand.SetResourceName(const aResourceName: string);
begin
  if aResourceName <> '' then
    ImageIndex := IDEImages.LoadImage(aResourceName)
  else
    ImageIndex := -1;
end;

procedure TIDESpecialCommand.ShortCutsUpdated(const aShortCut,
  aShortCutKey2: TShortCut);
begin
  //nothing here, override in descendants
end;

function TIDESpecialCommand.SyncAvailable: Boolean;
begin
  Result := FSyncProperties and (FBlockSync=0);
end;

procedure TIDESpecialCommand.UnblockSync;
begin
  Dec(FBlockSync);
end;

{ TIDESpecialCommandEnumerator }

constructor TIDESpecialCommandEnumerator.Create(AButtons: TIDESpecialCommands);
begin
  inherited Create;
  FList := AButtons;
  FPosition := -1;
end;

function TIDESpecialCommandEnumerator.GetCurrent: TIDESpecialCommand;
begin
  Result := TIDESpecialCommand(FList[FPosition]);
end;

function TIDESpecialCommandEnumerator.MoveNext: Boolean;
begin
  Inc(FPosition);
  Result := FPosition < FList.Count;
end;

{ TIDESpecialCommands }

procedure TIDESpecialCommands.Add(const aUser: TIDESpecialCommand);
begin
  FList.Add(aUser);
end;

constructor TIDESpecialCommands.Create;
begin
  inherited Create;
  FList := TFPList.Create;
end;

destructor TIDESpecialCommands.Destroy;
var
  I: Integer;
begin
  for I := 0 to Count-1 do
    Items[I].FCommand := nil;
  FList.Free;
  inherited Destroy;
end;

function TIDESpecialCommands.GetCount: Integer;
begin
  Result := FList.Count;
end;

function TIDESpecialCommands.GetEnumerator: TIDESpecialCommandEnumerator;
begin
  Result := TIDESpecialCommandEnumerator.Create(Self);
end;

function TIDESpecialCommands.GetItems(Index: Integer): TIDESpecialCommand;
begin
  Result := TIDESpecialCommand(FList[Index]);
end;

procedure TIDESpecialCommands.Remove(const aUser: TIDESpecialCommand);
begin
  FList.Remove(aUser);
end;

const
  IDEEditorCommandStrs: array[0..337] of TIdentMapEntry = (
  // search
    (Value: ecFind;                                   Name: 'ecFind'),
    (Value: ecFindAgain;                              Name: 'ecFindAgain'),
    (Value: ecFindNext;                               Name: 'ecFindNext'),
    (Value: ecFindPrevious;                           Name: 'ecFindPrevious'),
    (Value: ecReplace;                                Name: 'ecReplace'),
    (Value: ecIncrementalFind;                        Name: 'ecIncrementalFind'),
    (Value: ecFindProcedureDefinition;                Name: 'ecFindProcedureDefinition'),
    (Value: ecFindProcedureMethod;                    Name: 'ecFindProcedureMethod'),
    (Value: ecGotoLineNumber;                         Name: 'ecGotoLineNumber'),
    (Value: ecFindNextWordOccurrence;                 Name: 'ecFindNextWordOccurrence'),
    (Value: ecFindPrevWordOccurrence;                 Name: 'ecFindPrevWordOccurrence'),
    (Value: ecFindInFiles;                            Name: 'ecFindInFiles'),
    (Value: ecJumpBack;                               Name: 'ecJumpBack'),
    (Value: ecJumpForward;                            Name: 'ecJumpForward'),
    (Value: ecAddJumpPoint;                           Name: 'ecAddJumpPoint'),
    (Value: ecViewJumpHistory;                        Name: 'ecViewJumpHistory'),
    (Value: ecJumpToNextError;                        Name: 'ecJumpToNextError'),
    (Value: ecJumpToPrevError;                        Name: 'ecJumpToPrevError'),
    (Value: ecProcedureList;                          Name: 'ecProcedureList'),

  // search code
    (Value: ecFindDeclaration;                        Name: 'ecFindDeclaration'),
    (Value: ecFindBlockOtherEnd;                      Name: 'ecFindBlockOtherEnd'),
    (Value: ecFindBlockStart;                         Name: 'ecFindBlockStart'),
    (Value: ecOpenFileAtCursor;                       Name: 'ecOpenFileAtCursor'),
    (Value: ecGotoIncludeDirective;                   Name: 'ecGotoIncludeDirective'),
    (Value: ecJumpToInterface;                        Name: 'ecJumpToInterface'),
    (Value: ecJumpToInterfaceUses;                    Name: 'ecJumpToInterfaceUses'),
    (Value: ecJumpToImplementation;                   Name: 'ecJumpToImplementation'),
    (Value: ecJumpToImplementationUses;               Name: 'ecJumpToImplementationUses'),
    (Value: ecJumpToInitialization;                   Name: 'ecJumpToInitialization'),

  // edit selection
    (Value: ecSelectionUpperCase;                     Name: 'ecSelectionUpperCase'),
    (Value: ecSelectionLowerCase;                     Name: 'ecSelectionLowerCase'),
    (Value: ecSelectionSwapCase;                      Name: 'ecSelectionSwapCase'),
    (Value: ecSelectionTabs2Spaces;                   Name: 'ecSelectionTabs2Spaces'),
    (Value: ecSelectionEnclose;                       Name: 'ecSelectionEnclose'),
    (Value: ecSelectionComment;                       Name: 'ecSelectionComment'),
    (Value: ecSelectionUncomment;                     Name: 'ecSelectionUncomment'),
    (Value: ecSelectionSort;                          Name: 'ecSelectionSort'),
    (Value: ecSelectionBreakLines;                    Name: 'ecSelectionBreakLines'),
    (Value: ecSelectToBrace;                          Name: 'ecSelectToBrace'),
    (Value: ecSelectCodeBlock;                        Name: 'ecSelectCodeBlock'),
    (Value: ecSelectWord;                             Name: 'ecSelectWord'),
    (Value: ecSelectLine;                             Name: 'ecSelectLine'),
    (Value: ecSelectParagraph;                        Name: 'ecSelectParagraph'),
    (Value: ecSelectionEncloseIFDEF;                  Name: 'ecSelectionEncloseIFDEF'),
    (Value: ecToggleComment;                          Name: 'ecToggleComment'),

  // insert text
    (Value: ecInsertCharacter;                        Name: 'ecInsertCharacter'),
    (Value: ecInsertGUID;                             Name: 'ecInsertGUID'),
    (Value: ecInsertFilename;                         Name: 'ecInsertFilename'),
    (Value: ecInsertUserName;                         Name: 'ecInsertUserName'),
    (Value: ecInsertDateTime;                         Name: 'ecInsertDateTime'),
    (Value: ecInsertChangeLogEntry;                   Name: 'ecInsertChangeLogEntry'),
    (Value: ecInsertCVSAuthor;                        Name: 'ecInsertCVSAuthor'),
    (Value: ecInsertCVSDate;                          Name: 'ecInsertCVSDate'),
    (Value: ecInsertCVSHeader;                        Name: 'ecInsertCVSHeader'),
    (Value: ecInsertCVSID;                            Name: 'ecInsertCVSID'),
    (Value: ecInsertCVSLog;                           Name: 'ecInsertCVSLog'),
    (Value: ecInsertCVSName;                          Name: 'ecInsertCVSName'),
    (Value: ecInsertCVSRevision;                      Name: 'ecInsertCVSRevision'),
    (Value: ecInsertCVSSource;                        Name: 'ecInsertCVSSource'),
    (Value: ecInsertGPLNotice;                        Name: 'ecInsertGPLNotice'),
    (Value: ecInsertGPLNoticeTranslated;              Name: 'ecInsertGPLNoticeTranslated'),
    (Value: ecInsertLGPLNotice;                       Name: 'ecInsertLGPLNotice'),
    (Value: ecInsertLGPLNoticeTranslated;             Name: 'ecInsertLGPLNoticeTranslated'),
    (Value: ecInsertModifiedLGPLNotice;               Name: 'ecInsertModifiedLGPLNotice'),
    (Value: ecInsertModifiedLGPLNoticeTranslated;     Name: 'ecInsertModifiedLGPLNoticeTranslated'),
    (Value: ecInsertMITNotice;                        Name: 'ecInsertMITNotice'),
    (Value: ecInsertMITNoticeTranslated;              Name: 'ecInsertMITNoticeTranslated'),

  // source tools
    (Value: ecWordCompletion;                         Name: 'ecWordCompletion'),
    (Value: ecCompleteCode;                           Name: 'ecCompleteCode'),
    (Value: ecIdentCompletion;                        Name: 'ecIdentCompletion'),
    (Value: ecSyntaxCheck;                            Name: 'ecSyntaxCheck'),
    (Value: ecGuessUnclosedBlock;                     Name: 'ecGuessUnclosedBlock'),
    (Value: ecGuessMisplacedIFDEF;                    Name: 'ecGuessMisplacedIFDEF'),
    (Value: ecConvertDFM2LFM;                         Name: 'ecConvertDFM2LFM'),
    (Value: ecCheckLFM;                               Name: 'ecCheckLFM'),
    (Value: ecConvertDelphiUnit;                      Name: 'ecConvertDelphiUnit'),
    (Value: ecConvertDelphiProject;                   Name: 'ecConvertDelphiProject'),
    (Value: ecConvertDelphiPackage;                   Name: 'ecConvertDelphiPackage'),
    (Value: ecConvertEncoding;                        Name: 'ecConvertEncoding'),
    (Value: ecMakeResourceString;                     Name: 'ecMakeResourceString'),
    (Value: ecDiff;                                   Name: 'ecDiff'),
    (Value: ecExtractProc;                            Name: 'ecExtractProc'),
    (Value: ecFindIdentifierRefs;                     Name: 'ecFindIdentifierRefs'),
    (Value: ecRenameIdentifier;                       Name: 'ecRenameIdentifier'),
    (Value: ecInvertAssignment;                       Name: 'ecInvertAssignment'),
    (Value: ecShowCodeContext;                        Name: 'ecShowCodeContext'),
    (Value: ecShowAbstractMethods;                    Name: 'ecShowAbstractMethods'),
    (Value: ecRemoveEmptyMethods;                     Name: 'ecRemoveEmptyMethods'),
    (Value: ecRemoveUnusedUnits;                      Name: 'ecRemoveUnusedUnits'),
    (Value: ecUseUnit;                                Name: 'ecUseUnit'),
    (Value: ecFindOverloads;                          Name: 'ecFindOverloads'),
    (Value: ecFindUsedUnitRefs;                       Name: 'ecFindUsedUnitRefs'),
    (Value: ecCompleteCodeInteractive;                Name: 'ecCompleteCodeInteractive'),

  // file menu
    (Value: ecNew;                                    Name: 'ecNew'),
    (Value: ecNewUnit;                                Name: 'ecNewUnit'),
    (Value: ecNewForm;                                Name: 'ecNewForm'),
    (Value: ecOpen;                                   Name: 'ecOpen'),
    (Value: ecRevert;                                 Name: 'ecRevert'),
    (Value: ecSave;                                   Name: 'ecSave'),
    (Value: ecSaveAs;                                 Name: 'ecSaveAs'),
    (Value: ecSaveAll;                                Name: 'ecSaveAll'),
    (Value: ecClose;                                  Name: 'ecClose'),
    (Value: ecCleanDirectory;                         Name: 'ecCleanDirectory'),
    (Value: ecRestart;                                Name: 'ecRestart'),
    (Value: ecQuit;                                   Name: 'ecQuit'),
    (Value: ecCloseOtherTabs;                         Name: 'ecCloseOtherTabs'),
    (Value: ecCloseRightTabs;                         Name: 'ecCloseRightTabs'),

  // edit menu
    (Value: ecMultiPaste;                             Name: 'ecMultiPaste'),

  // IDE navigation
    (Value: ecToggleFormUnit;                         Name: 'ecToggleFormUnit'),
    (Value: ecToggleObjectInsp;                       Name: 'ecToggleObjectInsp'),
    (Value: ecToggleSourceEditor;                     Name: 'ecToggleSourceEditor'),
    (Value: ecToggleCodeExpl;                         Name: 'ecToggleCodeExpl'),
    (Value: ecToggleFPDocEditor;                      Name: 'ecToggleFPDocEditor'),
    (Value: ecToggleMessages;                         Name: 'ecToggleMessages'),
    (Value: ecToggleWatches;                          Name: 'ecToggleWatches'),
    (Value: ecToggleBreakPoints;                      Name: 'ecToggleBreakPoints'),
    (Value: ecToggleDebuggerOut;                      Name: 'ecToggleDebuggerOut'),
    (Value: ecViewUnitDependencies;                   Name: 'ecViewUnitDependencies'),
    (Value: ecViewUnitInfo;                           Name: 'ecViewUnitInfo'),
    (Value: ecToggleLocals;                           Name: 'ecToggleLocals'),
    (Value: ecToggleCallStack;                        Name: 'ecToggleCallStack'),
    (Value: ecToggleSearchResults;                    Name: 'ecToggleSearchResults'),
    (Value: ecViewAnchorEditor;                       Name: 'ecViewAnchorEditor'),
    (Value: ecViewTabOrder;                           Name: 'ecViewTabOrder'),
    (Value: ecToggleCodeBrowser;                      Name: 'ecToggleCodeBrowser'),
    (Value: ecToggleCompPalette;                      Name: 'ecToggleCompPalette'),
    (Value: ecToggleIDESpeedBtns;                     Name: 'ecToggleIDESpeedBtns'),
    (Value: ecViewComponents;                         Name: 'ecViewComponents'),
    (Value: ecToggleRestrictionBrowser;               Name: 'ecToggleRestrictionBrowser'),
    (Value: ecViewTodoList;                           Name: 'ecViewTodoList'),
    (Value: ecToggleRegisters;                        Name: 'ecToggleRegisters'),
    (Value: ecToggleAssembler;                        Name: 'ecToggleAssembler'),
    (Value: ecToggleMemViewer;                        Name: 'ecToggleMemViewer'),
    (Value: ecToggleDebugEvents;                      Name: 'ecToggleDebugEvents'),
    (Value: ecViewPseudoTerminal;                     Name: 'ecViewPseudoTerminal'),
    (Value: ecViewThreads;                            Name: 'ecViewThreads'),
    (Value: ecViewHistory;                            Name: 'ecViewHistory'),
    (Value: ecViewMacroList;                          Name: 'ecViewMacroList'),

  // sourcenotebook commands
    (Value: ecNextEditor;                             Name: 'ecNextEditor'),
    (Value: ecPrevEditor;                             Name: 'ecPrevEditor'),
    (Value: ecMoveEditorLeft;                         Name: 'ecMoveEditorLeft'),
    (Value: ecMoveEditorRight;                        Name: 'ecMoveEditorRight'),
    (Value: ecToggleBreakPoint;                       Name: 'ecToggleBreakPoint'),
    (Value: ecToggleBreakPointEnabled;                Name: 'ecToggleBreakPointEnabled'),
    (Value: ecBreakPointProperties;                   Name: 'ecBreakPointProperties'),

    (Value: ecRemoveBreakPoint;                       Name: 'ecRemoveBreakPoint'),
    (Value: ecMoveEditorLeftmost;                     Name: 'ecMoveEditorLeftmost'),
    (Value: ecMoveEditorRightmost;                    Name: 'ecMoveEditorRightmost'),

    (Value: ecNextSharedEditor;                       Name: 'ecNextSharedEditor'),
    (Value: ecPrevSharedEditor;                       Name: 'ecPrevSharedEditor'),

    (Value: ecNextWindow;                             Name: 'ecNextWindow'),
    (Value: ecPrevWindow;                             Name: 'ecPrevWindow'),
    (Value: ecMoveEditorNextWindow;                   Name: 'ecMoveEditorNextWindow'),
    (Value: ecMoveEditorPrevWindow;                   Name: 'ecMoveEditorPrevWindow'),
    (Value: ecMoveEditorNewWindow;                    Name: 'ecMoveEditorNewWindow'),
    (Value: ecCopyEditorNextWindow;                   Name: 'ecCopyEditorNextWindow'),
    (Value: ecCopyEditorPrevWindow;                   Name: 'ecCopyEditorPrevWindow'),
    (Value: ecCopyEditorNewWindow;                    Name: 'ecCopyEditorNewWindow'),
    (Value: ecPrevEditorInHistory;                    Name: 'ecPrevEditorInHistory'),
    (Value: ecNextEditorInHistory;                    Name: 'ecNextEditorInHistory'),

    (Value: ecGotoEditor1;                            Name: 'ecGotoEditor1'),
    (Value: ecGotoEditor2;                            Name: 'ecGotoEditor2'),
    (Value: ecGotoEditor3;                            Name: 'ecGotoEditor3'),
    (Value: ecGotoEditor4;                            Name: 'ecGotoEditor4'),
    (Value: ecGotoEditor5;                            Name: 'ecGotoEditor5'),
    (Value: ecGotoEditor6;                            Name: 'ecGotoEditor6'),
    (Value: ecGotoEditor7;                            Name: 'ecGotoEditor7'),
    (Value: ecGotoEditor8;                            Name: 'ecGotoEditor8'),
    (Value: ecGotoEditor9;                            Name: 'ecGotoEditor9'),
    (Value: ecGotoEditor0;                            Name: 'ecGotoEditor0'),

    (Value: ecLockEditor;                             Name: 'ecLockEditor'),

  // marker
    (Value: ecSetFreeBookmark;                        Name: 'ecSetFreeBookmark'),
    (Value: ecPrevBookmark;                           Name: 'ecPrevBookmark'),
    (Value: ecNextBookmark;                           Name: 'ecNextBookmark'),
    (Value: ecClearBookmarkForFile;                   Name: 'ecClearBookmarkForFile'),
    (Value: ecClearAllBookmark;                       Name: 'ecClearAllBookmark'),
    (Value: ecGotoBookmarks;                          Name: 'ecGotoBookmarks'),
    (Value: ecToggleBookmarks;                        Name: 'ecToggleBookmarks'),

  // Macro
    (Value: ecSynMacroRecord;                         Name: 'ecSynMacroRecord'),
    (Value: ecSynMacroPlay;                           Name: 'ecSynMacroPlay'),

  // run menu
    (Value: ecCompile;                                Name: 'ecCompile'),
    (Value: ecBuild;                                  Name: 'ecBuild'),
    (Value: ecQuickCompile;                           Name: 'ecQuickCompile'),
    (Value: ecCleanUpAndBuild;                        Name: 'ecCleanUpAndBuild'),
    (Value: ecAbortBuild;                             Name: 'ecAbortBuild'),
    (Value: ecRunWithoutDebugging;                    Name: 'ecRunWithoutDebugging'),
    (Value: ecRun;                                    Name: 'ecRun'),
    (Value: ecPause;                                  Name: 'ecPause'),
    (Value: ecStepInto;                               Name: 'ecStepInto'),
    (Value: ecStepOver;                               Name: 'ecStepOver'),
    (Value: ecStepToCursor;                            Name: 'ecStepToCursor'),
    (Value: ecRunToCursor;                            Name: 'ecRunToCursor'),
    (Value: ecStopProgram;                            Name: 'ecStopProgram'),
    (Value: ecResetDebugger;                          Name: 'ecResetDebugger'),
    (Value: ecRunParameters;                          Name: 'ecRunParameters'),
    (Value: ecBuildFile;                              Name: 'ecBuildFile'),
    (Value: ecRunFile;                                Name: 'ecRunFile'),
    (Value: ecConfigBuildFile;                        Name: 'ecConfigBuildFile'),
    (Value: ecInspect;                                Name: 'ecInspect'),
    (Value: ecEvaluate;                               Name: 'ecEvaluate'),
    (Value: ecAddWatch;                               Name: 'ecAddWatch'),
    (Value: ecShowExecutionPoint;                     Name: 'ecShowExecutionPoint'),
    (Value: ecStepOut;                                Name: 'ecStepOut'),
    (Value: ecStepIntoInstr;                          Name: 'ecStepIntoInstr'),
    (Value: ecStepOverInstr;                          Name: 'ecStepOverInstr'),
    (Value: ecStepIntoContext;                        Name: 'ecStepIntoContext'),
    (Value: ecStepOverContext;                        Name: 'ecStepOverContext'),
    (Value: ecAddBpSource;                            Name: 'ecAddBpSource'),
    (Value: ecAddBpAddress;                           Name: 'ecAddBpAddress'),
    (Value: ecAddBpDataWatch;                         Name: 'ecAddBpDataWatch'),
    (Value: ecAttach;                                 Name: 'ecAttach'),
    (Value: ecDetach;                                 Name: 'ecDetach'),

  // 460++ : used for ecViewHistory (debugger) / ecViewMacroList

  // project menu
    (Value: ecNewProject;                             Name: 'ecNewProject'),
    (Value: ecNewProjectFromFile;                     Name: 'ecNewProjectFromFile'),
    (Value: ecOpenProject;                            Name: 'ecOpenProject'),
    (Value: ecCloseProject;                           Name: 'ecCloseProject'),
    (Value: ecSaveProject;                            Name: 'ecSaveProject'),
    (Value: ecSaveProjectAs;                          Name: 'ecSaveProjectAs'),
    (Value: ecPublishProject;                         Name: 'ecPublishProject'),
    (Value: ecProjectInspector;                       Name: 'ecProjectInspector'),
    (Value: ecAddCurUnitToProj;                       Name: 'ecAddCurUnitToProj'),
    (Value: ecRemoveFromProj;                         Name: 'ecRemoveFromProj'),
    (Value: ecViewProjectUnits;                       Name: 'ecViewProjectUnits'),
    (Value: ecViewProjectForms;                       Name: 'ecViewProjectForms'),
    (Value: ecViewProjectSource;                      Name: 'ecViewProjectSource'),
    (Value: ecProjectOptions;                         Name: 'ecProjectOptions'),
    (Value: ecProjectChangeBuildMode;                 Name: 'ecProjectChangeBuildMode'),
    (Value: ecProjectResaveFormsWithI18n;             Name: 'ecProjectResaveFormsWithI18n'),

  // package menu
    (Value: ecOpenPackage;                            Name: 'ecOpenPackage'),
    (Value: ecOpenPackageFile;                        Name: 'ecOpenPackageFile'),
    (Value: ecOpenPackageOfCurUnit;                   Name: 'ecOpenPackageOfCurUnit'),
    (Value: ecAddCurFileToPkg;                        Name: 'ecAddCurFileToPkg'),
    (Value: ecNewPkgComponent;                        Name: 'ecNewPkgComponent'),
    //(Value: ecAddCurUnitToPkg;                        Name: 'ecAddCurUnitToPkg'),
    (Value: ecPackageGraph;                           Name: 'ecPackageGraph'),
    (Value: ecEditInstallPkgs;                        Name: 'ecEditInstallPkgs'),
    (Value: ecConfigCustomComps;                      Name: 'ecConfigCustomComps'),
    (Value: ecNewPackage;                             Name: 'ecNewPackage'),

  // custom tools menu
    (Value: ecExtToolFirst;                           Name: 'ecExtToolFirst'),
    (Value: ecExtToolLast;                            Name: 'ecExtToolLast'),

  // tools menu
    (Value: ecEnvironmentOptions;                     Name: 'ecEnvironmentOptions'),
    (Value: ecManageDesktops;                         Name: 'ecManageDesktops'),
    (Value: ecRescanFPCSrcDir;                        Name: 'ecRescanFPCSrcDir'),
    (Value: ecEditCodeTemplates;                      Name: 'ecEditCodeTemplates'),
    (Value: ecCodeToolsDefinesEd;                     Name: 'ecCodeToolsDefinesEd'),

    (Value: ecExtToolSettings;                        Name: 'ecExtToolSettings'),
    (Value: ecConfigBuildLazarus;                     Name: 'ecConfigBuildLazarus'),
    (Value: ecBuildLazarus;                           Name: 'ecBuildLazarus'),
    (Value: ecBuildAdvancedLazarus;                   Name: 'ecBuildAdvancedLazarus'),

  // window menu
    (Value: ecManageSourceEditors;                          Name: 'ecWindowManager'),

  // help menu
    (Value: ecAboutLazarus;                           Name: 'ecAboutLazarus'),
    (Value: ecOnlineHelp;                             Name: 'ecOnlineHelp'),
    (Value: ecContextHelp;                            Name: 'ecContextHelp'),
    (Value: ecEditContextHelp;                        Name: 'ecEditContextHelp'),
    (Value: ecReportingBug;                           Name: 'ecReportingBug'),
    (Value: ecFocusHint;                              Name: 'ecFocusHint'),
    (Value: ecSmartHint;                              Name: 'ecSmartHint'),

  // designer
    (Value: ecDesignerCopy;                           Name: 'ecDesignerCopy'),
    (Value: ecDesignerCut;                            Name: 'ecDesignerCut'),
    (Value: ecDesignerPaste;                          Name: 'ecDesignerPaste'),
    (Value: ecDesignerSelectParent;                   Name: 'ecDesignerSelectParent'),
    (Value: ecDesignerMoveToFront;                    Name: 'ecDesignerMoveToFront'),
    (Value: ecDesignerMoveToBack;                     Name: 'ecDesignerMoveToBack'),
    (Value: ecDesignerForwardOne;                     Name: 'ecDesignerForwardOne'),
    (Value: ecDesignerBackOne;                        Name: 'ecDesignerBackOne'),
    (Value: ecDesignerToggleNonVisComps;              Name: 'ecDesignerToggleNonVisComps'),

  // TSynPluginTemplateEdit - In cell
    (Value: ecIdePTmplEdNextCell;                     Name: 'ecIdePTmplEdNextCell'),
    (Value: ecIdePTmplEdNextCellSel;                  Name: 'ecIdePTmplEdNextCellSel'),
    (Value: ecIdePTmplEdNextCellRotate;               Name: 'ecIdePTmplEdNextCellRotate'),
    (Value: ecIdePTmplEdNextCellSelRotate;            Name: 'ecIdePTmplEdNextCellSelRotate'),
    (Value: ecIdePTmplEdPrevCell;                     Name: 'ecIdePTmplEdPrevCell'),
    (Value: ecIdePTmplEdPrevCellSel;                  Name: 'ecIdePTmplEdPrevCellSel'),
    (Value: ecIdePTmplEdCellHome;                     Name: 'ecIdePTmplEdCellHome'),
    (Value: ecIdePTmplEdCellEnd;                      Name: 'ecIdePTmplEdCellEnd'),
    (Value: ecIdePTmplEdCellSelect;                   Name: 'ecIdePTmplEdCellSelect'),
    (Value: ecIdePTmplEdFinish;                       Name: 'ecIdePTmplEdFinish'),
    (Value: ecIdePTmplEdEscape;                       Name: 'ecIdePTmplEdEscape'),
    (Value: ecIdePTmplEdNextFirstCell;                Name: 'ecIdePTmplEdNextFirstCell'),
    (Value: ecIdePTmplEdNextFirstCellSel;             Name: 'ecIdePTmplEdNextFirstCellSel'),
    (Value: ecIdePTmplEdNextFirstCellRotate;          Name: 'ecIdePTmplEdNextFirstCellRotate'),
    (Value: ecIdePTmplEdNextFirstCellSelRotate;       Name: 'ecIdePTmplEdNextFirstCellSelRotate'),
    (Value: ecIdePTmplEdPrevFirstCell;                Name: 'ecIdePTmplEdPrevFirstCell'),
    (Value: ecIdePTmplEdPrevFirstCellSel;             Name: 'ecIdePTmplEdPrevFirstCellSel'),

  // TSynPluginTemplateEdit - Out off Cell
    (Value: ecIdePTmplEdOutNextCell;                  Name: 'ecIdePTmplEdOutNextCell'),
    (Value: ecIdePTmplEdOutNextCellSel;               Name: 'ecIdePTmplEdOutNextCellSel'),
    (Value: ecIdePTmplEdOutNextCellRotate;            Name: 'ecIdePTmplEdOutNextCellRotate'),
    (Value: ecIdePTmplEdOutNextCellSelRotate;         Name: 'ecIdePTmplEdOutNextCellSelRotate'),
    (Value: ecIdePTmplEdOutPrevCell;                  Name: 'ecIdePTmplEdOutPrevCell'),
    (Value: ecIdePTmplEdOutPrevCellSel;               Name: 'ecIdePTmplEdOutPrevCellSel'),
    (Value: ecIdePTmplEdOutCellHome;                  Name: 'ecIdePTmplEdOutCellHome'),
    (Value: ecIdePTmplEdOutCellEnd;                   Name: 'ecIdePTmplEdOutCellEnd'),
    (Value: ecIdePTmplEdOutCellSelect;                Name: 'ecIdePTmplEdOutCellSelect'),
    (Value: ecIdePTmplEdOutFinish;                    Name: 'ecIdePTmplEdOutFinish'),
    (Value: ecIdePTmplEdOutEscape;                    Name: 'ecIdePTmplEdOutEscape'),
    (Value: ecIdePTmplEdOutNextFirstCell;             Name: 'ecIdePTmplEdOutNextFirstCell'),
    (Value: ecIdePTmplEdOutNextFirstCellSel;          Name: 'ecIdePTmplEdOutNextFirstCellSel'),
    (Value: ecIdePTmplEdOutNextFirstCellRotate;       Name: 'ecIdePTmplEdOutNextFirstCellRotate'),
    (Value: ecIdePTmplEdOutNextFirstCellSelRotate;    Name: 'ecIdePTmplEdOutNextFirstCellSelRotate'),
    (Value: ecIdePTmplEdOutPrevFirstCell;             Name: 'ecIdePTmplEdOutPrevFirstCell'),
    (Value: ecIdePTmplEdOutPrevFirstCellSel;          Name: 'ecIdePTmplEdOutPrevFirstCellSel'),

  // TSynPluginSyncroEdit - in celll
    (Value: ecIdePSyncroEdNextCell;                   Name: 'ecIdePSyncroEdNextCell'),
    (Value: ecIdePSyncroEdNextCellSel;                Name: 'ecIdePSyncroEdNextCellSel'),
    (Value: ecIdePSyncroEdPrevCell;                   Name: 'ecIdePSyncroEdPrevCell'),
    (Value: ecIdePSyncroEdPrevCellSel;                Name: 'ecIdePSyncroEdPrevCellSel'),
    (Value: ecIdePSyncroEdCellHome;                   Name: 'ecIdePSyncroEdCellHome'),
    (Value: ecIdePSyncroEdCellEnd;                    Name: 'ecIdePSyncroEdCellEnd'),
    (Value: ecIdePSyncroEdCellSelect;                 Name: 'ecIdePSyncroEdCellSelect'),
    (Value: ecIdePSyncroEdEscape;                     Name: 'ecIdePSyncroEdEscape'),
    (Value: ecIdePSyncroEdNextFirstCell;              Name: 'ecIdePSyncroEdNextFirstCell'),
    (Value: ecIdePSyncroEdNextFirstCellSel;           Name: 'ecIdePSyncroEdNextFirstCellSel'),
    (Value: ecIdePSyncroEdPrevFirstCell;              Name: 'ecIdePSyncroEdPrevFirstCell'),
    (Value: ecIdePSyncroEdPrevFirstCellSel;           Name: 'ecIdePSyncroEdPrevFirstCellSel'),
    (Value: ecIdePSyncroEdGrowCellLeft;               Name: 'ecIdePSyncroEdGrowCellLeft'),
    (Value: ecIdePSyncroEdShrinkCellLeft;             Name: 'ecIdePSyncroEdShrinkCellLeft'),
    (Value: ecIdePSyncroEdGrowCellRight;              Name: 'ecIdePSyncroEdGrowCellRight'),
    (Value: ecIdePSyncroEdShrinkCellRight;            Name: 'ecIdePSyncroEdShrinkCellRight'),
    (Value: ecIdePSyncroEdAddCell;                    Name: 'ecIdePSyncroEdAddCell'),
    (Value: ecIdePSyncroEdAddCellCtx;                 Name: 'ecIdePSyncroEdAddCellCtx'),
    (Value: ecIdePSyncroEdDelCell;                    Name: 'ecIdePSyncroEdDelCell'),

  // TSynPluginSyncroEdit - Out off cell
    (Value: ecIdePSyncroEdOutNextCell;                Name: 'ecIdePSyncroEdOutNextCell'),
    (Value: ecIdePSyncroEdOutNextCellSel;             Name: 'ecIdePSyncroEdOutNextCellSel'),
    (Value: ecIdePSyncroEdOutPrevCell;                Name: 'ecIdePSyncroEdOutPrevCell'),
    (Value: ecIdePSyncroEdOutPrevCellSel;             Name: 'ecIdePSyncroEdOutPrevCellSel'),
    (Value: ecIdePSyncroEdOutCellHome;                Name: 'ecIdePSyncroEdOutCellHome'),
    (Value: ecIdePSyncroEdOutCellEnd;                 Name: 'ecIdePSyncroEdOutCellEnd'),
    (Value: ecIdePSyncroEdOutCellSelect;              Name: 'ecIdePSyncroEdOutCellSelect'),
    (Value: ecIdePSyncroEdOutEscape;                  Name: 'ecIdePSyncroEdOutEscape'),
    (Value: ecIdePSyncroEdOutNextFirstCell;           Name: 'ecIdePSyncroEdOutNextFirstCell'),
    (Value: ecIdePSyncroEdOutNextFirstCellSel;        Name: 'ecIdePSyncroEdOutNextFirstCellSel'),
    (Value: ecIdePSyncroEdOutPrevFirstCell;           Name: 'ecIdePSyncroEdOutPrevFirstCell'),
    (Value: ecIdePSyncroEdOutPrevFirstCellSel;        Name: 'ecIdePSyncroEdOutPrevFirstCellSel'),
//    (Value: ecIdePSyncroEdGrowCellLeft;               Name: 'ecIdePSyncroEdGrowCellLeft'),
//    (Value: ecIdePSyncroEdShrinkCellLeft;             Name: 'ecIdePSyncroEdShrinkCellLeft'),
//    (Value: ecIdePSyncroEdGrowCellRight;              Name: 'ecIdePSyncroEdGrowCellRight'),
//    (Value: ecIdePSyncroEdShrinkCellRight;            Name: 'ecIdePSyncroEdShrinkCellRight'),
    (Value: ecIdePSyncroEdOutAddCell;                    Name: 'ecIdePSyncroEdOutAddCell'),
    (Value: ecIdePSyncroEdOutAddCellCase;                Name: 'ecIdePSyncroEdOutAddCellCase'),
    (Value: ecIdePSyncroEdOutAddCellCtx;                 Name: 'ecIdePSyncroEdOutAddCellCtx'),
    (Value: ecIdePSyncroEdOutAddCellCtxCase;             Name: 'ecIdePSyncroEdOutAddCellCtxCase'),

  // TSynPluginSyncroEdit - selecting
    (Value: ecIdePSyncroEdSelStart;        Name: 'ecIdePSyncroEdSelStart'),
    (Value: ecIdePSyncroEdSelStartCase;    Name: 'ecIdePSyncroEdSelStartCase'),
    (Value: ecIdePSyncroEdSelStartCtx;     Name: 'ecIdePSyncroEdSelStartCtx'),
    (Value: ecIdePSyncroEdSelStartCtxCase; Name: 'ecIdePSyncroEdSelStartCtxCase')
  );

function IdentToIDECommand(const Ident: string; var Cmd: longint): boolean;
begin
  Result := IdentToInt(Ident, Cmd, IDEEditorCommandStrs);
end;

function IDECommandToIdent(Cmd: longint; var Ident: string): boolean;
begin
  Result := IntToIdent(Cmd, Ident, IDEEditorCommandStrs);
end;

function IDECommandToIdent(Cmd: longint): string;
begin
  Result := '';
  if not IDECommandToIdent(Cmd, Result) then
    raise Exception.CreateFmt('IDECommandToIdent: command %d not found', [Cmd]);
end;

procedure GetIDEEditorCommandValues(Proc: TGetStrProc);
var
  i: integer;
begin
  for i := Low(IDEEditorCommandStrs) to High(IDEEditorCommandStrs) do
    Proc(IDEEditorCommandStrs[I].Name);
end;

var
  TheEmcIdeMouseCommandOffset: Integer;
  IDEEditorMouseCommandStrs: array[0..emcIdeMouseCommandsCount-1] of TIdentMapEntry = (
    // Initialize with Value = 0 .. emcIdeMouseCommandsCount
    (Value: emcOffsetToggleBreakPoint;                   Name: 'emcToggleBreakPoint'),
    (Value: emcOffsetToggleBreakPointEnabled;            Name: 'emcToggleBreakPointEnabled'),
    (Value: emcOffsetBreakPointProperties;               Name: 'emcBreakPointProperties')
  );

procedure SetIdeMouseCommandOffset(AStartNum: Integer);
begin
  TheEmcIdeMouseCommandOffset := AStartNum;
  emcToggleBreakPoint        := AStartNum + emcOffsetToggleBreakPoint;  // update last
  emcToggleBreakPointEnabled := AStartNum + emcOffsetToggleBreakPointEnabled;
  emcBreakPointProperties    := AStartNum + emcOffsetBreakPointProperties;
end;

function GetIdeMouseCommandOffset: Integer;
begin
  Result := TheEmcIdeMouseCommandOffset;
end;

function IdentToIDEMouseCommand(const Ident: string; var Cmd: longint): boolean;
begin
  Result := IdentToInt(Ident, Cmd, IDEEditorMouseCommandStrs);
  Cmd := Cmd + emcIdeMouseCommandOffset;
end;

function IDEMouseCommandToIdent(Cmd: longint; var Ident: string): boolean;
begin
  Result := IntToIdent(Cmd - emcIdeMouseCommandOffset, Ident, IDEEditorMouseCommandStrs);
end;

procedure GetIdeMouseCommandValues(Proc: TGetStrProc);
var
  i: Integer;
begin
  for i := Low(IDEEditorMouseCommandStrs) to High(IDEEditorMouseCommandStrs) do
    Proc(IDEEditorMouseCommandStrs[I].Name);
end;

end.