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
|
# HG changeset patch
# User Neil <nyamatongwe@gmail.com>
# Date 1497232196 -36000
# Node ID 7030530a9a0f4fc1203a04378e83d82f0c35e7a0
# Parent 7e28cdba6d61e090ac6f6627c855ffd2603508e4
Removed unused functions and methods from Platform.h.
Replaced Platform::Clamp with Sci::clamp but will later change this to
std::clamp once on full C++17 compilers.
Drop MouseButtonBounce workaround for very early GTK+/Linux.
diff -r 7e28cdba6d61 -r 7030530a9a0f cocoa/PlatCocoa.mm
--- a/cocoa/PlatCocoa.mm Sun Jun 11 14:08:43 2017 +1000
+++ b/cocoa/PlatCocoa.mm Mon Jun 12 11:49:56 2017 +1000
@@ -83,18 +83,6 @@
return rc;
}
-//----------------- Point --------------------------------------------------------------------------
-
-/**
- * Converts a point given as a long into a native Point structure.
- */
-Scintilla::Point Scintilla::Point::FromLong(long lpoint) {
- return Scintilla::Point(
- Platform::LowShortFromLong(lpoint),
- Platform::HighShortFromLong(lpoint)
- );
-}
-
//----------------- Font ---------------------------------------------------------------------------
Font::Font(): fid(0) {
@@ -921,7 +909,7 @@
} else if (codePage) {
int ui = 0;
for (int i=0; i<len;) {
- size_t lenChar = Platform::IsDBCSLeadByte(codePage, s[i]) ? 2 : 1;
+ size_t lenChar = DBCSIsLeadByte(codePage, s[i]) ? 2 : 1;
CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, ui+1, NULL);
for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
positions[i++] = static_cast<XYPOSITION>(xPosition);
@@ -984,15 +972,6 @@
return 0;
}
-XYPOSITION SurfaceImpl::ExternalLeading(Font &font_) {
- if (!font_.GetID())
- return 1;
-
- float leading = static_cast<QuartzTextStyle *>(font_.GetID())->getLeading();
- return leading + 0.5f;
-
-}
-
XYPOSITION SurfaceImpl::Height(Font &font_) {
return Ascent(font_) + Descent(font_);
@@ -1043,13 +1022,6 @@
//--------------------------------------------------------------------------------------------------
-bool Window::HasFocus() {
- NSView *container = (__bridge NSView *)(wid);
- return container.window.firstResponder == container;
-}
-
-//--------------------------------------------------------------------------------------------------
-
static CGFloat ScreenMax() {
return NSMaxY([NSScreen mainScreen].frame);
}
@@ -1205,19 +1177,6 @@
//--------------------------------------------------------------------------------------------------
-void Window::SetTitle(const char *s) {
- if (wid) {
- id idWin = (__bridge id)(wid);
- if ([idWin isKindOfClass: [NSWindow class]]) {
- NSWindow *win = idWin;
- NSString *sTitle = @(s);
- win.title = sTitle;
- }
- }
-}
-
-//--------------------------------------------------------------------------------------------------
-
PRectangle Window::GetMonitorRect(Point) {
if (wid) {
id idWin = (__bridge id)(wid);
@@ -1897,85 +1856,6 @@
//--------------------------------------------------------------------------------------------------
-bool Platform::MouseButtonBounce() {
- return false;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-/**
- * Helper method for the backend to reach through to the scintilla window.
- */
-long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
- return scintilla_send_message(w, msg, wParam, lParam);
-}
-
-//--------------------------------------------------------------------------------------------------
-
-/**
- * Helper method for the backend to reach through to the scintilla window.
- */
-long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
- return scintilla_send_message(w, msg, wParam, (long) lParam);
-}
-
-//--------------------------------------------------------------------------------------------------
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch) {
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage) {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xFC));
- // Lead bytes F0 to FC may be a Microsoft addition.
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 949:
- // Korean Wansung KS C-5601-1987
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- case 1361:
- // Korean Johab KS C-5601-1992
- return
- ((uch >= 0x84) && (uch <= 0xD3)) ||
- ((uch >= 0xD8) && (uch <= 0xDE)) ||
- ((uch >= 0xE0) && (uch <= 0xF9));
- }
- return false;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::DBCSCharLength(int /* codePage */, const char * /* s */) {
- // DBCS no longer uses this.
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::DBCSCharMaxLength() {
- return 2;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::Minimum(int a, int b) {
- return (a < b) ? a : b;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::Maximum(int a, int b) {
- return (a > b) ? a : b;
-}
-
-//--------------------------------------------------------------------------------------------------
-
//#define TRACE
#ifdef TRACE
@@ -2026,16 +1906,6 @@
#endif
}
-//--------------------------------------------------------------------------------------------------
-
-int Platform::Clamp(int val, int minVal, int maxVal) {
- if (val > maxVal)
- val = maxVal;
- if (val < minVal)
- val = minVal;
- return val;
-}
-
//----------------- DynamicLibrary -----------------------------------------------------------------
/**
diff -r 7e28cdba6d61 -r 7030530a9a0f cocoa/ScintillaCocoa.h
--- a/cocoa/ScintillaCocoa.h Sun Jun 11 14:08:43 2017 +1000
+++ b/cocoa/ScintillaCocoa.h Mon Jun 12 11:49:56 2017 +1000
@@ -52,6 +52,7 @@
#include "Document.h"
#include "CaseConvert.h"
#include "UniConversion.h"
+#include "DBCS.h"
#include "Selection.h"
#include "PositionCache.h"
#include "EditModel.h"
diff -r 7e28cdba6d61 -r 7030530a9a0f cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
--- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj Sun Jun 11 14:08:43 2017 +1000
+++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj Mon Jun 12 11:49:56 2017 +1000
@@ -199,6 +199,7 @@
280056FC188DDD2C00F200AE /* StringCopy.h in Headers */ = {isa = PBXBuildFile; fileRef = 280056F9188DDD2C00F200AE /* StringCopy.h */; };
280056FD188DDD2C00F200AE /* SubStyles.h in Headers */ = {isa = PBXBuildFile; fileRef = 280056FA188DDD2C00F200AE /* SubStyles.h */; };
28064A05190F12E100E6E47F /* LexDMIS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28064A04190F12E100E6E47F /* LexDMIS.cxx */; };
+ 28804B2C1EEE232E00C0D154 /* DBCS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28804B2B1EEE232E00C0D154 /* DBCS.cxx */; };
28A067111A36B42600B4966A /* LexHex.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A067101A36B42600B4966A /* LexHex.cxx */; };
28A1DD51196BE0CA006EFCDD /* EditModel.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */; };
28A1DD52196BE0CA006EFCDD /* EditView.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A1DD4F196BE0CA006EFCDD /* EditView.cxx */; };
@@ -423,6 +424,7 @@
280056FA188DDD2C00F200AE /* SubStyles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SubStyles.h; path = ../../lexlib/SubStyles.h; sourceTree = "<group>"; };
28064A04190F12E100E6E47F /* LexDMIS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexDMIS.cxx; path = ../../lexers/LexDMIS.cxx; sourceTree = "<group>"; };
282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexIndent.cxx; path = ../../lexers/LexIndent.cxx; sourceTree = SOURCE_ROOT; };
+ 28804B2B1EEE232E00C0D154 /* DBCS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DBCS.cxx; path = ../../src/DBCS.cxx; sourceTree = "<group>"; };
28A067101A36B42600B4966A /* LexHex.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexHex.cxx; path = ../../lexers/LexHex.cxx; sourceTree = "<group>"; };
28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditModel.cxx; path = ../../src/EditModel.cxx; sourceTree = "<group>"; };
28A1DD4F196BE0CA006EFCDD /* EditView.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditView.cxx; path = ../../src/EditView.cxx; sourceTree = "<group>"; };
@@ -724,6 +726,7 @@
114B6F8F11FA75BE004FB6AB /* CharacterSet.cxx */,
114B6F6411FA7597004FB6AB /* CharClassify.cxx */,
114B6F6511FA7597004FB6AB /* ContractionState.cxx */,
+ 28804B2B1EEE232E00C0D154 /* DBCS.cxx */,
114B6F6611FA7597004FB6AB /* Decoration.cxx */,
114B6F6711FA7597004FB6AB /* Document.cxx */,
28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */,
@@ -1010,6 +1013,7 @@
114B6F3911FA7526004FB6AB /* LexMySQL.cxx in Sources */,
114B6F3A11FA7526004FB6AB /* LexNimrod.cxx in Sources */,
114B6F3B11FA7526004FB6AB /* LexNsis.cxx in Sources */,
+ 28804B2C1EEE232E00C0D154 /* DBCS.cxx in Sources */,
114B6F3C11FA7526004FB6AB /* LexOpal.cxx in Sources */,
114B6F3E11FA7526004FB6AB /* LexPascal.cxx in Sources */,
28B6470D1B54C0720009DC49 /* LexDiff.cxx in Sources */,
diff -r 7e28cdba6d61 -r 7030530a9a0f gtk/PlatGTK.cxx
--- a/gtk/PlatGTK.cxx Sun Jun 11 14:08:43 2017 +1000
+++ b/gtk/PlatGTK.cxx Mon Jun 12 11:49:56 2017 +1000
@@ -107,12 +107,6 @@
return static_cast<GtkWidget *>(wid);
}
-Point Point::FromLong(long lpoint) {
- return Point(
- Platform::LowShortFromLong(lpoint),
- Platform::HighShortFromLong(lpoint));
-}
-
Font::Font() : fid(0) {}
Font::~Font() {}
@@ -184,7 +178,6 @@
XYPOSITION Ascent(Font &font_);
XYPOSITION Descent(Font &font_);
XYPOSITION InternalLeading(Font &font_);
- XYPOSITION ExternalLeading(Font &font_);
XYPOSITION Height(Font &font_);
XYPOSITION AverageCharWidth(Font &font_);
@@ -925,10 +918,6 @@
return 0;
}
-XYPOSITION SurfaceImpl::ExternalLeading(Font &) {
- return 0;
-}
-
XYPOSITION SurfaceImpl::Height(Font &font_) {
return Ascent(font_) + Descent(font_);
}
@@ -978,10 +967,6 @@
}
}
-bool Window::HasFocus() {
- return gtk_widget_has_focus(GTK_WIDGET(wid));
-}
-
PRectangle Window::GetPosition() {
// Before any size allocated pretend its 1000 wide so not scrolled
PRectangle rc(0, 0, 1000, 1000);
@@ -1125,10 +1110,6 @@
#endif
}
-void Window::SetTitle(const char *s) {
- gtk_window_set_title(GTK_WINDOW(wid), s);
-}
-
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
gdk window coordinates */
PRectangle Window::GetMonitorRect(Point pt) {
@@ -2025,83 +2006,10 @@
return 500; // Half a second
}
-bool Platform::MouseButtonBounce() {
- return true;
-}
-
void Platform::DebugDisplay(const char *s) {
fprintf(stderr, "%s", s);
}
-bool Platform::IsKeyDown(int) {
- // TODO: discover state of keys in GTK+/X
- return false;
-}
-
-long Platform::SendScintilla(
- WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
- return scintilla_send_message(SCINTILLA(w), msg, wParam, lParam);
-}
-
-long Platform::SendScintillaPointer(
- WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
- return scintilla_send_message(SCINTILLA(w), msg, wParam,
- reinterpret_cast<sptr_t>(lParam));
-}
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch) {
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage) {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xFC));
- // Lead bytes F0 to FC may be a Microsoft addition.
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- // Korean EUC-KR may be code page 949.
- }
- return false;
-}
-
-int Platform::DBCSCharLength(int codePage, const char *s) {
- if (codePage == 932 || codePage == 936 || codePage == 950) {
- return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
- } else {
- int bytes = mblen(s, MB_CUR_MAX);
- if (bytes >= 1)
- return bytes;
- else
- return 1;
- }
-}
-
-int Platform::DBCSCharMaxLength() {
- return MB_CUR_MAX;
- //return 2;
-}
-
-// These are utility functions not really tied to a platform
-
-int Platform::Minimum(int a, int b) {
- if (a < b)
- return a;
- else
- return b;
-}
-
-int Platform::Maximum(int a, int b) {
- if (a > b)
- return a;
- else
- return b;
-}
-
//#define TRACE
#ifdef TRACE
@@ -2134,14 +2042,6 @@
abort();
}
-int Platform::Clamp(int val, int minVal, int maxVal) {
- if (val > maxVal)
- val = maxVal;
- if (val < minVal)
- val = minVal;
- return val;
-}
-
void Platform_Initialise() {
}
diff -r 7e28cdba6d61 -r 7030530a9a0f gtk/makefile
--- a/gtk/makefile Sun Jun 11 14:08:43 2017 +1000
+++ b/gtk/makefile Mon Jun 12 11:49:56 2017 +1000
@@ -78,7 +78,7 @@
CTFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS)
endif
-CXXTFLAGS:=--std=gnu++0x $(CTFLAGS) $(REFLAGS)
+CXXTFLAGS:=--std=gnu++17 $(CTFLAGS) $(REFLAGS)
CONFIGFLAGS:=$(shell pkg-config --cflags $(GTKVERSION))
MARSHALLER=scintilla-marshal.o
diff -r 7e28cdba6d61 -r 7030530a9a0f include/Platform.h
--- a/include/Platform.h Sun Jun 11 14:08:43 2017 +1000
+++ b/include/Platform.h Mon Jun 12 11:49:56 2017 +1000
@@ -109,8 +109,6 @@
}
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
-
- static Point FromLong(long lpoint);
};
/**
@@ -332,7 +330,6 @@
virtual XYPOSITION Ascent(Font &font_)=0;
virtual XYPOSITION Descent(Font &font_)=0;
virtual XYPOSITION InternalLeading(Font &font_)=0;
- virtual XYPOSITION ExternalLeading(Font &font_)=0;
virtual XYPOSITION Height(Font &font_)=0;
virtual XYPOSITION AverageCharWidth(Font &font_)=0;
@@ -376,7 +373,6 @@
WindowID GetID() const { return wid; }
bool Created() const { return wid != 0; }
void Destroy();
- bool HasFocus();
PRectangle GetPosition();
void SetPosition(PRectangle rc);
void SetPositionRelative(PRectangle rc, Window relativeTo);
@@ -387,7 +383,6 @@
virtual void SetFont(Font &font);
enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };
void SetCursor(Cursor curs);
- void SetTitle(const char *s);
PRectangle GetMonitorRect(Point pt);
private:
Cursor cursorLast;
@@ -503,34 +498,14 @@
static const char *DefaultFont();
static int DefaultFontSize();
static unsigned int DoubleClickTime();
- static bool MouseButtonBounce();
static void DebugDisplay(const char *s);
- static bool IsKeyDown(int key);
- static long SendScintilla(
- WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
- static long SendScintillaPointer(
- WindowID w, unsigned int msg, unsigned long wParam=0, void *lParam=0);
- static bool IsDBCSLeadByte(int codePage, char ch);
- static int DBCSCharLength(int codePage, const char *s);
- static int DBCSCharMaxLength();
-
- // These are utility functions not really tied to a platform
- static int Minimum(int a, int b);
- static int Maximum(int a, int b);
- // Next three assume 16 bit shorts and 32 bit longs
static long LongFromTwoShorts(short a,short b) {
return (a) | ((b) << 16);
}
- static short HighShortFromLong(long x) {
- return static_cast<short>(x >> 16);
- }
- static short LowShortFromLong(long x) {
- return static_cast<short>(x & 0xffff);
- }
+
static void DebugPrintf(const char *format, ...);
static bool ShowAssertionPopUps(bool assertionPopUps_);
static void Assert(const char *c, const char *file, int line) CLANG_ANALYZER_NORETURN;
- static int Clamp(int val, int minVal, int maxVal);
};
#ifdef NDEBUG
diff -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEdit/ScintillaEdit.pro
--- a/qt/ScintillaEdit/ScintillaEdit.pro Sun Jun 11 14:08:43 2017 +1000
+++ b/qt/ScintillaEdit/ScintillaEdit.pro Mon Jun 12 11:49:56 2017 +1000
@@ -10,18 +10,14 @@
TARGET = ScintillaEdit
TEMPLATE = lib
CONFIG += lib_bundle
-
-unix {
- # <regex> requires C++11 support
- greaterThan(QT_MAJOR_VERSION, 4){
- CONFIG += c++11
- } else {
- QMAKE_CXXFLAGS += -std=c++0x
- }
-}
+CONFIG += c++14
VERSION = 3.7.5
+win32 {
+ QMAKE_CXXFLAGS += -std:c++latest
+}
+
SOURCES += \
ScintillaEdit.cpp \
ScintillaDocument.cpp \
@@ -48,6 +44,7 @@
../../src/EditModel.cxx \
../../src/Document.cxx \
../../src/Decoration.cxx \
+ ../../src/DBCS.cxx \
../../src/ContractionState.cxx \
../../src/CharClassify.cxx \
../../src/CellBuffer.cxx \
diff -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditBase/PlatQt.cpp
--- a/qt/ScintillaEditBase/PlatQt.cpp Sun Jun 11 14:08:43 2017 +1000
+++ b/qt/ScintillaEditBase/PlatQt.cpp Mon Jun 12 11:49:56 2017 +1000
@@ -10,6 +10,7 @@
#include "PlatQt.h"
#include "Scintilla.h"
+#include "DBCS.h"
#include "FontQuality.h"
#include <QApplication>
@@ -489,7 +490,7 @@
// DBCS
int ui = 0;
for (int i=0; i<len;) {
- size_t lenChar = Platform::IsDBCSLeadByte(codePage, s[i]) ? 2 : 1;
+ size_t lenChar = DBCSIsLeadByte(codePage, s[i]) ? 2 : 1;
qreal xPosition = tl.cursorToX(ui+1);
for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
positions[i++] = xPosition;
@@ -539,12 +540,6 @@
return 0;
}
-XYPOSITION SurfaceImpl::ExternalLeading(Font &font)
-{
- QFontMetricsF metrics(*FontPointer(font), device);
- return metrics.leading();
-}
-
XYPOSITION SurfaceImpl::Height(Font &font)
{
QFontMetricsF metrics(*FontPointer(font), device);
@@ -625,11 +620,6 @@
wid = 0;
}
-bool Window::HasFocus()
-{
- return wid ? window(wid)->hasFocus() : false;
-}
-
PRectangle Window::GetPosition()
{
// Before any size allocated pretend its 1000 wide so not scrolled
@@ -725,12 +715,6 @@
}
}
-void Window::SetTitle(const char *s)
-{
- if (wid)
- window(wid)->setWindowTitle(s);
-}
-
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
window coordinates */
PRectangle Window::GetMonitorRect(Point pt)
@@ -1201,47 +1185,6 @@
return QApplication::doubleClickInterval();
}
-bool Platform::MouseButtonBounce()
-{
- return false;
-}
-
-bool Platform::IsKeyDown(int /*key*/)
-{
- return false;
-}
-
-long Platform::SendScintilla(WindowID /*w*/,
- unsigned int /*msg*/,
- unsigned long /*wParam*/,
- long /*lParam*/)
-{
- return 0;
-}
-
-long Platform::SendScintillaPointer(WindowID /*w*/,
- unsigned int /*msg*/,
- unsigned long /*wParam*/,
- void * /*lParam*/)
-{
- return 0;
-}
-
-int Platform::Minimum(int a, int b)
-{
- return qMin(a, b);
-}
-
-int Platform::Maximum(int a, int b)
-{
- return qMax(a, b);
-}
-
-int Platform::Clamp(int val, int minVal, int maxVal)
-{
- return qBound(minVal, val, maxVal);
-}
-
void Platform::DebugDisplay(const char *s)
{
qWarning("Scintilla: %s", s);
@@ -1276,51 +1219,6 @@
}
}
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch)
-{
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage) {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xEF));
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 949:
- // Korean Wansung KS C-5601-1987
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- case 1361:
- // Korean Johab KS C-5601-1992
- return
- ((uch >= 0x84) && (uch <= 0xD3)) ||
- ((uch >= 0xD8) && (uch <= 0xDE)) ||
- ((uch >= 0xE0) && (uch <= 0xF9));
- }
- return false;
-}
-
-int Platform::DBCSCharLength(int codePage, const char *s)
-{
- if (codePage == 932 || codePage == 936 || codePage == 949 ||
- codePage == 950 || codePage == 1361) {
- return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
- } else {
- return 1;
- }
-}
-
-int Platform::DBCSCharMaxLength()
-{
- return 2;
-}
-
-
//----------------------------------------------------------------------
static QElapsedTimer timer;
diff -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditBase/PlatQt.h
--- a/qt/ScintillaEditBase/PlatQt.h Sun Jun 11 14:08:43 2017 +1000
+++ b/qt/ScintillaEditBase/PlatQt.h Mon Jun 12 11:49:56 2017 +1000
@@ -106,7 +106,6 @@
XYPOSITION Ascent(Font &font) override;
XYPOSITION Descent(Font &font) override;
XYPOSITION InternalLeading(Font &font) override;
- XYPOSITION ExternalLeading(Font &font) override;
XYPOSITION Height(Font &font) override;
XYPOSITION AverageCharWidth(Font &font) override;
diff -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditBase/ScintillaEditBase.pro
--- a/qt/ScintillaEditBase/ScintillaEditBase.pro Sun Jun 11 14:08:43 2017 +1000
+++ b/qt/ScintillaEditBase/ScintillaEditBase.pro Mon Jun 12 11:49:56 2017 +1000
@@ -10,18 +10,14 @@
TARGET = ScintillaEditBase
TEMPLATE = lib
CONFIG += lib_bundle
-
-unix {
- # <regex> requires C++11 support
- greaterThan(QT_MAJOR_VERSION, 4){
- CONFIG += c++11
- } else {
- QMAKE_CXXFLAGS += -std=c++0x
- }
-}
+CONFIG += c++14
VERSION = 3.7.5
+win32 {
+ QMAKE_CXXFLAGS += -std:c++latest
+}
+
SOURCES += \
PlatQt.cpp \
ScintillaQt.cpp \
@@ -46,6 +42,7 @@
../../src/EditModel.cxx \
../../src/Document.cxx \
../../src/Decoration.cxx \
+ ../../src/DBCS.cxx \
../../src/ContractionState.cxx \
../../src/CharClassify.cxx \
../../src/CellBuffer.cxx \
diff -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditPy/ScintillaEditPy.pro
--- a/qt/ScintillaEditPy/ScintillaEditPy.pro Sun Jun 11 14:08:43 2017 +1000
+++ b/qt/ScintillaEditPy/ScintillaEditPy.pro Mon Jun 12 11:49:56 2017 +1000
@@ -6,21 +6,14 @@
# Clear debug & release so that sepbuild.pri can set one or the other
CONFIG -= debug release
+CONFIG += c++14
include(sepbuild.pri)
VERSION = $$SCINTILLA_VERSION
-unix {
- # <regex> requires C++11 support
- greaterThan(QT_MAJOR_VERSION, 4){
- CONFIG += c++11
- } else {
- QMAKE_CXXFLAGS += -std=c++0x -Wno-deprecated-declarations
- }
-}
-
win32 {
+ QMAKE_CXXFLAGS += -std:c++latest
DebugBuild {
TARGET_EXT = _d.pyd
}
diff -r 7e28cdba6d61 -r 7030530a9a0f scripts/HeaderOrder.txt
--- a/scripts/HeaderOrder.txt Sun Jun 11 14:08:43 2017 +1000
+++ b/scripts/HeaderOrder.txt Mon Jun 12 11:49:56 2017 +1000
@@ -129,6 +129,7 @@
#include "CaseConvert.h"
#include "UniConversion.h"
#include "UnicodeFromUTF8.h"
+#include "DBCS.h"
#include "Selection.h"
#include "PositionCache.h"
#include "FontQuality.h"
diff -r 7e28cdba6d61 -r 7030530a9a0f src/DBCS.cxx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/DBCS.cxx Mon Jun 12 11:49:56 2017 +1000
@@ -0,0 +1,48 @@
+// Scintilla source code edit control
+/** @file DBCS.cxx
+ ** Functions to handle DBCS double byte encodings like Shift-JIS.
+ **/
+// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include "DBCS.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+bool DBCSIsLeadByte(int codePage, char ch) {
+ // Byte ranges found in Wikipedia articles with relevant search strings in each case
+ const unsigned char uch = static_cast<unsigned char>(ch);
+ switch (codePage) {
+ case 932:
+ // Shift_jis
+ return ((uch >= 0x81) && (uch <= 0x9F)) ||
+ ((uch >= 0xE0) && (uch <= 0xFC));
+ // Lead bytes F0 to FC may be a Microsoft addition.
+ case 936:
+ // GBK
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 949:
+ // Korean Wansung KS C-5601-1987
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 950:
+ // Big5
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 1361:
+ // Korean Johab KS C-5601-1992
+ return
+ ((uch >= 0x84) && (uch <= 0xD3)) ||
+ ((uch >= 0xD8) && (uch <= 0xDE)) ||
+ ((uch >= 0xE0) && (uch <= 0xF9));
+ }
+ return false;
+}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
diff -r 7e28cdba6d61 -r 7030530a9a0f src/DBCS.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/DBCS.h Mon Jun 12 11:49:56 2017 +1000
@@ -0,0 +1,21 @@
+// Scintilla source code edit control
+/** @file DBCS.h
+ ** Functions to handle DBCS double byte encodings like Shift-JIS.
+ **/
+// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef DBCS_H
+#define DBCS_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+bool DBCSIsLeadByte(int codePage, char ch);
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif
diff -r 7e28cdba6d61 -r 7030530a9a0f src/Document.cxx
--- a/src/Document.cxx Sun Jun 11 14:08:43 2017 +1000
+++ b/src/Document.cxx Mon Jun 12 11:49:56 2017 +1000
@@ -564,7 +564,7 @@
}
Sci::Position Document::ClampPositionIntoDocument(Sci::Position pos) const {
- return Platform::Clamp(pos, 0, Length());
+ return Sci::clamp(pos, 0, Length());
}
bool Document::IsCrLf(Sci::Position pos) const {
diff -r 7e28cdba6d61 -r 7030530a9a0f src/Editor.cxx
--- a/src/Editor.cxx Sun Jun 11 14:08:43 2017 +1000
+++ b/src/Editor.cxx Mon Jun 12 11:49:56 2017 +1000
@@ -888,10 +888,10 @@
Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
if (moveDir > 0) {
// lineDisplay is already line before fold as lines in fold use display line of line after fold
- lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
+ lineDisplay = Sci::clamp(lineDisplay, 0, cs.LinesDisplayed());
return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay)));
} else {
- lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed());
+ lineDisplay = Sci::clamp(lineDisplay - 1, 0, cs.LinesDisplayed());
return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay)));
}
}
@@ -915,7 +915,7 @@
}
void Editor::ScrollTo(Sci::Line line, bool moveThumb) {
- const Sci::Line topLineNew = Platform::Clamp(line, 0, MaxScrollPos());
+ const Sci::Line topLineNew = Sci::clamp(line, 0, MaxScrollPos());
if (topLineNew != topLine) {
// Try to optimise small scrolls
#ifndef UNDER_CE
@@ -1154,7 +1154,7 @@
} else {
// yMarginT must equal to caretYSlop, with a minimum of 1 and
// a maximum of slightly less than half the heigth of the text area.
- yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen);
+ yMarginT = Sci::clamp(caretYSlop, 1, halfScreen);
if (bEven) {
yMarginB = yMarginT;
} else {
@@ -1164,7 +1164,7 @@
yMoveT = yMarginT;
if (bEven) {
if (bJump) {
- yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen);
+ yMoveT = Sci::clamp(caretYSlop * 3, 1, halfScreen);
}
yMoveB = yMoveT;
} else {
@@ -1179,7 +1179,7 @@
}
} else { // Not strict
yMoveT = bJump ? caretYSlop * 3 : caretYSlop;
- yMoveT = Platform::Clamp(yMoveT, 1, halfScreen);
+ yMoveT = Sci::clamp(yMoveT, 1, halfScreen);
if (bEven) {
yMoveB = yMoveT;
} else {
@@ -1229,7 +1229,7 @@
newXY.topLine = std::min(newXY.topLine, lineCaret);
}
}
- newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos());
+ newXY.topLine = Sci::clamp(newXY.topLine, 0, MaxScrollPos());
}
// Horizontal positioning
@@ -1251,7 +1251,7 @@
} else {
// xMargin must equal to caretXSlop, with a minimum of 2 and
// a maximum of slightly less than half the width of the text area.
- xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen);
+ xMarginR = Sci::clamp(caretXSlop, 2, halfScreen);
if (bEven) {
xMarginL = xMarginR;
} else {
@@ -1260,7 +1260,7 @@
}
if (bJump && bEven) {
// Jump is used only in even mode
- xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen);
+ xMoveL = xMoveR = Sci::clamp(caretXSlop * 3, 1, halfScreen);
} else {
xMoveL = xMoveR = 0; // Not used, avoid a warning
}
@@ -1283,7 +1283,7 @@
}
} else { // Not strict
xMoveR = bJump ? caretXSlop * 3 : caretXSlop;
- xMoveR = Platform::Clamp(xMoveR, 1, halfScreen);
+ xMoveR = Sci::clamp(xMoveR, 1, halfScreen);
if (bEven) {
xMoveL = xMoveR;
} else {
@@ -1505,7 +1505,7 @@
const Sci::Line lineDocTop = cs.DocFromDisplay(topLine);
const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);
if (ws == wsVisible) {
- lineToWrap = Platform::Clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());
+ lineToWrap = Sci::clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());
// Priority wrap to just after visible area.
// Since wrapping could reduce display lines, treat each
// as taking only one display line.
@@ -1561,7 +1561,7 @@
if (wrapOccurred) {
SetScrollBars();
- SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(goodTopLine, 0, MaxScrollPos()));
SetVerticalScrollPos();
}
@@ -1816,7 +1816,7 @@
// TODO: ensure always showing as many lines as possible
// May not be, if, for example, window made larger
if (topLine > MaxScrollPos()) {
- SetTopLine(Platform::Clamp(topLine, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(topLine, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
@@ -2641,7 +2641,7 @@
if (mh.linesAdded != 0) {
// Avoid scrolling of display if change before current display
if (mh.position < posTopLine && !CanDeferToLastStep(mh)) {
- Sci::Line newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos());
+ Sci::Line newTop = Sci::clamp(topLine + mh.linesAdded, 0, MaxScrollPos());
if (newTop != topLine) {
SetTopLine(newTop);
SetVerticalScrollPos();
@@ -2877,7 +2877,7 @@
} else {
Point pt = LocationFromPosition(sel.MainCaret());
- topLineNew = Platform::Clamp(
+ topLineNew = Sci::clamp(
topLine + direction * LinesToScroll(), 0, MaxScrollPos());
newPos = SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())),
@@ -3209,6 +3209,14 @@
namespace {
+short HighShortFromLong(long x) {
+ return static_cast<short>(x >> 16);
+}
+
+short LowShortFromLong(long x) {
+ return static_cast<short>(x & 0xffff);
+}
+
unsigned int WithExtends(unsigned int iMessage) {
switch (iMessage) {
case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND;
@@ -4470,30 +4478,27 @@
if (!ctrl || !multipleSelection || (selectionType != selChar && selectionType != selWord))
SetEmptySelection(newPos.Position());
bool doubleClick = false;
- // Stop mouse button bounce changing selection type
- if (!Platform::MouseButtonBounce() || curTime != lastClickTime) {
- if (inSelMargin) {
- // Inside margin selection type should be either selSubLine or selWholeLine.
- if (selectionType == selSubLine) {
- // If it is selSubLine, we're inside a *double* click and word wrap is enabled,
- // so we switch to selWholeLine in order to select whole line.
- selectionType = selWholeLine;
- } else if (selectionType != selSubLine && selectionType != selWholeLine) {
- // If it is neither, reset selection type to line selection.
- selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
- }
+ if (inSelMargin) {
+ // Inside margin selection type should be either selSubLine or selWholeLine.
+ if (selectionType == selSubLine) {
+ // If it is selSubLine, we're inside a *double* click and word wrap is enabled,
+ // so we switch to selWholeLine in order to select whole line.
+ selectionType = selWholeLine;
+ } else if (selectionType != selSubLine && selectionType != selWholeLine) {
+ // If it is neither, reset selection type to line selection.
+ selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+ }
+ } else {
+ if (selectionType == selChar) {
+ selectionType = selWord;
+ doubleClick = true;
+ } else if (selectionType == selWord) {
+ // Since we ended up here, we're inside a *triple* click, which should always select
+ // whole line regardless of word wrap being enabled or not.
+ selectionType = selWholeLine;
} else {
- if (selectionType == selChar) {
- selectionType = selWord;
- doubleClick = true;
- } else if (selectionType == selWord) {
- // Since we ended up here, we're inside a *triple* click, which should always select
- // whole line regardless of word wrap being enabled or not.
- selectionType = selWholeLine;
- } else {
- selectionType = selChar;
- originalAnchorPos = sel.MainCaret();
- }
+ selectionType = selChar;
+ originalAnchorPos = sel.MainCaret();
}
}
@@ -5082,7 +5087,7 @@
// When scrolling, allow less time to ensure responsive
const double secondsAllowed = scrolling ? 0.005 : 0.02;
- const Sci::Line linesToStyle = Platform::Clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
+ const Sci::Line linesToStyle = Sci::clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
10, 0x10000);
const Sci::Line stylingMaxLine = std::min(
static_cast<Sci::Line>(pdoc->LineFromPosition(pdoc->GetEndStyled()) + linesToStyle),
@@ -5426,18 +5431,18 @@
const Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
if (visiblePolicy & VISIBLE_SLOP) {
if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) {
- SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(lineDisplay - visibleSlop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||
((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) {
- SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
} else {
if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) {
- SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
@@ -6040,7 +6045,7 @@
return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) + 1, 1, true);
case SCI_POSITIONRELATIVE:
- return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());
+ return Sci::clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());
case SCI_LINESCROLL:
ScrollTo(topLine + static_cast<Sci::Line>(lParam));
@@ -7290,13 +7295,13 @@
return vs.caretWidth;
case SCI_ASSIGNCMDKEY:
- kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
- Platform::HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));
+ kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)),
+ HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));
break;
case SCI_CLEARCMDKEY:
- kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
- Platform::HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);
+ kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)),
+ HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);
break;
case SCI_CLEARALLCMDKEYS:
diff -r 7e28cdba6d61 -r 7030530a9a0f src/Position.h
--- a/src/Position.h Sun Jun 11 14:08:43 2017 +1000
+++ b/src/Position.h Mon Jun 12 11:49:56 2017 +1000
@@ -25,6 +25,14 @@
const Position invalidPosition = -1;
+inline int clamp(int val, int minVal, int maxVal) {
+ if (val > maxVal)
+ val = maxVal;
+ if (val < minVal)
+ val = minVal;
+ return val;
+}
+
}
#endif
diff -r 7e28cdba6d61 -r 7030530a9a0f src/ViewStyle.cxx
--- a/src/ViewStyle.cxx Sun Jun 11 14:08:43 2017 +1000
+++ b/src/ViewStyle.cxx Mon Jun 12 11:49:56 2017 +1000
@@ -460,7 +460,7 @@
}
int ViewStyle::GetFrameWidth() const {
- return Platform::Clamp(caretLineFrame, 1, lineHeight / 3);
+ return Sci::clamp(caretLineFrame, 1, lineHeight / 3);
}
bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const {
diff -r 7e28cdba6d61 -r 7030530a9a0f win32/PlatWin.cxx
--- a/win32/PlatWin.cxx Sun Jun 11 14:08:43 2017 +1000
+++ b/win32/PlatWin.cxx Mon Jun 12 11:49:56 2017 +1000
@@ -46,6 +46,7 @@
#include "StringCopy.h"
#include "XPM.h"
#include "UniConversion.h"
+#include "DBCS.h"
#include "FontQuality.h"
#ifndef SPI_GETFONTSMOOTHINGCONTRAST
@@ -75,10 +76,6 @@
namespace Scintilla {
#endif
-Point Point::FromLong(long lpoint) {
- return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint)));
-}
-
static RECT RectFromPRectangle(PRectangle prc) {
RECT rc = {static_cast<LONG>(prc.left), static_cast<LONG>(prc.top),
static_cast<LONG>(prc.right), static_cast<LONG>(prc.bottom)};
@@ -558,7 +555,6 @@
XYPOSITION Ascent(Font &font_) override;
XYPOSITION Descent(Font &font_) override;
XYPOSITION InternalLeading(Font &font_) override;
- XYPOSITION ExternalLeading(Font &font_) override;
XYPOSITION Height(Font &font_) override;
XYPOSITION AverageCharWidth(Font &font_) override;
@@ -1010,13 +1006,6 @@
return static_cast<XYPOSITION>(tm.tmInternalLeading);
}
-XYPOSITION SurfaceGDI::ExternalLeading(Font &font_) {
- SetFont(font_);
- TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
- return static_cast<XYPOSITION>(tm.tmExternalLeading);
-}
-
XYPOSITION SurfaceGDI::Height(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
@@ -1121,7 +1110,6 @@
XYPOSITION Ascent(Font &font_) override;
XYPOSITION Descent(Font &font_) override;
XYPOSITION InternalLeading(Font &font_) override;
- XYPOSITION ExternalLeading(Font &font_) override;
XYPOSITION Height(Font &font_) override;
XYPOSITION AverageCharWidth(Font &font_) override;
@@ -1671,7 +1659,7 @@
int ui = 0;
for (int i=0; i<len && ui<tbuf.tlen;) {
positions[i] = poses.buffer[ui];
- if (Platform::IsDBCSLeadByte(codePageText, s[i])) {
+ if (DBCSIsLeadByte(codePageText, s[i])) {
positions[i+1] = poses.buffer[ui];
i += 2;
} else {
@@ -1716,11 +1704,6 @@
return floor(yInternalLeading);
}
-XYPOSITION SurfaceD2D::ExternalLeading(Font &) {
- // Not implemented, always return one
- return 1;
-}
-
XYPOSITION SurfaceD2D::Height(Font &font_) {
return Ascent(font_) + Descent(font_);
}
@@ -1786,10 +1769,6 @@
wid = 0;
}
-bool Window::HasFocus() {
- return ::GetFocus() == wid;
-}
-
PRectangle Window::GetPosition() {
RECT rc;
::GetWindowRect(static_cast<HWND>(wid), &rc);
@@ -1952,10 +1931,6 @@
}
}
-void Window::SetTitle(const char *s) {
- ::SetWindowTextA(static_cast<HWND>(wid), s);
-}
-
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
coordinates */
PRectangle Window::GetMonitorRect(Point pt) {
@@ -3024,85 +2999,10 @@
return ::GetDoubleClickTime();
}
-bool Platform::MouseButtonBounce() {
- return false;
-}
-
void Platform::DebugDisplay(const char *s) {
::OutputDebugStringA(s);
}
-bool Platform::IsKeyDown(int key) {
- return (::GetKeyState(key) & 0x80000000) != 0;
-}
-
-long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
- // This should never be called - its here to satisfy an old interface
- return static_cast<long>(::SendMessage(static_cast<HWND>(w), msg, wParam, lParam));
-}
-
-long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
- // This should never be called - its here to satisfy an old interface
- return static_cast<long>(::SendMessage(static_cast<HWND>(w), msg, wParam,
- reinterpret_cast<LPARAM>(lParam)));
-}
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch) {
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- const unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage) {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xEF));
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 949:
- // Korean Wansung KS C-5601-1987
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- case 1361:
- // Korean Johab KS C-5601-1992
- return
- ((uch >= 0x84) && (uch <= 0xD3)) ||
- ((uch >= 0xD8) && (uch <= 0xDE)) ||
- ((uch >= 0xE0) && (uch <= 0xF9));
- }
- return false;
-}
-
-int Platform::DBCSCharLength(int codePage, const char *s) {
- if (codePage == 932 || codePage == 936 || codePage == 949 ||
- codePage == 950 || codePage == 1361) {
- return Platform::IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
- } else {
- return 1;
- }
-}
-
-int Platform::DBCSCharMaxLength() {
- return 2;
-}
-
-// These are utility functions not really tied to a platform
-
-int Platform::Minimum(int a, int b) {
- if (a < b)
- return a;
- else
- return b;
-}
-
-int Platform::Maximum(int a, int b) {
- if (a > b)
- return a;
- else
- return b;
-}
-
//#define TRACE
#ifdef TRACE
@@ -3147,14 +3047,6 @@
}
}
-int Platform::Clamp(int val, int minVal, int maxVal) {
- if (val > maxVal)
- val = maxVal;
- if (val < minVal)
- val = minVal;
- return val;
-}
-
void Platform_Initialise(void *hInstance) {
::InitializeCriticalSection(&crPlatformLock);
hinstPlatformRes = static_cast<HINSTANCE>(hInstance);
diff -r 7e28cdba6d61 -r 7030530a9a0f win32/ScintillaWin.cxx
--- a/win32/ScintillaWin.cxx Sun Jun 11 14:08:43 2017 +1000
+++ b/win32/ScintillaWin.cxx Mon Jun 12 11:49:56 2017 +1000
@@ -156,6 +156,14 @@
return Point::FromInts(pt.x, pt.y);
}
+static Point PointFromLong(long lpoint) {
+ return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint)));
+}
+
+static bool KeyboardIsKeyDown(int key) {
+ return (::GetKeyState(key) & 0x80000000) != 0;
+}
+
class ScintillaWin; // Forward declaration for COM interface subobjects
typedef void VFunction(void);
@@ -1376,19 +1384,19 @@
::ImmNotifyIME(imc.hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
//
//Platform::DebugPrintf("Buttdown %d %x %x %x %x %x\n",iMessage, wParam, lParam,
- // Platform::IsKeyDown(VK_SHIFT),
- // Platform::IsKeyDown(VK_CONTROL),
- // Platform::IsKeyDown(VK_MENU));
+ // KeyboardIsKeyDown(VK_SHIFT),
+ // KeyboardIsKeyDown(VK_CONTROL),
+ // KeyboardIsKeyDown(VK_MENU));
::SetFocus(MainHWND());
- ButtonDown(Point::FromLong(static_cast<long>(lParam)), ::GetMessageTime(),
+ ButtonDown(PointFromLong(static_cast<long>(lParam)), ::GetMessageTime(),
(wParam & MK_SHIFT) != 0,
(wParam & MK_CONTROL) != 0,
- Platform::IsKeyDown(VK_MENU));
+ KeyboardIsKeyDown(VK_MENU));
}
break;
case WM_MOUSEMOVE: {
- const Point pt = Point::FromLong(static_cast<long>(lParam));
+ const Point pt = PointFromLong(static_cast<long>(lParam));
// Windows might send WM_MOUSEMOVE even though the mouse has not been moved:
// http://blogs.msdn.com/b/oldnewthing/archive/2003/10/01/55108.aspx
@@ -1397,7 +1405,7 @@
ButtonMoveWithModifiers(pt,
((wParam & MK_SHIFT) != 0 ? SCI_SHIFT : 0) |
((wParam & MK_CONTROL) != 0 ? SCI_CTRL : 0) |
- (Platform::IsKeyDown(VK_MENU) ? SCI_ALT : 0));
+ (KeyboardIsKeyDown(VK_MENU) ? SCI_ALT : 0));
}
}
break;
@@ -1408,22 +1416,22 @@
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_LBUTTONUP:
- ButtonUp(Point::FromLong(static_cast<long>(lParam)),
+ ButtonUp(PointFromLong(static_cast<long>(lParam)),
::GetMessageTime(),
(wParam & MK_CONTROL) != 0);
break;
case WM_RBUTTONDOWN: {
::SetFocus(MainHWND());
- Point pt = Point::FromLong(static_cast<long>(lParam));
+ Point pt = PointFromLong(static_cast<long>(lParam));
if (!PointInSelection(pt)) {
CancelModes();
- SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast<long>(lParam))));
+ SetEmptySelection(PositionFromLocation(PointFromLong(static_cast<long>(lParam))));
}
RightButtonDownWithModifiers(pt, ::GetMessageTime(), ModifierFlags((wParam & MK_SHIFT) != 0,
(wParam & MK_CONTROL) != 0,
- Platform::IsKeyDown(VK_MENU)));
+ KeyboardIsKeyDown(VK_MENU)));
}
break;
@@ -1487,9 +1495,9 @@
//Platform::DebugPrintf("S keydown %d %x %x %x %x\n",iMessage, wParam, lParam, ::IsKeyDown(VK_SHIFT), ::IsKeyDown(VK_CONTROL));
lastKeyDownConsumed = false;
const int ret = KeyDown(KeyTranslate(static_cast<int>(wParam)),
- Platform::IsKeyDown(VK_SHIFT),
- Platform::IsKeyDown(VK_CONTROL),
- Platform::IsKeyDown(VK_MENU),
+ KeyboardIsKeyDown(VK_SHIFT),
+ KeyboardIsKeyDown(VK_CONTROL),
+ KeyboardIsKeyDown(VK_MENU),
&lastKeyDownConsumed);
if (!ret && !lastKeyDownConsumed) {
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
@@ -1573,7 +1581,7 @@
}
case WM_CONTEXTMENU: {
- Point pt = Point::FromLong(static_cast<long>(lParam));
+ Point pt = PointFromLong(static_cast<long>(lParam));
POINT rpt = {static_cast<int>(pt.x), static_cast<int>(pt.y)};
::ScreenToClient(MainHWND(), &rpt);
const Point ptClient = PointFromPOINT(rpt);
@@ -3350,7 +3358,7 @@
return 0;
} else if (iMessage == WM_LBUTTONDOWN) {
// This does not fire due to the hit test code
- sciThis->ct.MouseClick(Point::FromLong(static_cast<long>(lParam)));
+ sciThis->ct.MouseClick(PointFromLong(static_cast<long>(lParam)));
sciThis->CallTipClick();
return 0;
} else if (iMessage == WM_SETCURSOR) {
diff -r 7e28cdba6d61 -r 7030530a9a0f win32/makefile
--- a/win32/makefile Sun Jun 11 14:08:43 2017 +1000
+++ b/win32/makefile Mon Jun 12 11:49:56 2017 +1000
@@ -13,7 +13,7 @@
LDMINGW = -Wl,--enable-runtime-pseudo-reloc-v2 -Wl,--add-stdcall-alias
LIBSMINGW = -lstdc++
STRIPOPTION = -s
-CXXSTD = gnu++0x
+CXXSTD = gnu++17
endif
.SUFFIXES: .cxx
@@ -83,6 +83,7 @@
CharacterSet.o \
CharClassify.o \
ContractionState.o \
+ DBCS.o \
Decoration.o \
Document.o \
EditModel.o \
diff -r 7e28cdba6d61 -r 7030530a9a0f win32/scintilla.mak
--- a/win32/scintilla.mak Sun Jun 11 14:08:43 2017 +1000
+++ b/win32/scintilla.mak Mon Jun 12 11:49:56 2017 +1000
@@ -25,7 +25,7 @@
!ENDIF
CRTFLAGS=-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 -D_CRT_SECURE_NO_DEPRECATE=1 -D_SCL_SECURE_NO_WARNINGS=1 $(XP_DEFINE)
-CXXFLAGS=-Zi -TP -MP -W4 -EHsc $(CRTFLAGS)
+CXXFLAGS=-Zi -TP -MP -W4 -EHsc -std:c++latest $(CRTFLAGS)
CXXDEBUG=-Od -MTd -DDEBUG
CXXNDEBUG=-O1 -MT -DNDEBUG -GL
NAME=-Fo
@@ -75,6 +75,7 @@
$(DIR_O)\CharacterSet.obj \
$(DIR_O)\CharClassify.obj \
$(DIR_O)\ContractionState.obj \
+ $(DIR_O)\DBCS.obj \
$(DIR_O)\Decoration.obj \
$(DIR_O)\Document.obj \
$(DIR_O)\EditModel.obj \
|