From 23c3644871df0968ede9806a9005357ea89e1c9f Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 28 Mar 2024 18:25:36 +0800 Subject: [PATCH] - enhancement: Highlight words in the string/comments. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 12 +- RedPandaIDE/settings.cpp | 1 - libs/qsynedit/qsynedit/syntaxer/cpp.cpp | 150 ++++++++++-------------- 4 files changed, 69 insertions(+), 95 deletions(-) diff --git a/NEWS.md b/NEWS.md index df82397a..dc17f420 100644 --- a/NEWS.md +++ b/NEWS.md @@ -103,6 +103,7 @@ Red Panda C++ Version 2.27 - change: Don't turn on the code format option "indent class" by default. - enhancement: Add compiler set by choose the executable. - fix: Compile info for project doesn't have name of the project executable. + - enhancement: Highlight words in the string/comments. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index e5bd2633..c100ce73 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1340,8 +1340,10 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to } } if (((attr->tokenType() == QSynedit::TokenType::Identifier) - || (attr->tokenType() == QSynedit::TokenType::Keyword) - || (attr->tokenType() == QSynedit::TokenType::Preprocessor) + || (attr->tokenType() == QSynedit::TokenType::Keyword) + || (attr->tokenType() == QSynedit::TokenType::Preprocessor) + || (attr->tokenType() == QSynedit::TokenType::String) + || (attr->tokenType() == QSynedit::TokenType::Comment) ) && (token == mCurrentHighlightedWord)) { // occurrencies of the selected identifier @@ -1881,8 +1883,10 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes) if (getTokenAttriAtRowCol(caretXY(), token,attri) && ( (attri->tokenType()==QSynedit::TokenType::Identifier) - || (attri->tokenType() == QSynedit::TokenType::Keyword) - || (attri->tokenType() == QSynedit::TokenType::Preprocessor) + || (attri->tokenType() == QSynedit::TokenType::Keyword) + || (attri->tokenType() == QSynedit::TokenType::Preprocessor) + || (attri->tokenType() == QSynedit::TokenType::String) + || (attri->tokenType() == QSynedit::TokenType::Comment) )) { mCurrentHighlightedWord = token; } else { diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index bfb11581..7ba4aa56 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -3186,7 +3186,6 @@ bool Settings::CompilerSets::addSets(const QString &folder, const QString& c_pro if (set->binDirs().contains(folder) && extractFileName(set->CCompiler())==c_prog) return false; } - qDebug()<name().isEmpty()) diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp index 4956503c..8541925f 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp @@ -349,9 +349,19 @@ void CppSyntaxer::procCppStyleComment() return; } mTokenId = TokenId::Comment; + bool isWord = isIdentChar(mLine[mRun]); while (mRun=mLineSize) { procNull(); return; } + bool isWord = isIdentChar(mLine[mRun]); while (mRun=mLineSize) { procNull(); return; } + bool isWord = isIdentChar(mLine[mRun]); while (mRun=mLineSize) { mRange.state = RangeState::rsStringUnfinished; return;