- implement: symbol usage count
- implement: user code snippet / template - implement: auto generate javadoc-style docstring for functions - enhancement: use up/down key to navigate function parameter tooltip - enhancement: press esc to close function parameter tooltip - enhancement: code suggestion for unicode identifiers
This commit is contained in:
parent
22341d11fa
commit
8ebe9174bb
1
NEWS.md
1
NEWS.md
|
@ -20,6 +20,7 @@ Version 0.3.0
|
||||||
- implement: auto generate javadoc-style docstring for functions
|
- implement: auto generate javadoc-style docstring for functions
|
||||||
- enhancement: use up/down key to navigate function parameter tooltip
|
- enhancement: use up/down key to navigate function parameter tooltip
|
||||||
- enhancement: press esc to close function parameter tooltip
|
- enhancement: press esc to close function parameter tooltip
|
||||||
|
- enhancement: code suggestion for unicode identifiers
|
||||||
|
|
||||||
Version 0.2.1
|
Version 0.2.1
|
||||||
- fix: crash when load last opens
|
- fix: crash when load last opens
|
||||||
|
|
|
@ -1004,6 +1004,56 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
|
||||||
SynEdit::mouseReleaseEvent(event);
|
SynEdit::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::inputMethodEvent(QInputMethodEvent *event)
|
||||||
|
{
|
||||||
|
bool handled = false;
|
||||||
|
auto action = finally([this,&handled,event](){
|
||||||
|
if (!handled)
|
||||||
|
SynEdit::inputMethodEvent(event);
|
||||||
|
});
|
||||||
|
if (pMainWindow->completionPopup()->isVisible()) {
|
||||||
|
if (onCompletionInputMethod(event)) {
|
||||||
|
handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QString s = event->commitString();
|
||||||
|
if (!s.isEmpty()) {
|
||||||
|
mLastIdCharPressed+=s.length();
|
||||||
|
if (pSettings->codeCompletion().enabled()
|
||||||
|
&& pSettings->codeCompletion().showCompletionWhileInput() ) {
|
||||||
|
if (mLastIdCharPressed>=1) {
|
||||||
|
QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY());
|
||||||
|
if (!lastWord.isEmpty()) {
|
||||||
|
if (CppTypeKeywords.contains(lastWord)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PStatement statement = mParser->findStatementOf(
|
||||||
|
mFilename,
|
||||||
|
lastWord,
|
||||||
|
caretY());
|
||||||
|
StatementKind kind = mParser->getKindOfStatement(statement);
|
||||||
|
if (kind == StatementKind::skClass
|
||||||
|
|| kind == StatementKind::skEnumClassType
|
||||||
|
|| kind == StatementKind::skEnumType
|
||||||
|
|| kind == StatementKind::skTypedef) {
|
||||||
|
//last word is a typedef/class/struct, this is a var or param define, and dont show suggestion
|
||||||
|
// if devEditor.UseTabnine then
|
||||||
|
// ShowTabnineCompletion;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSelText(s);
|
||||||
|
showCompletion(false);
|
||||||
|
handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::copyToClipboard()
|
void Editor::copyToClipboard()
|
||||||
{
|
{
|
||||||
if (pSettings->editor().copySizeLimit()) {
|
if (pSettings->editor().copySizeLimit()) {
|
||||||
|
@ -2233,6 +2283,9 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
|
||||||
BufferCoord pBeginPos,pEndPos;
|
BufferCoord pBeginPos,pEndPos;
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
case Qt::Key_Shift:
|
case Qt::Key_Shift:
|
||||||
|
case Qt::Key_Control:
|
||||||
|
case Qt::Key_Meta:
|
||||||
|
case Qt::Key_Alt:
|
||||||
//ignore it
|
//ignore it
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_Backspace:
|
case Qt::Key_Backspace:
|
||||||
|
@ -2334,6 +2387,25 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Editor::onCompletionInputMethod(QInputMethodEvent *event)
|
||||||
|
{
|
||||||
|
bool processed = false;
|
||||||
|
if (!mCompletionPopup->isVisible())
|
||||||
|
return processed;
|
||||||
|
QString s=event->commitString();
|
||||||
|
if (!s.isEmpty()) {
|
||||||
|
setSelText(s);
|
||||||
|
BufferCoord pBeginPos,pEndPos;
|
||||||
|
QString phrase = getWordAtPosition(this,caretXY(),
|
||||||
|
pBeginPos,pEndPos,
|
||||||
|
WordPurpose::wpCompletion);
|
||||||
|
mLastIdCharPressed = phrase.length();
|
||||||
|
mCompletionPopup->search(phrase, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos)
|
Editor::TipType Editor::getTipType(QPoint point, BufferCoord& pos)
|
||||||
{
|
{
|
||||||
// Only allow in the text area...
|
// Only allow in the text area...
|
||||||
|
|
|
@ -200,6 +200,7 @@ private:
|
||||||
|
|
||||||
bool onCompletionKeyPressed(QKeyEvent* event);
|
bool onCompletionKeyPressed(QKeyEvent* event);
|
||||||
bool onHeaderCompletionKeyPressed(QKeyEvent* event);
|
bool onHeaderCompletionKeyPressed(QKeyEvent* event);
|
||||||
|
bool onCompletionInputMethod(QInputMethodEvent *event);
|
||||||
|
|
||||||
TipType getTipType(QPoint point, BufferCoord& pos);
|
TipType getTipType(QPoint point, BufferCoord& pos);
|
||||||
void cancelHint();
|
void cancelHint();
|
||||||
|
@ -283,6 +284,10 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
// QWidget interface
|
||||||
|
protected:
|
||||||
|
void inputMethodEvent(QInputMethodEvent *) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
QString getWordAtPosition(SynEdit* editor,
|
QString getWordAtPosition(SynEdit* editor,
|
||||||
|
|
|
@ -3593,8 +3593,9 @@ bool CppParser::isSpaceChar(const QChar &ch)
|
||||||
|
|
||||||
bool CppParser::isWordChar(const QChar &ch)
|
bool CppParser::isWordChar(const QChar &ch)
|
||||||
{
|
{
|
||||||
return (ch>= 'A' && ch<='Z')
|
// return (ch>= 'A' && ch<='Z')
|
||||||
|| (ch>='a' && ch<='z')
|
// || (ch>='a' && ch<='z')
|
||||||
|
return ch.isLetter()
|
||||||
|| ch == '_'
|
|| ch == '_'
|
||||||
|| ch == '*'
|
|| ch == '*'
|
||||||
|| ch == '&';
|
|| ch == '&';
|
||||||
|
@ -3602,8 +3603,9 @@ bool CppParser::isWordChar(const QChar &ch)
|
||||||
|
|
||||||
bool CppParser::isLetterChar(const QChar &ch)
|
bool CppParser::isLetterChar(const QChar &ch)
|
||||||
{
|
{
|
||||||
return (ch>= 'A' && ch<='Z')
|
// return (ch>= 'A' && ch<='Z')
|
||||||
|| (ch>='a' && ch<='z')
|
// || (ch>='a' && ch<='z')
|
||||||
|
return ch.isLetter()
|
||||||
|| ch == '_';
|
|| ch == '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1000,7 +1000,10 @@ void CppPreprocessor::skipToPreprocessor()
|
||||||
|
|
||||||
bool CppPreprocessor::isWordChar(const QChar &ch)
|
bool CppPreprocessor::isWordChar(const QChar &ch)
|
||||||
{
|
{
|
||||||
if (ch=='_' || (ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9')) {
|
if (ch=='_'
|
||||||
|
// || (ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
|
||||||
|
|| ch.isLetter()
|
||||||
|
|| (ch>='0' && ch<='9')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1009,7 +1012,9 @@ bool CppPreprocessor::isWordChar(const QChar &ch)
|
||||||
bool CppPreprocessor::isIdentChar(const QChar &ch)
|
bool CppPreprocessor::isIdentChar(const QChar &ch)
|
||||||
{
|
{
|
||||||
if (ch=='_' || ch == '*' || ch == '&' || ch == '~' ||
|
if (ch=='_' || ch == '*' || ch == '&' || ch == '~' ||
|
||||||
(ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9')) {
|
ch.isLetter()
|
||||||
|
//(ch>='a' && ch<='z') || (ch>='A' && ch<='Z')
|
||||||
|
|| (ch>='0' && ch<='9')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1048,7 +1053,9 @@ bool CppPreprocessor::isOperatorChar(const QChar &ch)
|
||||||
|
|
||||||
bool CppPreprocessor::isMacroIdentChar(const QChar &ch)
|
bool CppPreprocessor::isMacroIdentChar(const QChar &ch)
|
||||||
{
|
{
|
||||||
return (ch>='A' && ch<='Z') || (ch>='a' && ch<='z') || ch == '_';
|
//return (ch>='A' && ch<='Z') || (ch>='a' && ch<='z')
|
||||||
|
return ch.isLetter()
|
||||||
|
|| ch == '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppPreprocessor::isDigit(const QChar &ch)
|
bool CppPreprocessor::isDigit(const QChar &ch)
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
CodeCompletionListView::CodeCompletionListView(QWidget *parent) : QListView(parent)
|
CodeCompletionListView::CodeCompletionListView(QWidget *parent) : QListView(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeCompletionListView::keyPressEvent(QKeyEvent *event)
|
void CodeCompletionListView::keyPressEvent(QKeyEvent *event)
|
||||||
|
@ -20,7 +19,7 @@ void CodeCompletionListView::keyPressEvent(QKeyEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeCompletionListView::focusInEvent(QFocusEvent *event)
|
void CodeCompletionListView::focusInEvent(QFocusEvent *)
|
||||||
{
|
{
|
||||||
Editor *editor = pMainWindow->editorList()->getEditor();
|
Editor *editor = pMainWindow->editorList()->getEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include "../parser/parserutils.h"
|
#include "../parser/parserutils.h"
|
||||||
using KeyPressedCallback = std::function<bool (QKeyEvent *)>;
|
using KeyPressedCallback = std::function<bool (QKeyEvent *)>;
|
||||||
|
using InputMethodCallback = std::function<bool (QInputMethodEvent*)>;
|
||||||
|
|
||||||
class CodeCompletionListView: public QListView {
|
class CodeCompletionListView: public QListView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -15,6 +16,9 @@ public:
|
||||||
const KeyPressedCallback &keypressedCallback() const;
|
const KeyPressedCallback &keypressedCallback() const;
|
||||||
void setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback);
|
void setKeypressedCallback(const KeyPressedCallback &newKeypressedCallback);
|
||||||
|
|
||||||
|
const InputMethodCallback &inputMethodCallback() const;
|
||||||
|
void setInputMethodCallback(const InputMethodCallback &newInputMethodCallback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue