1 // Scintilla source code edit control
2 /** @file ScintillaBase.cxx
3 ** An enhanced subclass of Editor with calltips, autocomplete and context menu.
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.
22 #include "Scintilla.h"
28 #include "PropSetSimple.h"
31 #include "LexerModule.h"
32 #include "Catalogue.h"
35 #include "SplitVector.h"
36 #include "Partitioning.h"
37 #include "RunStyles.h"
38 #include "ContractionState.h"
39 #include "CellBuffer.h"
42 #include "Indicator.h"
44 #include "LineMarker.h"
46 #include "ViewStyle.h"
47 #include "CharClassify.h"
48 #include "Decoration.h"
49 #include "CaseFolder.h"
51 #include "Selection.h"
52 #include "PositionCache.h"
54 #include "AutoComplete.h"
55 #include "ScintillaBase.h"
58 using namespace Scintilla
;
61 ScintillaBase::ScintillaBase() {
62 displayPopupMenu
= true;
65 multiAutoCMode
= SC_MULTIAUTOC_ONCE
;
68 ScintillaBase::~ScintillaBase() {
71 void ScintillaBase::Finalise() {
76 void ScintillaBase::AddCharUTF(char *s
, unsigned int len
, bool treatAsDBCS
) {
77 bool isFillUp
= ac
.Active() && ac
.IsFillUpChar(*s
);
79 Editor::AddCharUTF(s
, len
, treatAsDBCS
);
82 AutoCompleteCharacterAdded(s
[0]);
83 // For fill ups add the character after the autocompletion has
84 // triggered so containers see the key so can display a calltip.
86 Editor::AddCharUTF(s
, len
, treatAsDBCS
);
91 void ScintillaBase::Command(int cmdId
) {
95 case idAutoComplete
: // Nothing to do
99 case idCallTip
: // Nothing to do
104 WndProc(SCI_UNDO
, 0, 0);
108 WndProc(SCI_REDO
, 0, 0);
112 WndProc(SCI_CUT
, 0, 0);
116 WndProc(SCI_COPY
, 0, 0);
120 WndProc(SCI_PASTE
, 0, 0);
124 WndProc(SCI_CLEAR
, 0, 0);
128 WndProc(SCI_SELECTALL
, 0, 0);
133 int ScintillaBase::KeyCommand(unsigned int iMessage
) {
134 // Most key commands cancel autocompletion mode
142 AutoCompleteMove(-1);
145 AutoCompleteMove(ac
.lb
->GetVisibleRows());
148 AutoCompleteMove(-ac
.lb
->GetVisibleRows());
151 AutoCompleteMove(-5000);
154 AutoCompleteMove(5000);
158 AutoCompleteCharacterDeleted();
159 EnsureCaretVisible();
161 case SCI_DELETEBACKNOTLINE
:
163 AutoCompleteCharacterDeleted();
164 EnsureCaretVisible();
167 AutoCompleteCompleted();
170 AutoCompleteCompleted();
174 AutoCompleteCancel();
178 if (ct
.inCallTipMode
) {
180 (iMessage
!= SCI_CHARLEFT
) &&
181 (iMessage
!= SCI_CHARLEFTEXTEND
) &&
182 (iMessage
!= SCI_CHARRIGHT
) &&
183 (iMessage
!= SCI_CHARRIGHTEXTEND
) &&
184 (iMessage
!= SCI_EDITTOGGLEOVERTYPE
) &&
185 (iMessage
!= SCI_DELETEBACK
) &&
186 (iMessage
!= SCI_DELETEBACKNOTLINE
)
190 if ((iMessage
== SCI_DELETEBACK
) || (iMessage
== SCI_DELETEBACKNOTLINE
)) {
191 if (sel
.MainCaret() <= ct
.posStartCallTip
) {
196 return Editor::KeyCommand(iMessage
);
199 void ScintillaBase::AutoCompleteDoubleClick(void *p
) {
200 ScintillaBase
*sci
= reinterpret_cast<ScintillaBase
*>(p
);
201 sci
->AutoCompleteCompleted();
204 void ScintillaBase::AutoCompleteInsert(Position startPos
, int removeLen
, const char *text
, int textLen
) {
206 if (multiAutoCMode
== SC_MULTIAUTOC_ONCE
) {
207 pdoc
->DeleteChars(startPos
, removeLen
);
208 const int lengthInserted
= pdoc
->InsertString(startPos
, text
, textLen
);
209 SetEmptySelection(startPos
+ lengthInserted
);
211 // SC_MULTIAUTOC_EACH
212 for (size_t r
=0; r
<sel
.Count(); r
++) {
213 if (!RangeContainsProtected(sel
.Range(r
).Start().Position(),
214 sel
.Range(r
).End().Position())) {
215 int positionInsert
= sel
.Range(r
).Start().Position();
216 positionInsert
= InsertSpace(positionInsert
, sel
.Range(r
).caret
.VirtualSpace());
217 if (positionInsert
- removeLen
>= 0) {
218 positionInsert
-= removeLen
;
219 pdoc
->DeleteChars(positionInsert
, removeLen
);
221 const int lengthInserted
= pdoc
->InsertString(positionInsert
, text
, textLen
);
222 if (lengthInserted
> 0) {
223 sel
.Range(r
).caret
.SetPosition(positionInsert
+ lengthInserted
);
224 sel
.Range(r
).anchor
.SetPosition(positionInsert
+ lengthInserted
);
226 sel
.Range(r
).ClearVirtualSpace();
232 void ScintillaBase::AutoCompleteStart(int lenEntered
, const char *list
) {
233 //Platform::DebugPrintf("AutoComplete %s\n", list);
236 if (ac
.chooseSingle
&& (listType
== 0)) {
237 if (list
&& !strchr(list
, ac
.GetSeparator())) {
238 const char *typeSep
= strchr(list
, ac
.GetTypesep());
239 int lenInsert
= typeSep
?
240 static_cast<int>(typeSep
-list
) : static_cast<int>(strlen(list
));
242 // May need to convert the case before invocation, so remove lenEntered characters
243 AutoCompleteInsert(sel
.MainCaret() - lenEntered
, lenEntered
, list
, lenInsert
);
245 AutoCompleteInsert(sel
.MainCaret(), 0, list
+ lenEntered
, lenInsert
- lenEntered
);
251 ac
.Start(wMain
, idAutoComplete
, sel
.MainCaret(), PointMainCaret(),
252 lenEntered
, vs
.lineHeight
, IsUnicodeMode(), technology
);
254 PRectangle rcClient
= GetClientRectangle();
255 Point pt
= LocationFromPosition(sel
.MainCaret() - lenEntered
);
256 PRectangle rcPopupBounds
= wMain
.GetMonitorRect(pt
);
257 if (rcPopupBounds
.Height() == 0)
258 rcPopupBounds
= rcClient
;
260 int heightLB
= ac
.heightLBDefault
;
261 int widthLB
= ac
.widthLBDefault
;
262 if (pt
.x
>= rcClient
.right
- widthLB
) {
263 HorizontalScrollTo(static_cast<int>(xOffset
+ pt
.x
- rcClient
.right
+ widthLB
));
265 pt
= PointMainCaret();
267 if (wMargin
.GetID()) {
268 Point ptOrigin
= GetVisibleOriginInMain();
273 rcac
.left
= pt
.x
- ac
.lb
->CaretFromEdge();
274 if (pt
.y
>= rcPopupBounds
.bottom
- heightLB
&& // Wont fit below.
275 pt
.y
>= (rcPopupBounds
.bottom
+ rcPopupBounds
.top
) / 2) { // and there is more room above.
276 rcac
.top
= pt
.y
- heightLB
;
277 if (rcac
.top
< rcPopupBounds
.top
) {
278 heightLB
-= static_cast<int>(rcPopupBounds
.top
- rcac
.top
);
279 rcac
.top
= rcPopupBounds
.top
;
282 rcac
.top
= pt
.y
+ vs
.lineHeight
;
284 rcac
.right
= rcac
.left
+ widthLB
;
285 rcac
.bottom
= static_cast<XYPOSITION
>(Platform::Minimum(static_cast<int>(rcac
.top
) + heightLB
, static_cast<int>(rcPopupBounds
.bottom
)));
286 ac
.lb
->SetPositionRelative(rcac
, wMain
);
287 ac
.lb
->SetFont(vs
.styles
[STYLE_DEFAULT
].font
);
288 unsigned int aveCharWidth
= static_cast<unsigned int>(vs
.styles
[STYLE_DEFAULT
].aveCharWidth
);
289 ac
.lb
->SetAverageCharWidth(aveCharWidth
);
290 ac
.lb
->SetDoubleClickAction(AutoCompleteDoubleClick
, this);
292 ac
.SetList(list
? list
: "");
294 // Fiddle the position of the list so it is right next to the target and wide enough for all its strings
295 PRectangle rcList
= ac
.lb
->GetDesiredRect();
296 int heightAlloced
= static_cast<int>(rcList
.bottom
- rcList
.top
);
297 widthLB
= Platform::Maximum(widthLB
, static_cast<int>(rcList
.right
- rcList
.left
));
298 if (maxListWidth
!= 0)
299 widthLB
= Platform::Minimum(widthLB
, aveCharWidth
*maxListWidth
);
300 // Make an allowance for large strings in list
301 rcList
.left
= pt
.x
- ac
.lb
->CaretFromEdge();
302 rcList
.right
= rcList
.left
+ widthLB
;
303 if (((pt
.y
+ vs
.lineHeight
) >= (rcPopupBounds
.bottom
- heightAlloced
)) && // Wont fit below.
304 ((pt
.y
+ vs
.lineHeight
/ 2) >= (rcPopupBounds
.bottom
+ rcPopupBounds
.top
) / 2)) { // and there is more room above.
305 rcList
.top
= pt
.y
- heightAlloced
;
307 rcList
.top
= pt
.y
+ vs
.lineHeight
;
309 rcList
.bottom
= rcList
.top
+ heightAlloced
;
310 ac
.lb
->SetPositionRelative(rcList
, wMain
);
312 if (lenEntered
!= 0) {
313 AutoCompleteMoveToCurrentWord();
317 void ScintillaBase::AutoCompleteCancel() {
319 SCNotification scn
= {};
320 scn
.nmhdr
.code
= SCN_AUTOCCANCELLED
;
328 void ScintillaBase::AutoCompleteMove(int delta
) {
332 void ScintillaBase::AutoCompleteMoveToCurrentWord() {
333 std::string wordCurrent
= RangeText(ac
.posStart
- ac
.startLen
, sel
.MainCaret());
334 ac
.Select(wordCurrent
.c_str());
337 void ScintillaBase::AutoCompleteCharacterAdded(char ch
) {
338 if (ac
.IsFillUpChar(ch
)) {
339 AutoCompleteCompleted();
340 } else if (ac
.IsStopChar(ch
)) {
341 AutoCompleteCancel();
343 AutoCompleteMoveToCurrentWord();
347 void ScintillaBase::AutoCompleteCharacterDeleted() {
348 if (sel
.MainCaret() < ac
.posStart
- ac
.startLen
) {
349 AutoCompleteCancel();
350 } else if (ac
.cancelAtStartPos
&& (sel
.MainCaret() <= ac
.posStart
)) {
351 AutoCompleteCancel();
353 AutoCompleteMoveToCurrentWord();
355 SCNotification scn
= {};
356 scn
.nmhdr
.code
= SCN_AUTOCCHARDELETED
;
362 void ScintillaBase::AutoCompleteCompleted() {
363 int item
= ac
.GetSelection();
365 AutoCompleteCancel();
368 const std::string selected
= ac
.GetValue(item
);
372 SCNotification scn
= {};
373 scn
.nmhdr
.code
= listType
> 0 ? SCN_USERLISTSELECTION
: SCN_AUTOCSELECTION
;
375 scn
.wParam
= listType
;
376 scn
.listType
= listType
;
377 Position firstPos
= ac
.posStart
- ac
.startLen
;
378 scn
.position
= firstPos
;
379 scn
.lParam
= firstPos
;
380 scn
.text
= selected
.c_str();
390 Position endPos
= sel
.MainCaret();
391 if (ac
.dropRestOfWord
)
392 endPos
= pdoc
->ExtendWordSelect(endPos
, 1, true);
393 if (endPos
< firstPos
)
395 AutoCompleteInsert(firstPos
, endPos
- firstPos
, selected
.c_str(), static_cast<int>(selected
.length()));
399 int ScintillaBase::AutoCompleteGetCurrent() const {
402 return ac
.GetSelection();
405 int ScintillaBase::AutoCompleteGetCurrentText(char *buffer
) const {
407 int item
= ac
.GetSelection();
409 const std::string selected
= ac
.GetValue(item
);
411 memcpy(buffer
, selected
.c_str(), selected
.length()+1);
412 return static_cast<int>(selected
.length());
420 void ScintillaBase::CallTipShow(Point pt
, const char *defn
) {
422 // If container knows about STYLE_CALLTIP then use it in place of the
423 // STYLE_DEFAULT for the face name, size and character set. Also use it
424 // for the foreground and background colour.
425 int ctStyle
= ct
.UseStyleCallTip() ? STYLE_CALLTIP
: STYLE_DEFAULT
;
426 if (ct
.UseStyleCallTip()) {
427 ct
.SetForeBack(vs
.styles
[STYLE_CALLTIP
].fore
, vs
.styles
[STYLE_CALLTIP
].back
);
429 if (wMargin
.GetID()) {
430 Point ptOrigin
= GetVisibleOriginInMain();
434 PRectangle rc
= ct
.CallTipStart(sel
.MainCaret(), pt
,
437 vs
.styles
[ctStyle
].fontName
,
438 vs
.styles
[ctStyle
].sizeZoomed
,
440 vs
.styles
[ctStyle
].characterSet
,
443 // If the call-tip window would be out of the client
445 PRectangle rcClient
= GetClientRectangle();
446 int offset
= vs
.lineHeight
+ static_cast<int>(rc
.Height());
447 // adjust so it displays above the text.
448 if (rc
.bottom
> rcClient
.bottom
) {
452 // adjust so it displays below the text.
453 if (rc
.top
< rcClient
.top
) {
457 // Now display the window.
458 CreateCallTipWindow(rc
);
459 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
463 void ScintillaBase::CallTipClick() {
464 SCNotification scn
= {};
465 scn
.nmhdr
.code
= SCN_CALLTIPCLICK
;
466 scn
.position
= ct
.clickPlace
;
470 void ScintillaBase::ContextMenu(Point pt
) {
471 if (displayPopupMenu
) {
472 bool writable
= !WndProc(SCI_GETREADONLY
, 0, 0);
474 AddToPopUp("Undo", idcmdUndo
, writable
&& pdoc
->CanUndo());
475 AddToPopUp("Redo", idcmdRedo
, writable
&& pdoc
->CanRedo());
477 AddToPopUp("Cut", idcmdCut
, writable
&& !sel
.Empty());
478 AddToPopUp("Copy", idcmdCopy
, !sel
.Empty());
479 AddToPopUp("Paste", idcmdPaste
, writable
&& WndProc(SCI_CANPASTE
, 0, 0));
480 AddToPopUp("Delete", idcmdDelete
, writable
&& !sel
.Empty());
482 AddToPopUp("Select All", idcmdSelectAll
);
483 popup
.Show(pt
, wMain
);
487 void ScintillaBase::CancelModes() {
488 AutoCompleteCancel();
490 Editor::CancelModes();
493 void ScintillaBase::ButtonDownWithModifiers(Point pt
, unsigned int curTime
, int modifiers
) {
495 Editor::ButtonDownWithModifiers(pt
, curTime
, modifiers
);
498 void ScintillaBase::ButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
499 ButtonDownWithModifiers(pt
, curTime
, ModifierFlags(shift
, ctrl
, alt
));
505 namespace Scintilla
{
508 class LexState
: public LexInterface
{
509 const LexerModule
*lexCurrent
;
510 void SetLexerModule(const LexerModule
*lex
);
512 int interfaceVersion
;
516 explicit LexState(Document
*pdoc_
);
518 void SetLexer(uptr_t wParam
);
519 void SetLexerLanguage(const char *languageName
);
520 const char *DescribeWordListSets();
521 void SetWordList(int n
, const char *wl
);
522 const char *GetName() const;
523 void *PrivateCall(int operation
, void *pointer
);
524 const char *PropertyNames();
525 int PropertyType(const char *name
);
526 const char *DescribeProperty(const char *name
);
527 void PropSet(const char *key
, const char *val
);
528 const char *PropGet(const char *key
) const;
529 int PropGetInt(const char *key
, int defaultValue
=0) const;
530 int PropGetExpanded(const char *key
, char *result
) const;
532 int LineEndTypesSupported();
533 int AllocateSubStyles(int styleBase
, int numberStyles
);
534 int SubStylesStart(int styleBase
);
535 int SubStylesLength(int styleBase
);
536 int StyleFromSubStyle(int subStyle
);
537 int PrimaryStyleFromStyle(int style
);
538 void FreeSubStyles();
539 void SetIdentifiers(int style
, const char *identifiers
);
540 int DistanceToSecondaryStyles();
541 const char *GetSubStyleBases();
548 LexState::LexState(Document
*pdoc_
) : LexInterface(pdoc_
) {
550 performingStyle
= false;
551 interfaceVersion
= lvOriginal
;
552 lexLanguage
= SCLEX_CONTAINER
;
555 LexState::~LexState() {
562 LexState
*ScintillaBase::DocumentLexState() {
564 pdoc
->pli
= new LexState(pdoc
);
566 return static_cast<LexState
*>(pdoc
->pli
);
569 void LexState::SetLexerModule(const LexerModule
*lex
) {
570 if (lex
!= lexCurrent
) {
575 interfaceVersion
= lvOriginal
;
578 instance
= lexCurrent
->Create();
579 interfaceVersion
= instance
->Version();
581 pdoc
->LexerChanged();
585 void LexState::SetLexer(uptr_t wParam
) {
586 lexLanguage
= wParam
;
587 if (lexLanguage
== SCLEX_CONTAINER
) {
590 const LexerModule
*lex
= Catalogue::Find(lexLanguage
);
592 lex
= Catalogue::Find(SCLEX_NULL
);
597 void LexState::SetLexerLanguage(const char *languageName
) {
598 const LexerModule
*lex
= Catalogue::Find(languageName
);
600 lex
= Catalogue::Find(SCLEX_NULL
);
602 lexLanguage
= lex
->GetLanguage();
606 const char *LexState::DescribeWordListSets() {
608 return instance
->DescribeWordListSets();
614 void LexState::SetWordList(int n
, const char *wl
) {
616 int firstModification
= instance
->WordListSet(n
, wl
);
617 if (firstModification
>= 0) {
618 pdoc
->ModifiedAt(firstModification
);
623 const char *LexState::GetName() const {
624 return lexCurrent
? lexCurrent
->languageName
: "";
627 void *LexState::PrivateCall(int operation
, void *pointer
) {
628 if (pdoc
&& instance
) {
629 return instance
->PrivateCall(operation
, pointer
);
635 const char *LexState::PropertyNames() {
637 return instance
->PropertyNames();
643 int LexState::PropertyType(const char *name
) {
645 return instance
->PropertyType(name
);
647 return SC_TYPE_BOOLEAN
;
651 const char *LexState::DescribeProperty(const char *name
) {
653 return instance
->DescribeProperty(name
);
659 void LexState::PropSet(const char *key
, const char *val
) {
662 int firstModification
= instance
->PropertySet(key
, val
);
663 if (firstModification
>= 0) {
664 pdoc
->ModifiedAt(firstModification
);
669 const char *LexState::PropGet(const char *key
) const {
670 return props
.Get(key
);
673 int LexState::PropGetInt(const char *key
, int defaultValue
) const {
674 return props
.GetInt(key
, defaultValue
);
677 int LexState::PropGetExpanded(const char *key
, char *result
) const {
678 return props
.GetExpanded(key
, result
);
681 int LexState::LineEndTypesSupported() {
682 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
683 return static_cast<ILexerWithSubStyles
*>(instance
)->LineEndTypesSupported();
688 int LexState::AllocateSubStyles(int styleBase
, int numberStyles
) {
689 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
690 return static_cast<ILexerWithSubStyles
*>(instance
)->AllocateSubStyles(styleBase
, numberStyles
);
695 int LexState::SubStylesStart(int styleBase
) {
696 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
697 return static_cast<ILexerWithSubStyles
*>(instance
)->SubStylesStart(styleBase
);
702 int LexState::SubStylesLength(int styleBase
) {
703 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
704 return static_cast<ILexerWithSubStyles
*>(instance
)->SubStylesLength(styleBase
);
709 int LexState::StyleFromSubStyle(int subStyle
) {
710 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
711 return static_cast<ILexerWithSubStyles
*>(instance
)->StyleFromSubStyle(subStyle
);
716 int LexState::PrimaryStyleFromStyle(int style
) {
717 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
718 return static_cast<ILexerWithSubStyles
*>(instance
)->PrimaryStyleFromStyle(style
);
723 void LexState::FreeSubStyles() {
724 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
725 static_cast<ILexerWithSubStyles
*>(instance
)->FreeSubStyles();
729 void LexState::SetIdentifiers(int style
, const char *identifiers
) {
730 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
731 static_cast<ILexerWithSubStyles
*>(instance
)->SetIdentifiers(style
, identifiers
);
735 int LexState::DistanceToSecondaryStyles() {
736 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
737 return static_cast<ILexerWithSubStyles
*>(instance
)->DistanceToSecondaryStyles();
742 const char *LexState::GetSubStyleBases() {
743 if (instance
&& (interfaceVersion
>= lvSubStyles
)) {
744 return static_cast<ILexerWithSubStyles
*>(instance
)->GetSubStyleBases();
751 void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded
) {
753 if (DocumentLexState()->lexLanguage
!= SCLEX_CONTAINER
) {
754 int lineEndStyled
= pdoc
->LineFromPosition(pdoc
->GetEndStyled());
755 int endStyled
= pdoc
->LineStart(lineEndStyled
);
756 DocumentLexState()->Colourise(endStyled
, endStyleNeeded
);
760 Editor::NotifyStyleToNeeded(endStyleNeeded
);
763 void ScintillaBase::NotifyLexerChanged(Document
*, void *) {
765 vs
.EnsureStyle(0xff);
769 sptr_t
ScintillaBase::WndProc(unsigned int iMessage
, uptr_t wParam
, sptr_t lParam
) {
773 AutoCompleteStart(static_cast<int>(wParam
), reinterpret_cast<const char *>(lParam
));
776 case SCI_AUTOCCANCEL
:
780 case SCI_AUTOCACTIVE
:
783 case SCI_AUTOCPOSSTART
:
786 case SCI_AUTOCCOMPLETE
:
787 AutoCompleteCompleted();
790 case SCI_AUTOCSETSEPARATOR
:
791 ac
.SetSeparator(static_cast<char>(wParam
));
794 case SCI_AUTOCGETSEPARATOR
:
795 return ac
.GetSeparator();
798 ac
.SetStopChars(reinterpret_cast<char *>(lParam
));
801 case SCI_AUTOCSELECT
:
802 ac
.Select(reinterpret_cast<char *>(lParam
));
805 case SCI_AUTOCGETCURRENT
:
806 return AutoCompleteGetCurrent();
808 case SCI_AUTOCGETCURRENTTEXT
:
809 return AutoCompleteGetCurrentText(reinterpret_cast<char *>(lParam
));
811 case SCI_AUTOCSETCANCELATSTART
:
812 ac
.cancelAtStartPos
= wParam
!= 0;
815 case SCI_AUTOCGETCANCELATSTART
:
816 return ac
.cancelAtStartPos
;
818 case SCI_AUTOCSETFILLUPS
:
819 ac
.SetFillUpChars(reinterpret_cast<char *>(lParam
));
822 case SCI_AUTOCSETCHOOSESINGLE
:
823 ac
.chooseSingle
= wParam
!= 0;
826 case SCI_AUTOCGETCHOOSESINGLE
:
827 return ac
.chooseSingle
;
829 case SCI_AUTOCSETIGNORECASE
:
830 ac
.ignoreCase
= wParam
!= 0;
833 case SCI_AUTOCGETIGNORECASE
:
834 return ac
.ignoreCase
;
836 case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR
:
837 ac
.ignoreCaseBehaviour
= static_cast<unsigned int>(wParam
);
840 case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR
:
841 return ac
.ignoreCaseBehaviour
;
843 case SCI_AUTOCSETMULTI
:
844 multiAutoCMode
= static_cast<int>(wParam
);
847 case SCI_AUTOCGETMULTI
:
848 return multiAutoCMode
;
850 case SCI_AUTOCSETORDER
:
851 ac
.autoSort
= static_cast<int>(wParam
);
854 case SCI_AUTOCGETORDER
:
857 case SCI_USERLISTSHOW
:
858 listType
= static_cast<int>(wParam
);
859 AutoCompleteStart(0, reinterpret_cast<const char *>(lParam
));
862 case SCI_AUTOCSETAUTOHIDE
:
863 ac
.autoHide
= wParam
!= 0;
866 case SCI_AUTOCGETAUTOHIDE
:
869 case SCI_AUTOCSETDROPRESTOFWORD
:
870 ac
.dropRestOfWord
= wParam
!= 0;
873 case SCI_AUTOCGETDROPRESTOFWORD
:
874 return ac
.dropRestOfWord
;
876 case SCI_AUTOCSETMAXHEIGHT
:
877 ac
.lb
->SetVisibleRows(static_cast<int>(wParam
));
880 case SCI_AUTOCGETMAXHEIGHT
:
881 return ac
.lb
->GetVisibleRows();
883 case SCI_AUTOCSETMAXWIDTH
:
884 maxListWidth
= static_cast<int>(wParam
);
887 case SCI_AUTOCGETMAXWIDTH
:
890 case SCI_REGISTERIMAGE
:
891 ac
.lb
->RegisterImage(static_cast<int>(wParam
), reinterpret_cast<const char *>(lParam
));
894 case SCI_REGISTERRGBAIMAGE
:
895 ac
.lb
->RegisterRGBAImage(static_cast<int>(wParam
), static_cast<int>(sizeRGBAImage
.x
), static_cast<int>(sizeRGBAImage
.y
),
896 reinterpret_cast<unsigned char *>(lParam
));
899 case SCI_CLEARREGISTEREDIMAGES
:
900 ac
.lb
->ClearRegisteredImages();
903 case SCI_AUTOCSETTYPESEPARATOR
:
904 ac
.SetTypesep(static_cast<char>(wParam
));
907 case SCI_AUTOCGETTYPESEPARATOR
:
908 return ac
.GetTypesep();
910 case SCI_CALLTIPSHOW
:
911 CallTipShow(LocationFromPosition(static_cast<int>(wParam
)),
912 reinterpret_cast<const char *>(lParam
));
915 case SCI_CALLTIPCANCEL
:
919 case SCI_CALLTIPACTIVE
:
920 return ct
.inCallTipMode
;
922 case SCI_CALLTIPPOSSTART
:
923 return ct
.posStartCallTip
;
925 case SCI_CALLTIPSETPOSSTART
:
926 ct
.posStartCallTip
= static_cast<int>(wParam
);
929 case SCI_CALLTIPSETHLT
:
930 ct
.SetHighlight(static_cast<int>(wParam
), static_cast<int>(lParam
));
933 case SCI_CALLTIPSETBACK
:
934 ct
.colourBG
= ColourDesired(static_cast<long>(wParam
));
935 vs
.styles
[STYLE_CALLTIP
].back
= ct
.colourBG
;
936 InvalidateStyleRedraw();
939 case SCI_CALLTIPSETFORE
:
940 ct
.colourUnSel
= ColourDesired(static_cast<long>(wParam
));
941 vs
.styles
[STYLE_CALLTIP
].fore
= ct
.colourUnSel
;
942 InvalidateStyleRedraw();
945 case SCI_CALLTIPSETFOREHLT
:
946 ct
.colourSel
= ColourDesired(static_cast<long>(wParam
));
947 InvalidateStyleRedraw();
950 case SCI_CALLTIPUSESTYLE
:
951 ct
.SetTabSize(static_cast<int>(wParam
));
952 InvalidateStyleRedraw();
955 case SCI_CALLTIPSETPOSITION
:
956 ct
.SetPosition(wParam
!= 0);
957 InvalidateStyleRedraw();
961 displayPopupMenu
= wParam
!= 0;
966 DocumentLexState()->SetLexer(static_cast<int>(wParam
));
970 return DocumentLexState()->lexLanguage
;
973 if (DocumentLexState()->lexLanguage
== SCLEX_CONTAINER
) {
974 pdoc
->ModifiedAt(static_cast<int>(wParam
));
975 NotifyStyleToNeeded((lParam
== -1) ? pdoc
->Length() : static_cast<int>(lParam
));
977 DocumentLexState()->Colourise(static_cast<int>(wParam
), static_cast<int>(lParam
));
982 case SCI_SETPROPERTY
:
983 DocumentLexState()->PropSet(reinterpret_cast<const char *>(wParam
),
984 reinterpret_cast<const char *>(lParam
));
987 case SCI_GETPROPERTY
:
988 return StringResult(lParam
, DocumentLexState()->PropGet(reinterpret_cast<const char *>(wParam
)));
990 case SCI_GETPROPERTYEXPANDED
:
991 return DocumentLexState()->PropGetExpanded(reinterpret_cast<const char *>(wParam
),
992 reinterpret_cast<char *>(lParam
));
994 case SCI_GETPROPERTYINT
:
995 return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam
), static_cast<int>(lParam
));
997 case SCI_SETKEYWORDS
:
998 DocumentLexState()->SetWordList(wParam
, reinterpret_cast<const char *>(lParam
));
1001 case SCI_SETLEXERLANGUAGE
:
1002 DocumentLexState()->SetLexerLanguage(reinterpret_cast<const char *>(lParam
));
1005 case SCI_GETLEXERLANGUAGE
:
1006 return StringResult(lParam
, DocumentLexState()->GetName());
1008 case SCI_PRIVATELEXERCALL
:
1009 return reinterpret_cast<sptr_t
>(
1010 DocumentLexState()->PrivateCall(wParam
, reinterpret_cast<void *>(lParam
)));
1012 case SCI_GETSTYLEBITSNEEDED
:
1015 case SCI_PROPERTYNAMES
:
1016 return StringResult(lParam
, DocumentLexState()->PropertyNames());
1018 case SCI_PROPERTYTYPE
:
1019 return DocumentLexState()->PropertyType(reinterpret_cast<const char *>(wParam
));
1021 case SCI_DESCRIBEPROPERTY
:
1022 return StringResult(lParam
, DocumentLexState()->DescribeProperty(reinterpret_cast<const char *>(wParam
)));
1024 case SCI_DESCRIBEKEYWORDSETS
:
1025 return StringResult(lParam
, DocumentLexState()->DescribeWordListSets());
1027 case SCI_GETLINEENDTYPESSUPPORTED
:
1028 return DocumentLexState()->LineEndTypesSupported();
1030 case SCI_ALLOCATESUBSTYLES
:
1031 return DocumentLexState()->AllocateSubStyles(wParam
, lParam
);
1033 case SCI_GETSUBSTYLESSTART
:
1034 return DocumentLexState()->SubStylesStart(wParam
);
1036 case SCI_GETSUBSTYLESLENGTH
:
1037 return DocumentLexState()->SubStylesLength(wParam
);
1039 case SCI_GETSTYLEFROMSUBSTYLE
:
1040 return DocumentLexState()->StyleFromSubStyle(wParam
);
1042 case SCI_GETPRIMARYSTYLEFROMSTYLE
:
1043 return DocumentLexState()->PrimaryStyleFromStyle(wParam
);
1045 case SCI_FREESUBSTYLES
:
1046 DocumentLexState()->FreeSubStyles();
1049 case SCI_SETIDENTIFIERS
:
1050 DocumentLexState()->SetIdentifiers(wParam
, reinterpret_cast<const char *>(lParam
));
1053 case SCI_DISTANCETOSECONDARYSTYLES
:
1054 return DocumentLexState()->DistanceToSecondaryStyles();
1056 case SCI_GETSUBSTYLEBASES
:
1057 return StringResult(lParam
, DocumentLexState()->GetSubStyleBases());
1061 return Editor::WndProc(iMessage
, wParam
, lParam
);