void CompletableTextEdit::applyCompletion()
{
	if (isCompleterVisible()) {
		//
		// Получим выбранный из списка дополнений элемент
		//
		QModelIndex currentIndex = m_completer->popup()->currentIndex();
		QString completion = m_completer->popup()->model()->data(currentIndex).toString();

		applyCompletion(completion);

		closeCompleter();
	}
}
示例#2
0
void consoleKeyPress(char c) {
	if (!cursorPos)
		openConsole("");
	applyCompletion();

	int pos=cursorPos;
	setCursorPos(0);
	cmdLineRealloc(1);
	utilStrInsertChar(consoleLines->str+pos, c);
	cmdEnd++;

	updateCompletions();

	setCursorPos(pos+1);
	drawerInvokeRedisplay();
}
示例#3
0
void consoleEnter() {
	applyCompletion();
	consoleLines->str[cmdEnd]='\0';
	setCursorPos(0);

	if (historyMaxCount) {
		if (historyCount<historyMaxCount)
			historyCount++;
		else
			utilStrListRm(&historyFirst);
		utilStrListAddAfter(&historyLast);
		if (!historyFirst)
			historyFirst=historyLast;
		utilStrRealloc(&historyLast->str, 0, cmdEnd+1);
		strncpy(historyLast->str, consoleLines->str+1, cmdEnd-1);
		historyLast->str[cmdEnd-1]='\0';
	}
	char *cmd=consoleLines->str;
	consoleLines->str=0;
	consoleClear();
	consoleExecuteCmd(cmd+cmdBegin); // skip : and consoleSpecialColorNormal
	utilStrRealloc(&cmd, 0, 0);
	drawerInvokeRedisplay();
}
CompletableTextEdit::CompletableTextEdit(QWidget* _parent) :
	SpellCheckTextEdit(_parent), m_useCompleter(true), m_completer(new MyCompleter(this))
{
	m_completer->setWidget(this);
	connect(m_completer, SIGNAL(activated(QString)), this, SLOT(applyCompletion(QString)));
}