- enhancement: add project templates for tcp server / tcp client

- enhancement: only show function tips when cursor is after ',' or '('.
  - enhancement: when auto complete function names, only append '(' if before identifier or "/'
This commit is contained in:
Roy Qu 2022-04-22 15:55:39 +08:00
parent 331365b0c7
commit a64bbd0d4b
4 changed files with 45 additions and 8 deletions

View File

@ -6,6 +6,10 @@ Red Panda C++ Version 1.0.5
- enhancement: add project template for libmysqlclient(libmariadbclient)
- enhancement: add libmysqlclient to the x86-64 version gcc in distribution
- enhancement: select and delete multiple watches
- enhancement: add project templates for tcp server / tcp client
- enhancement: only show function tips when cursor is after ',' or '('.
- enhancement: when auto complete function names, only append '(' if before identifier or "/'
- update highconstrast icon set
Red Panda C++ Version 1.0.4
- fix: hide function tips, when move or resize the main window

View File

@ -809,8 +809,9 @@ void Editor::keyPressEvent(QKeyEvent *event)
handled = handleSymbolCompletion(ch);
return;
case '(': {
QChar nextCh = nextNotspaceChar(caretY()-1,caretX()-1);
if (!isIdentChar(nextCh) && nextCh!='(' ){
QChar nextCh = nextNonSpaceChar(caretY()-1,caretX()-1);
if (!isIdentChar(nextCh) && nextCh!='('
&& nextCh!='"' && nextCh!='\'' ){
handled = handleSymbolCompletion(ch);
}
return;
@ -3080,10 +3081,14 @@ void Editor::completionInsert(bool appendFunc)
||
(statement->kind == StatementKind::skPreprocessor
&& !statement->args.isEmpty())) {
if ((p.Char >= lineText().length()) // it's the last char on line
|| (lineText().at(p.Char-1) != '(')) { // it don't have '(' after it
if (statement->fullName!="std::endl")
funcAddOn = "()";
QChar nextCh = nextNonSpaceChar(caretY()-1,p.Char-1);
if (nextCh=='(') {
funcAddOn = "";
} else if (isIdentChar(nextCh) || nextCh == '"'
|| nextCh == '\'') {
funcAddOn = '(';
} else {
funcAddOn = "()";
}
}
}
@ -3476,6 +3481,11 @@ void Editor::updateFunctionTip(bool showTip)
int currentParamPos = 1;
if (currentLine>=document()->count())
return;
QChar ch=lastNonSpaceChar(currentLine,currentChar);
qDebug()<<ch;
if (ch!="(" && ch!=",")
return;
while (currentLine>=0) {
QString line = document()->getString(currentLine);
if (currentLine!=caretPos.Line-1)

View File

@ -1093,7 +1093,7 @@ QChar SynEdit::charAt(const BufferCoord &pos)
return QChar(0);
}
QChar SynEdit::nextNotspaceChar(int line, int ch)
QChar SynEdit::nextNonSpaceChar(int line, int ch)
{
if (ch<0)
return QChar();
@ -1110,6 +1110,28 @@ QChar SynEdit::nextNotspaceChar(int line, int ch)
return QChar();
}
QChar SynEdit::lastNonSpaceChar(int line, int ch)
{
if (line>=mDocument->count())
return QChar();
QString s = mDocument->getString(line);
int x = std::min(ch-1,s.length()-1);
while (line>=0) {
while (x>=0) {
QChar c = s[x];
if (!c.isSpace())
return c;
x--;
}
line--;
if (line>=0) {
s = mDocument->getString(line);
x = s.length()-1;
}
}
return QChar();
}
void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord &ptBefore, const BufferCoord &ptAfter)
{
SynSelectionMode vOldMode = mActiveSelectionMode;

View File

@ -215,7 +215,8 @@ public:
QString wordAtRowCol(const BufferCoord& XY);
QChar charAt(const BufferCoord& pos);
QChar nextNotspaceChar(int line, int ch);
QChar nextNonSpaceChar(int line, int ch);
QChar lastNonSpaceChar(int line, int ch);
int charColumns(QChar ch) const;
bool isPointInSelection(const BufferCoord& Value) const;