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