GUI: Updated codeeditor formatting
This commit is contained in:
parent
17388c33aa
commit
1b53e3ec1d
|
@ -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;
|
||||
|
|
|
@ -41,7 +41,6 @@ private:
|
|||
QTextCharFormat singleLineCommentFormat;
|
||||
QTextCharFormat multiLineCommentFormat;
|
||||
QTextCharFormat quotationFormat;
|
||||
QTextCharFormat functionFormat;
|
||||
QTextCharFormat symbolFormat;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue