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