Minor Scintilla update to 3.2.4
[TortoiseGit.git] / ext / scintilla / src / ScintillaBase.cxx
blob4a88411f5bb6155cff6c5e275bbf3277566a9af0
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>
12 #include <assert.h>
14 #include <string>
15 #include <vector>
16 #include <map>
18 #include "Platform.h"
20 #include "ILexer.h"
21 #include "Scintilla.h"
23 #include "PropSetSimple.h"
24 #ifdef SCI_LEXER
25 #include "SciLexer.h"
26 #include "LexerModule.h"
27 #include "Catalogue.h"
28 #endif
29 #include "SplitVector.h"
30 #include "Partitioning.h"
31 #include "RunStyles.h"
32 #include "ContractionState.h"
33 #include "CellBuffer.h"
34 #include "CallTip.h"
35 #include "KeyMap.h"
36 #include "Indicator.h"
37 #include "XPM.h"
38 #include "LineMarker.h"
39 #include "Style.h"
40 #include "ViewStyle.h"
41 #include "AutoComplete.h"
42 #include "CharClassify.h"
43 #include "Decoration.h"
44 #include "Document.h"
45 #include "Selection.h"
46 #include "PositionCache.h"
47 #include "Editor.h"
48 #include "ScintillaBase.h"
50 #ifdef SCI_NAMESPACE
51 using namespace Scintilla;
52 #endif
54 ScintillaBase::ScintillaBase() {
55 displayPopupMenu = true;
56 listType = 0;
57 maxListWidth = 0;
60 ScintillaBase::~ScintillaBase() {
63 void ScintillaBase::Finalise() {
64 Editor::Finalise();
65 popup.Destroy();
68 void ScintillaBase::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
69 bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
70 if (!isFillUp) {
71 Editor::AddCharUTF(s, len, treatAsDBCS);
73 if (ac.Active()) {
74 AutoCompleteCharacterAdded(s[0]);
75 // For fill ups add the character after the autocompletion has
76 // triggered so containers see the key so can display a calltip.
77 if (isFillUp) {
78 Editor::AddCharUTF(s, len, treatAsDBCS);
83 void ScintillaBase::Command(int cmdId) {
85 switch (cmdId) {
87 case idAutoComplete: // Nothing to do
89 break;
91 case idCallTip: // Nothing to do
93 break;
95 case idcmdUndo:
96 WndProc(SCI_UNDO, 0, 0);
97 break;
99 case idcmdRedo:
100 WndProc(SCI_REDO, 0, 0);
101 break;
103 case idcmdCut:
104 WndProc(SCI_CUT, 0, 0);
105 break;
107 case idcmdCopy:
108 WndProc(SCI_COPY, 0, 0);
109 break;
111 case idcmdPaste:
112 WndProc(SCI_PASTE, 0, 0);
113 break;
115 case idcmdDelete:
116 WndProc(SCI_CLEAR, 0, 0);
117 break;
119 case idcmdSelectAll:
120 WndProc(SCI_SELECTALL, 0, 0);
121 break;
125 int ScintillaBase::KeyCommand(unsigned int iMessage) {
126 // Most key commands cancel autocompletion mode
127 if (ac.Active()) {
128 switch (iMessage) {
129 // Except for these
130 case SCI_LINEDOWN:
131 AutoCompleteMove(1);
132 return 0;
133 case SCI_LINEUP:
134 AutoCompleteMove(-1);
135 return 0;
136 case SCI_PAGEDOWN:
137 AutoCompleteMove(ac.lb->GetVisibleRows());
138 return 0;
139 case SCI_PAGEUP:
140 AutoCompleteMove(-ac.lb->GetVisibleRows());
141 return 0;
142 case SCI_VCHOME:
143 AutoCompleteMove(-5000);
144 return 0;
145 case SCI_LINEEND:
146 AutoCompleteMove(5000);
147 return 0;
148 case SCI_DELETEBACK:
149 DelCharBack(true);
150 AutoCompleteCharacterDeleted();
151 EnsureCaretVisible();
152 return 0;
153 case SCI_DELETEBACKNOTLINE:
154 DelCharBack(false);
155 AutoCompleteCharacterDeleted();
156 EnsureCaretVisible();
157 return 0;
158 case SCI_TAB:
159 AutoCompleteCompleted();
160 return 0;
161 case SCI_NEWLINE:
162 AutoCompleteCompleted();
163 return 0;
165 default:
166 AutoCompleteCancel();
170 if (ct.inCallTipMode) {
171 if (
172 (iMessage != SCI_CHARLEFT) &&
173 (iMessage != SCI_CHARLEFTEXTEND) &&
174 (iMessage != SCI_CHARRIGHT) &&
175 (iMessage != SCI_CHARRIGHTEXTEND) &&
176 (iMessage != SCI_EDITTOGGLEOVERTYPE) &&
177 (iMessage != SCI_DELETEBACK) &&
178 (iMessage != SCI_DELETEBACKNOTLINE)
180 ct.CallTipCancel();
182 if ((iMessage == SCI_DELETEBACK) || (iMessage == SCI_DELETEBACKNOTLINE)) {
183 if (sel.MainCaret() <= ct.posStartCallTip) {
184 ct.CallTipCancel();
188 return Editor::KeyCommand(iMessage);
191 void ScintillaBase::AutoCompleteDoubleClick(void *p) {
192 ScintillaBase *sci = reinterpret_cast<ScintillaBase *>(p);
193 sci->AutoCompleteCompleted();
196 void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
197 //Platform::DebugPrintf("AutoComplete %s\n", list);
198 ct.CallTipCancel();
200 if (ac.chooseSingle && (listType == 0)) {
201 if (list && !strchr(list, ac.GetSeparator())) {
202 const char *typeSep = strchr(list, ac.GetTypesep());
203 int lenInsert = typeSep ?
204 static_cast<int>(typeSep-list) : static_cast<int>(strlen(list));
205 UndoGroup ug(pdoc);
206 if (ac.ignoreCase) {
207 SetEmptySelection(sel.MainCaret() - lenEntered);
208 pdoc->DeleteChars(sel.MainCaret(), lenEntered);
209 SetEmptySelection(sel.MainCaret());
210 pdoc->InsertString(sel.MainCaret(), list, lenInsert);
211 SetEmptySelection(sel.MainCaret() + lenInsert);
212 } else {
213 SetEmptySelection(sel.MainCaret());
214 pdoc->InsertString(sel.MainCaret(), list + lenEntered, lenInsert - lenEntered);
215 SetEmptySelection(sel.MainCaret() + lenInsert - lenEntered);
217 ac.Cancel();
218 return;
221 ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(),
222 lenEntered, vs.lineHeight, IsUnicodeMode(), technology);
224 PRectangle rcClient = GetClientRectangle();
225 Point pt = LocationFromPosition(sel.MainCaret() - lenEntered);
226 PRectangle rcPopupBounds = wMain.GetMonitorRect(pt);
227 if (rcPopupBounds.Height() == 0)
228 rcPopupBounds = rcClient;
230 int heightLB = ac.heightLBDefault;
231 int widthLB = ac.widthLBDefault;
232 if (pt.x >= rcClient.right - widthLB) {
233 HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB);
234 Redraw();
235 pt = PointMainCaret();
237 PRectangle rcac;
238 rcac.left = pt.x - ac.lb->CaretFromEdge();
239 if (pt.y >= rcPopupBounds.bottom - heightLB && // Wont fit below.
240 pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above.
241 rcac.top = pt.y - heightLB;
242 if (rcac.top < rcPopupBounds.top) {
243 heightLB -= (rcPopupBounds.top - rcac.top);
244 rcac.top = rcPopupBounds.top;
246 } else {
247 rcac.top = pt.y + vs.lineHeight;
249 rcac.right = rcac.left + widthLB;
250 rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom);
251 ac.lb->SetPositionRelative(rcac, wMain);
252 ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
253 unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;
254 ac.lb->SetAverageCharWidth(aveCharWidth);
255 ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this);
257 ac.SetList(list);
259 // Fiddle the position of the list so it is right next to the target and wide enough for all its strings
260 PRectangle rcList = ac.lb->GetDesiredRect();
261 int heightAlloced = rcList.bottom - rcList.top;
262 widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left);
263 if (maxListWidth != 0)
264 widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth);
265 // Make an allowance for large strings in list
266 rcList.left = pt.x - ac.lb->CaretFromEdge();
267 rcList.right = rcList.left + widthLB;
268 if (((pt.y + vs.lineHeight) >= (rcPopupBounds.bottom - heightAlloced)) && // Wont fit below.
269 ((pt.y + vs.lineHeight / 2) >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2)) { // and there is more room above.
270 rcList.top = pt.y - heightAlloced;
271 } else {
272 rcList.top = pt.y + vs.lineHeight;
274 rcList.bottom = rcList.top + heightAlloced;
275 ac.lb->SetPositionRelative(rcList, wMain);
276 ac.Show(true);
277 if (lenEntered != 0) {
278 AutoCompleteMoveToCurrentWord();
282 void ScintillaBase::AutoCompleteCancel() {
283 if (ac.Active()) {
284 SCNotification scn = {0};
285 scn.nmhdr.code = SCN_AUTOCCANCELLED;
286 scn.wParam = 0;
287 scn.listType = 0;
288 NotifyParent(scn);
290 ac.Cancel();
293 void ScintillaBase::AutoCompleteMove(int delta) {
294 ac.Move(delta);
297 void ScintillaBase::AutoCompleteMoveToCurrentWord() {
298 std::string wordCurrent = RangeText(ac.posStart - ac.startLen, sel.MainCaret());
299 ac.Select(wordCurrent.c_str());
302 void ScintillaBase::AutoCompleteCharacterAdded(char ch) {
303 if (ac.IsFillUpChar(ch)) {
304 AutoCompleteCompleted();
305 } else if (ac.IsStopChar(ch)) {
306 AutoCompleteCancel();
307 } else {
308 AutoCompleteMoveToCurrentWord();
312 void ScintillaBase::AutoCompleteCharacterDeleted() {
313 if (sel.MainCaret() < ac.posStart - ac.startLen) {
314 AutoCompleteCancel();
315 } else if (ac.cancelAtStartPos && (sel.MainCaret() <= ac.posStart)) {
316 AutoCompleteCancel();
317 } else {
318 AutoCompleteMoveToCurrentWord();
320 SCNotification scn = {0};
321 scn.nmhdr.code = SCN_AUTOCCHARDELETED;
322 scn.wParam = 0;
323 scn.listType = 0;
324 NotifyParent(scn);
327 void ScintillaBase::AutoCompleteCompleted() {
328 int item = ac.GetSelection();
329 if (item == -1) {
330 AutoCompleteCancel();
331 return;
333 const std::string selected = ac.GetValue(item);
335 ac.Show(false);
337 SCNotification scn = {0};
338 scn.nmhdr.code = listType > 0 ? SCN_USERLISTSELECTION : SCN_AUTOCSELECTION;
339 scn.message = 0;
340 scn.wParam = listType;
341 scn.listType = listType;
342 Position firstPos = ac.posStart - ac.startLen;
343 scn.position = firstPos;
344 scn.lParam = firstPos;
345 scn.text = selected.c_str();
346 NotifyParent(scn);
348 if (!ac.Active())
349 return;
350 ac.Cancel();
352 if (listType > 0)
353 return;
355 Position endPos = sel.MainCaret();
356 if (ac.dropRestOfWord)
357 endPos = pdoc->ExtendWordSelect(endPos, 1, true);
358 if (endPos < firstPos)
359 return;
360 UndoGroup ug(pdoc);
361 if (endPos != firstPos) {
362 pdoc->DeleteChars(firstPos, endPos - firstPos);
364 SetEmptySelection(ac.posStart);
365 if (item != -1) {
366 pdoc->InsertCString(firstPos, selected.c_str());
367 SetEmptySelection(firstPos + static_cast<int>(selected.length()));
369 SetLastXChosen();
372 int ScintillaBase::AutoCompleteGetCurrent() {
373 if (!ac.Active())
374 return -1;
375 return ac.GetSelection();
378 int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) {
379 if (ac.Active()) {
380 int item = ac.GetSelection();
381 if (item != -1) {
382 const std::string selected = ac.GetValue(item);
383 if (buffer != NULL)
384 strcpy(buffer, selected.c_str());
385 return static_cast<int>(selected.length());
388 if (buffer != NULL)
389 *buffer = '\0';
390 return 0;
393 void ScintillaBase::CallTipShow(Point pt, const char *defn) {
394 ac.Cancel();
395 // If container knows about STYLE_CALLTIP then use it in place of the
396 // STYLE_DEFAULT for the face name, size and character set. Also use it
397 // for the foreground and background colour.
398 int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT;
399 if (ct.UseStyleCallTip()) {
400 ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);
402 PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt,
403 vs.lineHeight,
404 defn,
405 vs.styles[ctStyle].fontName,
406 vs.styles[ctStyle].sizeZoomed,
407 CodePage(),
408 vs.styles[ctStyle].characterSet,
409 vs.technology,
410 wMain);
411 // If the call-tip window would be out of the client
412 // space
413 PRectangle rcClient = GetClientRectangle();
414 int offset = vs.lineHeight + rc.Height();
415 // adjust so it displays below the text.
416 if (rc.top < rcClient.top) {
417 rc.top += offset;
418 rc.bottom += offset;
420 // adjust so it displays above the text.
421 if (rc.bottom > rcClient.bottom) {
422 rc.top -= offset;
423 rc.bottom -= offset;
425 // Now display the window.
426 CreateCallTipWindow(rc);
427 ct.wCallTip.SetPositionRelative(rc, wMain);
428 ct.wCallTip.Show();
431 void ScintillaBase::CallTipClick() {
432 SCNotification scn = {0};
433 scn.nmhdr.code = SCN_CALLTIPCLICK;
434 scn.position = ct.clickPlace;
435 NotifyParent(scn);
438 void ScintillaBase::ContextMenu(Point pt) {
439 if (displayPopupMenu) {
440 bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
441 popup.CreatePopUp();
442 AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo());
443 AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo());
444 AddToPopUp("");
445 AddToPopUp("Cut", idcmdCut, writable && !sel.Empty());
446 AddToPopUp("Copy", idcmdCopy, !sel.Empty());
447 AddToPopUp("Paste", idcmdPaste, writable && WndProc(SCI_CANPASTE, 0, 0));
448 AddToPopUp("Delete", idcmdDelete, writable && !sel.Empty());
449 AddToPopUp("");
450 AddToPopUp("Select All", idcmdSelectAll);
451 popup.Show(pt, wMain);
455 void ScintillaBase::CancelModes() {
456 AutoCompleteCancel();
457 ct.CallTipCancel();
458 Editor::CancelModes();
461 void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
462 CancelModes();
463 Editor::ButtonDown(pt, curTime, shift, ctrl, alt);
466 #ifdef SCI_LEXER
468 #ifdef SCI_NAMESPACE
469 namespace Scintilla {
470 #endif
472 class LexState : public LexInterface {
473 const LexerModule *lexCurrent;
474 void SetLexerModule(const LexerModule *lex);
475 PropSetSimple props;
476 public:
477 int lexLanguage;
479 LexState(Document *pdoc_);
480 virtual ~LexState();
481 void SetLexer(uptr_t wParam);
482 void SetLexerLanguage(const char *languageName);
483 const char *DescribeWordListSets();
484 void SetWordList(int n, const char *wl);
485 int GetStyleBitsNeeded() const;
486 const char *GetName() const;
487 void *PrivateCall(int operation, void *pointer);
488 const char *PropertyNames();
489 int PropertyType(const char *name);
490 const char *DescribeProperty(const char *name);
491 void PropSet(const char *key, const char *val);
492 const char *PropGet(const char *key) const;
493 int PropGetInt(const char *key, int defaultValue=0) const;
494 int PropGetExpanded(const char *key, char *result) const;
497 #ifdef SCI_NAMESPACE
499 #endif
501 LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) {
502 lexCurrent = 0;
503 performingStyle = false;
504 lexLanguage = SCLEX_CONTAINER;
507 LexState::~LexState() {
508 if (instance) {
509 instance->Release();
510 instance = 0;
514 LexState *ScintillaBase::DocumentLexState() {
515 if (!pdoc->pli) {
516 pdoc->pli = new LexState(pdoc);
518 return static_cast<LexState *>(pdoc->pli);
521 void LexState::SetLexerModule(const LexerModule *lex) {
522 if (lex != lexCurrent) {
523 if (instance) {
524 instance->Release();
525 instance = 0;
527 lexCurrent = lex;
528 if (lexCurrent)
529 instance = lexCurrent->Create();
530 pdoc->LexerChanged();
534 void LexState::SetLexer(uptr_t wParam) {
535 lexLanguage = wParam;
536 if (lexLanguage == SCLEX_CONTAINER) {
537 SetLexerModule(0);
538 } else {
539 const LexerModule *lex = Catalogue::Find(lexLanguage);
540 if (!lex)
541 lex = Catalogue::Find(SCLEX_NULL);
542 SetLexerModule(lex);
546 void LexState::SetLexerLanguage(const char *languageName) {
547 const LexerModule *lex = Catalogue::Find(languageName);
548 if (!lex)
549 lex = Catalogue::Find(SCLEX_NULL);
550 if (lex)
551 lexLanguage = lex->GetLanguage();
552 SetLexerModule(lex);
555 const char *LexState::DescribeWordListSets() {
556 if (instance) {
557 return instance->DescribeWordListSets();
558 } else {
559 return 0;
563 void LexState::SetWordList(int n, const char *wl) {
564 if (instance) {
565 int firstModification = instance->WordListSet(n, wl);
566 if (firstModification >= 0) {
567 pdoc->ModifiedAt(firstModification);
572 int LexState::GetStyleBitsNeeded() const {
573 return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5;
576 const char *LexState::GetName() const {
577 return lexCurrent ? lexCurrent->languageName : "";
580 void *LexState::PrivateCall(int operation, void *pointer) {
581 if (pdoc && instance) {
582 return instance->PrivateCall(operation, pointer);
583 } else {
584 return 0;
588 const char *LexState::PropertyNames() {
589 if (instance) {
590 return instance->PropertyNames();
591 } else {
592 return 0;
596 int LexState::PropertyType(const char *name) {
597 if (instance) {
598 return instance->PropertyType(name);
599 } else {
600 return SC_TYPE_BOOLEAN;
604 const char *LexState::DescribeProperty(const char *name) {
605 if (instance) {
606 return instance->DescribeProperty(name);
607 } else {
608 return 0;
612 void LexState::PropSet(const char *key, const char *val) {
613 props.Set(key, val);
614 if (instance) {
615 int firstModification = instance->PropertySet(key, val);
616 if (firstModification >= 0) {
617 pdoc->ModifiedAt(firstModification);
622 const char *LexState::PropGet(const char *key) const {
623 return props.Get(key);
626 int LexState::PropGetInt(const char *key, int defaultValue) const {
627 return props.GetInt(key, defaultValue);
630 int LexState::PropGetExpanded(const char *key, char *result) const {
631 return props.GetExpanded(key, result);
634 #endif
636 void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
637 #ifdef SCI_LEXER
638 if (DocumentLexState()->lexLanguage != SCLEX_CONTAINER) {
639 int lineEndStyled = pdoc->LineFromPosition(pdoc->GetEndStyled());
640 int endStyled = pdoc->LineStart(lineEndStyled);
641 DocumentLexState()->Colourise(endStyled, endStyleNeeded);
642 return;
644 #endif
645 Editor::NotifyStyleToNeeded(endStyleNeeded);
648 void ScintillaBase::NotifyLexerChanged(Document *, void *) {
649 #ifdef SCI_LEXER
650 int bits = DocumentLexState()->GetStyleBitsNeeded();
651 vs.EnsureStyle((1 << bits) - 1);
652 #endif
655 sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
656 switch (iMessage) {
657 case SCI_AUTOCSHOW:
658 listType = 0;
659 AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam));
660 break;
662 case SCI_AUTOCCANCEL:
663 ac.Cancel();
664 break;
666 case SCI_AUTOCACTIVE:
667 return ac.Active();
669 case SCI_AUTOCPOSSTART:
670 return ac.posStart;
672 case SCI_AUTOCCOMPLETE:
673 AutoCompleteCompleted();
674 break;
676 case SCI_AUTOCSETSEPARATOR:
677 ac.SetSeparator(static_cast<char>(wParam));
678 break;
680 case SCI_AUTOCGETSEPARATOR:
681 return ac.GetSeparator();
683 case SCI_AUTOCSTOPS:
684 ac.SetStopChars(reinterpret_cast<char *>(lParam));
685 break;
687 case SCI_AUTOCSELECT:
688 ac.Select(reinterpret_cast<char *>(lParam));
689 break;
691 case SCI_AUTOCGETCURRENT:
692 return AutoCompleteGetCurrent();
694 case SCI_AUTOCGETCURRENTTEXT:
695 return AutoCompleteGetCurrentText(reinterpret_cast<char *>(lParam));
697 case SCI_AUTOCSETCANCELATSTART:
698 ac.cancelAtStartPos = wParam != 0;
699 break;
701 case SCI_AUTOCGETCANCELATSTART:
702 return ac.cancelAtStartPos;
704 case SCI_AUTOCSETFILLUPS:
705 ac.SetFillUpChars(reinterpret_cast<char *>(lParam));
706 break;
708 case SCI_AUTOCSETCHOOSESINGLE:
709 ac.chooseSingle = wParam != 0;
710 break;
712 case SCI_AUTOCGETCHOOSESINGLE:
713 return ac.chooseSingle;
715 case SCI_AUTOCSETIGNORECASE:
716 ac.ignoreCase = wParam != 0;
717 break;
719 case SCI_AUTOCGETIGNORECASE:
720 return ac.ignoreCase;
722 case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR:
723 ac.ignoreCaseBehaviour = wParam;
724 break;
726 case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR:
727 return ac.ignoreCaseBehaviour;
729 case SCI_USERLISTSHOW:
730 listType = wParam;
731 AutoCompleteStart(0, reinterpret_cast<const char *>(lParam));
732 break;
734 case SCI_AUTOCSETAUTOHIDE:
735 ac.autoHide = wParam != 0;
736 break;
738 case SCI_AUTOCGETAUTOHIDE:
739 return ac.autoHide;
741 case SCI_AUTOCSETDROPRESTOFWORD:
742 ac.dropRestOfWord = wParam != 0;
743 break;
745 case SCI_AUTOCGETDROPRESTOFWORD:
746 return ac.dropRestOfWord;
748 case SCI_AUTOCSETMAXHEIGHT:
749 ac.lb->SetVisibleRows(wParam);
750 break;
752 case SCI_AUTOCGETMAXHEIGHT:
753 return ac.lb->GetVisibleRows();
755 case SCI_AUTOCSETMAXWIDTH:
756 maxListWidth = wParam;
757 break;
759 case SCI_AUTOCGETMAXWIDTH:
760 return maxListWidth;
762 case SCI_REGISTERIMAGE:
763 ac.lb->RegisterImage(wParam, reinterpret_cast<const char *>(lParam));
764 break;
766 case SCI_REGISTERRGBAIMAGE:
767 ac.lb->RegisterRGBAImage(wParam, sizeRGBAImage.x, sizeRGBAImage.y, reinterpret_cast<unsigned char *>(lParam));
768 break;
770 case SCI_CLEARREGISTEREDIMAGES:
771 ac.lb->ClearRegisteredImages();
772 break;
774 case SCI_AUTOCSETTYPESEPARATOR:
775 ac.SetTypesep(static_cast<char>(wParam));
776 break;
778 case SCI_AUTOCGETTYPESEPARATOR:
779 return ac.GetTypesep();
781 case SCI_CALLTIPSHOW:
782 CallTipShow(LocationFromPosition(wParam),
783 reinterpret_cast<const char *>(lParam));
784 break;
786 case SCI_CALLTIPCANCEL:
787 ct.CallTipCancel();
788 break;
790 case SCI_CALLTIPACTIVE:
791 return ct.inCallTipMode;
793 case SCI_CALLTIPPOSSTART:
794 return ct.posStartCallTip;
796 case SCI_CALLTIPSETHLT:
797 ct.SetHighlight(wParam, lParam);
798 break;
800 case SCI_CALLTIPSETBACK:
801 ct.colourBG = ColourDesired(wParam);
802 vs.styles[STYLE_CALLTIP].back = ct.colourBG;
803 InvalidateStyleRedraw();
804 break;
806 case SCI_CALLTIPSETFORE:
807 ct.colourUnSel = ColourDesired(wParam);
808 vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel;
809 InvalidateStyleRedraw();
810 break;
812 case SCI_CALLTIPSETFOREHLT:
813 ct.colourSel = ColourDesired(wParam);
814 InvalidateStyleRedraw();
815 break;
817 case SCI_CALLTIPUSESTYLE:
818 ct.SetTabSize((int)wParam);
819 InvalidateStyleRedraw();
820 break;
822 case SCI_CALLTIPSETPOSITION:
823 ct.SetPosition(wParam != 0);
824 InvalidateStyleRedraw();
825 break;
827 case SCI_USEPOPUP:
828 displayPopupMenu = wParam != 0;
829 break;
831 #ifdef SCI_LEXER
832 case SCI_SETLEXER:
833 DocumentLexState()->SetLexer(wParam);
834 break;
836 case SCI_GETLEXER:
837 return DocumentLexState()->lexLanguage;
839 case SCI_COLOURISE:
840 if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) {
841 pdoc->ModifiedAt(wParam);
842 NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam);
843 } else {
844 DocumentLexState()->Colourise(wParam, lParam);
846 Redraw();
847 break;
849 case SCI_SETPROPERTY:
850 DocumentLexState()->PropSet(reinterpret_cast<const char *>(wParam),
851 reinterpret_cast<const char *>(lParam));
852 break;
854 case SCI_GETPROPERTY:
855 return StringResult(lParam, DocumentLexState()->PropGet(reinterpret_cast<const char *>(wParam)));
857 case SCI_GETPROPERTYEXPANDED:
858 return DocumentLexState()->PropGetExpanded(reinterpret_cast<const char *>(wParam),
859 reinterpret_cast<char *>(lParam));
861 case SCI_GETPROPERTYINT:
862 return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), lParam);
864 case SCI_SETKEYWORDS:
865 DocumentLexState()->SetWordList(wParam, reinterpret_cast<const char *>(lParam));
866 break;
868 case SCI_SETLEXERLANGUAGE:
869 DocumentLexState()->SetLexerLanguage(reinterpret_cast<const char *>(lParam));
870 break;
872 case SCI_GETLEXERLANGUAGE:
873 return StringResult(lParam, DocumentLexState()->GetName());
875 case SCI_PRIVATELEXERCALL:
876 return reinterpret_cast<sptr_t>(
877 DocumentLexState()->PrivateCall(wParam, reinterpret_cast<void *>(lParam)));
879 case SCI_GETSTYLEBITSNEEDED:
880 return DocumentLexState()->GetStyleBitsNeeded();
882 case SCI_PROPERTYNAMES:
883 return StringResult(lParam, DocumentLexState()->PropertyNames());
885 case SCI_PROPERTYTYPE:
886 return DocumentLexState()->PropertyType(reinterpret_cast<const char *>(wParam));
888 case SCI_DESCRIBEPROPERTY:
889 return StringResult(lParam, DocumentLexState()->DescribeProperty(reinterpret_cast<const char *>(wParam)));
891 case SCI_DESCRIBEKEYWORDSETS:
892 return StringResult(lParam, DocumentLexState()->DescribeWordListSets());
894 #endif
896 default:
897 return Editor::WndProc(iMessage, wParam, lParam);
899 return 0l;