]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/ScintillaBase.cxx
Updated Scintilla to version 1.70
[wxWidgets.git] / src / stc / scintilla / src / ScintillaBase.cxx
1 // Scintilla source code edit control
2 /** @file ScintillaBase.cxx
3 ** An enhanced subclass of Editor with calltips, autocomplete and context menu.
4 **/
5 // Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <stdio.h>
11 #include <ctype.h>
12
13 #include "Platform.h"
14
15 #include "Scintilla.h"
16 #include "PropSet.h"
17 #ifdef SCI_LEXER
18 #include "SciLexer.h"
19 #include "Accessor.h"
20 #include "DocumentAccessor.h"
21 #include "KeyWords.h"
22 #endif
23 #include "ContractionState.h"
24 #include "SVector.h"
25 #include "CellBuffer.h"
26 #include "CallTip.h"
27 #include "KeyMap.h"
28 #include "Indicator.h"
29 #include "XPM.h"
30 #include "LineMarker.h"
31 #include "Style.h"
32 #include "ViewStyle.h"
33 #include "AutoComplete.h"
34 #include "CharClassify.h"
35 #include "Document.h"
36 #include "Editor.h"
37 #include "ScintillaBase.h"
38
39 ScintillaBase::ScintillaBase() {
40 displayPopupMenu = true;
41 listType = 0;
42 maxListWidth = 0;
43 #ifdef SCI_LEXER
44 lexLanguage = SCLEX_CONTAINER;
45 performingStyle = false;
46 lexCurrent = 0;
47 for (int wl = 0;wl < numWordLists;wl++)
48 keyWordLists[wl] = new WordList;
49 keyWordLists[numWordLists] = 0;
50 #endif
51 }
52
53 ScintillaBase::~ScintillaBase() {
54 #ifdef SCI_LEXER
55 for (int wl = 0;wl < numWordLists;wl++)
56 delete keyWordLists[wl];
57 #endif
58 }
59
60 void ScintillaBase::Finalise() {
61 Editor::Finalise();
62 popup.Destroy();
63 }
64
65 void ScintillaBase::RefreshColourPalette(Palette &pal, bool want) {
66 Editor::RefreshColourPalette(pal, want);
67 ct.RefreshColourPalette(pal, want);
68 }
69
70 void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
71 bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
72 if (!isFillUp) {
73 Editor::AddCharUTF(s, len, treatAsDBCS);
74 }
75 if (ac.Active()) {
76 AutoCompleteCharacterAdded(s[0]);
77 // For fill ups add the character after the autocompletion has
78 // triggered so containers see the key so can display a calltip.
79 if (isFillUp) {
80 Editor::AddCharUTF(s, len, treatAsDBCS);
81 }
82 }
83 }
84
85 void ScintillaBase::Command(int cmdId) {
86
87 switch (cmdId) {
88
89 case idAutoComplete: // Nothing to do
90
91 break;
92
93 case idCallTip: // Nothing to do
94
95 break;
96
97 case idcmdUndo:
98 WndProc(SCI_UNDO, 0, 0);
99 break;
100
101 case idcmdRedo:
102 WndProc(SCI_REDO, 0, 0);
103 break;
104
105 case idcmdCut:
106 WndProc(SCI_CUT, 0, 0);
107 break;
108
109 case idcmdCopy:
110 WndProc(SCI_COPY, 0, 0);
111 break;
112
113 case idcmdPaste:
114 WndProc(SCI_PASTE, 0, 0);
115 break;
116
117 case idcmdDelete:
118 WndProc(SCI_CLEAR, 0, 0);
119 break;
120
121 case idcmdSelectAll:
122 WndProc(SCI_SELECTALL, 0, 0);
123 break;
124 }
125 }
126
127 int ScintillaBase::KeyCommand(unsigned int iMessage) {
128 // Most key commands cancel autocompletion mode
129 if (ac.Active()) {
130 switch (iMessage) {
131 // Except for these
132 case SCI_LINEDOWN:
133 AutoCompleteMove(1);
134 return 0;
135 case SCI_LINEUP:
136 AutoCompleteMove( -1);
137 return 0;
138 case SCI_PAGEDOWN:
139 AutoCompleteMove(5);
140 return 0;
141 case SCI_PAGEUP:
142 AutoCompleteMove( -5);
143 return 0;
144 case SCI_VCHOME:
145 AutoCompleteMove( -5000);
146 return 0;
147 case SCI_LINEEND:
148 AutoCompleteMove(5000);
149 return 0;
150 case SCI_DELETEBACK:
151 DelCharBack(true);
152 AutoCompleteCharacterDeleted();
153 EnsureCaretVisible();
154 return 0;
155 case SCI_DELETEBACKNOTLINE:
156 DelCharBack(false);
157 AutoCompleteCharacterDeleted();
158 EnsureCaretVisible();
159 return 0;
160 case SCI_TAB:
161 AutoCompleteCompleted();
162 return 0;
163 case SCI_NEWLINE:
164 AutoCompleteCompleted();
165 return 0;
166
167 default:
168 ac.Cancel();
169 }
170 }
171
172 if (ct.inCallTipMode) {
173 if (
174 (iMessage != SCI_CHARLEFT) &&
175 (iMessage != SCI_CHARLEFTEXTEND) &&
176 (iMessage != SCI_CHARRIGHT) &&
177 (iMessage != SCI_CHARLEFTEXTEND) &&
178 (iMessage != SCI_EDITTOGGLEOVERTYPE) &&
179 (iMessage != SCI_DELETEBACK) &&
180 (iMessage != SCI_DELETEBACKNOTLINE)
181 ) {
182 ct.CallTipCancel();
183 }
184 if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
185 if (currentPos <= ct.posStartCallTip) {
186 ct.CallTipCancel();
187 }
188 }
189 }
190 return Editor::KeyCommand(iMessage);
191 }
192
193 void ScintillaBase::AutoCompleteDoubleClick(void* p) {
194 ScintillaBase* sci = reinterpret_cast<ScintillaBase*>(p);
195 sci->AutoCompleteCompleted();
196 }
197
198 void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
199 //Platform::DebugPrintf("AutoComplete %s\n", list);
200 ct.CallTipCancel();
201
202 if (ac.chooseSingle && (listType == 0)) {
203 if (list && !strchr(list, ac.GetSeparator())) {
204 const char *typeSep = strchr(list, ac.GetTypesep());
205 size_t lenInsert = (typeSep) ? (typeSep-list) : strlen(list);
206 if (ac.ignoreCase) {
207 SetEmptySelection(currentPos - lenEntered);
208 pdoc->DeleteChars(currentPos, lenEntered);
209 SetEmptySelection(currentPos);
210 pdoc->InsertString(currentPos, list, lenInsert);
211 SetEmptySelection(currentPos + lenInsert);
212 } else {
213 SetEmptySelection(currentPos);
214 pdoc->InsertString(currentPos, list + lenEntered, lenInsert - lenEntered);
215 SetEmptySelection(currentPos + lenInsert - lenEntered);
216 }
217 return;
218 }
219 }
220 ac.Start(wMain, idAutoComplete, currentPos, LocationFromPosition(currentPos),
221 lenEntered, vs.lineHeight, IsUnicodeMode());
222
223 PRectangle rcClient = GetClientRectangle();
224 Point pt = LocationFromPosition(currentPos - lenEntered);
225
226 int heightLB = 100;
227 int widthLB = 100;
228 if (pt.x >= rcClient.right - widthLB) {
229 HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB);
230 Redraw();
231 pt = LocationFromPosition(currentPos);
232 }
233 PRectangle rcac;
234 rcac.left = pt.x - ac.lb->CaretFromEdge();
235 if (pt.y >= rcClient.bottom - heightLB && // Wont fit below.
236 pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
237 rcac.top = pt.y - heightLB;
238 if (rcac.top < 0) {
239 heightLB += rcac.top;
240 rcac.top = 0;
241 }
242 } else {
243 rcac.top = pt.y + vs.lineHeight;
244 }
245 rcac.right = rcac.left + widthLB;
246 rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcClient.bottom);
247 ac.lb->SetPositionRelative(rcac, wMain);
248 ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
249 unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;
250 ac.lb->SetAverageCharWidth(aveCharWidth);
251 ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this);
252
253 ac.SetList(list);
254
255 // Fiddle the position of the list so it is right next to the target and wide enough for all its strings
256 PRectangle rcList = ac.lb->GetDesiredRect();
257 int heightAlloced = rcList.bottom - rcList.top;
258 widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left);
259 if (maxListWidth != 0)
260 widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth);
261 // Make an allowance for large strings in list
262 rcList.left = pt.x - ac.lb->CaretFromEdge();
263 rcList.right = rcList.left + widthLB;
264 if (((pt.y + vs.lineHeight) >= (rcClient.bottom - heightAlloced)) && // Wont fit below.
265 ((pt.y + vs.lineHeight / 2) >= (rcClient.bottom + rcClient.top) / 2)) { // and there is more room above.
266 rcList.top = pt.y - heightAlloced;
267 } else {
268 rcList.top = pt.y + vs.lineHeight;
269 }
270 rcList.bottom = rcList.top + heightAlloced;
271 ac.lb->SetPositionRelative(rcList, wMain);
272 ac.Show(true);
273 if (lenEntered != 0) {
274 AutoCompleteMoveToCurrentWord();
275 }
276 }
277
278 void ScintillaBase::AutoCompleteCancel() {
279 ac.Cancel();
280 }
281
282 void ScintillaBase::AutoCompleteMove(int delta) {
283 ac.Move(delta);
284 }
285
286 void ScintillaBase::AutoCompleteMoveToCurrentWord() {
287 char wordCurrent[1000];
288 int i;
289 int startWord = ac.posStart - ac.startLen;
290 for (i = startWord; i < currentPos && i - startWord < 1000; i++)
291 wordCurrent[i - startWord] = pdoc->CharAt(i);
292 wordCurrent[Platform::Minimum(i - startWord, 999)] = '\0';
293 ac.Select(wordCurrent);
294 }
295
296 void ScintillaBase::AutoCompleteCharacterAdded(char ch) {
297 if (ac.IsFillUpChar(ch)) {
298 AutoCompleteCompleted();
299 } else if (ac.IsStopChar(ch)) {
300 ac.Cancel();
301 } else {
302 AutoCompleteMoveToCurrentWord();
303 }
304 }
305
306 void ScintillaBase::AutoCompleteCharacterDeleted() {
307 if (currentPos < ac.posStart - ac.startLen) {
308 ac.Cancel();
309 } else if (ac.cancelAtStartPos && (currentPos <= ac.posStart)) {
310 ac.Cancel();
311 } else {
312 AutoCompleteMoveToCurrentWord();
313 }
314 }
315
316 void ScintillaBase::AutoCompleteCompleted() {
317 int item = ac.lb->GetSelection();
318 char selected[1000];
319 selected[0] = '\0';
320 if (item != -1) {
321 ac.lb->GetValue(item, selected, sizeof(selected));
322 } else {
323 ac.Cancel();
324 return;
325 }
326
327 ac.Show(false);
328
329 listSelected = selected;
330 SCNotification scn = {0};
331 scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION;
332 scn.message = 0;
333 scn.wParam = listType;
334 scn.listType = listType;
335 Position firstPos = ac.posStart - ac.startLen;
336 scn.lParam = firstPos;
337 scn.text = listSelected.c_str();
338 NotifyParent(scn);
339
340 if (!ac.Active())
341 return;
342 ac.Cancel();
343
344 if (listType > 0)
345 return;
346
347 Position endPos = currentPos;
348 if (ac.dropRestOfWord)
349 endPos = pdoc->ExtendWordSelect(endPos, 1, true);
350 if (endPos < firstPos)
351 return;
352 pdoc->BeginUndoAction();
353 if (endPos != firstPos) {
354 pdoc->DeleteChars(firstPos, endPos - firstPos);
355 }
356 SetEmptySelection(ac.posStart);
357 if (item != -1) {
358 SString piece = selected;
359 pdoc->InsertString(firstPos, piece.c_str());
360 SetEmptySelection(firstPos + static_cast<int>(piece.length()));
361 }
362 pdoc->EndUndoAction();
363 }
364
365 int ScintillaBase::AutoCompleteGetCurrent() {
366 return ac.lb->GetSelection();
367 }
368
369 void ScintillaBase::CallTipShow(Point pt, const char *defn) {
370 AutoCompleteCancel();
371 pt.y += vs.lineHeight;
372 // If container knows about STYLE_CALLTIP then use it in place of the
373 // STYLE_DEFAULT for the face name, size and character set. Also use it
374 // for the foreground and background colour.
375 int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT;
376 if (ct.UseStyleCallTip()) {
377 ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);
378 }
379 PRectangle rc = ct.CallTipStart(currentPos, pt,
380 defn,
381 vs.styles[ctStyle].fontName,
382 vs.styles[ctStyle].sizeZoomed,
383 CodePage(),
384 vs.styles[ctStyle].characterSet,
385 wMain);
386 // If the call-tip window would be out of the client
387 // space, adjust so it displays above the text.
388 PRectangle rcClient = GetClientRectangle();
389 if (rc.bottom > rcClient.bottom) {
390 int offset = vs.lineHeight + rc.Height();
391 rc.top -= offset;
392 rc.bottom -= offset;
393 }
394 // Now display the window.
395 CreateCallTipWindow(rc);
396 ct.wCallTip.SetPositionRelative(rc, wMain);
397 ct.wCallTip.Show();
398 }
399
400 void ScintillaBase::CallTipClick() {
401 SCNotification scn = {0};
402 scn.nmhdr.code = SCN_CALLTIPCLICK;
403 scn.position = ct.clickPlace;
404 NotifyParent(scn);
405 }
406
407 void ScintillaBase::ContextMenu(Point pt) {
408 if (displayPopupMenu) {
409 bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
410 popup.CreatePopUp();
411 AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo());
412 AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo());
413 AddToPopUp("");
414 AddToPopUp("Cut", idcmdCut, writable && currentPos != anchor);
415 AddToPopUp("Copy", idcmdCopy, currentPos != anchor);
416 AddToPopUp("Paste", idcmdPaste, writable && WndProc(SCI_CANPASTE, 0, 0));
417 AddToPopUp("Delete", idcmdDelete, writable && currentPos != anchor);
418 AddToPopUp("");
419 AddToPopUp("Select All", idcmdSelectAll);
420 popup.Show(pt, wMain);
421 }
422 }
423
424 void ScintillaBase::CancelModes() {
425 AutoCompleteCancel();
426 ct.CallTipCancel();
427 Editor::CancelModes();
428 }
429
430 void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
431 CancelModes();
432 Editor::ButtonDown(pt, curTime, shift, ctrl, alt);
433 }
434
435 #ifdef SCI_LEXER
436 void ScintillaBase::SetLexer(uptr_t wParam) {
437 lexLanguage = wParam;
438 lexCurrent = LexerModule::Find(lexLanguage);
439 if (!lexCurrent)
440 lexCurrent = LexerModule::Find(SCLEX_NULL);
441 }
442
443 void ScintillaBase::SetLexerLanguage(const char *languageName) {
444 lexLanguage = SCLEX_CONTAINER;
445 lexCurrent = LexerModule::Find(languageName);
446 if (!lexCurrent)
447 lexCurrent = LexerModule::Find(SCLEX_NULL);
448 if (lexCurrent)
449 lexLanguage = lexCurrent->GetLanguage();
450 }
451
452 void ScintillaBase::Colourise(int start, int end) {
453 if (!performingStyle) {
454 // Protect against reentrance, which may occur, for example, when
455 // fold points are discovered while performing styling and the folding
456 // code looks for child lines which may trigger styling.
457 performingStyle = true;
458
459 int lengthDoc = pdoc->Length();
460 if (end == -1)
461 end = lengthDoc;
462 int len = end - start;
463
464 PLATFORM_ASSERT(len >= 0);
465 PLATFORM_ASSERT(start + len <= lengthDoc);
466
467 //WindowAccessor styler(wMain.GetID(), props);
468 DocumentAccessor styler(pdoc, props, wMain.GetID());
469
470 int styleStart = 0;
471 if (start > 0)
472 styleStart = styler.StyleAt(start - 1) & pdoc->stylingBitsMask;
473 styler.SetCodePage(pdoc->dbcsCodePage);
474
475 if (lexCurrent && (len > 0)) { // Should always succeed as null lexer should always be available
476 lexCurrent->Lex(start, len, styleStart, keyWordLists, styler);
477 styler.Flush();
478 if (styler.GetPropertyInt("fold")) {
479 lexCurrent->Fold(start, len, styleStart, keyWordLists, styler);
480 styler.Flush();
481 }
482 }
483
484 performingStyle = false;
485 }
486 }
487 #endif
488
489 void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
490 #ifdef SCI_LEXER
491 if (lexLanguage != SCLEX_CONTAINER) {
492 int endStyled = WndProc(SCI_GETENDSTYLED, 0, 0);
493 int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);
494 endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);
495 Colourise(endStyled, endStyleNeeded);
496 return;
497 }
498 #endif
499 Editor::NotifyStyleToNeeded(endStyleNeeded);
500 }
501
502 sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
503 switch (iMessage) {
504 case SCI_AUTOCSHOW:
505 listType = 0;
506 AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam));
507 break;
508
509 case SCI_AUTOCCANCEL:
510 AutoCompleteCancel();
511 break;
512
513 case SCI_AUTOCACTIVE:
514 return ac.Active();
515
516 case SCI_AUTOCPOSSTART:
517 return ac.posStart;
518
519 case SCI_AUTOCCOMPLETE:
520 AutoCompleteCompleted();
521 break;
522
523 case SCI_AUTOCSETSEPARATOR:
524 ac.SetSeparator(static_cast<char>(wParam));
525 break;
526
527 case SCI_AUTOCGETSEPARATOR:
528 return ac.GetSeparator();
529
530 case SCI_AUTOCSTOPS:
531 ac.SetStopChars(reinterpret_cast<char *>(lParam));
532 break;
533
534 case SCI_AUTOCSELECT:
535 ac.Select(reinterpret_cast<char *>(lParam));
536 break;
537
538 case SCI_AUTOCGETCURRENT:
539 return AutoCompleteGetCurrent();
540
541 case SCI_AUTOCSETCANCELATSTART:
542 ac.cancelAtStartPos = wParam != 0;
543 break;
544
545 case SCI_AUTOCGETCANCELATSTART:
546 return ac.cancelAtStartPos;
547
548 case SCI_AUTOCSETFILLUPS:
549 ac.SetFillUpChars(reinterpret_cast<char *>(lParam));
550 break;
551
552 case SCI_AUTOCSETCHOOSESINGLE:
553 ac.chooseSingle = wParam != 0;
554 break;
555
556 case SCI_AUTOCGETCHOOSESINGLE:
557 return ac.chooseSingle;
558
559 case SCI_AUTOCSETIGNORECASE:
560 ac.ignoreCase = wParam != 0;
561 break;
562
563 case SCI_AUTOCGETIGNORECASE:
564 return ac.ignoreCase;
565
566 case SCI_USERLISTSHOW:
567 listType = wParam;
568 AutoCompleteStart(0, reinterpret_cast<const char *>(lParam));
569 break;
570
571 case SCI_AUTOCSETAUTOHIDE:
572 ac.autoHide = wParam != 0;
573 break;
574
575 case SCI_AUTOCGETAUTOHIDE:
576 return ac.autoHide;
577
578 case SCI_AUTOCSETDROPRESTOFWORD:
579 ac.dropRestOfWord = wParam != 0;
580 break;
581
582 case SCI_AUTOCGETDROPRESTOFWORD:
583 return ac.dropRestOfWord;
584
585 case SCI_AUTOCSETMAXHEIGHT:
586 ac.lb->SetVisibleRows(wParam);
587 break;
588
589 case SCI_AUTOCGETMAXHEIGHT:
590 return ac.lb->GetVisibleRows();
591
592 case SCI_AUTOCSETMAXWIDTH:
593 maxListWidth = wParam;
594 break;
595
596 case SCI_AUTOCGETMAXWIDTH:
597 return maxListWidth;
598
599 case SCI_REGISTERIMAGE:
600 ac.lb->RegisterImage(wParam, reinterpret_cast<const char *>(lParam));
601 break;
602
603 case SCI_CLEARREGISTEREDIMAGES:
604 ac.lb->ClearRegisteredImages();
605 break;
606
607 case SCI_AUTOCSETTYPESEPARATOR:
608 ac.SetTypesep(static_cast<char>(wParam));
609 break;
610
611 case SCI_AUTOCGETTYPESEPARATOR:
612 return ac.GetTypesep();
613
614 case SCI_CALLTIPSHOW:
615 CallTipShow(LocationFromPosition(wParam),
616 reinterpret_cast<const char *>(lParam));
617 break;
618
619 case SCI_CALLTIPCANCEL:
620 ct.CallTipCancel();
621 break;
622
623 case SCI_CALLTIPACTIVE:
624 return ct.inCallTipMode;
625
626 case SCI_CALLTIPPOSSTART:
627 return ct.posStartCallTip;
628
629 case SCI_CALLTIPSETHLT:
630 ct.SetHighlight(wParam, lParam);
631 break;
632
633 case SCI_CALLTIPSETBACK:
634 ct.colourBG = ColourDesired(wParam);
635 vs.styles[STYLE_CALLTIP].fore = ct.colourBG;
636 InvalidateStyleRedraw();
637 break;
638
639 case SCI_CALLTIPSETFORE:
640 ct.colourUnSel = ColourDesired(wParam);
641 vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel;
642 InvalidateStyleRedraw();
643 break;
644
645 case SCI_CALLTIPSETFOREHLT:
646 ct.colourSel = ColourDesired(wParam);
647 InvalidateStyleRedraw();
648 break;
649
650 case SCI_CALLTIPUSESTYLE:
651 ct.SetTabSize((int)wParam);
652 InvalidateStyleRedraw();
653 break;
654
655 case SCI_USEPOPUP:
656 displayPopupMenu = wParam != 0;
657 break;
658
659 #ifdef SCI_LEXER
660 case SCI_SETLEXER:
661 SetLexer(wParam);
662 lexLanguage = wParam;
663 break;
664
665 case SCI_GETLEXER:
666 return lexLanguage;
667
668 case SCI_COLOURISE:
669 if (lexLanguage == SCLEX_CONTAINER) {
670 pdoc->ModifiedAt(wParam);
671 NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam);
672 } else {
673 Colourise(wParam, lParam);
674 }
675 Redraw();
676 break;
677
678 case SCI_SETPROPERTY:
679 props.Set(reinterpret_cast<const char *>(wParam),
680 reinterpret_cast<const char *>(lParam));
681 break;
682
683 case SCI_GETPROPERTY: {
684 SString val = props.Get(reinterpret_cast<const char *>(wParam));
685 const int n = val.length();
686 if (lParam != 0) {
687 char *ptr = reinterpret_cast<char *>(lParam);
688 memcpy(ptr, val.c_str(), n);
689 ptr[n] = '\0'; // terminate
690 }
691 return n; // Not including NUL
692 }
693
694 case SCI_GETPROPERTYEXPANDED: {
695 SString val = props.GetExpanded(reinterpret_cast<const char *>(wParam));
696 const int n = val.length();
697 if (lParam != 0) {
698 char *ptr = reinterpret_cast<char *>(lParam);
699 memcpy(ptr, val.c_str(), n);
700 ptr[n] = '\0'; // terminate
701 }
702 return n; // Not including NUL
703 }
704
705 case SCI_GETPROPERTYINT:
706 return props.GetInt(reinterpret_cast<const char *>(wParam), lParam);
707
708 case SCI_SETKEYWORDS:
709 if (wParam < numWordLists) {
710 keyWordLists[wParam]->Clear();
711 keyWordLists[wParam]->Set(reinterpret_cast<const char *>(lParam));
712 }
713 break;
714
715 case SCI_SETLEXERLANGUAGE:
716 SetLexerLanguage(reinterpret_cast<const char *>(lParam));
717 break;
718
719 case SCI_GETSTYLEBITSNEEDED:
720 return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5;
721 #endif
722
723 default:
724 return Editor::WndProc(iMessage, wParam, lParam);
725 }
726 return 0l;
727 }