-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathScintillaCtrl.cpp
5743 lines (4633 loc) · 196 KB
/
ScintillaCtrl.cpp
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
/*
Module : ScintillaCtrl.cpp
Purpose: Defines the implementation for an MFC wrapper class for the Scintilla edit control (www.scintilla.org)
Created: PJN / 19-03-2004
History: PJN / 19-03-2004 1. Initial implementation synchronized to the v1.59 release of Scintilla
PJN / 19-03-2004 1. Updated the sample app's Find Next and Find Previous marker functions. Now correctly
goes to the next and previous markers when a marker is on the current line.
2. Updated the sample app's passing of messages to Scintilla from the top level
CMainFrame window
PJN / 06-06-2004 1. Updated class to work with Scintilla v1.61
PJN / 20-12-2004 1. Updated class to work with Scintilla v1.62.
2. Sample app now includes a common control 6 manifest
3. Sample app now includes an example of scintilla autocompletion. When you type
"scintilla is " case insensitively a autocompletion list is displayed which allows
"very cool", "easy" or "way cool!!" to be entered.
4. Sample app now includes an example of scintilla calltips. Whenever you hover
over text which is "author " case insensitively, a call tip with the text
"PJ Naughter" is displayed.
PJN / 10-07-2005 1. Updated class to work with Scintilla v1.64.
2. Fixed a number of warnings when the code is compiled using Visual Studio .NET 2003.
PJN / 03-01-2006.1. Updated class to work with Scintilla v1.67. New messages wrapped include:
SCI_MARKERADDSET, SCI_SETPASTECONVERTENDINGS, SCI_GETPASTECONVERTENDINGS,
SCI_SELECTIONDUPLICATE and SCI_GETSTYLEBITSNEEDED.
2. Updated copyright messages
PJN / 14-03-2006 1. Updated class to work with Scintilla v1.68. New messages wrapped include:
SCI_CALLTIPUSESTYLE, SCI_SETCARETLINEBACKALPHA and SCI_GETCARETLINEBACKALPHA.
PJN / 05-06-2006 1. Updated class to work with Scintilla v1.69. New messages wrapped include:
SCI_MARKERSETALPHA, SCI_GETSELALPHA and SCI_SETSELALPHA.
PJN / 06-06-2006 1. Updated the wrapper class to work correctly when compiled for Unicode.
PJN / 29-06-2006 1. Code now uses new C++ style casts rather than old style C casts where necessary.
2. Optimized CScintillaCtrl constructor code
3. Updated the code to clean compile in VC 2005
4. Fixed a bug in the sample program when you invoke Print Preview when compiled
using VC 2005
PJN / 27-07-2006 1. Minor update to the sample app to fix an ASSERT related to the formatting of the
IDR_SCINTITYPE string resource. Thanks to Matt Spear for reporting this issue.
PJN / 17-09-2006 1. Fixed a bug in UTF82W (and W2UTF8) where if GetLine is called in a Unicode build
for the end of the file (i.e. a line having a length of 0), the UTF82W function would
allocate no buffer, but still erroneously write a one character terminating null. In
addition, the caller (GetLine) will try to deallocate the buffer that was never
allocated. Thanks to Scott Kelley for spotting this nasty bug.
2. Added of a GetLineEx method which explicitly sets the first WORD value in the text
string to the maximum size. This avoids client code from having to deal with the
weird semantics of the EM_GETLINE message. Thanks to Scott Kelley for providing this
nice addition.
3. Verified code implements all the functionality of Scintilla v1.71
PJN / 11-06-2007 1. Updated copyright details.
2. CScintillaCtrl::GetSelText now uses CString::GetBufferSetLength to avoid having to
allocate an intermediate buffer. Thanks to Jochen Neubeck for reporting this
optimization
3. Addition of a SCINTILLACTRL_EXT_CLASS preprocessor macro to allow the classes to be
more easily used in an extension DLL.
4. Updated class to work with Scintilla v1.73. New messages wrapped include:
SCI_STYLEGETFORE, SCI_STYLEGETBACK, SCI_STYLEGETBOLD, SCI_STYLEGETITALIC, SCI_STYLEGETSIZE,
SCI_STYLEGETFONT, SCI_STYLEGETEOLFILLED, SCI_STYLEGETUNDERLINE, SCI_STYLEGETCASE,
SCI_STYLEGETCHARACTERSET, SCI_STYLEGETVISIBLE, SCI_STYLEGETCHANGEABLE, SCI_STYLEGETHOTSPOT,
SCI_GETSELEOLFILLED, SCI_SETSELEOLFILLED, SCI_GETHOTSPOTACTIVEFORE, SCI_GETHOTSPOTACTIVEBACK,
SCI_GETHOTSPOTACTIVEUNDERLINE & SCI_GETHOTSPOTSINGLELINE
PJN / 28-11-2007 1. Updated class to work with Scintilla v1.75. New messages wrapped include: SCI_INDICSETUNDER,
SCI_INDICGETUNDER, new behavior for SCI_SETINDENTATIONGUIDES & SCI_GETINDENTATIONGUIDES,
SCI_SETSCROLLWIDTHTRACKING, SCI_GETSCROLLWIDTHTRACKING, SCI_DELWORDRIGHTEND, SCI_SETCARETSTYLE,
SCI_GETCARETSTYLE, SCI_SETINDICATORCURRENT, SCI_SETINDICATORVALUE, SCI_INDICATORFILLRANGE,
SCI_INDICATORCLEARRANGE, SCI_INDICATORALLONFOR, SCI_INDICATORVALUEAT, SCI_INDICATORSTART,
SCI_INDICATOREND, SCI_SETPOSITIONCACHE & SCI_GETPOSITIONCACHE.
2. The auto completion sample in CScintillaDemoView::OnCharAdded has been extended to show
another style of auto completion. Thanks to Alessandro Limonta for suggesting this update.
PJN / 19-03-2008 1. Updated class to work with Scintilla v1.76. New messages wrapped include: SCI_COPYALLOWLINE.
2. Updated copyright details.
3. Updated code to clean compile on VC 2008.
4. Removed VC 6 style classwizard comments from the code.
5. Updated the sample apps document icon.
6. Fixed a level 4 warning when the code is compiled on VC 6.
PJN / 15-06-2008 1. Code now compiles cleanly using Code Analysis (/analyze)
2. Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS define
3. The code now only supports VC 2005 or later.
PJN / 01-11-2008 1. Updated class to work with Scintilla v1.77. New messages wrapped include:
SCI_GETCHARACTERPOINTER, SCI_SETKEYSUNICODE & SCI_GETKEYSUNICODE
2. Reworked all the key Unicode functions which expose string length management and
reimplemented them to use CScintillaCtrl::StringW output parameters. Equivalent ASCII versions have also been
provided. This new approach helps to raise the level of abstraction provided by the wrapper
class. In the process the need for the GetLineEx function has been removed. Thanks to Alexei
Letov for prompting this update.
PJN / 20-01-2009 1. Updated copyright details.
PJN / 03-10-2009 1. Fixed a bug in CScintillaCtrl::Create where a crash can occur in a Unicode build if the CreateEx
call fails (for example, if the Scintilla DLL was not loaded). Thanks to Simon Smith for reporting
this bug
2. Updated class to work with Scintilla v2.01. New messages wrapped include:
SCI_SETWRAPINDENTMODE, SCI_GETWRAPINDENTMODE, SCI_INDICSETALPHA, SCI_INDICGETALPHA, SCI_SETEXTRAASCENT,
SCI_GETEXTRAASCENT, SCI_SETEXTRADESCENT, SCI_GETEXTRADESCENT, SCI_MARKERSYMBOLDEFINED, SCI_MARGINSETTEXT,
SCI_MARGINGETTEXT, SCI_MARGINSETSTYLE, SCI_MARGINGETSTYLE, SCI_MARGINSETSTYLES, SCI_MARGINGETSTYLES,
SCI_MARGINTEXTCLEARALL, SCI_MARGINSETSTYLEOFFSET, SCI_MARGINGETSTYLEOFFSET, SCI_ANNOTATIONSETTEXT,
SCI_ANNOTATIONGETTEXT, SCI_ANNOTATIONSETSTYLE, SCI_ANNOTATIONGETSTYLE, SCI_ANNOTATIONSETSTYLES,
SCI_ANNOTATIONGETSTYLES, SCI_ANNOTATIONGETLINES, SCI_ANNOTATIONCLEARALL, SCI_ANNOTATIONSETVISIBLE,
SCI_ANNOTATIONGETVISIBLE, SCI_ANNOTATIONSETSTYLEOFFSET, SCI_ANNOTATIONGETSTYLEOFFSET,
SCI_ADDUNDOACTION, SCI_CHARPOSITIONFROMPOINT, SCI_CHARPOSITIONFROMPOINTCLOSE, SCI_SETMULTIPLESELECTION,
SCI_GETMULTIPLESELECTION, SCI_SETADDITIONALSELECTIONTYPING, SCI_GETADDITIONALSELECTIONTYPING,
SCI_SETADDITIONALCARETSBLINK, SCI_GETADDITIONALCARETSBLINK, SCI_GETSELECTIONS, SCI_CLEARSELECTIONS,
SCI_SETSELECTION, SCI_ADDSELECTION, SCI_SETMAINSELECTION, SCI_GETMAINSELECTION, SCI_SETSELECTIONNCARET,
SCI_GETSELECTIONNCARET, SCI_SETSELECTIONNANCHOR, SCI_GETSELECTIONNANCHOR, SCI_SETSELECTIONNCARETVIRTUALSPACE,
SCI_GETSELECTIONNCARETVIRTUALSPACE, SCI_SETSELECTIONNANCHORVIRTUALSPACE, SCI_GETSELECTIONNANCHORVIRTUALSPACE,
SCI_SETSELECTIONNSTART, SCI_GETSELECTIONNSTART, SCI_SETSELECTIONNEND, SCI_GETSELECTIONNEND,
SCI_SETRECTANGULARSELECTIONCARET, SCI_GETRECTANGULARSELECTIONCARET, SCI_SETRECTANGULARSELECTIONANCHOR,
SCI_GETRECTANGULARSELECTIONANCHOR, SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE, SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE,
SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE, SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE,
SCI_SETVIRTUALSPACEOPTIONS, SCI_GETVIRTUALSPACEOPTIONS, SCI_SETRECTANGULARSELECTIONMODIFIER,
SCI_GETRECTANGULARSELECTIONMODIFIER, SCI_SETADDITIONALSELFORE, SCI_SETADDITIONALSELBACK, SCI_SETADDITIONALSELALPHA,
SCI_GETADDITIONALSELALPHA, SCI_SETADDITIONALCARETFORE, SCI_GETADDITIONALCARETFORE, SCI_ROTATESELECTION &
SCI_SWAPMAINANCHORCARET
PJN / 22-11-2010 1. Updated copyright details.
2. Updated sample app to clean compile on VC 2010
3. Updated class to work with Scintilla v2.22. New messages wrapped include:
SCI_SETWHITESPACESIZE, SCI_GETWHITESPACESIZE, SCI_SETFONTQUALITY, SCI_GETFONTQUALITY, SCI_SETFIRSTVISIBLELINE,
SCI_SETMULTIPASTE, SCI_GETMULTIPASTE, SCI_GETTAG, SCI_AUTOCGETCURRENTTEXT, SCI_SETADDITIONALCARETSVISIBLE,
SCI_GETADDITIONALCARETSVISIBLE, SCI_CHANGELEXERSTATE, SCI_CONTRACTEDFOLDNEXT, SCI_VERTICALCENTRECARET,
SCI_GETLEXERLANGUAGE, SCI_PRIVATELEXERCALL, SCI_PROPERTYNAMES, SCI_PROPERTYTYPE, SCI_DESCRIBEPROPERTY,
SCI_DESCRIBEKEYWORDSETS. Also there were some parameter changes to existing messages.
PJN / 01-04-2011 1. Updated copyright details.
2. Updated class to work with Scintilla v2.25. New messages wrapped include:
SCI_SETMARGINCURSORN & SCI_GETMARGINCURSORN
PJN / 09-12-2011 1. Updated class to work with Scintilla v3.0.2. New messages wrapped include: SCI_MARKERSETBACKSELECTED,
SCI_MARKERENABLEHIGHLIGHT, SCI_STYLESETSIZEFRACTIONAL, SCI_STYLEGETSIZEFRACTIONAL, SCI_STYLESETWEIGHT,
SCI_STYLEGETWEIGHT, SCI_COUNTCHARACTERS, SCI_SETEMPTYSELECTION, SCI_CALLTIPSETPOSITION, SCI_GETALLLINESVISIBLE,
SCI_BRACEHIGHLIGHTINDICATOR, SCI_BRACEBADLIGHTINDICATOR, SCI_INDICSETOUTLINEALPHA, SCI_INDICGETOUTLINEALPHA,
SCI_SETMARGINOPTIONS, SCI_GETMARGINOPTIONS, SCI_MOVESELECTEDLINESUP, SCI_MOVESELECTEDLINESDOWN, SCI_SETIDENTIFIER,
SCI_GETIDENTIFIER, SCI_RGBAIMAGESETWIDTH, SCI_RGBAIMAGESETHEIGHT, SCI_MARKERDEFINERGBAIMAGE, SCI_REGISTERRGBAIMAGE,
SCI_SCROLLTOSTART, SCI_SCROLLTOEND, SCI_SETTECHNOLOGY, SCI_GETTECHNOLOGY & SCI_CREATELOADER
Messages dropped include: SCI_SETUSEPALETTE & SCI_GETUSEPALETTE
PJN / 15-08-2012 1. Updated copyright details
2. Updated class to work with Scintilla v3.2.1 New Messaged wrapped include: SCI_DELETERANGE, SCI_GETWORDCHARS,
SCI_GETWHITESPACECHARS, SCI_SETPUNCTUATIONCHARS, SCI_GETPUNCTUATIONCHARS, SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR,
SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR, SCI_GETRANGEPOINTER, SCI_GETGAPPOSITION, SCI_FINDINDICATORSHOW,
SCI_FINDINDICATORFLASH & SCI_FINDINDICATORHIDE.
3. SetDocPointer method now uses a void* parameter instead of an int. This prevents a pointer truncation issue
on 64bit platforms. Thanks to Kenny Liu for reporting this issue.
4. GetDocPointer method now also returns a void* instead of an int return value
5. Updated the code to clean compile on VC 2012
PJN / 18-01-2013 1. Updated copyright details
2. Updated class to work with Scintilla v3.2.4. New messages wrapped include: SCI_GETSELECTIONEMPTY,
SCI_RGBAIMAGESETSCALE, SCI_VCHOMEDISPLAY, SCI_VCHOMEDISPLAYEXTEND, SCI_GETCARETLINEVISIBLEALWAYS &
SCI_SETCARETLINEVISIBLEALWAYS.
3. The classes are now encapsulated in a Scintilla namespace if the SCI_NAMESPACE define
is defined. This is consistent with how the scintilla.h header file operates in the
presence of this define. Thanks to Markus Nissl for prompting this update.
4. Updated the sample app to compile when the SCI_NAMESPACE define is defined.
5. The sample app is now built by default with the SCI_NAMESPACE defined. This means that all the
classes of the author will appear in the "Scintilla" namespace.
6. The demo app now loads the SciLexer.dll from the application directory only. This avoids DLL planting security
issues.
PJN / 23-02-2013 1. PrivateLexerCall method now uses a void* parameter instead of an int. This prevents a pointer truncation issue
on 64bit platforms. Thanks to Simon Smith for reporting this issue.
PJN / 18-01-2013 1. Updated class to work with Scintilla v3.3.3. New messages wrapped include: SCI_SCROLLRANGE, SCI_FOLDLINE,
SCI_FOLDCHILDREN, SCI_EXPANDCHILDREN, SCI_FOLDALL, SCI_SETAUTOMATICFOLD, SCI_GETAUTOMATICFOLD, SCI_AUTOCSETORDER,
SCI_AUTOCGETORDER, SCI_RELEASEALLEXTENDEDSTYLES, SCI_ALLOCATEEXTENDEDSTYLES, SCI_SETLINEENDTYPESALLOWED,
SCI_GETLINEENDTYPESALLOWED, SCI_GETLINEENDTYPESACTIVE, SCI_GETLINEENDTYPESSUPPORTED, SCI_ALLOCATESUBSTYLES,
SCI_GETSUBSTYLESSTART, SCI_GETSUBSTYLESLENGTH, SCI_FREESUBSTYLES, SCI_SETIDENTIFIERS, SCI_DISTANCETOSECONDARYSTYLES &
SCI_GETSUBSTYLEBASES.
2. Updated all the MFC MESSAGE_MAP's to use modern C++ style to reference methods of a class.
3. Fixed a heap overwrite bug in the two versions of the GetSelText(BOOL bDirect) method. The code now correctly uses
SCI_GETSELTEXT(0,0) to determine the buffer size to retrieve the data into. Thanks to Bengt Vagnhammar for reporting
this bug.
PJN / 26-01-2015 1. Updated copyright details
2. Updated the code to clean compile on VC 2013
3. Updated class to work with Scintilla v3.5.3. New messages wrapped include: SCI_CHANGEINSERTION,
SCI_CLEARTABSTOPS, SCI_ADDTABSTOP, SCI_GETNEXTTABSTOP, SCI_GETIMEINTERACTION, SCI_SETIMEINTERACTION,
SCI_CALLTIPSETPOSSTART, SCI_GETPHASESDRAW, SCI_SETPHASESDRAW, SCI_POSITIONRELATIVE, SCI_AUTOCSETMULTI,
SCI_AUTOCGETMULTI, SCI_SETMOUSESELECTIONRECTANGULARSWITCH, SCI_GETMOUSESELECTIONRECTANGULARSWITCH,
SCI_DROPSELECTIONN, SCI_SETREPRESENTATION, SCI_GETREPRESENTATION, SCI_CLEARREPRESENTATION,
SCI_GETSTYLEFROMSUBSTYLE & SCI_GETPRIMARYSTYLEFROMSTYLE
PJN / 19-09-2015 1. Updated class to work with Scintilla v3.6.1. New messages wrapped include: SCI_INDICSETHOVERSTYLE,
SCI_INDICGETHOVERSTYLE, SCI_INDICSETHOVERFORE, SCI_INDICGETHOVERFORE, SCI_INDICSETFLAGS,
SCI_INDICGETFLAGS, SCI_SETTARGETRANGE, SCI_GETTARGETTEXT, SCI_TARGETWHOLEDOCUMENT, SCI_ISRANGEWORD.
SCI_MULTIPLESELECTADDNEXT & SCI_MULTIPLESELECTADDEACH.
Removed messages include: SCI_SETKEYSUNICODE & SCI_GETKEYSUNICODE
2. All APIs which use a logical document position which previously used a C long has now been replaced with the
Scintilla define "Sci_Position". This is to mirror the ongoing changes in Scintilla to enable support for documents
larger than 2GB.
PJN / 23-01-2016 1. Updated copyright details.
2. Updated class to work with Scintilla v3.6.3. New messages wrapped include: SCI_SETIDLESTYLING &
SCI_GETIDLESTYLING
PJN / 11-07-2016 1. Verified class against Scintilla v3.6.6. As no new messages were introduced between v3.6.3 and v3.6.6 no
changes were required in the code.
2. Removed the bDirect parameter from all the method calls and instead replaced this functionality with a
new pair of getter / setter methods called GetCallDirect and SetCallDirect. Thanks to Chad Marlow for prompting this
update
PJN / 25-07-2016 1. Added SAL annotations to all the code
PJN / 16-10-2016 1. Replaced all occurrences of NULL with nullptr throughout the codebase. This now means that the minimum
requirement to compile the code is Visual Studio 2010 or later. Thanks to Markus Nissl for requesting this update.
2. Updated class to work with Scintilla v3.7.0. New messages wrapped include: SCI_SETMARGINBACKN,
SCI_GETMARGINBACKN, SCI_SETMARGINS, SCI_GETMARGINS, SCI_MULTIEDGEADDLINE, SCI_MULTIEDGECLEARALL,
SCI_SETMOUSEWHEELCAPTURES & SCI_GETMOUSEWHEELCAPTURES.
PJN / 20-12-2016 1. Updated class to work with Scintilla v3.7.1. New messages wrapped include: SCI_GETTABDRAWMODE, SCI_SETTABDRAWMODE,
SCI_TOGGLEFOLDSHOWTEXT & SCI_FOLDDISPLAYTEXTSETSTYLE. The parameter to support the SCI_USEPOPUP message has been
changed from a BOOL to an int.
2. Updated code to use Sci_RangeToFormat typedef instead of RangeToFormat
3. Updated code to use Sci_TextToFind typedef instead of TextToFind
4. Updated code to no longer use Scintilla namespace which has been removed from
Scintilla.h
PJN / 04-03-2017 1. Updated copyright details
2. Updated class to work with Scintilla v3.7.3. The only change to support this version was to have now no return
value from the SetSelection and AddSelection methods
3. Updated the download to include the correct VC 2010 project files. Thanks to Kenny Lau for reporting this
issue.
PJN / 03-04-2017 1. Updated class to work with Scintilla v3.7.4. New messages wrapped include: SCI_SETACCESSIBILITY &
SCI_GETACCESSIBILITY
PJN / 12-06-2017 1. Updated class to work with Scintilla v3.7.5. New messages wrapped include: SCI_GETCARETLINEFRAME,
SCI_SETCARETLINEFRAME & SCI_LINEREVERSE
PJN / 31-08-2017 1. Updated class to work with Scintilla v4.0.0. New messages wrapped include: SCI_GETNAMEDSTYLES, SCI_NAMEOFSTYLE,
SCI_TAGSOFSTYLE & SCI_DESCRIPTIONOFSTYLE. Messages removed include SCI_GETTWOPHASEDRAW & SCI_SETTWOPHASEDRAW
2. Fixed up a number of compiler warnings when the code is compiled for x64
PJN / 27-12-2017 1. Updated class to work with Scintilla v4.0.2. Some messages have been removed in 4.0.2 including SCI_SETSTYLEBITS,
SCI_GETSTYLEBITS & SCI_GETSTYLEBITSNEEDED.
PJN / 03-01-2018 1. Updated copyright details.
2. Removed Unicode versions of MarginSetStyles & AnnotationSetStyles methods as these methods take byte buffers
and do not take text data. Thanks to Karagoez Yusuf for reporting this issue.
PJN / 18-03-2018 1. Updated class to work with Scintilla v4.0.3. New parameters to SCI_CREATEDOCUMENT & SCI_CREATELOADER messages.
New messages wrapped include: SCI_GETMOVEEXTENDSSELECTION message, SCI_GETBIDIRECTIONAL & SCI_SETBIDIRECTIONAL
2. SCI_ADDREFDOCUMENT and SCI_RELEASEDOCUMENT wrappers now use void* for the document parameter.
PJN / 03-05-2018 1. Verified the code works with the latest Scintilla v4.0.4. No new messages were added for this release of
scintilla.
PJN / 14-07-2018 1. Fixed a number of C++ core guidelines compiler warnings. These changes mean that
the code will now only compile on VC 2017 or later.
2. Code page is now explicitly set to ANSI when building for ANSI. This is necessary because as of Scintilla 4 the
default code page is now UTF-8. Thanks to Karagoez Yusuf for reporting this issue.
3. CScintillaCtrl::SetProperty has been renamed SetScintillaProperty to avoid clashing with CWnd::SetProperty
4. CScintillaCtrl::GetProperty has been renamed GetScintillaProperty to avoid clashing with CWnd::GetProperty
5. Updated class to work with Scintilla v4.1.0. New messages wrapped include: SCI_GETDOCUMENTOPTIONS
PJN / 09-09-2018 1. Fixed a number of compiler warnings when using VS 2017 15.8.2
2. Updated class to work with Scintilla v4.1.1. New messages wrapped include: SCI_COUNTCODEUNITS,
SCI_POSITIONRELATIVECODEUNITS, SCI_GETLINECHARACTERINDEX, SCI_ALLOCATELINECHARACTERINDEX,
SCI_RELEASELINECHARACTERINDEX, SCI_LINEFROMINDEXPOSITION & SCI_INDEXPOSITIONFROMLINE
PJN / 19-01-2019 1. Updated copyright details
2. Updated class to work with Scintilla v4.1.3. New messages wrapped include: SCI_SETCOMMANDEVENTS &
SCI_GETCOMMANDEVENTS.
3. Added code to suppress C4263 off by default compiler warning. Thanks to Karagoez Yusuf for reporting this issue.
PJN / 23-02-2019 1. Fixed a number of compiler warnings when the code is compiled with VS 2019 Preview
PJN / 02-04-2019 1. Verified the code works with the latest Scintilla v4.1.4. No new messages were added for this release of
scintilla.
PJN / 25-06-2019 1. Updated class to work with Scintilla v4.1.7. New messages wrapped include: SCI_SETCHARACTERCATEGORYOPTIMIZATION,
SCI_GETCHARACTERCATEGORYOPTIMIZATION, SCI_FOLDDISPLAYTEXTGETSTYLE, SCI_SETDEFAULTFOLDDISPLAYTEXT &
SCI_GETDEFAULTFOLDDISPLAYTEXT.
PJN / 23-08-2019 1. Updated class to work with Scintilla v4.2.0. Various API definitions have been updated to use Sci_Position
instead of int parameters. No new actual messages were added.
PJN / 03-11-2019 1. Updated class to work with Scintilla v4.2.1. New messages wrapper include: SCI_SETTABMINIMUMWIDTH and
SCI_GETTABMINIMUMWIDTH.
2. Updated initialization of various structs to use C++ 11 list initialization
PJN / 27-12-2019 1. Updated class to work with Scintilla v4.2.3. New messages wrapped include: SCI_SETTARGETSTARTVIRTUALSPACE,
SCI_GETTARGETSTARTVIRTUALSPACE, SCI_SETTARGETENDVIRTUALSPACE, SCI_GETTARGETENDVIRTUALSPACE,
SCI_GETSELECTIONNSTARTVIRTUALSPACE & SCI_GETSELECTIONNENDVIRTUALSPACE.
2. Fixed various Clang-Tidy static code analysis warnings in the code.
PJN / 21-03-2020 1. Updated copyright details.
2. Fixed more Clang-Tidy static code analysis warnings in the code.
3. Updated class to work with Scintilla v4.3.2. New messages wrapped include: SCI_SETILEXER
PJN / 07-05-2020 1. Added missing static_casts in the GetSelectionNStartVirtualSpace and
GetSelectionNEndVirtualSpace methods. Thanks to Yusuf Karagöz for reporting this issue.
2. Updated class to work with Scintilla v4.3.3. New messages wrapped include: SCI_MARKERHANDLEFROMLINE and
SCI_MARKERNUMBERFROMLINE.
3. Changed two parameters to CallTipSetHlt method to be Sci_Position from int.
4. Changed return value from IndicatorStart method to be Sci_Position from int.
5. Changed return value from IndicatorEnd method to be Sci_Position from int.
PJN / 14-06-2020 1. Verified the code against Scintilla v4.4.3.
PJN / 15-08-2020 1. Updated class to work with Scintilla v4.4.4. New messages wrapped include: SCI_BRACEMATCHNEXT,
SCI_EOLANNOTATIONSETTEXT, SCI_EOLANNOTATIONGETTEXT, SCI_EOLANNOTATIONSETSTYLE, SCI_EOLANNOTATIONGETSTYLE,
SCI_EOLANNOTATIONCLEARALL, SCI_EOLANNOTATIONSETVISIBLE, SCI_EOLANNOTATIONGETVISIBLE,
SCI_EOLANNOTATIONSETSTYLEOFFSET & SCI_EOLANNOTATIONGETSTYLEOFFSET.
PJN / 26-09-2020 1. Updated class to work with Scintilla v4.4.5. New messages wrapped include: SCI_GETMULTIEDGECOLUMN
PJN / 10-05-2021 1. Updated class to work with Scintilla v5.0.2. New messages wrapped include: SCI_SETFONTLOCALE,
SCI_GETFONTLOCALE, SCI_MARKERSETFORETRANSLUCENT, SCI_MARKERSETBACKTRANSLUCENT, SCI_MARKERSETBACKSELECTEDTRANSLUCENT,
SCI_MARKERSETSTROKEWIDTH, SCI_SETELEMENTCOLOUR, SCI_GETELEMENTCOLOUR, SCI_RESETELEMENTCOLOUR, SCI_GETELEMENTISSET,
SCI_GETELEMENTALLOWSTRANSLUCENT, SCI_INDICSETSTROKEWIDTH, SCI_INDICGETSTROKEWIDTH & SCI_SUPPORTSFEATURE
2. Updated copyright details
PJN / 05-06-2021 1. Updated class to work with Scintilla v5.0.3. New messages wrapped include: SCI_MARKERGETLAYER,
SCI_MARKERSETLAYER, SCI_GETELEMENTBASECOLOUR, SCI_GETSELECTIONLAYER, SCI_SETSELECTIONLAYER, SCI_GETCARETLINELAYER
& SCI_SETCARETLINELAYER.
PJN / 11-07-2021 1. Updated class to work with Scintilla v5.1.0. New messages wrapped include: SCI_GETDIRECTSTATUSFUNCTION,
SCI_REPLACERECTANGULAR, SCI_CLEARALLREPRESENTATIONS, SCI_SETREPRESENTATIONAPPEARANCE,
SCI_GETREPRESENTATIONAPPEARANCE, SCI_SETREPRESENTATIONCOLOUR & SCI_GETREPRESENTATIONCOLOUR
2. Changed the return values from GetDirectFunction & GetDirectPointer to less generic data types.
PJN / 14-08-2021 1. Updated class to work with Scintilla v5.1.1. New messages wrapped include: SCI_AUTOCSETOPTIONS,
SCI_AUTOCGETOPTIONS & SCI_ALLOCATELINES.
PJN / 30-09-2021 1. Updated class to work with Scintilla v5.1.3. New messages wrapped include:
SCI_STYLESETCHECKMONOSPACED, SCI_STYLEGETCHECKMONOSPACED, SCI_GETCARETLINEHIGHLIGHTSUBLINE &
SCI_SETCARETLINEHIGHLIGHTSUBLINE.
PJN / 31-03-2022 1. Updated copyright details.
2. Updated class to work with Scintilla v5.2.2. New messages wrapped include:
SCI_GETSTYLEINDEXAT, SCI_SETLAYOUTTHREADS and SCI_GETLAYOUTTHREADS.
3. Updated the code to use C++ uniform initialization for all variable declarations.
PJN / 31-03-2022 1. Updated class to work with Scintilla v5.2.4. New messages wrapped include:
SCI_FINDTEXTFULL, SCI_FORMATRANGEFULL & SCI_GETTEXTRANGEFULL.
PJN / 10-08-2022 1. Updated all line parameters to use intptr_t instead of int. Thanks to Markus Nissl for reporting this issue.
PJN / 12-09-2022 1. Updated class to work with Scintilla v5.3.0. New messages wrapped include:
SCI_SETCHANGEHISTORY, SCI_GETCHANGEHISTORY & SCI_GETSELECTIONHIDDEN.
2. Updated CScintillaCtrl class to support being compiled with WTL support. Thanks to Niek Albers for
suggesting this update.
PJN / 29-10-2022 1. Updated class to work with Scintilla v5.3.1. New messages wrapped include:
SCI_STYLESETINVISIBLEREPRESENTATION & SCI_STYLEGETINVISIBLEREPRESENTATION.
PJN / 13-12-2022 1. All classes are now contained in the workspace "Scintilla".
2. Updated code to use enums from Scintilla provided "ScintillaTypes.h" header file.
3. Updated class to work with Scintilla v5.3.2. New messages wrapped include: SCI_GETSTYLEDTEXTFULL and
SCI_REPLACETARGETMINIMAL.
PJN / 14-12-2022 1. Fixed up issue with Regular expression checkbox not appearing in find and replace dialogs.
2. Replaced intptr_t type with Line typedef.
3. Updated code to use message values from Scintilla provided "ScintillaMessages.h" header file.
4. Renamed SetScintillaProperty method to SetSCIProperty.
5. Renamed GetScintillaProperty method to GetSCIProperty.
6. Updated code to use structs from Scintilla provided "ScintillaStructures.h" header file.
7. Updated code to use Scintilla provided "ScintillaCall.h" header file instead of the "Scintilla.h"
which is designed for C clients.
8. Updated code to use Scintilla::Position instead of Sci_Position.
PJN / 19-12-2022 1. Fixed a bug where the first parameter to SetXCaretPolicy and SetYCaretPolicy should be a
CaretPolicy instead of VisiblePolicy. Thanks to Markus Nissl for reporting this issue.
2. Removed unnecessary Scintilla namespace usage in ScintillaCtrl.cpp. Thanks to Markus
Nissl for reporting this issue.
PJN / 21-03-2023 1. Updated modules to indicate that it needs to be compiled using /std:c++17. Thanks to Martin Richter for
reporting this issue.
PJN / 28-12-2023 1. Updated class to work with Scintilla v5.4.1. New messages wrapped include: SCI_CHANGESELECTIONMODE,
SCI_SETMOVEEXTENDSSELECTION & SCI_SELECTIONFROMPOINT. Also updated the signatures of the following
methods: GetDocPointer, SetDocPointer, CreateDocument, AddRefDocument and ReleaseDocument.
PJN / 29-03-2024 1. Updated copyright details.
2. Updated class to work with Scintilla v5.4.3. New messages wrapped include: SCI_GETUNDOACTIONS,
SCI_GETUNDOSAVEPOINT, SCI_SETUNDODETACH, SCI_SETUNDOTENTATIVE, SCI_SETUNDOCURRENT, SCI_PUSHUNDOACTIONTYPE,
SCI_CHANGELASTUNDOACTIONTEXT, SCI_GETUNDOACTIONTYPE, SCI_GETUNDOACTIONPOSITION & SCI_GETUNDOACTIONTEXT.
PJN / 26-04-2024 1. Verified the code against Scintilla v5.5.0.
PJN / 22-07-2024 1. Updated class to work with Scintilla v5.5.1. New messages wrapped include: SCI_AUTOCSETSTYLE,
SCI_AUTOCGETSTYLE & SCI_CUTALLOWLINE.
PJN / 24-08-2024 1. Updated class to work with Scintilla v5.5.2. New messages wrapped include: SCI_STYLESETSTRETCH,
SCI_STYLEGETSTRETCH, SCI_GETUNDOSEQUENCE, SCI_LineIndent, SCI_LINEDEDENT, SCI_SETCOPYSEPARATOR &
SCI_GETCOPYSEPARATOR.
PJN / 26-10-2024 1. Verified the code against Scintilla v5.5.3.
PJN / 21-12-2024 1. Verified the code against Scintilla v5.5.4.
Copyright (c) 2004 - 2025 by PJ Naughter (Web: www.naughter.com, Email: [email protected])
All rights reserved.
Copyright / Usage Details:
You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise)
when your product is released in binary form. You are allowed to modify the source code in any way you want
except you cannot modify the copyright details at the top of each module. If you want to distribute source
code with your application, then you are only allowed to distribute versions released by the author. This is
to maintain a single distribution point for the source code.
*/
//////////////////// Includes /////////////////////////////////////////////////
#include "stdafx.h"
#include "ScintillaCtrl.h"
#ifndef SCINTILLAMESSAGES_H
#pragma message("To avoid this message, please put ScintillaMessages.h in your pre compiled header (normally stdafx.h)")
#include <ScintillaMessages.h>
#endif //#ifndef SCINTILLAMESSAGES_H
//////////////////// Statics / Macros /////////////////////////////////////////
#ifdef _DEBUG
#define new DEBUG_NEW
#endif //#ifdef _DEBUG
//////////////////// Implementation ///////////////////////////////////////////
using namespace Scintilla;
#ifdef _AFX
#pragma warning(suppress: 26433 26440 26477)
IMPLEMENT_DYNAMIC(CScintillaCtrl, CWnd)
#endif //#ifdef _AFX
CScintillaCtrl::CScintillaCtrl() noexcept : m_DirectStatusFunction{ nullptr },
m_DirectPointer{ 0 },
m_LastStatus{ Status::Ok },
m_dwOwnerThreadID{ 0 },
m_bDoneInitialSetup{ false }
{
}
#ifdef _AFX
BOOL CScintillaCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, DWORD dwExStyle, LPVOID lpParam)
{
//Call our base class implementation of CWnd::CreateEx
if (!CreateEx(dwExStyle, _T("scintilla"), nullptr, dwStyle, rect, pParentWnd, nID, lpParam))
return FALSE;
#else
#pragma warning(suppress: 26434)
BOOL CScintillaCtrl::Create(_In_ HWND hWndParent, _In_ ATL::_U_RECT rect, _In_ DWORD dwStyle, _In_ UINT nID, _In_ DWORD dwExStyle, _In_opt_ LPVOID lpParam)
{
//Call our base class implementation of ATL::CWindow::Create
if (!__super::Create(GetWndClassName(), hWndParent, rect, nullptr, dwStyle, dwExStyle, nID, lpParam))
return FALSE;
#endif //#ifdef _AFX
//Setup the direct access data
if (!m_bDoneInitialSetup)
{
m_bDoneInitialSetup = true;
SetupDirectAccess();
//If we are running as Unicode, then use the UTF8 codepage else disable multi-byte support
#ifdef _UNICODE
SetCodePage(CpUtf8);
#else
SetCodePage(0);
#endif //#ifdef _UNICODE
//Cache the return value from GetWindowThreadProcessId in the m_dwOwnerThreadID member variable
m_dwOwnerThreadID = GetWindowThreadProcessId(m_hWnd, nullptr);
}
return TRUE;
}
#ifdef _AFX
void CScintillaCtrl::PreSubclassWindow()
{
//Let the base class do its thing
__super::PreSubclassWindow();
//Setup the direct access data
if (!m_bDoneInitialSetup)
{
SetupDirectAccess();
if ((m_DirectPointer == 0) || (m_DirectStatusFunction == nullptr))
return;
m_bDoneInitialSetup = true;
//If we are running as Unicode, then use the UTF8 codepage else use the ANSI codepage
#ifdef _UNICODE
SetCodePage(CpUtf8);
#else
SetCodePage(0);
#endif //#ifdef _UNICODE
//Cache the return value from GetWindowThreadProcessId in the m_dwOwnerThreadID member variable
m_dwOwnerThreadID = GetWindowThreadProcessId(m_hWnd, nullptr);
}
}
#endif //#ifdef _AFX
void CScintillaCtrl::SetupDirectAccess()
{
//Setup the direct access data
m_DirectPointer = GetDirectPointer();
m_DirectStatusFunction = GetDirectStatusFunction();
}
#pragma warning(suppress: 26440)
sptr_t CScintillaCtrl::GetDirectPointer()
{
return SendMessage(static_cast<UINT>(Message::GetDirectPointer), 0, 0);
}
#pragma warning(suppress: 26440)
FunctionDirect CScintillaCtrl::GetDirectStatusFunction()
{
#pragma warning(suppress: 26490)
return reinterpret_cast<FunctionDirect>(SendMessage(static_cast<UINT>(Message::GetDirectStatusFunction), 0, 0));
}
Status CScintillaCtrl::GetLastStatus() const noexcept
{
return m_LastStatus;
}
CScintillaCtrl::StringA CScintillaCtrl::W2UTF8(_In_NLS_string_(nLength) const wchar_t* pszText, _In_ int nLength)
{
//First call the function to determine how much space we need to allocate
int nUTF8Length{ WideCharToMultiByte(CP_UTF8, 0, pszText, nLength, nullptr, 0, nullptr, nullptr) };
//If the calculated length is zero, then ensure we have at least room for a null terminator
if (nUTF8Length == 0)
nUTF8Length = 1;
//Now recall with the buffer to get the converted text
StringA sUTF;
#pragma warning(suppress: 26429)
char* const pszUTF8Text{ sUTF.GetBuffer(nUTF8Length + 1) }; //include an extra byte because we may be null terminating the string ourselves
int nCharsWritten{ WideCharToMultiByte(CP_UTF8, 0, pszText, nLength, pszUTF8Text, nUTF8Length, nullptr, nullptr) };
//Ensure we null terminate the text if WideCharToMultiByte doesn't do it for us
if (nLength != -1)
{
#pragma warning(suppress: 26477 26496)
ATLASSUME(nCharsWritten <= nUTF8Length);
#pragma warning(suppress: 26481)
pszUTF8Text[nCharsWritten] = '\0';
}
sUTF.ReleaseBuffer();
return sUTF;
}
CScintillaCtrl::StringW CScintillaCtrl::UTF82W(_In_NLS_string_(nLength) const char* pszText, _In_ int nLength)
{
//First call the function to determine how much space we need to allocate
int nWideLength{ MultiByteToWideChar(CP_UTF8, 0, pszText, nLength, nullptr, 0) };
//If the calculated length is zero, then ensure we have at least room for a null terminator
if (nWideLength == 0)
nWideLength = 1;
//Now recall with the buffer to get the converted text
StringW sWideString;
#pragma warning(suppress: 26429)
wchar_t* pszWText{ sWideString.GetBuffer(nWideLength + 1) }; //include an extra byte because we may be null terminating the string ourselves
int nCharsWritten{ MultiByteToWideChar(CP_UTF8, 0, pszText, nLength, pszWText, nWideLength) };
//Ensure we null terminate the text if MultiByteToWideChar doesn't do it for us
if (nLength != -1)
{
#pragma warning(suppress: 26477 26496)
ATLASSUME(nCharsWritten <= nWideLength);
#pragma warning(suppress: 26481)
pszWText[nCharsWritten] = '\0';
}
sWideString.ReleaseBuffer();
return sWideString;
}
#ifdef _UNICODE
void CScintillaCtrl::AddText(_In_ int length, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, length) };
//Call the native scintilla version of the function with the UTF8 text
AddText(sUTF8.GetLength(), sUTF8);
}
void CScintillaCtrl::InsertText(_In_ Position pos, _In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
InsertText(pos, sUTF8);
}
void CScintillaCtrl::ChangeInsertion(_In_ int length, _In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
ChangeInsertion(length, sUTF8);
}
CScintillaCtrl::StringW CScintillaCtrl::GetSelText()
{
//Work out the length of string to allocate
const Position nUTF8Length{ GetSelText(nullptr) };
//Call the function which does the work
StringA sUTF8;
#pragma warning(suppress: 26472)
GetSelText(sUTF8.GetBufferSetLength(static_cast<int>(nUTF8Length)));
sUTF8.ReleaseBuffer();
//Now convert the UTF8 text back to Unicode
return UTF82W(sUTF8, -1);
}
CScintillaCtrl::StringW CScintillaCtrl::GetCurLine()
{
//Work out the length of string to allocate
const Position nUTF8Length{ GetCurLine(0, nullptr) };
//Call the function which does the work
StringA sUTF8;
#pragma warning(suppress: 26472)
GetCurLine(nUTF8Length, sUTF8.GetBufferSetLength(static_cast<int>(nUTF8Length)));
sUTF8.ReleaseBuffer();
return UTF82W(sUTF8, -1);
}
void CScintillaCtrl::StyleSetFont(_In_ int style, _In_z_ const wchar_t* fontName)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(fontName, -1) };
StyleSetFont(style, sUTF8);
}
void CScintillaCtrl::SetWordChars(_In_z_ const wchar_t* characters)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(characters, -1) };
SetWordChars(sUTF8);
}
void CScintillaCtrl::AutoCShow(_In_ int lenEntered, _In_z_ const wchar_t* itemList)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(itemList, -1) };
//Call the native scintilla version of the function with the UTF8 text
AutoCShow(lenEntered, sUTF8);
}
void CScintillaCtrl::AutoCStops(_In_z_ const wchar_t* characterSet)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(characterSet, -1) };
//Call the native scintilla version of the function with the UTF8 text
AutoCStops(sUTF8);
}
void CScintillaCtrl::AutoCSelect(_In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
AutoCSelect(sUTF8);
}
void CScintillaCtrl::AutoCSetFillUps(_In_z_ const wchar_t* characterSet)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(characterSet, -1) };
//Call the native scintilla version of the function with the UTF8 text
AutoCSetFillUps(sUTF8);
}
void CScintillaCtrl::UserListShow(_In_ int listType, _In_z_ const wchar_t* itemList)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(itemList, -1) };
//Call the native scintilla version of the function with the UTF8 text
UserListShow(listType, sUTF8);
}
CScintillaCtrl::StringW CScintillaCtrl::GetLine(_In_ Line line)
{
//Work out the length of string to allocate
const Position nUTF8Length{ GetLine(line, nullptr) };
//Call the function which does the work
StringA sUTF8;
#pragma warning(suppress: 26472)
GetLine(line, sUTF8.GetBufferSetLength(static_cast<int>(nUTF8Length)));
sUTF8.ReleaseBuffer();
return UTF82W(sUTF8, -1);
}
void CScintillaCtrl::ReplaceSel(_In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
ReplaceSel(sUTF8);
}
void CScintillaCtrl::SetText(_In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
SetText(sUTF8);
}
CScintillaCtrl::StringW CScintillaCtrl::GetText(_In_ int length)
{
//Work out the length of string to allocate
const int nUTF8Length{ length * 4 }; //A Unicode character can take up to 4 octets when expressed as UTF8
//Call the function which does the work
StringA sUTF8;
GetText(nUTF8Length, sUTF8.GetBufferSetLength(nUTF8Length));
sUTF8.ReleaseBuffer();
//Now convert the UTF8 text back to Unicode
StringW sWideText{ UTF82W(sUTF8, -1) };
return sWideText.Left(length - 1);
}
Position CScintillaCtrl::ReplaceTarget(_In_ Position length, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
#pragma warning(suppress: 26472)
StringA sUTF8{ W2UTF8(text, static_cast<int>(length)) };
//Call the native scintilla version of the function with the UTF8 text
return ReplaceTarget(sUTF8.GetLength(), sUTF8);
}
Position CScintillaCtrl::ReplaceTargetRE(_In_ Position length, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
#pragma warning(suppress: 26472)
StringA sUTF8{ W2UTF8(text, static_cast<int>(length)) };
//Call the native scintilla version of the function with the UTF8 text
return ReplaceTargetRE(sUTF8.GetLength(), sUTF8);
}
Position CScintillaCtrl::ReplaceTargetMinimal(_In_ Position length, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
#pragma warning(suppress: 26472)
StringA sUTF8{ W2UTF8(text, static_cast<int>(length)) };
//Call the native scintilla version of the function with the UTF8 text
return ReplaceTargetMinimal(sUTF8.GetLength(), sUTF8);
}
Position CScintillaCtrl::SearchInTarget(_In_ Position length, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
#pragma warning(suppress: 26472)
StringA sUTF8{ W2UTF8(text, static_cast<int>(length)) };
//Call the native scintilla version of the function with the UTF8 text
return SearchInTarget(sUTF8.GetLength(), sUTF8);
}
void CScintillaCtrl::CallTipShow(_In_ Position pos, _In_z_ const wchar_t* definition)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(definition, -1) };
//Call the native scintilla version of the function with the UTF8 text
CallTipShow(pos, sUTF8);
}
int CScintillaCtrl::TextWidth(_In_ int style, _In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
return TextWidth(style, sUTF8);
}
void CScintillaCtrl::AppendText(_In_ int length, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, length) };
//Call the native scintilla version of the function with the UTF8 text
AppendText(sUTF8.GetLength(), sUTF8);
}
Position CScintillaCtrl::SearchNext(_In_ FindOption flags, _In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
return SearchNext(flags, sUTF8);
}
Position CScintillaCtrl::SearchPrev(_In_ FindOption flags, _In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
return SearchPrev(flags, sUTF8);
}
void CScintillaCtrl::CopyText(_In_ int length, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, length) };
//Call the native scintilla version of the function with the UTF8 text
CopyText(sUTF8.GetLength(), sUTF8);
}
void CScintillaCtrl::SetWhitespaceChars(_In_z_ const wchar_t* characters)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(characters, -1) };
//Call the native scintilla version of the function with the UTF8 text
SetWhitespaceChars(sUTF8);
}
void CScintillaCtrl::SetSCIProperty(_In_z_ const wchar_t* key, _In_z_ const wchar_t* value)
{
//Convert the unicode texts to UTF8
StringA sUTF8Key{ W2UTF8(key, -1) };
StringA sUTF8Value{ W2UTF8(value, -1) };
//Call the native scintilla version of the function with the UTF8 text
SetSCIProperty(sUTF8Key, sUTF8Value);
}
void CScintillaCtrl::SetKeyWords(_In_ int keywordSet, _In_z_ const wchar_t* keyWords)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(keyWords, -1) };
//Call the native scintilla version of the function with the UTF8 text
SetKeyWords(keywordSet, sUTF8);
}
void CScintillaCtrl::SetIdentifiers(_In_ int style, _In_z_ const wchar_t* identifiers)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(identifiers, -1) };
//Call the native scintilla version of the function with the UTF8 text
SetIdentifiers(style, sUTF8);
}
void CScintillaCtrl::ChangeLastUndoActionText(_In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
ChangeLastUndoActionText(sUTF8.GetLength(), sUTF8);
}
CScintillaCtrl::StringW CScintillaCtrl::GetSCIProperty(_In_z_ const wchar_t* key)
{
//Validate our parameters
#pragma warning(suppress: 26477)
ATLASSERT(key != nullptr);
//Convert the Key value to UTF8
StringA sUTF8Key{ W2UTF8(key, -1) };
//Work out the length of string to allocate
const int nUTF8ValueLength{ GetSCIProperty(sUTF8Key, nullptr) };
//Call the function which does the work
StringA sUTF8Value;
GetSCIProperty(sUTF8Key, sUTF8Value.GetBufferSetLength(nUTF8ValueLength));
sUTF8Value.ReleaseBuffer();
return UTF82W(sUTF8Value, -1);
}
CScintillaCtrl::StringW CScintillaCtrl::GetPropertyExpanded(_In_z_ const wchar_t* key)
{
//Validate our parameters
#pragma warning(suppress: 26477)
ATLASSERT(key != nullptr);
//Convert the Key value to UTF8
StringA sUTF8Key{ W2UTF8(key, -1) };
//Work out the length of string to allocate
const int nUTF8ValueLength{ GetPropertyExpanded(sUTF8Key, nullptr) };
//Call the function which does the work
StringA sUTF8Value;
GetPropertyExpanded(sUTF8Key, sUTF8Value.GetBufferSetLength(nUTF8ValueLength));
sUTF8Value.ReleaseBuffer();
return UTF82W(sUTF8Value, -1);
}
int CScintillaCtrl::GetPropertyInt(_In_z_ const wchar_t* key, _In_ int defaultValue)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(key, -1) };
//Call the native scintilla version of the function with the UTF8 text
return GetPropertyInt(sUTF8, defaultValue);
}
CScintillaCtrl::StringW CScintillaCtrl::StyleGetFont(_In_ int style)
{
//Work out the length of string to allocate
const int nUTF8Length{ StyleGetFont(style, nullptr) };
//Call the function which does the work
StringA sUTF8FontName;
StyleGetFont(style, sUTF8FontName.GetBufferSetLength(nUTF8Length));
sUTF8FontName.ReleaseBuffer();
return UTF82W(sUTF8FontName, -1);
}
void CScintillaCtrl::MarginSetText(_In_ Line line, _In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
MarginSetText(line, sUTF8);
}
void CScintillaCtrl::AnnotationSetText(_In_ Line line, _In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
AnnotationSetText(line, sUTF8);
}
CScintillaCtrl::StringW CScintillaCtrl::AutoCGetCurrentText()
{
//Work out the length of string to allocate
const int nUTF8Length{ AutoCGetCurrentText(nullptr) };
//Call the function which does the work
StringA sUTF8;
AutoCGetCurrentText(sUTF8.GetBufferSetLength(nUTF8Length));
sUTF8.ReleaseBuffer();
//Now convert the UTF8 text back to Unicode
return UTF82W(sUTF8, -1);
}
CScintillaCtrl::StringW CScintillaCtrl::GetLexerLanguage()
{
//Work out the length of string to allocate
const int nUTF8Length{ GetLexerLanguage(nullptr) };
//Call the function which does the work
StringA sUTF8;
GetLexerLanguage(sUTF8.GetBufferSetLength(nUTF8Length));
sUTF8.ReleaseBuffer();
//Now convert the UTF8 text back to Unicode
return UTF82W(sUTF8, -1);
}
CScintillaCtrl::StringW CScintillaCtrl::PropertyNames()
{
//Work out the length of string to allocate
const int nUTF8Length{ PropertyNames(nullptr) };
//Call the function which does the work
StringA sUTF8;
PropertyNames(sUTF8.GetBufferSetLength(nUTF8Length));
sUTF8.ReleaseBuffer();
//Now convert the UTF8 text back to Unicode
return UTF82W(sUTF8, -1);
}
TypeProperty CScintillaCtrl::PropertyType(_In_z_ const wchar_t* name)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(name, -1) };
//Call the native scintilla version of the function with the UTF8 text
return PropertyType(sUTF8);
}
void CScintillaCtrl::ToggleFoldShowText(_In_ Line line, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
ToggleFoldShowText(line, sUTF8);
}
void CScintillaCtrl::SetDefaultFoldDisplayText(_In_z_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
SetDefaultFoldDisplayText(sUTF8);
}
void CScintillaCtrl::EOLAnnotationSetText(_In_ Line line, _In_ const wchar_t* text)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(text, -1) };
//Call the native scintilla version of the function with the UTF8 text
EOLAnnotationSetText(line, sUTF8);
}
void CScintillaCtrl::StyleSetInvisibleRepresentation(_In_ int style, _In_z_ const wchar_t* representation)
{
//Convert the unicode text to UTF8
StringA sUTF8{ W2UTF8(representation, -1) };
//Call the native scintilla version of the function with the UTF8 text
StyleSetInvisibleRepresentation(style, sUTF8);
}
void CScintillaCtrl::SetCopySeparator(_In_z_ const wchar_t* separator)
{
//Convert the unicode text to UTF8