diff options
| author | Neil <nyamatongwe@gmail.com> | 2014-05-24 10:20:06 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2014-05-24 10:20:06 +1000 | 
| commit | 0e25a153a1970e5b895072f265c02bac9fd7f3fa (patch) | |
| tree | b2570a653b9dfb0d8349dc09a48ce5e9cc74a84f /src | |
| parent | aba660e18c19beaada7cc75c21a81760c0ee976e (diff) | |
| download | scintilla-mirror-0e25a153a1970e5b895072f265c02bac9fd7f3fa.tar.gz | |
SCI_AUTOCSETMULTI allows setting whether autocompletion text is inserted at each
selection when multiple selections are active.
From Mitchell Foral.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ScintillaBase.cxx | 34 | ||||
| -rw-r--r-- | src/ScintillaBase.h | 1 | 
2 files changed, 32 insertions, 3 deletions
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 32ad962e8..e39b5e2a8 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -57,6 +57,7 @@ ScintillaBase::ScintillaBase() {  	displayPopupMenu = true;  	listType = 0;  	maxListWidth = 0; +	multiAutoCMode = SC_MULTIAUTOC_ONCE;  }  ScintillaBase::~ScintillaBase() { @@ -197,9 +198,29 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) {  void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) {  	UndoGroup ug(pdoc); -	pdoc->DeleteChars(startPos, removeLen); -	const int lengthInserted = pdoc->InsertString(startPos, text, textLen); -	SetEmptySelection(startPos + lengthInserted); +	if (multiAutoCMode == SC_MULTIAUTOC_ONCE) { +		pdoc->DeleteChars(startPos, removeLen); +		const int lengthInserted = pdoc->InsertString(startPos, text, textLen); +		SetEmptySelection(startPos + lengthInserted); +	} else { +		// SC_MULTIAUTOC_EACH +		for (size_t r=0; r<sel.Count(); r++) { +			if (!RangeContainsProtected(sel.Range(r).Start().Position(), +				sel.Range(r).End().Position())) { +				int positionInsert = sel.Range(r).Start().Position(); +				positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); +				if (positionInsert - removeLen >= 0) { +					pdoc->DeleteChars(positionInsert - removeLen, removeLen); +				} +				const int lengthInserted = pdoc->InsertString(positionInsert, text, textLen); +				if (lengthInserted > 0) { +					sel.Range(r).caret.SetPosition(positionInsert + lengthInserted); +					sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted); +				} +				sel.Range(r).ClearVirtualSpace(); +			} +		} +	}  }  void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { @@ -813,6 +834,13 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara  	case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR:  		return ac.ignoreCaseBehaviour; +	case SCI_AUTOCSETMULTI: +		multiAutoCMode = static_cast<int>(wParam); +		break; + +	case SCI_AUTOCGETMULTI: +		return multiAutoCMode; +  	case SCI_AUTOCSETORDER:  		ac.autoSort = static_cast<int>(wParam);  		break; diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index 59ffea41e..8440ebecc 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -46,6 +46,7 @@ protected:  	int listType;			///< 0 is an autocomplete list  	int maxListWidth;		/// Maximum width of list, in average character widths +	int multiAutoCMode; /// Mode for autocompleting when multiple selections are present  #ifdef SCI_LEXER  	LexState *DocumentLexState();  | 
