forked from qt-creator/qt-creator
fakevim: trigger autocompletion on '.' and '>'
This commit is contained in:
@@ -1512,6 +1512,9 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int,
|
|||||||
if (leftText.simplified().isEmpty())
|
if (leftText.simplified().isEmpty())
|
||||||
indentRegion(text.at(0));
|
indentRegion(text.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (text.at(0) == '.' || text.at(0) == '>')
|
||||||
|
emit q->completionRequested();
|
||||||
} else {
|
} else {
|
||||||
return EventUnhandled;
|
return EventUnhandled;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ signals:
|
|||||||
const QString &fileName, const QString &contents);
|
const QString &fileName, const QString &contents);
|
||||||
void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor);
|
void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor);
|
||||||
void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar);
|
void indentRegion(int *amount, int beginLine, int endLine, QChar typedChar);
|
||||||
|
void completionRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject *ob, QEvent *ev);
|
bool eventFilter(QObject *ob, QEvent *ev);
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ private slots:
|
|||||||
void installHandlerOnCurrentEditor();
|
void installHandlerOnCurrentEditor();
|
||||||
void installHandler(Core::IEditor *editor);
|
void installHandler(Core::IEditor *editor);
|
||||||
void removeHandler();
|
void removeHandler();
|
||||||
|
void triggerCompletions();
|
||||||
|
|
||||||
void showCommandBuffer(const QString &contents);
|
void showCommandBuffer(const QString &contents);
|
||||||
void showExtraInformation(const QString &msg);
|
void showExtraInformation(const QString &msg);
|
||||||
@@ -208,6 +209,8 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
|
|||||||
this, SLOT(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)));
|
this, SLOT(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)));
|
||||||
connect(handler, SIGNAL(indentRegion(int*,int,int,QChar)),
|
connect(handler, SIGNAL(indentRegion(int*,int,int,QChar)),
|
||||||
this, SLOT(indentRegion(int*,int,int,QChar)));
|
this, SLOT(indentRegion(int*,int,int,QChar)));
|
||||||
|
connect(handler, SIGNAL(completionRequested()),
|
||||||
|
this, SLOT(triggerCompletions()));
|
||||||
|
|
||||||
handler->setupWidget();
|
handler->setupWidget();
|
||||||
handler->setExtraData(editor);
|
handler->setExtraData(editor);
|
||||||
@@ -235,6 +238,15 @@ void FakeVimPluginPrivate::installHandlerOnCurrentEditor()
|
|||||||
installHandler(EditorManager::instance()->currentEditor());
|
installHandler(EditorManager::instance()->currentEditor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimPluginPrivate::triggerCompletions()
|
||||||
|
{
|
||||||
|
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||||
|
if (!handler)
|
||||||
|
return;
|
||||||
|
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(handler->widget()))
|
||||||
|
bt->triggerCompletions();
|
||||||
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::writeFile(bool *handled,
|
void FakeVimPluginPrivate::writeFile(bool *handled,
|
||||||
const QString &fileName, const QString &contents)
|
const QString &fileName, const QString &contents)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user