void AutoCompletion::update(int character)
{
    const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
    if (!_funcCompletionActive && nppGUI._autocStatus == nppGUI.autoc_func)
        return;

    if (nppGUI._funcParams || _funcCalltip.isVisible())
    {
        if (_funcCalltip.updateCalltip(character)) // calltip visible because triggered by autocomplete, set mode
        {
            _activeCompletion = CompletionFunc;
            return; // Only return in case of success, else autocomplete
        }
    }

    if (!character)
        return;

    //If autocomplete already active, let Scintilla handle it
    if (_pEditView->execute(SCI_AUTOCACTIVE) != 0)
        return;

    const int wordSize = 64;
    TCHAR s[wordSize];
    _pEditView->getWordToCurrentPos(s, wordSize);

    if (lstrlen(s) >= int(nppGUI._autocFromLen))
    {
        if (nppGUI._autocStatus == nppGUI.autoc_word)
        {
            // Walk around - to avoid the crash under Chinese Windows7 ANSI doc mode
            if (!_pEditView->isCJK())
            {
                showWordComplete(false);
            }
            else
            {
                if ((_pEditView->getCurrentBuffer())->getUnicodeMode() != uni8Bit)
                    showWordComplete(false);
            }
        }
        else if (nppGUI._autocStatus == nppGUI.autoc_func)
            showAutoComplete();

        /*
        if (nppGUI._autocStatus == nppGUI.autoc_word)
        	showWordComplete(false);
        else if (nppGUI._autocStatus == nppGUI.autoc_func)
        	showAutoComplete();
        */
    }
}
Esempio n. 2
0
void AutoCompletion::update(int character)
{
	const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
	if (!_funcCompletionActive && nppGUI._autocStatus == nppGUI.autoc_func)
		return;

	if (nppGUI._funcParams || _funcCalltip.isVisible()) {
		if (_funcCalltip.updateCalltip(character)) {	//calltip visible because triggered by autocomplete, set mode
			_activeCompletion = CompletionFunc;
			return;	//only return in case of success, else autocomplete
		}
	}

	if (!character)
		return;

	//If autocomplete already active, let Scintilla handle it
	if (_pEditView->execute(SCI_AUTOCACTIVE) != 0)
		return;

	const int wordSize = 64;
	TCHAR s[wordSize];
	_pEditView->getWordToCurrentPos(s, wordSize);
	
	if (lstrlen(s) >= int(nppGUI._autocFromLen))
	{
		if (nppGUI._autocStatus == nppGUI.autoc_word)
			showWordComplete(false);
		else if (nppGUI._autocStatus == nppGUI.autoc_func)
			showAutoComplete();
		else if (nppGUI._autocStatus == nppGUI.autoc_func_and_word)
			showWordAndFuncComplete();	// 新增的函数和单词自动完成
	}
}