Menu

[r704]: / trunk / ext / scintilla / src / ScintillaBase.cxx  Maximize  Restore  History

Download this file

909 lines (768 with data), 23.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
// Scintilla source code edit control
/** @file ScintillaBase.cxx
** An enhanced subclass of Editor with calltips, autocomplete and context menu.
**/
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <string>
#include <vector>
#include <map>
#include "Platform.h"
#include "ILexer.h"
#include "Scintilla.h"
#include "PropSetSimple.h"
#ifdef SCI_LEXER
#include "SciLexer.h"
#include "LexerModule.h"
#include "Catalogue.h"
#endif
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
#include "ContractionState.h"
#include "CellBuffer.h"
#include "CallTip.h"
#include "KeyMap.h"
#include "Indicator.h"
#include "XPM.h"
#include "LineMarker.h"
#include "Style.h"
#include "ViewStyle.h"
#include "AutoComplete.h"
#include "CharClassify.h"
#include "Decoration.h"
#include "Document.h"
#include "Selection.h"
#include "PositionCache.h"
#include "Editor.h"
#include "ScintillaBase.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
ScintillaBase::ScintillaBase() {
displayPopupMenu = true;
listType = 0;
maxListWidth = 0;
}
ScintillaBase::~ScintillaBase() {
}
void ScintillaBase::Finalise() {
Editor::Finalise();
popup.Destroy();
}
void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
if (!isFillUp) {
Editor::AddCharUTF(s, len, treatAsDBCS);
}
if (ac.Active()) {
AutoCompleteCharacterAdded(s[0]);
// For fill ups add the character after the autocompletion has
// triggered so containers see the key so can display a calltip.
if (isFillUp) {
Editor::AddCharUTF(s, len, treatAsDBCS);
}
}
}
void ScintillaBase::Command(int cmdId) {
switch (cmdId) {
case idAutoComplete: // Nothing to do
break;
case idCallTip: // Nothing to do
break;
case idcmdUndo:
WndProc(SCI_UNDO, 0, 0);
break;
case idcmdRedo:
WndProc(SCI_REDO, 0, 0);
break;
case idcmdCut:
WndProc(SCI_CUT, 0, 0);
break;
case idcmdCopy:
WndProc(SCI_COPY, 0, 0);
break;
case idcmdPaste:
WndProc(SCI_PASTE, 0, 0);
break;
case idcmdDelete:
WndProc(SCI_CLEAR, 0, 0);
break;
case idcmdSelectAll:
WndProc(SCI_SELECTALL, 0, 0);
break;
}
}
int ScintillaBase::KeyCommand(unsigned int iMessage) {
// Most key commands cancel autocompletion mode
if (ac.Active()) {
switch (iMessage) {
// Except for these
case SCI_LINEDOWN:
AutoCompleteMove(1);
return 0;
case SCI_LINEUP:
AutoCompleteMove(-1);
return 0;
case SCI_PAGEDOWN:
AutoCompleteMove(ac.lb->GetVisibleRows());
return 0;
case SCI_PAGEUP:
AutoCompleteMove(-ac.lb->GetVisibleRows());
return 0;
case SCI_VCHOME:
AutoCompleteMove(-5000);
return 0;
case SCI_LINEEND:
AutoCompleteMove(5000);
return 0;
case SCI_DELETEBACK:
DelCharBack(true);
AutoCompleteCharacterDeleted();
EnsureCaretVisible();
return 0;
case SCI_DELETEBACKNOTLINE:
DelCharBack(false);
AutoCompleteCharacterDeleted();
EnsureCaretVisible();
return 0;
case SCI_TAB:
AutoCompleteCompleted();
return 0;
case SCI_NEWLINE:
AutoCompleteCompleted();
return 0;
default:
AutoCompleteCancel();
}
}
if (ct.inCallTipMode) {
if (
(iMessage != SCI_CHARLEFT) &&
(iMessage != SCI_CHARLEFTEXTEND) &&
(iMessage != SCI_CHARRIGHT) &&
(iMessage != SCI_CHARRIGHTEXTEND) &&
(iMessage != SCI_EDITTOGGLEOVERTYPE) &&
(iMessage != SCI_DELETEBACK) &&
(iMessage != SCI_DELETEBACKNOTLINE)
) {
ct.CallTipCancel();
}
if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
if (sel.MainCaret() <= ct.posStartCallTip) {
ct.CallTipCancel();
}
}
}
return Editor::KeyCommand(iMessage);
}
void ScintillaBase::AutoCompleteDoubleClick(void *p) {
ScintillaBase *sci = reinterpret_cast<ScintillaBase *>(p);
sci->AutoCompleteCompleted();
}
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
//Platform::DebugPrintf("AutoComplete %s\n", list);
ct.CallTipCancel();
if (ac.chooseSingle && (listType == 0)) {
if (list && !strchr(list, ac.GetSeparator())) {
const char *typeSep = strchr(list, ac.GetTypesep());
int lenInsert = typeSep ?
static_cast<int>(typeSep-list) : static_cast<int>(strlen(list));
if (ac.ignoreCase) {
SetEmptySelection(sel.MainCaret() - lenEntered);
pdoc->DeleteChars(sel.MainCaret(), lenEntered);
SetEmptySelection(sel.MainCaret());
pdoc->InsertString(sel.MainCaret(), list, lenInsert);
SetEmptySelection(sel.MainCaret() + lenInsert);
} else {
SetEmptySelection(sel.MainCaret());
pdoc->InsertString(sel.MainCaret(), list + lenEntered, lenInsert - lenEntered);
SetEmptySelection(sel.MainCaret() + lenInsert - lenEntered);
}
return;
}
}
ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(),
lenEntered, vs.lineHeight, IsUnicodeMode(), technology);
PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(sel.MainCaret() - lenEntered);
PRectangle rcPopupBounds = wMain.GetMonitorRect(pt);
if (rcPopupBounds.Height() == 0)
rcPopupBounds = rcClient;
int heightLB = 100;
int widthLB = 100;
if (pt.x >= rcClient.right - widthLB) {
HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB);
Redraw();
pt = PointMainCaret();
}
PRectangle rcac;
rcac.left = pt.x - ac.lb->CaretFromEdge();
if (pt.y >= rcPopupBounds.bottom - heightLB && // Wont fit below.
pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above.
rcac.top = pt.y - heightLB;
if (rcac.top < rcPopupBounds.top) {
heightLB -= (rcPopupBounds.top - rcac.top);
rcac.top = rcPopupBounds.top;
}
} else {
rcac.top = pt.y + vs.lineHeight;
}
rcac.right = rcac.left + widthLB;
rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom);
ac.lb->SetPositionRelative(rcac, wMain);
ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;
ac.lb->SetAverageCharWidth(aveCharWidth);
ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this);
ac.SetList(list);
// Fiddle the position of the list so it is right next to the target and wide enough for all its strings
PRectangle rcList = ac.lb->GetDesiredRect();
int heightAlloced = rcList.bottom - rcList.top;
widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left);
if (maxListWidth != 0)
widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth);
// Make an allowance for large strings in list
rcList.left = pt.x - ac.lb->CaretFromEdge();
rcList.right = rcList.left + widthLB;
if (((pt.y + vs.lineHeight) >= (rcPopupBounds.bottom - heightAlloced)) && // Wont fit below.
((pt.y + vs.lineHeight / 2) >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2)) { // and there is more room above.
rcList.top = pt.y - heightAlloced;
} else {
rcList.top = pt.y + vs.lineHeight;
}
rcList.bottom = rcList.top + heightAlloced;
ac.lb->SetPositionRelative(rcList, wMain);
ac.Show(true);
if (lenEntered != 0) {
AutoCompleteMoveToCurrentWord();
}
}
void ScintillaBase::AutoCompleteCancel() {
if (ac.Active()) {
SCNotification scn = {0};
scn.nmhdr.code = SCN_AUTOCCANCELLED;
scn.wParam = 0;
scn.listType = 0;
NotifyParent(scn);
}
ac.Cancel();
}
void ScintillaBase::AutoCompleteMove(int delta) {
ac.Move(delta);
}
void ScintillaBase::AutoCompleteMoveToCurrentWord() {
char wordCurrent[1000];
int i;
int startWord = ac.posStart - ac.startLen;
for (i = startWord; i < sel.MainCaret() && i - startWord < 1000; i++)
wordCurrent[i - startWord] = pdoc->CharAt(i);
wordCurrent[Platform::Minimum(i - startWord, 999)] = '\0';
ac.Select(wordCurrent);
}
void ScintillaBase::AutoCompleteCharacterAdded(char ch) {
if (ac.IsFillUpChar(ch)) {
AutoCompleteCompleted();
} else if (ac.IsStopChar(ch)) {
AutoCompleteCancel();
} else {
AutoCompleteMoveToCurrentWord();
}
}
void ScintillaBase::AutoCompleteCharacterDeleted() {
if (sel.MainCaret() < ac.posStart - ac.startLen) {
AutoCompleteCancel();
} else if (ac.cancelAtStartPos && (sel.MainCaret() <= ac.posStart)) {
AutoCompleteCancel();
} else {
AutoCompleteMoveToCurrentWord();
}
SCNotification scn = {0};
scn.nmhdr.code = SCN_AUTOCCHARDELETED;
scn.wParam = 0;
scn.listType = 0;
NotifyParent(scn);
}
void ScintillaBase::AutoCompleteCompleted() {
int item = ac.lb->GetSelection();
char selected[1000];
selected[0] = '\0';
if (item != -1) {
ac.lb->GetValue(item, selected, sizeof(selected));
} else {
AutoCompleteCancel();
return;
}
ac.Show(false);
SCNotification scn = {0};
scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION;
scn.message = 0;
scn.wParam = listType;
scn.listType = listType;
Position firstPos = ac.posStart - ac.startLen;
scn.position = firstPos;
scn.lParam = firstPos;
scn.text = selected;
NotifyParent(scn);
if (!ac.Active())
return;
ac.Cancel();
if (listType > 0)
return;
Position endPos = sel.MainCaret();
if (ac.dropRestOfWord)
endPos = pdoc->ExtendWordSelect(endPos, 1, true);
if (endPos < firstPos)
return;
UndoGroup ug(pdoc);
if (endPos != firstPos) {
pdoc->DeleteChars(firstPos, endPos - firstPos);
}
SetEmptySelection(ac.posStart);
if (item != -1) {
pdoc->InsertCString(firstPos, selected);
SetEmptySelection(firstPos + static_cast<int>(strlen(selected)));
}
SetLastXChosen();
}
int ScintillaBase::AutoCompleteGetCurrent() {
if (!ac.Active())
return -1;
return ac.lb->GetSelection();
}
int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
if (ac.Active()) {
int item = ac.lb->GetSelection();
char selected[1000];
selected[0] = '\0';
if (item != -1) {
ac.lb->GetValue(item, selected, sizeof(selected));
if (buffer != NULL)
strcpy(buffer, selected);
return static_cast<int>(strlen(selected));
}
}
if (buffer != NULL)
*buffer = '\0';
return 0;
}
void ScintillaBase::CallTipShow(Point pt, const char *defn) {
ac.Cancel();
// If container knows about STYLE_CALLTIP then use it in place of the
// STYLE_DEFAULT for the face name, size and character set. Also use it
// for the foreground and background colour.
int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT;
if (ct.UseStyleCallTip()) {
ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);
}
PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt,
vs.lineHeight,
defn,
vs.styles[ctStyle].fontName,
vs.styles[ctStyle].sizeZoomed,
CodePage(),
vs.styles[ctStyle].characterSet,
vs.technology,
wMain);
// If the call-tip window would be out of the client
// space
PRectangle rcClient = GetClientRectangle();
int offset = vs.lineHeight + rc.Height();
// adjust so it displays below the text.
if (rc.top < rcClient.top) {
rc.top += offset;
rc.bottom += offset;
}
// adjust so it displays above the text.
if (rc.bottom > rcClient.bottom) {
rc.top -= offset;
rc.bottom -= offset;
}
// Now display the window.
CreateCallTipWindow(rc);
ct.wCallTip.SetPositionRelative(rc, wMain);
ct.wCallTip.Show();
}
void ScintillaBase::CallTipClick() {
SCNotification scn = {0};
scn.nmhdr.code = SCN_CALLTIPCLICK;
scn.position = ct.clickPlace;
NotifyParent(scn);
}
void ScintillaBase::ContextMenu(Point pt) {
if (displayPopupMenu) {
bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
popup.CreatePopUp();
AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo());
AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo());
AddToPopUp("");
AddToPopUp("Cut", idcmdCut, writable && !sel.Empty());
AddToPopUp("Copy", idcmdCopy, !sel.Empty());
AddToPopUp("Paste", idcmdPaste, writable && WndProc(SCI_CANPASTE, 0, 0));
AddToPopUp("Delete", idcmdDelete, writable && !sel.Empty());
AddToPopUp("");
AddToPopUp("Select All", idcmdSelectAll);
popup.Show(pt, wMain);
}
}
void ScintillaBase::CancelModes() {
AutoCompleteCancel();
ct.CallTipCancel();
Editor::CancelModes();
}
void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
CancelModes();
Editor::ButtonDown(pt, curTime, shift, ctrl, alt);
}
#ifdef SCI_LEXER
#ifdef SCI_NAMESPACE
namespace Scintilla {
#endif
class LexState : public LexInterface {
const LexerModule *lexCurrent;
void SetLexerModule(const LexerModule *lex);
PropSetSimple props;
public:
int lexLanguage;
LexState(Document *pdoc_);
virtual ~LexState();
void SetLexer(uptr_t wParam);
void SetLexerLanguage(const char *languageName);
const char *DescribeWordListSets();
void SetWordList(int n, const char *wl);
int GetStyleBitsNeeded() const;
const char *GetName() const;
void *PrivateCall(int operation, void *pointer);
const char *PropertyNames();
int PropertyType(const char *name);
const char *DescribeProperty(const char *name);
void PropSet(const char *key, const char *val);
const char *PropGet(const char *key) const;
int PropGetInt(const char *key, int defaultValue=0) const;
int PropGetExpanded(const char *key, char *result) const;
};
#ifdef SCI_NAMESPACE
}
#endif
LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) {
lexCurrent = 0;
performingStyle = false;
lexLanguage = SCLEX_CONTAINER;
}
LexState::~LexState() {
if (instance) {
instance->Release();
instance = 0;
}
}
LexState *ScintillaBase::DocumentLexState() {
if (!pdoc->pli) {
pdoc->pli = new LexState(pdoc);
}
return static_cast<LexState *>(pdoc->pli);
}
void LexState::SetLexerModule(const LexerModule *lex) {
if (lex != lexCurrent) {
if (instance) {
instance->Release();
instance = 0;
}
lexCurrent = lex;
if (lexCurrent)
instance = lexCurrent->Create();
pdoc->LexerChanged();
}
}
void LexState::SetLexer(uptr_t wParam) {
lexLanguage = wParam;
if (lexLanguage == SCLEX_CONTAINER) {
SetLexerModule(0);
} else {
const LexerModule *lex = Catalogue::Find(lexLanguage);
if (!lex)
lex = Catalogue::Find(SCLEX_NULL);
SetLexerModule(lex);
}
}
void LexState::SetLexerLanguage(const char *languageName) {
const LexerModule *lex = Catalogue::Find(languageName);
if (!lex)
lex = Catalogue::Find(SCLEX_NULL);
if (lex)
lexLanguage = lex->GetLanguage();
SetLexerModule(lex);
}
const char *LexState::DescribeWordListSets() {
if (instance) {
return instance->DescribeWordListSets();
} else {
return 0;
}
}
void LexState::SetWordList(int n, const char *wl) {
if (instance) {
int firstModification = instance->WordListSet(n, wl);
if (firstModification >= 0) {
pdoc->ModifiedAt(firstModification);
}
}
}
int LexState::GetStyleBitsNeeded() const {
return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5;
}
const char *LexState::GetName() const {
return lexCurrent ? lexCurrent->languageName : "";
}
void *LexState::PrivateCall(int operation, void *pointer) {
if (pdoc && instance) {
return instance->PrivateCall(operation, pointer);
} else {
return 0;
}
}
const char *LexState::PropertyNames() {
if (instance) {
return instance->PropertyNames();
} else {
return 0;
}
}
int LexState::PropertyType(const char *name) {
if (instance) {
return instance->PropertyType(name);
} else {
return SC_TYPE_BOOLEAN;
}
}
const char *LexState::DescribeProperty(const char *name) {
if (instance) {
return instance->DescribeProperty(name);
} else {
return 0;
}
}
void LexState::PropSet(const char *key, const char *val) {
props.Set(key, val);
if (instance) {
int firstModification = instance->PropertySet(key, val);
if (firstModification >= 0) {
pdoc->ModifiedAt(firstModification);
}
}
}
const char *LexState::PropGet(const char *key) const {
return props.Get(key);
}
int LexState::PropGetInt(const char *key, int defaultValue) const {
return props.GetInt(key, defaultValue);
}
int LexState::PropGetExpanded(const char *key, char *result) const {
return props.GetExpanded(key, result);
}
#endif
void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
#ifdef SCI_LEXER
if (DocumentLexState()->lexLanguage != SCLEX_CONTAINER) {
int lineEndStyled = pdoc->LineFromPosition(pdoc->GetEndStyled());
int endStyled = pdoc->LineStart(lineEndStyled);
DocumentLexState()->Colourise(endStyled, endStyleNeeded);
return;
}
#endif
Editor::NotifyStyleToNeeded(endStyleNeeded);
}
void ScintillaBase::NotifyLexerChanged(Document *, void *) {
#ifdef SCI_LEXER
int bits = DocumentLexState()->GetStyleBitsNeeded();
vs.EnsureStyle((1 << bits) - 1);
#endif
}
sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
switch (iMessage) {
case SCI_AUTOCSHOW:
listType = 0;
AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam));
break;
case SCI_AUTOCCANCEL:
ac.Cancel();
break;
case SCI_AUTOCACTIVE:
return ac.Active();
case SCI_AUTOCPOSSTART:
return ac.posStart;
case SCI_AUTOCCOMPLETE:
AutoCompleteCompleted();
break;
case SCI_AUTOCSETSEPARATOR:
ac.SetSeparator(static_cast<char>(wParam));
break;
case SCI_AUTOCGETSEPARATOR:
return ac.GetSeparator();
case SCI_AUTOCSTOPS:
ac.SetStopChars(reinterpret_cast<char *>(lParam));
break;
case SCI_AUTOCSELECT:
ac.Select(reinterpret_cast<char *>(lParam));
break;
case SCI_AUTOCGETCURRENT:
return AutoCompleteGetCurrent();
case SCI_AUTOCGETCURRENTTEXT:
return AutoCompleteGetCurrentText(reinterpret_cast<char *>(lParam));
case SCI_AUTOCSETCANCELATSTART:
ac.cancelAtStartPos = wParam != 0;
break;
case SCI_AUTOCGETCANCELATSTART:
return ac.cancelAtStartPos;
case SCI_AUTOCSETFILLUPS:
ac.SetFillUpChars(reinterpret_cast<char *>(lParam));
break;
case SCI_AUTOCSETCHOOSESINGLE:
ac.chooseSingle = wParam != 0;
break;
case SCI_AUTOCGETCHOOSESINGLE:
return ac.chooseSingle;
case SCI_AUTOCSETIGNORECASE:
ac.ignoreCase = wParam != 0;
break;
case SCI_AUTOCGETIGNORECASE:
return ac.ignoreCase;
case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR:
ac.ignoreCaseBehaviour = wParam;
break;
case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR:
return ac.ignoreCaseBehaviour;
case SCI_USERLISTSHOW:
listType = wParam;
AutoCompleteStart(0, reinterpret_cast<const char *>(lParam));
break;
case SCI_AUTOCSETAUTOHIDE:
ac.autoHide = wParam != 0;
break;
case SCI_AUTOCGETAUTOHIDE:
return ac.autoHide;
case SCI_AUTOCSETDROPRESTOFWORD:
ac.dropRestOfWord = wParam != 0;
break;
case SCI_AUTOCGETDROPRESTOFWORD:
return ac.dropRestOfWord;
case SCI_AUTOCSETMAXHEIGHT:
ac.lb->SetVisibleRows(wParam);
break;
case SCI_AUTOCGETMAXHEIGHT:
return ac.lb->GetVisibleRows();
case SCI_AUTOCSETMAXWIDTH:
maxListWidth = wParam;
break;
case SCI_AUTOCGETMAXWIDTH:
return maxListWidth;
case SCI_REGISTERIMAGE:
ac.lb->RegisterImage(wParam, reinterpret_cast<const char *>(lParam));
break;
case SCI_REGISTERRGBAIMAGE:
ac.lb->RegisterRGBAImage(wParam, sizeRGBAImage.x, sizeRGBAImage.y, reinterpret_cast<unsigned char *>(lParam));
break;
case SCI_CLEARREGISTEREDIMAGES:
ac.lb->ClearRegisteredImages();
break;
case SCI_AUTOCSETTYPESEPARATOR:
ac.SetTypesep(static_cast<char>(wParam));
break;
case SCI_AUTOCGETTYPESEPARATOR:
return ac.GetTypesep();
case SCI_CALLTIPSHOW:
CallTipShow(LocationFromPosition(wParam),
reinterpret_cast<const char *>(lParam));
break;
case SCI_CALLTIPCANCEL:
ct.CallTipCancel();
break;
case SCI_CALLTIPACTIVE:
return ct.inCallTipMode;
case SCI_CALLTIPPOSSTART:
return ct.posStartCallTip;
case SCI_CALLTIPSETHLT:
ct.SetHighlight(wParam, lParam);
break;
case SCI_CALLTIPSETBACK:
ct.colourBG = ColourDesired(wParam);
vs.styles[STYLE_CALLTIP].back = ct.colourBG;
InvalidateStyleRedraw();
break;
case SCI_CALLTIPSETFORE:
ct.colourUnSel = ColourDesired(wParam);
vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel;
InvalidateStyleRedraw();
break;
case SCI_CALLTIPSETFOREHLT:
ct.colourSel = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
case SCI_CALLTIPUSESTYLE:
ct.SetTabSize((int)wParam);
InvalidateStyleRedraw();
break;
case SCI_CALLTIPSETPOSITION:
ct.SetPosition(wParam != 0);
InvalidateStyleRedraw();
break;
case SCI_USEPOPUP:
displayPopupMenu = wParam != 0;
break;
#ifdef SCI_LEXER
case SCI_SETLEXER:
DocumentLexState()->SetLexer(wParam);
break;
case SCI_GETLEXER:
return DocumentLexState()->lexLanguage;
case SCI_COLOURISE:
if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) {
pdoc->ModifiedAt(wParam);
NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam);
} else {
DocumentLexState()->Colourise(wParam, lParam);
}
Redraw();
break;
case SCI_SETPROPERTY:
DocumentLexState()->PropSet(reinterpret_cast<const char *>(wParam),
reinterpret_cast<const char *>(lParam));
break;
case SCI_GETPROPERTY:
return StringResult(lParam, DocumentLexState()->PropGet(reinterpret_cast<const char *>(wParam)));
case SCI_GETPROPERTYEXPANDED:
return DocumentLexState()->PropGetExpanded(reinterpret_cast<const char *>(wParam),
reinterpret_cast<char *>(lParam));
case SCI_GETPROPERTYINT:
return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), lParam);
case SCI_SETKEYWORDS:
DocumentLexState()->SetWordList(wParam, reinterpret_cast<const char *>(lParam));
break;
case SCI_SETLEXERLANGUAGE:
DocumentLexState()->SetLexerLanguage(reinterpret_cast<const char *>(lParam));
break;
case SCI_GETLEXERLANGUAGE:
return StringResult(lParam, DocumentLexState()->GetName());
case SCI_PRIVATELEXERCALL:
return reinterpret_cast<sptr_t>(
DocumentLexState()->PrivateCall(wParam, reinterpret_cast<void *>(lParam)));
case SCI_GETSTYLEBITSNEEDED:
return DocumentLexState()->GetStyleBitsNeeded();
case SCI_PROPERTYNAMES:
return StringResult(lParam, DocumentLexState()->PropertyNames());
case SCI_PROPERTYTYPE:
return DocumentLexState()->PropertyType(reinterpret_cast<const char *>(wParam));
case SCI_DESCRIBEPROPERTY:
return StringResult(lParam, DocumentLexState()->DescribeProperty(reinterpret_cast<const char *>(wParam)));
case SCI_DESCRIBEKEYWORDSETS:
return StringResult(lParam, DocumentLexState()->DescribeWordListSets());
#endif
default:
return Editor::WndProc(iMessage, wParam, lParam);
}
return 0l;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.