diff options
| author | nyamatongwe <unknown> | 2000-07-12 03:20:19 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2000-07-12 03:20:19 +0000 | 
| commit | 372b4cbe4a43236de333d2b0dda964973b886bc8 (patch) | |
| tree | 4b778b01098b96d73f86437e2ea3a35d0085453b /src | |
| parent | d03640b271b24ef2ee59dd78157efae5c7ed3ea9 (diff) | |
| download | scintilla-mirror-372b4cbe4a43236de333d2b0dda964973b886bc8.tar.gz | |
John's changes to autocompletion.
Diffstat (limited to 'src')
| -rw-r--r-- | src/AutoComplete.cxx | 1 | ||||
| -rw-r--r-- | src/AutoComplete.h | 2 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 26 | ||||
| -rw-r--r-- | src/ScintillaBase.h | 1 | 
4 files changed, 21 insertions, 9 deletions
| diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index 75e26fe28..00a3a75fc 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -16,6 +16,7 @@ AutoComplete::AutoComplete() {  	posStart = 0;  	strcpy(stopChars, "");  	separator = ' '; +	cancelAtStartPos = false;  }  AutoComplete::~AutoComplete() { diff --git a/src/AutoComplete.h b/src/AutoComplete.h index e4f8ade0d..96d061f50 100644 --- a/src/AutoComplete.h +++ b/src/AutoComplete.h @@ -14,6 +14,8 @@ public:  	ListBox lb;  	int posStart;  	int startLen; +	// Should autocompletion be canceled if editor's currentPos <= startPos? +	bool cancelAtStartPos;  	AutoComplete();  	~AutoComplete(); diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index ff2e001ec..f14426969 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -211,8 +211,10 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {  	}  	rcList.bottom = rcList.top + heightAlloced;  	ac.lb.SetPositionRelative(rcList, wMain); -	//lbAutoComplete.SetPosition(rcList);  	ac.Show(); +	if (lenEntered != 0) { +		AutoCompleteMoveToCurrentWord(); +	}		  }  void ScintillaBase::AutoCompleteCancel() { @@ -223,19 +225,25 @@ void ScintillaBase::AutoCompleteMove(int delta) {  	ac.Move(delta);  } +void ScintillaBase::AutoCompleteMoveToCurrentWord() { +	char wordCurrent[1000]; +	int i; +	int startWord = ac.posStart - ac.startLen; +	for (i = startWord; i < currentPos; i++) +		wordCurrent[i - startWord] = pdoc->CharAt(i); +	wordCurrent[i - startWord] = '\0'; +	ac.Select(wordCurrent); +} +  void ScintillaBase::AutoCompleteChanged(char ch) { -	if (currentPos <= ac.posStart) { +	if (currentPos <= ac.posStart - ac.startLen) { +		ac.Cancel(); +	} else if (ac.cancelAtStartPos && currentPos <= ac.posStart) {  		ac.Cancel();  	} else if (ac.IsStopChar(ch)) {  		ac.Cancel();  	} else { -		char wordCurrent[1000]; -		int i; -		int startWord = ac.posStart - ac.startLen; -		for (i = startWord; i < currentPos; i++) -			wordCurrent[i - startWord] = pdoc->CharAt(i); -		wordCurrent[i - startWord] = '\0'; -		ac.Select(wordCurrent); +		AutoCompleteMoveToCurrentWord();  	}  } diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index 6344b17a3..a7aefd8bc 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -54,6 +54,7 @@ protected:  	void AutoCompleteMove(int delta);  	void AutoCompleteChanged(char ch=0);  	void AutoCompleteCompleted(); +	void AutoCompleteMoveToCurrentWord();  	virtual void CreateCallTipWindow(PRectangle rc) = 0; | 
