|
|
@ -40,40 +40,44 @@ static bool isInList(generic_string word, const vector<generic_string> & wordArr
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
bool AutoCompletion::showAutoComplete() {
|
|
|
|
bool AutoCompletion::showApiComplete()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!_funcCompletionActive)
|
|
|
|
if (!_funcCompletionActive)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// calculate entered word's length
|
|
|
|
int curPos = int(_pEditView->execute(SCI_GETCURRENTPOS));
|
|
|
|
int curPos = int(_pEditView->execute(SCI_GETCURRENTPOS));
|
|
|
|
int line = _pEditView->getCurrentLineNumber();
|
|
|
|
int line = _pEditView->getCurrentLineNumber();
|
|
|
|
int startLinePos = int(_pEditView->execute(SCI_POSITIONFROMLINE, line ));
|
|
|
|
int startLinePos = int(_pEditView->execute(SCI_POSITIONFROMLINE, line ));
|
|
|
|
int startWordPos = startLinePos;
|
|
|
|
int startWordPos = startLinePos;
|
|
|
|
|
|
|
|
|
|
|
|
int len = curPos-startLinePos;
|
|
|
|
int len = curPos - startLinePos;
|
|
|
|
char * lineBuffer = new char[len+1];
|
|
|
|
char * lineBuffer = new char[len+1];
|
|
|
|
_pEditView->getText(lineBuffer, startLinePos, curPos);
|
|
|
|
_pEditView->getText(lineBuffer, startLinePos, curPos);
|
|
|
|
|
|
|
|
|
|
|
|
int offset = len-1;
|
|
|
|
int offset = len - 1;
|
|
|
|
int nrChars = 0;
|
|
|
|
int nrChars = 0;
|
|
|
|
char c;
|
|
|
|
char c;
|
|
|
|
while (offset>=0)
|
|
|
|
while (offset >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
c = lineBuffer[offset];
|
|
|
|
c = lineBuffer[offset];
|
|
|
|
if (isalnum(c) || c == '_') {
|
|
|
|
if (isalnum(c) || c == '_')
|
|
|
|
|
|
|
|
{
|
|
|
|
++nrChars;
|
|
|
|
++nrChars;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--offset;
|
|
|
|
--offset;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
startWordPos = curPos-nrChars;
|
|
|
|
startWordPos = curPos - nrChars;
|
|
|
|
|
|
|
|
|
|
|
|
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM('\n'));
|
|
|
|
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM('\n'));
|
|
|
|
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
|
|
|
|
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
|
|
|
|
_pEditView->showAutoComletion(curPos - startWordPos, _keyWords.c_str());
|
|
|
|
_pEditView->showAutoComletion(curPos - startWordPos, _keyWords.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
_activeCompletion = CompletionAuto;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -230,7 +234,6 @@ void AutoCompletion::showPathCompletion()
|
|
|
|
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM('\n'));
|
|
|
|
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM('\n'));
|
|
|
|
_pEditView->execute(SCI_AUTOCSETIGNORECASE, true);
|
|
|
|
_pEditView->execute(SCI_AUTOCSETIGNORECASE, true);
|
|
|
|
_pEditView->showAutoComletion(rawPath.length(), autoCompleteEntries.c_str());
|
|
|
|
_pEditView->showAutoComletion(rawPath.length(), autoCompleteEntries.c_str());
|
|
|
|
_activeCompletion = CompletionPath;
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -247,6 +250,8 @@ bool AutoCompletion::showWordComplete(bool autoInsert)
|
|
|
|
if (len >= bufSize)
|
|
|
|
if (len >= bufSize)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get word array
|
|
|
|
|
|
|
|
|
|
|
|
TCHAR beginChars[bufSize];
|
|
|
|
TCHAR beginChars[bufSize];
|
|
|
|
|
|
|
|
|
|
|
|
_pEditView->getGenericText(beginChars, bufSize, startPos, curPos);
|
|
|
|
_pEditView->getGenericText(beginChars, bufSize, startPos, curPos);
|
|
|
@ -291,6 +296,8 @@ bool AutoCompletion::showWordComplete(bool autoInsert)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sort(wordArray.begin(), wordArray.end());
|
|
|
|
sort(wordArray.begin(), wordArray.end());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get word list
|
|
|
|
generic_string words(TEXT(""));
|
|
|
|
generic_string words(TEXT(""));
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0, len = wordArray.size(); i < len; ++i)
|
|
|
|
for (size_t i = 0, len = wordArray.size(); i < len; ++i)
|
|
|
@ -304,17 +311,16 @@ bool AutoCompletion::showWordComplete(bool autoInsert)
|
|
|
|
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' '));
|
|
|
|
_pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' '));
|
|
|
|
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
|
|
|
|
_pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase);
|
|
|
|
_pEditView->showAutoComletion(curPos - startPos, words.c_str());
|
|
|
|
_pEditView->showAutoComletion(curPos - startPos, words.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
_activeCompletion = CompletionWord;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool AutoCompletion::showFunctionComplete() {
|
|
|
|
bool AutoCompletion::showFunctionComplete()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!_funcCompletionActive)
|
|
|
|
if (!_funcCompletionActive)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (_funcCalltip.updateCalltip(0, true)) {
|
|
|
|
if (_funcCalltip.updateCalltip(0, true))
|
|
|
|
_activeCompletion = CompletionFunc;
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -418,7 +424,6 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m
|
|
|
|
_pEditView->execute(SCI_INSERTTEXT, caretPos, (LPARAM)matchedChars);
|
|
|
|
_pEditView->execute(SCI_INSERTTEXT, caretPos, (LPARAM)matchedChars);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AutoCompletion::update(int character)
|
|
|
|
void AutoCompletion::update(int character)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
|
|
|
|
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
|
|
|
@ -427,7 +432,6 @@ void AutoCompletion::update(int character)
|
|
|
|
|
|
|
|
|
|
|
|
if (nppGUI._funcParams || _funcCalltip.isVisible()) {
|
|
|
|
if (nppGUI._funcParams || _funcCalltip.isVisible()) {
|
|
|
|
if (_funcCalltip.updateCalltip(character)) { //calltip visible because triggered by autocomplete, set mode
|
|
|
|
if (_funcCalltip.updateCalltip(character)) { //calltip visible because triggered by autocomplete, set mode
|
|
|
|
_activeCompletion = CompletionFunc;
|
|
|
|
|
|
|
|
return; //only return in case of success, else autocomplete
|
|
|
|
return; //only return in case of success, else autocomplete
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -459,14 +463,7 @@ void AutoCompletion::update(int character)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nppGUI._autocStatus == nppGUI.autoc_func)
|
|
|
|
else if (nppGUI._autocStatus == nppGUI.autoc_func)
|
|
|
|
showAutoComplete();
|
|
|
|
showApiComplete();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
if (nppGUI._autocStatus == nppGUI.autoc_word)
|
|
|
|
|
|
|
|
showWordComplete(false);
|
|
|
|
|
|
|
|
else if (nppGUI._autocStatus == nppGUI.autoc_func)
|
|
|
|
|
|
|
|
showAutoComplete();
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -562,7 +559,9 @@ bool AutoCompletion::setLanguage(LangType language) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_keyWords = TEXT("");
|
|
|
|
_keyWords = TEXT("");
|
|
|
|
if (_funcCompletionActive) { //Cache the keywords
|
|
|
|
if (_funcCompletionActive)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//Cache the keywords
|
|
|
|
//Iterate through all keywords
|
|
|
|
//Iterate through all keywords
|
|
|
|
TiXmlElement *funcNode = _pXmlKeyword;
|
|
|
|
TiXmlElement *funcNode = _pXmlKeyword;
|
|
|
|
const TCHAR * name = NULL;
|
|
|
|
const TCHAR * name = NULL;
|
|
|
@ -577,7 +576,8 @@ bool AutoCompletion::setLanguage(LangType language) {
|
|
|
|
return _funcCompletionActive;
|
|
|
|
return _funcCompletionActive;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const TCHAR * AutoCompletion::getApiFileName() {
|
|
|
|
const TCHAR * AutoCompletion::getApiFileName()
|
|
|
|
|
|
|
|
{
|
|
|
|
if (_curLang == L_USER)
|
|
|
|
if (_curLang == L_USER)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Buffer * currentBuf = _pEditView->getCurrentBuffer();
|
|
|
|
Buffer * currentBuf = _pEditView->getCurrentBuffer();
|
|
|
|