PMsrHighlighter: fix keyword bugs and C++17 tidy-ups
Build and Deploy Documentation / build-and-deploy (push) Successful in 32s
Build and Deploy Documentation / build-and-deploy (push) Successful in 32s
- Fix missing comma that concatenated "ab" and "skg" into the bogus keyword "abskg", dropping abragam/skewedGss highlighting. - Remove duplicate "snkzf" short name in the theory keyword list. - Add missing theory keywords: "sg" (simpleGss short form), "userFcn" and its short form "u", to match src/include/PTheory.h. - Use std::as_const in highlightBlock's range-for to avoid a potential QVector detach on every call. - Pass QTextCharFormat to addRule by const reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QStyleHints>
|
||||
#include <QMessageBox> //as35
|
||||
@@ -170,12 +172,13 @@ PMsrHighlighter::PMsrHighlighter(QTextDocument *parent)
|
||||
"Bessel", "internbsl", "internFldGK", "internFldLL",
|
||||
"F_mu_F", "abragam", "skewedGss", "staticNKZF",
|
||||
"staticNKTF", "dynamicNKZF", "dynamicNKTF", "muMinusExpTF",
|
||||
"polynom"};
|
||||
"polynom", "userFcn"};
|
||||
|
||||
QStringList theory_keywords_short = {"c",
|
||||
"a",
|
||||
"se",
|
||||
"ge",
|
||||
"sg",
|
||||
"stg",
|
||||
"sgktlf",
|
||||
"dgktlf",
|
||||
@@ -196,15 +199,15 @@ PMsrHighlighter::PMsrHighlighter(QTextDocument *parent)
|
||||
"ifgk",
|
||||
"ifll",
|
||||
"fmuf",
|
||||
"ab"
|
||||
"ab",
|
||||
"skg",
|
||||
"snkzf",
|
||||
"snktf",
|
||||
"snkzf",
|
||||
"dnkzf",
|
||||
"dnktf",
|
||||
"mmsetf",
|
||||
"p"};
|
||||
"p",
|
||||
"u"};
|
||||
|
||||
// combine both theory keyword lists
|
||||
QStringList theory_keywords = theory_keywords_long + theory_keywords_short;
|
||||
@@ -457,7 +460,7 @@ PMsrHighlighter::PMsrHighlighter(QTextDocument *parent)
|
||||
* to the Qt layout interface engine.
|
||||
*/
|
||||
void PMsrHighlighter::addRule(const QStringList &keywords,
|
||||
const QTextCharFormat formatting) {
|
||||
const QTextCharFormat &formatting) {
|
||||
// Instantiate the HighlighingRule struct.
|
||||
HighlightingRule rule;
|
||||
|
||||
@@ -488,7 +491,7 @@ void PMsrHighlighter::addRule(const QStringList &keywords,
|
||||
void PMsrHighlighter::highlightBlock(const QString &text) {
|
||||
|
||||
// Sequentially process each entry stored inside the rules vector array.
|
||||
for (const HighlightingRule &rule : highlightingRules) {
|
||||
for (const HighlightingRule &rule : std::as_const(highlightingRules)) {
|
||||
// Execute a global search through the single block string provided.
|
||||
QRegularExpressionMatchIterator matchIterator =
|
||||
rule.pattern.globalMatch(text);
|
||||
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
* @brief Helper function for passing formatting information to the
|
||||
* highlightingRules dynamic array.
|
||||
*/
|
||||
void addRule(const QStringList &keywords, const QTextCharFormat formatting);
|
||||
void addRule(const QStringList &keywords, const QTextCharFormat &formatting);
|
||||
|
||||
QTextCharFormat blockFormat; ///< Formatting profile for BLOCK keywords.
|
||||
QTextCharFormat titleFormat; ///< Formatting profile for TITLE line.
|
||||
|
||||
Reference in New Issue
Block a user