From 1b53e3ec1dfcbabe635eec8dd2f92ed82a954807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 23 Feb 2018 22:17:40 +0100 Subject: [PATCH] GUI: Updated codeeditor formatting --- gui/codeeditor.cpp | 58 ++++++++++++++++++++++++++++++++-------------- gui/codeeditor.h | 1 - 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/gui/codeeditor.cpp b/gui/codeeditor.cpp index ab2ef41ba..0e69e5427 100644 --- a/gui/codeeditor.cpp +++ b/gui/codeeditor.cpp @@ -11,18 +11,48 @@ Highlighter::Highlighter(QTextDocument *parent) keywordFormat.setForeground(Qt::darkBlue); keywordFormat.setFontWeight(QFont::Bold); QStringList keywordPatterns; - keywordPatterns << "\\bchar\\b" << "\\bclass\\b" << "\\bconst\\b" - << "\\bdouble\\b" << "\\benum\\b" << "\\bexplicit\\b" - << "\\bfriend\\b" << "\\binline\\b" << "\\bint\\b" - << "\\blong\\b" << "\\bnamespace\\b" << "\\boperator\\b" - << "\\bprivate\\b" << "\\bprotected\\b" << "\\bpublic\\b" - << "\\bshort\\b" << "\\bsignals\\b" << "\\bsigned\\b" - << "\\bslots\\b" << "\\bstatic\\b" << "\\bstruct\\b" - << "\\btemplate\\b" << "\\btypedef\\b" << "\\btypename\\b" - << "\\bunion\\b" << "\\bunsigned\\b" << "\\bvirtual\\b" - << "\\bvoid\\b" << "\\bvolatile\\b" << "\\bbool\\b"; + keywordPatterns << "bool" + << "break" + << "case" + << "char" + << "class" + << "const" + << "continue" + << "default" + << "do" + << "double" + << "else" + << "enum" + << "explicit" + << "for" + << "friend" + << "if" + << "inline" + << "int" + << "long" + << "namespace" + << "operator" + << "private" + << "protected" + << "public" + << "return" + << "short" + << "signed" + << "static" + << "struct" + << "switch" + << "template" + << "throw" + << "typedef" + << "typename" + << "union" + << "unsigned" + << "virtual" + << "void" + << "volatile" + << "while"; foreach (const QString &pattern, keywordPatterns) { - rule.pattern = QRegularExpression(pattern); + rule.pattern = QRegularExpression("\\b" + pattern + "\\b"); rule.format = keywordFormat; highlightingRules.append(rule); } @@ -38,12 +68,6 @@ Highlighter::Highlighter(QTextDocument *parent) rule.format = quotationFormat; highlightingRules.append(rule); - functionFormat.setFontItalic(true); - functionFormat.setForeground(Qt::blue); - rule.pattern = QRegularExpression("\\b[A-Za-z0-9_]+(?=\\()"); - rule.format = functionFormat; - highlightingRules.append(rule); - singleLineCommentFormat.setForeground(Qt::gray); rule.pattern = QRegularExpression("//[^\n]*"); rule.format = singleLineCommentFormat; diff --git a/gui/codeeditor.h b/gui/codeeditor.h index 00d721de4..5b44cb848 100644 --- a/gui/codeeditor.h +++ b/gui/codeeditor.h @@ -41,7 +41,6 @@ private: QTextCharFormat singleLineCommentFormat; QTextCharFormat multiLineCommentFormat; QTextCharFormat quotationFormat; - QTextCharFormat functionFormat; QTextCharFormat symbolFormat; };