14    static int NOT_MULTILINE_COMMENT = 0;
 
   15    static int MULTILINE_COMMENT = 1;
 
   21       QSyntaxHighlighter(pc_text) {
 
   22       SHighlightingRule sRule;
 
   23       m_cKeywordFormat.setForeground(Qt::darkBlue);
 
   24       m_cKeywordFormat.setFontWeight(QFont::Bold);
 
   25       QStringList cKeywordPatterns;
 
   26       cKeywordPatterns << 
"\\band\\b"    << 
"\\bbreak\\b"  << 
"\\bdo\\b"   << 
"\\belse\\b"     << 
"\\belseif\\b" 
   27                        << 
"\\bend\\b"    << 
"\\bfalse\\b"  << 
"\\bfor\\b"  << 
"\\bfunction\\b" << 
"\\bif\\b" 
   28                        << 
"\\bin\\b"     << 
"\\blocal\\b"  << 
"\\bnil\\b"  << 
"\\bnot\\b"      << 
"\\bor\\b" 
   29                        << 
"\\brepeat\\b" << 
"\\breturn\\b" << 
"\\bthen\\b" << 
"\\btrue\\b"     << 
"\\buntil\\b" << 
"\\bwhile\\b";
 
   30       foreach (
const QString& cPattern, cKeywordPatterns) {
 
   31          sRule.Pattern = QRegExp(cPattern);
 
   32          sRule.Format = m_cKeywordFormat;
 
   33          m_vecHighlightingRules.append(sRule);
 
   36       m_cQuotationFormat.setForeground(Qt::darkGreen);
 
   37       sRule.Pattern = QRegExp(
"\".*\"");
 
   38       sRule.Format = m_cQuotationFormat;
 
   39       m_vecHighlightingRules.append(sRule);
 
   41       m_cSingleLineCommentFormat.setForeground(Qt::darkGray);
 
   42       m_cSingleLineCommentFormat.setFontItalic(
true);
 
   43       sRule.Pattern = QRegExp(
"--[^[\n]*");
 
   44       sRule.Format = m_cSingleLineCommentFormat;
 
   45       m_vecHighlightingRules.append(sRule);
 
   47       m_cMultiLineCommentFormat.setForeground(Qt::darkGray);
 
   48       m_cMultiLineCommentFormat.setFontItalic(
true);
 
   49       m_cCommentStartExpression = QRegExp(
"--\\[\\[");
 
   50       m_cCommentEndExpression = QRegExp(
"\\]\\]");      
 
   60       foreach (
const SHighlightingRule& sRule, m_vecHighlightingRules) {
 
   61          QRegExp cExpression(sRule.Pattern);
 
   62          int i = cExpression.indexIn(str_text);
 
   64             int nLength = cExpression.matchedLength();
 
   65             setFormat(i, nLength, sRule.Format);
 
   66             i = cExpression.indexIn(str_text, i + nLength);
 
   72       setCurrentBlockState(NOT_MULTILINE_COMMENT);
 
   74       if (previousBlockState() != MULTILINE_COMMENT) {
 
   75          nStartIndex = m_cCommentStartExpression.indexIn(str_text);
 
   77       while(nStartIndex >= 0) {
 
   78          int nEndIndex = m_cCommentEndExpression.indexIn(str_text, nStartIndex);
 
   80          if (nEndIndex == -1) {
 
   81             setCurrentBlockState(MULTILINE_COMMENT);
 
   82             nCommentLength = str_text.length() - nStartIndex;
 
   84             nCommentLength = nEndIndex - nStartIndex
 
   85                + m_cCommentEndExpression.matchedLength();
 
   87          setFormat(nStartIndex, nCommentLength, m_cMultiLineCommentFormat);
 
   88          nStartIndex = m_cCommentStartExpression.indexIn(str_text, nStartIndex + nCommentLength);
 
CQTOpenGLLuaSyntaxHighlighter(QTextDocument *pc_text)
 
void highlightBlock(const QString &str_text)
 
The namespace containing all the ARGoS related code.