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