diff options
| -rw-r--r-- | include/Scintilla.h | 2 | ||||
| -rw-r--r-- | include/Scintilla.iface | 6 | ||||
| -rw-r--r-- | src/AutoComplete.cxx | 3 | ||||
| -rw-r--r-- | src/AutoComplete.h | 1 | ||||
| -rw-r--r-- | src/Document.cxx | 9 | ||||
| -rw-r--r-- | src/Document.h | 2 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 24 | 
7 files changed, 36 insertions, 11 deletions
| diff --git a/include/Scintilla.h b/include/Scintilla.h index 246301578..543edeaf1 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -225,6 +225,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_USERLISTSHOW 2117  #define SCI_AUTOCSETAUTOHIDE 2118  #define SCI_AUTOCGETAUTOHIDE 2119 +#define SCI_AUTOCSETDROPRESTOFWORD 2270 +#define SCI_AUTOCGETDROPRESTOFWORD 2271  #define SCI_SETINDENT 2122  #define SCI_GETINDENT 2123  #define SCI_SETUSETABS 2124 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 2f9de7d5a..a74f69075 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -540,6 +540,12 @@ set void AutoCSetAutoHide=2118(bool autoHide,)  # Retrieve whether or not autocompletion is hidden automatically when nothing matches  get bool AutoCGetAutoHide=2119(,) +# Set whether or not autocompletion deletes any word characters after the inserted text upon completion +set void AutoCSetDropRestOfWord=2270(bool dropRestOfWord,) + +# Retrieve whether or not autocompletion deletes any word characters after the inserted text upon completion +get bool AutoCGetDropRestOfWord=2271(,) +  # Set the number of spaces used for one level of indentation.  set void SetIndent=2122(int indentSize,) diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index 7f7412e43..f67d42b0b 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -22,7 +22,8 @@ AutoComplete::AutoComplete() :  	posStart(0),  	startLen(0),  	cancelAtStartPos(true), -	autoHide(true) { +	autoHide(true), +	dropRestOfWord(false)	{  	stopChars[0] = '\0';  	fillUpChars[0] = '\0';  } diff --git a/src/AutoComplete.h b/src/AutoComplete.h index 79d467529..80dc95dc0 100644 --- a/src/AutoComplete.h +++ b/src/AutoComplete.h @@ -25,6 +25,7 @@ public:  	/// Should autocompletion be canceled if editor's currentPos <= startPos?  	bool cancelAtStartPos;  	bool autoHide; +	bool dropRestOfWord;  	AutoComplete();  	~AutoComplete(); diff --git a/src/Document.cxx b/src/Document.cxx index 8483d86f1..b7acc8610 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -722,13 +722,16 @@ Document::charClassification Document::WordCharClass(unsigned char ch) {   * Used by commmands that want to select whole words.   * Finds the start of word at pos when delta < 0 or the end of the word when delta >= 0.   */ -int Document::ExtendWordSelect(int pos, int delta) { +int Document::ExtendWordSelect(int pos, int delta, bool onlyWordCharacters) { +	charClassification ccStart = ccWord;  	if (delta < 0) { -		charClassification ccStart = WordCharClass(cb.CharAt(pos-1)); +		if (!onlyWordCharacters) +			ccStart = WordCharClass(cb.CharAt(pos-1));  		while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))  			pos--;  	} else { -		charClassification ccStart = WordCharClass(cb.CharAt(pos)); +		if (!onlyWordCharacters) +			ccStart = WordCharClass(cb.CharAt(pos));  		while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))  			pos++;  	} diff --git a/src/Document.h b/src/Document.h index 09814fec8..51cfa9d53 100644 --- a/src/Document.h +++ b/src/Document.h @@ -177,7 +177,7 @@ public:  	int GetFoldParent(int line);  	void Indent(bool forwards); -	int ExtendWordSelect(int pos, int delta); +	int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);  	int NextWordStart(int pos, int delta);  	int Length() { return cb.Length(); }  	long FindText(int minPos, int maxPos, const char *s,  diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 2994f42db..4a9b87670 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -307,14 +307,18 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {  		scn.lParam = 0;  		scn.text = userListSelected.c_str();  		NotifyParent(scn); -		return ; +		return;  	}  	Position firstPos = ac.posStart - ac.startLen; -	if (currentPos < firstPos) -		return ; -	if (currentPos != firstPos) { -		pdoc->DeleteChars(firstPos, currentPos - firstPos); +	Position endPos = currentPos; +	if (ac.dropRestOfWord) +		endPos = pdoc->ExtendWordSelect(endPos, 1, true); +	if (endPos < firstPos) +		return; +	pdoc->BeginUndoAction(); +	if (endPos != firstPos) { +		pdoc->DeleteChars(firstPos, endPos - firstPos);  	}  	SetEmptySelection(ac.posStart);  	if (item != -1) { @@ -324,6 +328,7 @@ void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) {  		pdoc->InsertString(firstPos, piece.c_str());  		SetEmptySelection(firstPos + piece.length());  	} +	pdoc->EndUndoAction();  }  void ScintillaBase::ContextMenu(Point pt) { @@ -404,7 +409,7 @@ void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {  		int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0);  		endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0);  		Colourise(endStyled, endStyleNeeded); -		return ; +		return;  	}  #endif  	Editor::NotifyStyleToNeeded(endStyleNeeded); @@ -483,6 +488,13 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara  	case SCI_AUTOCGETAUTOHIDE:  		return ac.autoHide; +	case SCI_AUTOCSETDROPRESTOFWORD: +		ac.dropRestOfWord = wParam != 0; +		break; + +	case SCI_AUTOCGETDROPRESTOFWORD: +		return ac.dropRestOfWord; +  	case SCI_CALLTIPSHOW: {  			AutoCompleteCancel();  			if (!ct.wCallTip.Created()) { | 
