diff options
author | Ken Moore <ken@pcbsd.org> | 2016-09-06 14:39:04 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2016-09-06 14:39:04 -0400 |
commit | 62a509fcac6a57014707ce1e5d1561d23749a3a9 (patch) | |
tree | 001629e6cdf85e65662bfa0da0c38972147c4db0 | |
parent | Add possible whitespace to the preprocessor rule for C/C++ code. (diff) | |
download | lumina-62a509fcac6a57014707ce1e5d1561d23749a3a9.tar.gz lumina-62a509fcac6a57014707ce1e5d1561d23749a3a9.tar.bz2 lumina-62a509fcac6a57014707ce1e5d1561d23749a3a9.zip |
Add a new test.cpp file for checking C/C++ syntax stuff, and fix up the backwards highlighting routine when both a start and end character are in close proximity in teh middle of the search.
3 files changed, 18 insertions, 4 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp index 6f583e4e..82b742ec 100644 --- a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp @@ -166,17 +166,18 @@ void PlainTextEditor::highlightMatch(QChar ch, bool forward, int fromPos, QChar int tmpFromPos = fromPos; QString doc = this->toPlainText(); while( nested>0 && tmpFromPos<doc.length() && ( (tmpFromPos>=fromPos && forward) || ( tmpFromPos<=fromPos && !forward ) ) ){ - if(forward){ + if(forward){ QTextCursor cur = this->document()->find(ch, tmpFromPos); if(!cur.isNull()){ nested += doc.mid(tmpFromPos+1, cur.position()-tmpFromPos).count(startch) -1; if(nested==0){ matchright = cur.position(); } else{ tmpFromPos = cur.position(); } }else{ break; } - }else{ + }else{ QTextCursor cur = this->document()->find(ch, tmpFromPos, QTextDocument::FindBackward); if(!cur.isNull()){ - nested += doc.mid(cur.position(), tmpFromPos-cur.position()).count(startch) -1; + QString mid = doc.mid(cur.position()-1, tmpFromPos-cur.position()); + nested += mid.count(startch) - mid.count(ch); if(nested==0){ matchleft = cur.position(); } else{ tmpFromPos = cur.position()-1; } }else{ break; } diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp index 3b4dd003..c13385d7 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp @@ -52,7 +52,7 @@ void Custom_Syntax::loadRules(QString type){ if(type=="C++"){ //Keywords (standard C/C++/Qt definitions) QStringList keywords; - keywords << "char" << "class" << "const" << "double" << "enum" << "explicit" << "extern" << "friend" << "inline" \ + keywords << "char" << "class" << "const" << "double" << "enum" << "explicit" << "extern" << "float" << "friend" << "inline" \ << "int" << "long" << "namespace" << "operator" << "private" << "protected" << "public" \ << "short" << "signals" << "signed" << "slots" << "static" << "struct" << "template" \ << "typedef" << "typename" << "union" << "unsigned" << "virtual" << "void" << "volatile" \ diff --git a/src-qt5/desktop-utils/lumina-textedit/tests/test.cpp b/src-qt5/desktop-utils/lumina-textedit/tests/test.cpp new file mode 100644 index 00000000..f78748bf --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/tests/test.cpp @@ -0,0 +1,13 @@ +Test(QString test){ + nestedFunction(){ } +} +if else done +return exit +bool float double + +some stuff // in-line comment + +some stuff /*multi +line +comment*/ +stuff |