[r735]: trunk / PowerEditor / src / NppCommands.cpp Maximize Restore History

Download this file

NppCommands.cpp    2221 lines (1933 with data), 66.1 kB

   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
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "precompiledHeaders.h"
#include "Notepad_plus_Window.h"
#include "EncodingMapper.h"
#include "ShortcutMapper.h"
#include "TaskListDlg.h"
void Notepad_plus::macroPlayback(Macro macro)
{
_pEditView->execute(SCI_BEGINUNDOACTION);
for (Macro::iterator step = macro.begin(); step != macro.end(); step++)
{
if (step->isPlayable())
step->PlayBack(this->_pPublicInterface, _pEditView);
else
_findReplaceDlg.execSavedCommand(step->message, step->lParameter, step->sParameter);
}
_pEditView->execute(SCI_ENDUNDOACTION);
}
void Notepad_plus::command(int id)
{
switch (id)
{
case IDM_FILE_NEW:
fileNew();
break;
case IDM_FILE_OPEN:
fileOpen();
break;
case IDM_FILE_RELOAD:
fileReload();
break;
case IDM_FILE_CLOSE:
if (fileClose())
checkDocState();
break;
case IDM_FILE_DELETE:
if (fileDelete())
checkDocState();
break;
case IDM_FILE_RENAME:
fileRename();
break;
case IDM_FILE_CLOSEALL:
fileCloseAll();
checkDocState();
break;
case IDM_FILE_CLOSEALL_BUT_CURRENT :
fileCloseAllButCurrent();
checkDocState();
break;
case IDM_FILE_SAVE :
fileSave();
break;
case IDM_FILE_SAVEALL :
fileSaveAll();
break;
case IDM_FILE_SAVEAS :
fileSaveAs();
break;
case IDM_FILE_SAVECOPYAS :
fileSaveAs(BUFFER_INVALID, true);
break;
case IDM_FILE_LOADSESSION:
fileLoadSession();
break;
case IDM_FILE_SAVESESSION:
fileSaveSession();
break;
case IDM_FILE_PRINTNOW :
filePrint(false);
break;
case IDM_FILE_PRINT :
filePrint(true);
break;
case IDM_FILE_EXIT:
::SendMessage(_pPublicInterface->getHSelf(), WM_CLOSE, 0, 0);
break;
case IDM_EDIT_UNDO:
_pEditView->execute(WM_UNDO);
checkClipboard();
checkUndoState();
break;
case IDM_EDIT_REDO:
_pEditView->execute(SCI_REDO);
checkClipboard();
checkUndoState();
break;
case IDM_EDIT_CUT:
_pEditView->execute(WM_CUT);
checkClipboard();
break;
case IDM_EDIT_COPY:
_pEditView->execute(WM_COPY);
checkClipboard();
break;
case IDM_EDIT_PASTE:
{
int eolMode = int(_pEditView->execute(SCI_GETEOLMODE));
_pEditView->execute(SCI_PASTE);
_pEditView->execute(SCI_CONVERTEOLS, eolMode);
}
break;
case IDM_EDIT_DELETE:
_pEditView->execute(WM_CLEAR);
break;
case IDM_MACRO_STARTRECORDINGMACRO:
case IDM_MACRO_STOPRECORDINGMACRO:
case IDC_EDIT_TOGGLEMACRORECORDING:
{
if (_recordingMacro)
{
// STOP !!!
_mainEditView.execute(SCI_STOPRECORD);
_subEditView.execute(SCI_STOPRECORD);
_mainEditView.execute(SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL);
_subEditView.execute(SCI_SETCURSOR, (WPARAM)SC_CURSORNORMAL);
_recordingMacro = false;
_runMacroDlg.initMacroList();
}
else
{
_mainEditView.execute(SCI_SETCURSOR, 9);
_subEditView.execute(SCI_SETCURSOR, 9);
_macro.clear();
// START !!!
_mainEditView.execute(SCI_STARTRECORD);
_subEditView.execute(SCI_STARTRECORD);
_recordingMacro = true;
}
checkMacroState();
break;
}
case IDM_MACRO_PLAYBACKRECORDEDMACRO:
if (!_recordingMacro) // if we're not currently recording, then playback the recorded keystrokes
macroPlayback(_macro);
break;
case IDM_MACRO_RUNMULTIMACRODLG :
{
if (!_recordingMacro) // if we're not currently recording, then playback the recorded keystrokes
{
bool isFirstTime = !_runMacroDlg.isCreated();
_runMacroDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
{
_nativeLangSpeaker.changeDlgLang(_runMacroDlg.getHSelf(), "MultiMacro");
}
break;
}
}
break;
case IDM_MACRO_SAVECURRENTMACRO :
{
if (addCurrentMacro())
_runMacroDlg.initMacroList();
break;
}
case IDM_EDIT_FULLPATHTOCLIP :
case IDM_EDIT_CURRENTDIRTOCLIP :
case IDM_EDIT_FILENAMETOCLIP :
{
Buffer * buf = _pEditView->getCurrentBuffer();
if (id == IDM_EDIT_FULLPATHTOCLIP)
{
str2Cliboard(buf->getFullPathName());
}
else if (id == IDM_EDIT_CURRENTDIRTOCLIP)
{
generic_string dir(buf->getFullPathName());
PathRemoveFileSpec(dir);
str2Cliboard(dir.c_str());
}
else if (id == IDM_EDIT_FILENAMETOCLIP)
{
str2Cliboard(buf->getFileName());
}
}
break;
case IDM_SEARCH_FIND :
case IDM_SEARCH_REPLACE :
{
const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize];
bool isFirstTime = !_findReplaceDlg.isCreated();
_findReplaceDlg.doDialog((id == IDM_SEARCH_FIND)?FIND_DLG:REPLACE_DLG, _nativeLangSpeaker.isRTL());
_pEditView->getGenericSelectedText(str, strSize);
_findReplaceDlg.setSearchText(str);
setFindReplaceFolderFilter(NULL, NULL);
if (isFirstTime)
_nativeLangSpeaker.changeFindReplaceDlgLang(_findReplaceDlg);
break;
}
case IDM_SEARCH_FINDINFILES :
{
::SendMessage(_pPublicInterface->getHSelf(), NPPM_LAUNCHFINDINFILESDLG, 0, 0);
break;
}
case IDM_SEARCH_FINDINCREMENT :
{
const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize];
_pEditView->getGenericSelectedText(str, strSize, false);
if (0!=str[0]) // the selected text is not empty, then use it
_incrementFindDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
_incrementFindDlg.display();
}
break;
case IDM_SEARCH_FINDNEXT :
case IDM_SEARCH_FINDPREV :
{
if (!_findReplaceDlg.isCreated())
return;
FindOption op = _findReplaceDlg.getCurrentOptions();
op._whichDirection = (id == IDM_SEARCH_FINDNEXT?DIR_DOWN:DIR_UP);
generic_string s = _findReplaceDlg.getText2search();
_findReplaceDlg.processFindNext(s.c_str(), &op);
break;
}
break;
case IDM_SEARCH_SETANDFINDNEXT :
case IDM_SEARCH_SETANDFINDPREV :
{
bool isFirstTime = !_findReplaceDlg.isCreated();
if (isFirstTime)
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL(), false);
const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR str[strSize];
_pEditView->getGenericSelectedText(str, strSize);
_findReplaceDlg.setSearchText(str);
_findReplaceDlg._env->_str2Search = str;
setFindReplaceFolderFilter(NULL, NULL);
if (isFirstTime)
_nativeLangSpeaker.changeFindReplaceDlgLang(_findReplaceDlg);
FindOption op = _findReplaceDlg.getCurrentOptions();
op._whichDirection = (id == IDM_SEARCH_SETANDFINDNEXT?DIR_DOWN:DIR_UP);
_findReplaceDlg.processFindNext(str, &op);
break;
}
case IDM_SEARCH_GOTONEXTFOUND:
{
_findReplaceDlg.gotoNextFoundResult();
break;
}
case IDM_SEARCH_GOTOPREVFOUND:
{
_findReplaceDlg.gotoNextFoundResult(-1);
break;
}
case IDM_FOCUS_ON_FOUND_RESULTS:
{
if (GetFocus() == _findReplaceDlg.getHFindResults())
// focus already on found results, switch to current edit view
switchEditViewTo(currentView());
else
_findReplaceDlg.focusOnFinder();
break;
}
case IDM_SEARCH_VOLATILE_FINDNEXT :
case IDM_SEARCH_VOLATILE_FINDPREV :
{
TCHAR text2Find[MAX_PATH];
_pEditView->getGenericSelectedText(text2Find, MAX_PATH);
FindOption op;
op._isWholeWord = false;
op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT?DIR_DOWN:DIR_UP);
_findReplaceDlg.processFindNext(text2Find, &op);
break;
}
case IDM_SEARCH_MARKALLEXT1 :
case IDM_SEARCH_MARKALLEXT2 :
case IDM_SEARCH_MARKALLEXT3 :
case IDM_SEARCH_MARKALLEXT4 :
case IDM_SEARCH_MARKALLEXT5 :
{
int styleID;
if (id == IDM_SEARCH_MARKALLEXT1)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT1;
else if (id == IDM_SEARCH_MARKALLEXT2)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT2;
else if (id == IDM_SEARCH_MARKALLEXT3)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT3;
else if (id == IDM_SEARCH_MARKALLEXT4)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT4;
else // (id == IDM_SEARCH_MARKALLEXT5)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
const int strSize = FINDREPLACE_MAXLENGTH;
TCHAR text2Find[strSize];
_pEditView->getGenericSelectedText(text2Find, strSize, false);
if (text2Find[0] == '\0')
{
_pEditView->getGenericWordOnCaretPos(text2Find, strSize);
}
_findReplaceDlg.markAll(text2Find, styleID);
break;
}
case IDM_SEARCH_UNMARKALLEXT1 :
case IDM_SEARCH_UNMARKALLEXT2 :
case IDM_SEARCH_UNMARKALLEXT3 :
case IDM_SEARCH_UNMARKALLEXT4 :
case IDM_SEARCH_UNMARKALLEXT5 :
{
int styleID;
if (id == IDM_SEARCH_UNMARKALLEXT1)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT1;
else if (id == IDM_SEARCH_UNMARKALLEXT2)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT2;
else if (id == IDM_SEARCH_UNMARKALLEXT3)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT3;
else if (id == IDM_SEARCH_UNMARKALLEXT4)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT4;
else // (id == IDM_SEARCH_UNMARKALLEXT5)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
_pEditView->clearIndicator(styleID);
break;
}
case IDM_SEARCH_GONEXTMARKER1 :
case IDM_SEARCH_GONEXTMARKER2 :
case IDM_SEARCH_GONEXTMARKER3 :
case IDM_SEARCH_GONEXTMARKER4 :
case IDM_SEARCH_GONEXTMARKER5 :
case IDM_SEARCH_GONEXTMARKER_DEF :
{
int styleID;
if (id == IDM_SEARCH_GONEXTMARKER1)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT1;
else if (id == IDM_SEARCH_GONEXTMARKER2)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT2;
else if (id == IDM_SEARCH_GONEXTMARKER3)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT3;
else if (id == IDM_SEARCH_GONEXTMARKER4)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT4;
else if (id == IDM_SEARCH_GONEXTMARKER5)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
else // (id == IDM_SEARCH_GONEXTMARKER_DEF)
styleID = SCE_UNIVERSAL_FOUND_STYLE;
goToNextIndicator(styleID);
break;
}
case IDM_SEARCH_GOPREVMARKER1 :
case IDM_SEARCH_GOPREVMARKER2 :
case IDM_SEARCH_GOPREVMARKER3 :
case IDM_SEARCH_GOPREVMARKER4 :
case IDM_SEARCH_GOPREVMARKER5 :
case IDM_SEARCH_GOPREVMARKER_DEF :
{
int styleID;
if (id == IDM_SEARCH_GOPREVMARKER1)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT1;
else if (id == IDM_SEARCH_GOPREVMARKER2)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT2;
else if (id == IDM_SEARCH_GOPREVMARKER3)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT3;
else if (id == IDM_SEARCH_GOPREVMARKER4)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT4;
else if (id == IDM_SEARCH_GOPREVMARKER5)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
else // (id == IDM_SEARCH_GOPREVMARKER_DEF)
styleID = SCE_UNIVERSAL_FOUND_STYLE;
goToPreviousIndicator(styleID);
break;
}
case IDM_SEARCH_CLEARALLMARKS :
{
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_EXT1);
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_EXT2);
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_EXT3);
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_EXT4);
_pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_EXT5);
break;
}
case IDM_SEARCH_GOTOLINE :
{
bool isFirstTime = !_goToLineDlg.isCreated();
_goToLineDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
_nativeLangSpeaker.changeDlgLang(_goToLineDlg.getHSelf(), "GoToLine");
break;
}
case IDM_EDIT_COLUMNMODE :
{
bool isFirstTime = !_colEditorDlg.isCreated();
_colEditorDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
_nativeLangSpeaker.changeDlgLang(_colEditorDlg.getHSelf(), "ColumnEditor");
break;
}
case IDM_SEARCH_GOTOMATCHINGBRACE :
{
int braceAtCaret = -1;
int braceOpposite = -1;
findMatchingBracePos(braceAtCaret, braceOpposite);
if (braceOpposite != -1)
_pEditView->execute(SCI_GOTOPOS, braceOpposite);
break;
}
case IDM_SEARCH_TOGGLE_BOOKMARK :
bookmarkToggle(-1);
break;
case IDM_SEARCH_NEXT_BOOKMARK:
bookmarkNext(true);
break;
case IDM_SEARCH_PREV_BOOKMARK:
bookmarkNext(false);
break;
case IDM_SEARCH_CLEAR_BOOKMARKS:
bookmarkClearAll();
break;
case IDM_VIEW_USER_DLG :
{
bool isUDDlgVisible = false;
UserDefineDialog *udd = _pEditView->getUserDefineDlg();
if (!udd->isCreated())
{
_pEditView->doUserDefineDlg(true, _nativeLangSpeaker.isRTL());
_nativeLangSpeaker.changeUserDefineLang(udd);
if (_isUDDocked)
::SendMessage(udd->getHSelf(), WM_COMMAND, IDC_DOCK_BUTTON, 0);
}
else
{
isUDDlgVisible = udd->isVisible();
bool isUDDlgDocked = udd->isDocked();
if ((isUDDlgDocked)&&(isUDDlgVisible))
{
::ShowWindow(_pMainSplitter->getHSelf(), SW_HIDE);
if (bothActive())
_pMainWindow = &_subSplitter;
else
_pMainWindow = _pDocTab;
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
udd->display(false);
_mainWindowStatus &= ~WindowUserActive;
}
else if ((isUDDlgDocked)&&(!isUDDlgVisible))
{
if (!_pMainSplitter)
{
_pMainSplitter = new SplitterContainer;
_pMainSplitter->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf());
Window *pWindow;
if (bothActive())
pWindow = &_subSplitter;
else
pWindow = _pDocTab;
_pMainSplitter->create(pWindow, ScintillaEditView::getUserDefineDlg(), 8, RIGHT_FIX, 45);
}
_pMainWindow = _pMainSplitter;
_pMainSplitter->setWin0((bothActive())?(Window *)&_subSplitter:(Window *)_pDocTab);
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
_pMainWindow->display();
_mainWindowStatus |= WindowUserActive;
}
else if ((!isUDDlgDocked)&&(isUDDlgVisible))
{
udd->display(false);
}
else //((!isUDDlgDocked)&&(!isUDDlgVisible))
udd->display();
}
checkMenuItem(IDM_VIEW_USER_DLG, !isUDDlgVisible);
_toolBar.setCheck(IDM_VIEW_USER_DLG, !isUDDlgVisible);
break;
}
case IDM_EDIT_SELECTALL:
_pEditView->execute(SCI_SELECTALL);
checkClipboard();
break;
case IDM_EDIT_INS_TAB:
_pEditView->execute(SCI_TAB);
break;
case IDM_EDIT_RMV_TAB:
_pEditView->execute(SCI_BACKTAB);
break;
case IDM_EDIT_DUP_LINE:
_pEditView->execute(SCI_LINEDUPLICATE);
break;
case IDM_EDIT_SPLIT_LINES:
_pEditView->execute(SCI_TARGETFROMSELECTION);
_pEditView->execute(SCI_LINESSPLIT);
break;
case IDM_EDIT_JOIN_LINES:
_pEditView->execute(SCI_TARGETFROMSELECTION);
_pEditView->execute(SCI_LINESJOIN);
break;
case IDM_EDIT_LINE_UP:
_pEditView->currentLinesUp();
break;
case IDM_EDIT_LINE_DOWN:
_pEditView->currentLinesDown();
break;
case IDM_EDIT_UPPERCASE:
_pEditView->convertSelectedTextToUpperCase();
break;
case IDM_EDIT_LOWERCASE:
_pEditView->convertSelectedTextToLowerCase();
break;
case IDM_EDIT_BLOCK_COMMENT:
doBlockComment(cm_toggle);
break;
case IDM_EDIT_BLOCK_COMMENT_SET:
doBlockComment(cm_comment);
break;
case IDM_EDIT_BLOCK_UNCOMMENT:
doBlockComment(cm_uncomment);
break;
case IDM_EDIT_STREAM_COMMENT:
doStreamComment();
break;
case IDM_EDIT_TRIMTRAILING:
_pEditView->execute(SCI_BEGINUNDOACTION);
doTrim(lineTail);
_pEditView->execute(SCI_ENDUNDOACTION);
break;
case IDM_EDIT_TRIMLINEHEAD:
_pEditView->execute(SCI_BEGINUNDOACTION);
doTrim(lineHeader);
_pEditView->execute(SCI_ENDUNDOACTION);
break;
case IDM_EDIT_TRIM_BOTH:
_pEditView->execute(SCI_BEGINUNDOACTION);
doTrim(lineTail);
doTrim(lineHeader);
_pEditView->execute(SCI_ENDUNDOACTION);
break;
case IDM_EDIT_EOL2WS:
_pEditView->execute(SCI_BEGINUNDOACTION);
_pEditView->execute(SCI_SETTARGETSTART, 0);
_pEditView->execute(SCI_SETTARGETEND, _pEditView->getCurrentDocLen());
_pEditView->execute(SCI_LINESJOIN);
_pEditView->execute(SCI_ENDUNDOACTION);
break;
case IDM_EDIT_TRIMALL:
_pEditView->execute(SCI_BEGINUNDOACTION);
doTrim(lineTail);
doTrim(lineHeader);
_pEditView->execute(SCI_SETTARGETSTART, 0);
_pEditView->execute(SCI_SETTARGETEND, _pEditView->getCurrentDocLen());
_pEditView->execute(SCI_LINESJOIN);
_pEditView->execute(SCI_ENDUNDOACTION);
break;
case IDM_EDIT_TAB2SW:
wsTabConvert(true);
break;
case IDM_EDIT_SW2TAB:
wsTabConvert(false);
break;
case IDM_EDIT_SETREADONLY:
{
Buffer * buf = _pEditView->getCurrentBuffer();
buf->setUserReadOnly(!buf->getUserReadOnly());
}
break;
case IDM_EDIT_CLEARREADONLY:
{
Buffer * buf = _pEditView->getCurrentBuffer();
DWORD dwFileAttribs = ::GetFileAttributes(buf->getFullPathName());
dwFileAttribs ^= FILE_ATTRIBUTE_READONLY;
::SetFileAttributes(buf->getFullPathName(), dwFileAttribs);
buf->setFileReadOnly(false);
}
break;
case IDM_SEARCH_CUTMARKEDLINES :
cutMarkedLines();
break;
case IDM_SEARCH_COPYMARKEDLINES :
copyMarkedLines();
break;
case IDM_SEARCH_PASTEMARKEDLINES :
pasteToMarkedLines();
break;
case IDM_SEARCH_DELETEMARKEDLINES :
deleteMarkedLines();
break;
case IDM_SEARCH_INVERSEMARKS :
inverseMarks();
break;
case IDM_VIEW_FULLSCREENTOGGLE :
fullScreenToggle();
break;
case IDM_VIEW_ALWAYSONTOP:
{
int check = (::GetMenuState(_mainMenuHandle, id, MF_BYCOMMAND) == MF_CHECKED)?MF_UNCHECKED:MF_CHECKED;
::CheckMenuItem(_mainMenuHandle, id, MF_BYCOMMAND | check);
SetWindowPos(_pPublicInterface->getHSelf(), check == MF_CHECKED?HWND_TOPMOST:HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
}
break;
case IDM_VIEW_FOLD_CURRENT :
case IDM_VIEW_UNFOLD_CURRENT :
_pEditView->foldCurrentPos((id==IDM_VIEW_FOLD_CURRENT)?fold_collapse:fold_uncollapse);
break;
case IDM_VIEW_TOGGLE_FOLDALL:
case IDM_VIEW_TOGGLE_UNFOLDALL:
{
_pEditView->foldAll((id==IDM_VIEW_TOGGLE_FOLDALL)?fold_collapse:fold_uncollapse);
}
break;
case IDM_VIEW_FOLD_1:
case IDM_VIEW_FOLD_2:
case IDM_VIEW_FOLD_3:
case IDM_VIEW_FOLD_4:
case IDM_VIEW_FOLD_5:
case IDM_VIEW_FOLD_6:
case IDM_VIEW_FOLD_7:
case IDM_VIEW_FOLD_8:
_pEditView->collapse(id - IDM_VIEW_FOLD - 1, fold_collapse);
break;
case IDM_VIEW_UNFOLD_1:
case IDM_VIEW_UNFOLD_2:
case IDM_VIEW_UNFOLD_3:
case IDM_VIEW_UNFOLD_4:
case IDM_VIEW_UNFOLD_5:
case IDM_VIEW_UNFOLD_6:
case IDM_VIEW_UNFOLD_7:
case IDM_VIEW_UNFOLD_8:
_pEditView->collapse(id - IDM_VIEW_UNFOLD - 1, fold_uncollapse);
break;
case IDM_VIEW_TOOLBAR_REDUCE:
{
toolBarStatusType state = _toolBar.getState();
if (state != TB_SMALL)
{
_toolBar.reduce();
changeToolBarIcons();
}
}
break;
case IDM_VIEW_TOOLBAR_ENLARGE:
{
toolBarStatusType state = _toolBar.getState();
if (state != TB_LARGE)
{
_toolBar.enlarge();
changeToolBarIcons();
}
}
break;
case IDM_VIEW_TOOLBAR_STANDARD:
{
toolBarStatusType state = _toolBar.getState();
if (state != TB_STANDARD)
{
_toolBar.setToUglyIcons();
}
}
break;
case IDM_VIEW_REDUCETABBAR :
{
_toReduceTabBar = !_toReduceTabBar;
//Resize the icon
int iconSize = _toReduceTabBar?12:18;
//Resize the tab height
int tabHeight = _toReduceTabBar?20:25;
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabHeight);
_docTabIconList.setIconSize(iconSize);
//change the font
int stockedFont = _toReduceTabBar?DEFAULT_GUI_FONT:SYSTEM_FONT;
HFONT hf = (HFONT)::GetStockObject(stockedFont);
if (hf)
{
::SendMessage(_mainDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
::SendMessage(_subDocTab.getHSelf(), WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE, 0));
}
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break;
}
case IDM_VIEW_REFRESHTABAR :
{
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break;
}
case IDM_VIEW_LOCKTABBAR:
{
bool isDrag = TabBarPlus::doDragNDropOrNot();
TabBarPlus::doDragNDrop(!isDrag);
//checkMenuItem(IDM_VIEW_LOCKTABBAR, isDrag);
break;
}
case IDM_VIEW_DRAWTABBAR_INACIVETAB:
{
TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab());
//TabBarPlus::setDrawInactiveTab(!TabBarPlus::drawInactiveTab(), _subDocTab.getHSelf());
break;
}
case IDM_VIEW_DRAWTABBAR_TOPBAR:
{
TabBarPlus::setDrawTopBar(!TabBarPlus::drawTopBar());
break;
}
case IDM_VIEW_DRAWTABBAR_CLOSEBOTTUN :
{
TabBarPlus::setDrawTabCloseButton(!TabBarPlus::drawTabCloseButton());
// This part is just for updating (redraw) the tabs
{
int tabHeight = TabBarPlus::drawTabCloseButton()?21:20;
TabCtrl_SetItemSize(_mainDocTab.getHSelf(), 45, tabHeight);
TabCtrl_SetItemSize(_subDocTab.getHSelf(), 45, tabHeight);
}
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break;
}
case IDM_VIEW_DRAWTABBAR_DBCLK2CLOSE :
{
TabBarPlus::setDbClk2Close(!TabBarPlus::isDbClk2Close());
break;
}
case IDM_VIEW_DRAWTABBAR_VERTICAL :
{
TabBarPlus::setVertical(!TabBarPlus::isVertical());
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break;
}
case IDM_VIEW_DRAWTABBAR_MULTILINE :
{
TabBarPlus::setMultiLine(!TabBarPlus::isMultiLine());
::SendMessage(_pPublicInterface->getHSelf(), WM_SIZE, 0, 0);
break;
}
case IDM_VIEW_POSTIT :
{
postItToggle();
}
break;
case IDM_VIEW_TAB_SPACE:
{
bool isChecked = !(::GetMenuState(_mainMenuHandle, IDM_VIEW_TAB_SPACE, MF_BYCOMMAND) == MF_CHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_EOL, MF_BYCOMMAND | MF_UNCHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_ALL_CHARACTERS, MF_BYCOMMAND | MF_UNCHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_TAB_SPACE, MF_BYCOMMAND | (isChecked?MF_CHECKED:MF_UNCHECKED));
_toolBar.setCheck(IDM_VIEW_ALL_CHARACTERS, false);
_mainEditView.showEOL(false);
_mainEditView.showWSAndTab(isChecked);
_subEditView.showEOL(false);
_subEditView.showWSAndTab(isChecked);
ScintillaViewParams & svp1 = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP();
svp1._whiteSpaceShow = isChecked;
svp1._eolShow = false;
break;
}
case IDM_VIEW_EOL:
{
bool isChecked = !(::GetMenuState(_mainMenuHandle, IDM_VIEW_EOL, MF_BYCOMMAND) == MF_CHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_TAB_SPACE, MF_BYCOMMAND | MF_UNCHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_EOL, MF_BYCOMMAND | (isChecked?MF_CHECKED:MF_UNCHECKED));
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_ALL_CHARACTERS, MF_BYCOMMAND | MF_UNCHECKED);
_toolBar.setCheck(IDM_VIEW_ALL_CHARACTERS, false);
_mainEditView.showEOL(isChecked);
_subEditView.showEOL(isChecked);
_mainEditView.showWSAndTab(false);
_subEditView.showWSAndTab(false);
ScintillaViewParams & svp1 = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP();
svp1._whiteSpaceShow = false;
svp1._eolShow = isChecked;
break;
}
case IDM_VIEW_ALL_CHARACTERS:
{
bool isChecked = !(::GetMenuState(_mainMenuHandle, id, MF_BYCOMMAND) == MF_CHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_EOL, MF_BYCOMMAND | MF_UNCHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_TAB_SPACE, MF_BYCOMMAND | MF_UNCHECKED);
::CheckMenuItem(_mainMenuHandle, IDM_VIEW_ALL_CHARACTERS, MF_BYCOMMAND | (isChecked?MF_CHECKED:MF_UNCHECKED));
_mainEditView.showInvisibleChars(isChecked);
_subEditView.showInvisibleChars(isChecked);
_toolBar.setCheck(IDM_VIEW_ALL_CHARACTERS, isChecked);
ScintillaViewParams & svp1 = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP();
svp1._whiteSpaceShow = isChecked;
svp1._eolShow = isChecked;
break;
}
case IDM_VIEW_INDENT_GUIDE:
{
_mainEditView.showIndentGuideLine(!_pEditView->isShownIndentGuide());
_subEditView.showIndentGuideLine(!_pEditView->isShownIndentGuide());
_toolBar.setCheck(IDM_VIEW_INDENT_GUIDE, _pEditView->isShownIndentGuide());
checkMenuItem(IDM_VIEW_INDENT_GUIDE, _pEditView->isShownIndentGuide());
ScintillaViewParams & svp1 = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP();
svp1._indentGuideLineShow = _pEditView->isShownIndentGuide();
break;
}
case IDM_VIEW_WRAP:
{
bool isWraped = !_pEditView->isWrap();
_mainEditView.wrap(isWraped);
_subEditView.wrap(isWraped);
_toolBar.setCheck(IDM_VIEW_WRAP, isWraped);
checkMenuItem(IDM_VIEW_WRAP, isWraped);
ScintillaViewParams & svp1 = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP();
svp1._doWrap = isWraped;
break;
}
case IDM_VIEW_WRAP_SYMBOL:
{
_mainEditView.showWrapSymbol(!_pEditView->isWrapSymbolVisible());
_subEditView.showWrapSymbol(!_pEditView->isWrapSymbolVisible());
checkMenuItem(IDM_VIEW_WRAP_SYMBOL, _pEditView->isWrapSymbolVisible());
ScintillaViewParams & svp1 = (ScintillaViewParams &)(NppParameters::getInstance())->getSVP();
svp1._wrapSymbolShow = _pEditView->isWrapSymbolVisible();
break;
}
case IDM_VIEW_HIDELINES:
{
_pEditView->hideLines();
break;
}
case IDM_VIEW_ZOOMIN:
{
_pEditView->execute(SCI_ZOOMIN);
break;
}
case IDM_VIEW_ZOOMOUT:
_pEditView->execute(SCI_ZOOMOUT);
break;
case IDM_VIEW_ZOOMRESTORE:
//Zoom factor of 0 points means default view
_pEditView->execute(SCI_SETZOOM, 0);//_zoomOriginalValue);
break;
case IDM_VIEW_SYNSCROLLV:
{
bool isSynScollV = !_syncInfo._isSynScollV;
checkMenuItem(IDM_VIEW_SYNSCROLLV, isSynScollV);
_toolBar.setCheck(IDM_VIEW_SYNSCROLLV, isSynScollV);
_syncInfo._isSynScollV = isSynScollV;
if (_syncInfo._isSynScollV)
{
int mainCurrentLine = _mainEditView.execute(SCI_GETFIRSTVISIBLELINE);
int subCurrentLine = _subEditView.execute(SCI_GETFIRSTVISIBLELINE);
_syncInfo._line = mainCurrentLine - subCurrentLine;
}
}
break;
case IDM_VIEW_SYNSCROLLH:
{
bool isSynScollH = !_syncInfo._isSynScollH;
checkMenuItem(IDM_VIEW_SYNSCROLLH, isSynScollH);
_toolBar.setCheck(IDM_VIEW_SYNSCROLLH, isSynScollH);
_syncInfo._isSynScollH = isSynScollH;
if (_syncInfo._isSynScollH)
{
int mxoffset = _mainEditView.execute(SCI_GETXOFFSET);
int pixel = int(_mainEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
int mainColumn = mxoffset/pixel;
int sxoffset = _subEditView.execute(SCI_GETXOFFSET);
pixel = int(_subEditView.execute(SCI_TEXTWIDTH, STYLE_DEFAULT, (LPARAM)"P"));
int subColumn = sxoffset/pixel;
_syncInfo._column = mainColumn - subColumn;
}
}
break;
case IDM_VIEW_SUMMARY:
{
generic_string characterNumber = TEXT("");
Buffer * curBuf = _pEditView->getCurrentBuffer();
int fileLen = curBuf->getFileLength();
if (fileLen != -1)
{
TCHAR *filePathLabel = TEXT("Full file path: ");
TCHAR *fileCreateTimeLabel = TEXT("Created: ");
TCHAR *fileModifyTimeLabel = TEXT("Modified: ");
TCHAR *fileLenLabel = TEXT("File length (in byte): ");
characterNumber += filePathLabel;
characterNumber += curBuf->getFullPathName();
characterNumber += TEXT("\r");
characterNumber += fileCreateTimeLabel;
characterNumber += curBuf->getFileTime(Buffer::ft_created);
characterNumber += TEXT("\r");
characterNumber += fileModifyTimeLabel;
characterNumber += curBuf->getFileTime(Buffer::ft_modified);
characterNumber += TEXT("\r");
TCHAR fileLenStr[64];
generic_sprintf(fileLenStr, TEXT("%d"), (size_t)fileLen);
characterNumber += fileLenLabel;
characterNumber += fileLenStr;
characterNumber += TEXT("\r");
characterNumber += TEXT("\r");
}
TCHAR *nbCharLabel = TEXT("Characters (without blanks): ");
TCHAR *nbWordLabel = TEXT("Words: ");
TCHAR *nbLineLabel = TEXT("Lines: ");
TCHAR *nbByteLabel = TEXT("Current document length: ");
TCHAR *nbSelLabel1 = TEXT(" selected characters (");
TCHAR *nbSelLabel2 = TEXT(" bytes) in ");
TCHAR *nbRangeLabel = TEXT(" ranges");
UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode();
int nbChar = getCurrentDocCharCount(um);
int nbWord = wordCount();
size_t nbLine = _pEditView->execute(SCI_GETLINECOUNT);
int nbByte = _pEditView->execute(SCI_GETLENGTH);
int nbSel = getSelectedCharNumber(um);
int nbSelByte = getSelectedBytes();
int nbRange = getSelectedAreas();
TCHAR nbCharStr[32];
TCHAR nbWordStr[16];
TCHAR nbByteStr[32];
TCHAR nbLineStr[32];
TCHAR nbSelStr[32];
TCHAR nbSelByteStr[32];
TCHAR nbRangeStr[8];
generic_sprintf(nbCharStr, TEXT("%d"), nbChar);
characterNumber += nbCharLabel;
characterNumber += nbCharStr;
characterNumber += TEXT("\r");
generic_sprintf(nbWordStr, TEXT("%d"), nbWord);
characterNumber += nbWordLabel;
characterNumber += nbWordStr;
characterNumber += TEXT("\r");
generic_sprintf(nbLineStr, TEXT("%d"), nbLine);
characterNumber += nbLineLabel;
characterNumber += nbLineStr;
characterNumber += TEXT("\r");
generic_sprintf(nbByteStr, TEXT("%d"), nbByte);
characterNumber += nbByteLabel;
characterNumber += nbByteStr;
characterNumber += TEXT("\r");
generic_sprintf(nbSelStr, TEXT("%d"), nbSel);
generic_sprintf(nbSelByteStr, TEXT("%d"), nbSelByte);
generic_sprintf(nbRangeStr, TEXT("%d"), nbRange);
characterNumber += nbSelStr;
characterNumber += nbSelLabel1;
characterNumber += nbSelByteStr;
characterNumber += nbSelLabel2;
characterNumber += nbRangeStr;
characterNumber += nbRangeLabel;
characterNumber += TEXT("\r");
::MessageBox(_pPublicInterface->getHSelf(), characterNumber.c_str(), TEXT("Summary"), MB_OK|MB_APPLMODAL);
}
break;
case IDM_EXECUTE:
{
bool isFirstTime = !_runDlg.isCreated();
_runDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
_nativeLangSpeaker.changeDlgLang(_runDlg.getHSelf(), "Run");
break;
}
case IDM_FORMAT_TODOS :
case IDM_FORMAT_TOUNIX :
case IDM_FORMAT_TOMAC :
{
Buffer * buf = _pEditView->getCurrentBuffer();
int f = int((id == IDM_FORMAT_TODOS)?SC_EOL_CRLF:(id == IDM_FORMAT_TOUNIX)?SC_EOL_LF:SC_EOL_CR);
buf->setFormat((formatType)f);
_pEditView->execute(SCI_CONVERTEOLS, buf->getFormat());
break;
}
case IDM_FORMAT_ANSI :
case IDM_FORMAT_UTF_8 :
case IDM_FORMAT_UCS_2BE :
case IDM_FORMAT_UCS_2LE :
case IDM_FORMAT_AS_UTF_8 :
{
Buffer * buf = _pEditView->getCurrentBuffer();
UniMode um;
bool shoulBeDirty = true;
switch (id)
{
case IDM_FORMAT_AS_UTF_8:
shoulBeDirty = buf->getUnicodeMode() != uni8Bit;
um = uniCookie;
break;
case IDM_FORMAT_UTF_8:
um = uniUTF8;
break;
case IDM_FORMAT_UCS_2BE:
um = uni16BE;
break;
case IDM_FORMAT_UCS_2LE:
um = uni16LE;
break;
default : // IDM_FORMAT_ANSI
shoulBeDirty = buf->getUnicodeMode() != uniCookie;
um = uni8Bit;
}
if (buf->getEncoding() != -1)
{
if (buf->isDirty())
{
int answer = _nativeLangSpeaker.messageBox("SaveCurrentModifWaring",
NULL,
TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"),
TEXT("Save Current Modification"),
MB_YESNO);
if (answer == IDYES)
{
fileSave();
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
}
else
return;
}
if (_pEditView->execute(SCI_CANUNDO) == TRUE)
{
generic_string msg, title;
int answer = _nativeLangSpeaker.messageBox("LoseUndoAbilityWaring",
NULL,
TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"),
TEXT("Lose Undo Ability Waning"),
MB_YESNO);
if (answer == IDYES)
{
// Do nothing
}
else
return;
}
buf->setEncoding(-1);
if (um == uni8Bit)
_pEditView->execute(SCI_SETCODEPAGE, CP_ACP);
else
buf->setUnicodeMode(um);
fileReload();
}
else
{
if (buf->getUnicodeMode() != um)
{
buf->setUnicodeMode(um);
if (shoulBeDirty)
buf->setDirty(true);
}
}
break;
}
case IDM_FORMAT_WIN_1250 :
case IDM_FORMAT_WIN_1251 :
case IDM_FORMAT_WIN_1252 :
case IDM_FORMAT_WIN_1253 :
case IDM_FORMAT_WIN_1254 :
case IDM_FORMAT_WIN_1255 :
case IDM_FORMAT_WIN_1256 :
case IDM_FORMAT_WIN_1257 :
case IDM_FORMAT_WIN_1258 :
case IDM_FORMAT_ISO_8859_1 :
case IDM_FORMAT_ISO_8859_2 :
case IDM_FORMAT_ISO_8859_3 :
case IDM_FORMAT_ISO_8859_4 :
case IDM_FORMAT_ISO_8859_5 :
case IDM_FORMAT_ISO_8859_6 :
case IDM_FORMAT_ISO_8859_7 :
case IDM_FORMAT_ISO_8859_8 :
case IDM_FORMAT_ISO_8859_9 :
case IDM_FORMAT_ISO_8859_10 :
case IDM_FORMAT_ISO_8859_11 :
case IDM_FORMAT_ISO_8859_13 :
case IDM_FORMAT_ISO_8859_14 :
case IDM_FORMAT_ISO_8859_15 :
case IDM_FORMAT_ISO_8859_16 :
case IDM_FORMAT_DOS_437 :
case IDM_FORMAT_DOS_720 :
case IDM_FORMAT_DOS_737 :
case IDM_FORMAT_DOS_775 :
case IDM_FORMAT_DOS_850 :
case IDM_FORMAT_DOS_852 :
case IDM_FORMAT_DOS_855 :
case IDM_FORMAT_DOS_857 :
case IDM_FORMAT_DOS_858 :
case IDM_FORMAT_DOS_860 :
case IDM_FORMAT_DOS_861 :
case IDM_FORMAT_DOS_862 :
case IDM_FORMAT_DOS_863 :
case IDM_FORMAT_DOS_865 :
case IDM_FORMAT_DOS_866 :
case IDM_FORMAT_DOS_869 :
case IDM_FORMAT_BIG5 :
case IDM_FORMAT_GB2312 :
case IDM_FORMAT_SHIFT_JIS :
case IDM_FORMAT_KOREAN_WIN :
case IDM_FORMAT_EUC_KR :
case IDM_FORMAT_TIS_620 :
case IDM_FORMAT_MAC_CYRILLIC :
case IDM_FORMAT_KOI8U_CYRILLIC :
case IDM_FORMAT_KOI8R_CYRILLIC :
{
int index = id - IDM_FORMAT_ENCODE;
EncodingMapper *em = EncodingMapper::getInstance();
int encoding = em->getEncodingFromIndex(index);
if (encoding == -1)
{
//printStr(TEXT("Encoding problem. Command is not added in encoding_table?"));
return;
}
Buffer * buf = _pEditView->getCurrentBuffer();
if (buf->isDirty())
{
generic_string warning, title;
int answer = _nativeLangSpeaker.messageBox("SaveCurrentModifWaring",
NULL,
TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"),
TEXT("Save Current Modification"),
MB_YESNO);
if (answer == IDYES)
{
fileSave();
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
}
else
return;
}
if (_pEditView->execute(SCI_CANUNDO) == TRUE)
{
generic_string msg, title;
int answer = _nativeLangSpeaker.messageBox("LoseUndoAbilityWaring",
NULL,
TEXT("You should save the current modification.\rAll the saved modifications can not be undone.\r\rContinue?"),
TEXT("Lose Undo Ability Waning"),
MB_YESNO);
if (answer == IDYES)
{
// Do nothing
}
else
return;
}
if (!buf->isDirty())
{
Buffer *buf = _pEditView->getCurrentBuffer();
buf->setEncoding(encoding);
buf->setUnicodeMode(uniCookie);
fileReload();
}
break;
}
case IDM_FORMAT_CONV2_ANSI:
case IDM_FORMAT_CONV2_AS_UTF_8:
case IDM_FORMAT_CONV2_UTF_8:
case IDM_FORMAT_CONV2_UCS_2BE:
case IDM_FORMAT_CONV2_UCS_2LE:
{
int idEncoding = -1;
Buffer *buf = _pEditView->getCurrentBuffer();
UniMode um = buf->getUnicodeMode();
int encoding = buf->getEncoding();
switch(id)
{
case IDM_FORMAT_CONV2_ANSI:
{
if (encoding != -1)
{
// do nothing
return;
}
else
{
if (um == uni8Bit)
return;
// set scintilla to ANSI
idEncoding = IDM_FORMAT_ANSI;
}
break;
}
case IDM_FORMAT_CONV2_AS_UTF_8:
{
if (encoding != -1)
{
buf->setDirty(true);
buf->setUnicodeMode(uniCookie);
buf->setEncoding(-1);
return;
}
idEncoding = IDM_FORMAT_AS_UTF_8;
if (um == uniCookie)
return;
if (um != uni8Bit)
{
::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, idEncoding, 0);
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
return;
}
break;
}
case IDM_FORMAT_CONV2_UTF_8:
{
if (encoding != -1)
{
buf->setDirty(true);
buf->setUnicodeMode(uniUTF8);
buf->setEncoding(-1);
return;
}
idEncoding = IDM_FORMAT_UTF_8;
if (um == uniUTF8)
return;
if (um != uni8Bit)
{
::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, idEncoding, 0);
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
return;
}
break;
}
case IDM_FORMAT_CONV2_UCS_2BE:
{
if (encoding != -1)
{
buf->setDirty(true);
buf->setUnicodeMode(uni16BE);
buf->setEncoding(-1);
return;
}
idEncoding = IDM_FORMAT_UCS_2BE;
if (um == uni16BE)
return;
if (um != uni8Bit)
{
::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, idEncoding, 0);
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
return;
}
break;
}
case IDM_FORMAT_CONV2_UCS_2LE:
{
if (encoding != -1)
{
buf->setDirty(true);
buf->setUnicodeMode(uni16LE);
buf->setEncoding(-1);
return;
}
idEncoding = IDM_FORMAT_UCS_2LE;
if (um == uni16LE)
return;
if (um != uni8Bit)
{
::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, idEncoding, 0);
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
return;
}
break;
}
}
if (idEncoding != -1)
{
// Save the current clipboard content
::OpenClipboard(_pPublicInterface->getHSelf());
HANDLE clipboardData = ::GetClipboardData(CF_TEXT);
int len = ::GlobalSize(clipboardData);
LPVOID clipboardDataPtr = ::GlobalLock(clipboardData);
HANDLE allocClipboardData = ::GlobalAlloc(GMEM_MOVEABLE, len);
LPVOID clipboardData2 = ::GlobalLock(allocClipboardData);
::memcpy(clipboardData2, clipboardDataPtr, len);
::GlobalUnlock(clipboardData);
::GlobalUnlock(allocClipboardData);
::CloseClipboard();
_pEditView->saveCurrentPos();
// Cut all text
int docLen = _pEditView->getCurrentDocLen();
_pEditView->execute(SCI_COPYRANGE, 0, docLen);
_pEditView->execute(SCI_CLEARALL);
// Change to the proper buffer, save buffer status
::SendMessage(_pPublicInterface->getHSelf(), WM_COMMAND, idEncoding, 0);
// Paste the texte, restore buffer status
_pEditView->execute(SCI_PASTE);
_pEditView->restoreCurrentPos();
// Restore the previous clipboard data
::OpenClipboard(_pPublicInterface->getHSelf());
::EmptyClipboard();
::SetClipboardData(CF_TEXT, clipboardData2);
::CloseClipboard();
//Do not free anything, EmptyClipboard does that
_pEditView->execute(SCI_EMPTYUNDOBUFFER);
}
break;
}
/*
case (IDM_FORMAT_WIN_1250 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1251 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1252 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1253 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1254 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1255 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1256 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1257 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_WIN_1258 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_1 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_2 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_3 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_4 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_5 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_6 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_7 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_8 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_9 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_10 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_11 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_13 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_14 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_15 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_ISO_8859_16 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_437 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_720 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_737 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_775 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_850 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_852 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_855 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_857 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_858 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_860 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_861 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_862 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_863 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_865 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_866 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_DOS_869 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_BIG5 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_GB2312 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_SHIFT_JIS + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_KOREAN_WIN + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_EUC_KR + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_TIS_620 + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_MAC_CYRILLIC + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_KOI8U_CYRILLIC + IDM_FORMAT_CONVERT):
case (IDM_FORMAT_KOI8R_CYRILLIC + IDM_FORMAT_CONVERT):
{
int index = id - IDM_FORMAT_CONVERT - IDM_FORMAT_ENCODE;
EncodingMapper *em = EncodingMapper::getInstance();
int newEncoding = em->getEncodingFromIndex(index);
if (newEncoding == -1)
{
return;
}
Buffer *buf = _pEditView->getCurrentBuffer();
UniMode um = buf->getUnicodeMode();
int oldEncoding = buf->getEncoding();
if (oldEncoding == newEncoding)
return;
if (oldEncoding != -1)
{
//do waring
}
buf->setEncoding(newEncoding);
break;
}
*/
case IDM_SETTING_TAB_REPLCESPACE:
case IDM_SETTING_TAB_SIZE:
{
_pEditView->setTabSettings(_pEditView->getCurrentBuffer()->getCurrentLang());
break;
}
case IDM_SETTING_AUTOCNBCHAR:
{
const int NB_MIN_CHAR = 1;
const int NB_MAX_CHAR = 9;
ValueDlg valDlg;
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
valDlg.init(_pPublicInterface->getHinst(), _preference.getHSelf(), nppGUI._autocFromLen, TEXT("Nb char : "));
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_pPublicInterface->getHParent(), &p);
int size = valDlg.doDialog(p, _nativeLangSpeaker.isRTL());
if (size != -1)
{
if (size > NB_MAX_CHAR)
size = NB_MAX_CHAR;
else if (size < NB_MIN_CHAR)
size = NB_MIN_CHAR;
nppGUI._autocFromLen = size;
}
break;
}
case IDM_SETTING_HISTORY_SIZE :
{
ValueDlg nbHistoryDlg;
NppParameters *pNppParam = NppParameters::getInstance();
nbHistoryDlg.init(_pPublicInterface->getHinst(), _preference.getHSelf(), pNppParam->getNbMaxFile(), TEXT("Max File : "));
POINT p;
::GetCursorPos(&p);
::ScreenToClient(_pPublicInterface->getHParent(), &p);
int size = nbHistoryDlg.doDialog(p, _nativeLangSpeaker.isRTL());
if (size != -1)
{
if (size > NB_MAX_LRF_FILE)
size = NB_MAX_LRF_FILE;
pNppParam->setNbMaxFile(size);
_lastRecentFileList.setUserMaxNbLRF(size);
}
break;
}
case IDM_SETTING_IMPORTPLUGIN :
{
// get plugin source path
TCHAR *extFilterName = TEXT("Notepad++ plugin");
TCHAR *extFilter = TEXT(".dll");
TCHAR *destDir = TEXT("plugins");
vector<generic_string> copiedFiles = addNppComponents(destDir, extFilterName, extFilter);
// load plugin
vector<generic_string> dll2Remove;
for (size_t i = 0 ; i < copiedFiles.size() ; i++)
{
int index = _pluginsManager.loadPlugin(copiedFiles[i].c_str(), dll2Remove);
if (_pluginsManager.getMenuHandle())
_pluginsManager.addInMenuFromPMIndex(index);
}
if (!_pluginsManager.getMenuHandle())
_pluginsManager.setMenu(_mainMenuHandle, NULL);
::DrawMenuBar(_pPublicInterface->getHSelf());
break;
}
case IDM_SETTING_IMPORTSTYLETHEMS :
{
// get plugin source path
TCHAR *extFilterName = TEXT("Notepad++ style theme");
TCHAR *extFilter = TEXT(".xml");
TCHAR *destDir = TEXT("themes");
// load styler
NppParameters *pNppParams = NppParameters::getInstance();
ThemeSwitcher & themeSwitcher = pNppParams->getThemeSwitcher();
vector<generic_string> copiedFiles = addNppComponents(destDir, extFilterName, extFilter);
for (size_t i = 0 ; i < copiedFiles.size() ; i++)
{
generic_string themeName(themeSwitcher.getThemeFromXmlFileName(copiedFiles[i].c_str()));
if (!themeSwitcher.themeNameExists(themeName.c_str()))
{
themeSwitcher.addThemeFromXml(copiedFiles[i].c_str());
if (_configStyleDlg.isCreated())
{
_configStyleDlg.addLastThemeEntry();
}
}
}
break;
}
case IDM_SETTING_SHORTCUT_MAPPER :
case IDM_SETTING_SHORTCUT_MAPPER_MACRO :
case IDM_SETTING_SHORTCUT_MAPPER_RUN :
{
GridState st = id==IDM_SETTING_SHORTCUT_MAPPER_MACRO?STATE_MACRO:id==IDM_SETTING_SHORTCUT_MAPPER_RUN?STATE_USER:STATE_MENU;
ShortcutMapper shortcutMapper;
shortcutMapper.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), st);
_nativeLangSpeaker.changeShortcutmapperLang(&shortcutMapper);
shortcutMapper.doDialog(_nativeLangSpeaker.isRTL());
shortcutMapper.destroy();
break;
}
case IDM_SETTING_PREFERECE :
{
bool isFirstTime = !_preference.isCreated();
_preference.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
{
_nativeLangSpeaker.changePrefereceDlgLang(_preference);
}
break;
}
case IDM_SETTING_EDITCONTEXTMENU :
{
//if (contion)
{
generic_string warning, title;
_nativeLangSpeaker.messageBox("ContextMenuXmlEditWaring",
_pPublicInterface->getHSelf(),
TEXT("Editing contextMenu.xml allows you to modify your Notepad++ popup context menu.\rYou have to restart your Notepad++ to take effect after modifying contextMenu.xml."),
TEXT("Editing contextMenu"),
MB_OK|MB_APPLMODAL);
}
NppParameters *pNppParams = NppParameters::getInstance();
BufferID bufID = doOpen((pNppParams->getContextMenuPath()).c_str());
switchToFile(bufID);
break;
}
case IDM_VIEW_GOTO_ANOTHER_VIEW:
docGotoAnotherEditView(TransferMove);
checkSyncState();
break;
case IDM_VIEW_CLONE_TO_ANOTHER_VIEW:
docGotoAnotherEditView(TransferClone);
checkSyncState();
break;
case IDM_VIEW_GOTO_NEW_INSTANCE :
docOpenInNewInstance(TransferMove);
break;
case IDM_VIEW_LOAD_IN_NEW_INSTANCE:
docOpenInNewInstance(TransferClone);
break;
case IDM_VIEW_SWITCHTO_OTHER_VIEW:
{
int view_to_focus;
HWND wnd = GetFocus();
if (_pEditView->getHSelf() == wnd)
{
view_to_focus = otherView();
if (!viewVisible(view_to_focus)) view_to_focus = _activeView;
}
else
{
view_to_focus = currentView();
}
switchEditViewTo(view_to_focus);
break;
}
case IDM_ABOUT:
{
bool isFirstTime = !_aboutDlg.isCreated();
_aboutDlg.doDialog();
if (isFirstTime && _nativeLangSpeaker.getNativeLangA())
{
if (_nativeLangSpeaker.getLangEncoding() == NPP_CP_BIG5)
{
char *authorName = "�J���^";
HWND hItem = ::GetDlgItem(_aboutDlg.getHSelf(), IDC_AUTHOR_NAME);
#ifdef UNICODE
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const wchar_t *authorNameW = wmc->char2wchar(authorName, NPP_CP_BIG5);
::SetWindowText(hItem, authorNameW);
#else
::SetWindowText(hItem, authorName);
#endif
}
}
break;
}
case IDM_HELP :
{
generic_string tmp((NppParameters::getInstance())->getNppPath());
generic_string nppHelpPath = tmp.c_str();
nppHelpPath += TEXT("\\user.manual\\documentation\\%2Fnotepad-online-document.html");
if (::PathFileExists(nppHelpPath.c_str()))
::ShellExecute(NULL, TEXT("open"), nppHelpPath.c_str(), NULL, NULL, SW_SHOWNORMAL);
else
{
generic_string msg = nppHelpPath;
generic_string warning, title;
if (!_nativeLangSpeaker.getMsgBoxLang("NppHelpAbsentWaring", title, warning))
{
title = TEXT("File does not exist");
warning = TEXT("\rdoesn't exist. Please download it on Notepad++ site.");
}
msg += warning;
::MessageBox(_pPublicInterface->getHSelf(), msg.c_str(), title.c_str(), MB_OK);
}
}
break;
case IDM_HOMESWEETHOME :
{
::ShellExecute(NULL, TEXT("open"), TEXT("http://notepad-plus-plus.org/"), NULL, NULL, SW_SHOWNORMAL);
break;
}
case IDM_PROJECTPAGE :
{
::ShellExecute(NULL, TEXT("open"), TEXT("http://sourceforge.net/projects/notepad-plus/"), NULL, NULL, SW_SHOWNORMAL);
break;
}
case IDM_ONLINEHELP:
{
::ShellExecute(NULL, TEXT("open"), TEXT("http://npp-community.tuxfamily.org/"), NULL, NULL, SW_SHOWNORMAL);
break;
}
case IDM_FORUM:
{
::ShellExecute(NULL, TEXT("open"), TEXT("http://sourceforge.net/forum/?group_id=95717"), NULL, NULL, SW_SHOWNORMAL);
break;
}
case IDM_PLUGINSHOME:
{
::ShellExecute(NULL, TEXT("open"), TEXT("http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Central"), NULL, NULL, SW_SHOWNORMAL);
break;
}
case IDM_UPDATE_NPP :
{
generic_string updaterDir = (NppParameters::getInstance())->getNppPath();
PathAppend(updaterDir ,TEXT("updater"));
generic_string updaterFullPath = updaterDir;
PathAppend(updaterFullPath, TEXT("gup.exe"));
generic_string param = TEXT("-verbose -v");
param += VERSION_VALUE;
Process updater(updaterFullPath.c_str(), param.c_str(), updaterDir.c_str());
updater.run();
break;
}
case IDM_EDIT_AUTOCOMPLETE :
showAutoComp();
break;
case IDM_EDIT_AUTOCOMPLETE_CURRENTFILE :
autoCompFromCurrentFile();
break;
case IDM_EDIT_FUNCCALLTIP :
showFunctionComp();
break;
case IDM_LANGSTYLE_CONFIG_DLG :
{
bool isFirstTime = !_configStyleDlg.isCreated();
_configStyleDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
_nativeLangSpeaker.changeConfigLang(_configStyleDlg.getHSelf());
break;
}
case IDM_LANG_C :
case IDM_LANG_CPP :
case IDM_LANG_JAVA :
case IDM_LANG_CS :
case IDM_LANG_HTML :
case IDM_LANG_XML :
case IDM_LANG_JS :
case IDM_LANG_PHP :
case IDM_LANG_ASP :
case IDM_LANG_CSS :
case IDM_LANG_LUA :
case IDM_LANG_PERL :
case IDM_LANG_PYTHON :
case IDM_LANG_PASCAL :
case IDM_LANG_BATCH :
case IDM_LANG_OBJC :
case IDM_LANG_VB :
case IDM_LANG_SQL :
case IDM_LANG_ASCII :
case IDM_LANG_TEXT :
case IDM_LANG_RC :
case IDM_LANG_MAKEFILE :
case IDM_LANG_INI :
case IDM_LANG_TEX :
case IDM_LANG_FORTRAN :
case IDM_LANG_BASH :
case IDM_LANG_FLASH :
case IDM_LANG_NSIS :
case IDM_LANG_TCL :
case IDM_LANG_LISP :
case IDM_LANG_SCHEME :
case IDM_LANG_ASM :
case IDM_LANG_DIFF :
case IDM_LANG_PROPS :
case IDM_LANG_PS:
case IDM_LANG_RUBY:
case IDM_LANG_SMALLTALK:
case IDM_LANG_VHDL :
case IDM_LANG_KIX :
case IDM_LANG_CAML :
case IDM_LANG_ADA :
case IDM_LANG_VERILOG :
case IDM_LANG_MATLAB :
case IDM_LANG_HASKELL :
case IDM_LANG_AU3 :
case IDM_LANG_INNO :
case IDM_LANG_CMAKE :
case IDM_LANG_YAML :
case IDM_LANG_COBOL :
case IDM_LANG_D :
case IDM_LANG_GUI4CLI :
case IDM_LANG_POWERSHELL :
case IDM_LANG_R :
case IDM_LANG_JSP :
case IDM_LANG_USER :
{
setLanguage(menuID2LangType(id));
}
break;
case IDC_PREV_DOC :
case IDC_NEXT_DOC :
{
int nbDoc = viewVisible(MAIN_VIEW)?_mainDocTab.nbItem():0;
nbDoc += viewVisible(SUB_VIEW)?_subDocTab.nbItem():0;
bool doTaskList = ((NppParameters::getInstance())->getNppGUI())._doTaskList;
if (nbDoc > 1)
{
bool direction = (id == IDC_NEXT_DOC)?dirDown:dirUp;
if (!doTaskList)
{
activateNextDoc(direction);
}
else
{
TaskListDlg tld;
HIMAGELIST hImgLst = _docTabIconList.getHandle();
tld.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst, direction);
tld.doDialog();
}
}
_linkTriggered = true;
}
break;
case IDM_OPEN_ALL_RECENT_FILE : {
BufferID lastOne = BUFFER_INVALID;
int size = _lastRecentFileList.getSize();
for (int i = size - 1; i >= 0; i--)
{
BufferID test = doOpen(_lastRecentFileList.getIndex(i).c_str());
if (test != BUFFER_INVALID)
lastOne = test;
}
if (lastOne != BUFFER_INVALID) {
switchToFile(lastOne);
}
break; }
case IDM_CLEAN_RECENT_FILE_LIST :
_lastRecentFileList.clear();
break;
case IDM_EDIT_RTL :
case IDM_EDIT_LTR :
{
long exStyle = ::GetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE);
exStyle = (id == IDM_EDIT_RTL)?exStyle|WS_EX_LAYOUTRTL:exStyle&(~WS_EX_LAYOUTRTL);
::SetWindowLongPtr(_pEditView->getHSelf(), GWL_EXSTYLE, exStyle);
_pEditView->redraw();
}
break;
case IDM_WINDOW_WINDOWS :
{
WindowsDlg _windowsDlg;
_windowsDlg.init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), _pDocTab);
const TiXmlNodeA *nativeLangA = _nativeLangSpeaker.getNativeLangA();
TiXmlNodeA *dlgNode = NULL;
if (nativeLangA)
{
dlgNode = nativeLangA->FirstChild("Dialog");
if (dlgNode)
dlgNode = _nativeLangSpeaker.searchDlgNode(dlgNode, "Window");
}
_windowsDlg.doDialog(dlgNode);
}
break;
case IDM_SYSTRAYPOPUP_NEWDOC:
{
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW);
fileNew();
}
break;
case IDM_SYSTRAYPOPUP_ACTIVATE :
{
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW);
}
break;
case IDM_SYSTRAYPOPUP_NEW_AND_PASTE:
{
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW);
BufferID bufferID = _pEditView->getCurrentBufferID();
Buffer * buf = MainFileManager->getBufferByID(bufferID);
if (!buf->isUntitled() || buf->docLength() != 0)
{
fileNew();
}
command(IDM_EDIT_PASTE);
}
break;
case IDM_SYSTRAYPOPUP_OPENFILE:
{
NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI());
::ShowWindow(_pPublicInterface->getHSelf(), nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW);
fileOpen();
}
break;
case IDM_SYSTRAYPOPUP_CLOSE:
{
_pPublicInterface->setIsPrelaunch(false);
_pTrayIco->doTrayIcon(REMOVE);
if (!::IsWindowVisible(_pPublicInterface->getHSelf()))
::SendMessage(_pPublicInterface->getHSelf(), WM_CLOSE, 0,0);
}
break;
default :
if (id > IDM_FILEMENU_LASTONE && id < (IDM_FILEMENU_LASTONE + _lastRecentFileList.getMaxNbLRF() + 1))
{
BufferID lastOpened = doOpen(_lastRecentFileList.getItem(id).c_str());
if (lastOpened != BUFFER_INVALID) {
switchToFile(lastOpened);
}
}
else if ((id > IDM_LANG_USER) && (id < IDM_LANG_USER_LIMIT))
{
TCHAR langName[langNameLenMax];
::GetMenuString(_mainMenuHandle, id, langName, langNameLenMax, MF_BYCOMMAND);
_pEditView->getCurrentBuffer()->setLangType(L_USER, langName);
}
else if ((id >= IDM_LANG_EXTERNAL) && (id <= IDM_LANG_EXTERNAL_LIMIT))
{
setLanguage((LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL));
}
else if ((id >= ID_MACRO) && (id < ID_MACRO_LIMIT))
{
int i = id - ID_MACRO;
vector<MacroShortcut> & theMacros = (NppParameters::getInstance())->getMacroList();
macroPlayback(theMacros[i].getMacro());
}
else if ((id >= ID_USER_CMD) && (id < ID_USER_CMD_LIMIT))
{
int i = id - ID_USER_CMD;
vector<UserCommand> & theUserCommands = (NppParameters::getInstance())->getUserCommandList();
UserCommand ucmd = theUserCommands[i];
Command cmd(ucmd.getCmd());
cmd.run(_pPublicInterface->getHSelf());
}
else if ((id >= ID_PLUGINS_CMD) && (id < ID_PLUGINS_CMD_LIMIT))
{
int i = id - ID_PLUGINS_CMD;
_pluginsManager.runPluginCommand(i);
}
else if (_pluginsManager.inDynamicRange(id)) // in the dynamic range allocated with NPPM_ALLOCATECMDID
{
_pluginsManager.relayNppMessages(WM_COMMAND, id, 0);
}
/*UNLOAD
else if ((id >= ID_PLUGINS_REMOVING) && (id < ID_PLUGINS_REMOVING_END))
{
int i = id - ID_PLUGINS_REMOVING;
_pluginsManager.unloadPlugin(i, _pPublicInterface->getHSelf());
}
*/
else if ((id >= IDM_WINDOW_MRU_FIRST) && (id <= IDM_WINDOW_MRU_LIMIT))
{
activateDoc(id-IDM_WINDOW_MRU_FIRST);
}
}
if (_recordingMacro)
switch (id)
{
case IDM_FILE_NEW :
case IDM_FILE_CLOSE :
case IDM_FILE_CLOSEALL :
case IDM_FILE_CLOSEALL_BUT_CURRENT :
case IDM_FILE_SAVE :
case IDM_FILE_SAVEALL :
case IDM_FILE_RELOAD:
case IDM_EDIT_UNDO:
case IDM_EDIT_REDO:
case IDM_EDIT_CUT:
case IDM_EDIT_COPY:
//case IDM_EDIT_PASTE:
case IDM_EDIT_DELETE:
case IDM_SEARCH_FINDNEXT :
case IDM_SEARCH_FINDPREV :
case IDM_SEARCH_SETANDFINDNEXT :
case IDM_SEARCH_SETANDFINDPREV :
case IDM_SEARCH_GOTOMATCHINGBRACE :
case IDM_SEARCH_TOGGLE_BOOKMARK :
case IDM_SEARCH_NEXT_BOOKMARK:
case IDM_SEARCH_PREV_BOOKMARK:
case IDM_SEARCH_CLEAR_BOOKMARKS:
case IDM_EDIT_SELECTALL:
case IDM_EDIT_INS_TAB:
case IDM_EDIT_RMV_TAB:
case IDM_EDIT_DUP_LINE:
case IDM_EDIT_TRANSPOSE_LINE:
case IDM_EDIT_SPLIT_LINES:
case IDM_EDIT_JOIN_LINES:
case IDM_EDIT_LINE_UP:
case IDM_EDIT_LINE_DOWN:
case IDM_EDIT_UPPERCASE:
case IDM_EDIT_LOWERCASE:
case IDM_EDIT_BLOCK_COMMENT:
case IDM_EDIT_BLOCK_COMMENT_SET:
case IDM_EDIT_BLOCK_UNCOMMENT:
case IDM_EDIT_STREAM_COMMENT:
case IDM_EDIT_TRIMTRAILING:
case IDM_EDIT_TRIMLINEHEAD:
case IDM_EDIT_TRIM_BOTH:
case IDM_EDIT_EOL2WS:
case IDM_EDIT_TRIMALL:
case IDM_EDIT_TAB2SW:
case IDM_EDIT_SW2TAB:
case IDM_EDIT_SETREADONLY :
case IDM_EDIT_FULLPATHTOCLIP :
case IDM_EDIT_FILENAMETOCLIP :
case IDM_EDIT_CURRENTDIRTOCLIP :
case IDM_EDIT_CLEARREADONLY :
case IDM_EDIT_RTL :
case IDM_EDIT_LTR :
case IDM_VIEW_FULLSCREENTOGGLE :
case IDM_VIEW_ALWAYSONTOP :
case IDM_VIEW_WRAP :
case IDM_VIEW_FOLD_CURRENT :
case IDM_VIEW_UNFOLD_CURRENT :
case IDM_VIEW_TOGGLE_FOLDALL:
case IDM_VIEW_TOGGLE_UNFOLDALL:
case IDM_VIEW_FOLD_1:
case IDM_VIEW_FOLD_2:
case IDM_VIEW_FOLD_3:
case IDM_VIEW_FOLD_4:
case IDM_VIEW_FOLD_5:
case IDM_VIEW_FOLD_6:
case IDM_VIEW_FOLD_7:
case IDM_VIEW_FOLD_8:
case IDM_VIEW_UNFOLD_1:
case IDM_VIEW_UNFOLD_2:
case IDM_VIEW_UNFOLD_3:
case IDM_VIEW_UNFOLD_4:
case IDM_VIEW_UNFOLD_5:
case IDM_VIEW_UNFOLD_6:
case IDM_VIEW_UNFOLD_7:
case IDM_VIEW_UNFOLD_8:
case IDM_VIEW_GOTO_ANOTHER_VIEW:
case IDM_VIEW_SYNSCROLLV:
case IDM_VIEW_SYNSCROLLH:
case IDC_PREV_DOC :
case IDC_NEXT_DOC :
case IDM_SEARCH_GOPREVMARKER1 :
case IDM_SEARCH_GOPREVMARKER2 :
case IDM_SEARCH_GOPREVMARKER3 :
case IDM_SEARCH_GOPREVMARKER4 :
case IDM_SEARCH_GOPREVMARKER5 :
case IDM_SEARCH_GOPREVMARKER_DEF:
case IDM_SEARCH_GONEXTMARKER1 :
case IDM_SEARCH_GONEXTMARKER2 :
case IDM_SEARCH_GONEXTMARKER3 :
case IDM_SEARCH_GONEXTMARKER4 :
case IDM_SEARCH_GONEXTMARKER5 :
case IDM_SEARCH_GONEXTMARKER_DEF:
case IDM_SEARCH_VOLATILE_FINDNEXT:
case IDM_SEARCH_VOLATILE_FINDPREV:
case IDM_SEARCH_CUTMARKEDLINES :
case IDM_SEARCH_COPYMARKEDLINES :
case IDM_SEARCH_PASTEMARKEDLINES :
case IDM_SEARCH_DELETEMARKEDLINES:
case IDM_SEARCH_MARKALLEXT1 :
case IDM_SEARCH_UNMARKALLEXT1 :
case IDM_SEARCH_MARKALLEXT2 :
case IDM_SEARCH_UNMARKALLEXT2 :
case IDM_SEARCH_MARKALLEXT3 :
case IDM_SEARCH_UNMARKALLEXT3 :
case IDM_SEARCH_MARKALLEXT4 :
case IDM_SEARCH_UNMARKALLEXT4 :
case IDM_SEARCH_MARKALLEXT5 :
case IDM_SEARCH_UNMARKALLEXT5 :
case IDM_SEARCH_CLEARALLMARKS :
_macro.push_back(recordedMacroStep(id));
break;
}
}