diff options
| author | Neil <nyamatongwe@gmail.com> | 2017-06-11 14:08:43 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2017-06-11 14:08:43 +1000 | 
| commit | 09972b3a179d7ea39ef6ce7e0474531797c549fb (patch) | |
| tree | 530dd174861606cacb57bce355cd14720f0bef9c /src | |
| parent | a4051422b4364d1193abc9a31d1f3df42fdedc47 (diff) | |
| download | scintilla-mirror-09972b3a179d7ea39ef6ce7e0474531797c549fb.tar.gz | |
Implement SCN_AUTOCSELECTIONCHANGE notification.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ScintillaBase.cxx | 33 | ||||
| -rw-r--r-- | src/ScintillaBase.h | 5 | 
2 files changed, 32 insertions, 6 deletions
| diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 3979354eb..2da142462 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -202,9 +202,15 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {  	return Editor::KeyCommand(iMessage);  } -void ScintillaBase::AutoCompleteDoubleClick(void *p) { -	ScintillaBase *sci = static_cast<ScintillaBase *>(p); -	sci->AutoCompleteCompleted(0, SC_AC_DOUBLECLICK); +void ScintillaBase::ListNotify(ListBoxEvent *plbe) { +	switch (plbe->event) { +	case ListBoxEvent::EventType::selectionChange: +		AutoCompleteSelection(); +		break; +	case ListBoxEvent::EventType::doubleClick: +		AutoCompleteCompleted(0, SC_AC_DOUBLECLICK); +		break; +	}  }  void ScintillaBase::AutoCompleteInsert(Sci::Position startPos, int removeLen, const char *text, int textLen) { @@ -293,7 +299,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {  	ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);  	unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth);  	ac.lb->SetAverageCharWidth(aveCharWidth); -	ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this); +	ac.lb->SetDelegate(this);  	ac.SetList(list ? list : ""); @@ -340,6 +346,25 @@ void ScintillaBase::AutoCompleteMoveToCurrentWord() {  	ac.Select(wordCurrent.c_str());  } +void ScintillaBase::AutoCompleteSelection() { +	int item = ac.GetSelection(); +	std::string selected; +	if (item != -1) { +		selected = ac.GetValue(item); +	} + +	SCNotification scn = {}; +	scn.nmhdr.code = SCN_AUTOCSELECTIONCHANGE; +	scn.message = 0; +	scn.wParam = listType; +	scn.listType = listType; +	Sci::Position firstPos = ac.posStart - ac.startLen; +	scn.position = firstPos; +	scn.lParam = firstPos; +	scn.text = selected.c_str(); +	NotifyParent(scn); +} +  void ScintillaBase::AutoCompleteCharacterAdded(char ch) {  	if (ac.IsFillUpChar(ch)) {  		AutoCompleteCompleted(ch, SC_AC_FILLUP); diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index cd8a1f5a1..9b8f08ae3 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -18,7 +18,7 @@ class LexState;  /**   */ -class ScintillaBase : public Editor { +class ScintillaBase : public Editor, IListBoxDelegate {  protected:  	/** Enumeration of commands and child windows. */  	enum { @@ -76,7 +76,8 @@ protected:  	void AutoCompleteCharacterDeleted();  	void AutoCompleteCompleted(char ch, unsigned int completionMethod);  	void AutoCompleteMoveToCurrentWord(); -	static void AutoCompleteDoubleClick(void *p); +	void AutoCompleteSelection(); +	void ListNotify(ListBoxEvent *plbe) override;  	void CallTipClick();  	void CallTipShow(Point pt, const char *defn); | 
