[Greenengine-developer] syntax highlighting
Status: Planning
Brought to you by:
jeromiya
|
From: Nado . <cbr...@gm...> - 2007-11-12 19:45:07
|
A short description for so anyone can edit the syntax highlighter if you
want to.
The syntax highlighter is located in greenengine/greenengine/src/interface
and it is in highlighter.h and .cpp
the general format for adding a keyword is
HighlightingRule rule;
//keywords
keywordFormat.setForeground(Qt::darkBlue);
keywordFormat.setFontWeight(QFont::Bold);
QStringList keywordPatterns;
keywordPatterns << "\\bbehavior\\b" << "\\bcondition\\b" << "\\bif\\b"
<< "\\belseif\\b" << "\\belse\\b" << "\\breturn\\b";
foreach (QString pattern, keywordPatterns)
{
rule.pattern = QRegExp(pattern);
rule.format = keywordFormat;
highlightingRules.append(rule);
}
rule is just a temp variable used to add to highlightingRules. This should
be fairly self explanatory so the only thing I will mention is that the
keywords are surrounded with \\b
so if is put int as \\bif\\b
|