Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00873_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00873_source.php on line 2
The ARGoS Website

qtopengl_lua_syntax_highlighter.cpp
Go to the documentation of this file.
1 
8 
9 namespace argos {
10 
11  /****************************************/
12  /****************************************/
13 
14  static int NOT_MULTILINE_COMMENT = 0;
15  static int MULTILINE_COMMENT = 1;
16 
17  /****************************************/
18  /****************************************/
19 
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);
34  }
35 
36  m_cQuotationFormat.setForeground(Qt::darkGreen);
37  sRule.Pattern = QRegExp("\".*\"");
38  sRule.Format = m_cQuotationFormat;
39  m_vecHighlightingRules.append(sRule);
40 
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);
46 
47  m_cMultiLineCommentFormat.setForeground(Qt::darkGray);
48  m_cMultiLineCommentFormat.setFontItalic(true);
49  m_cCommentStartExpression = QRegExp("--\\[\\[");
50  m_cCommentEndExpression = QRegExp("\\]\\]");
51  }
52 
53  /****************************************/
54  /****************************************/
55 
56  void CQTOpenGLLuaSyntaxHighlighter::highlightBlock(const QString& str_text) {
57  /*
58  * Apply normal rules
59  */
60  foreach (const SHighlightingRule& sRule, m_vecHighlightingRules) {
61  QRegExp cExpression(sRule.Pattern);
62  int i = cExpression.indexIn(str_text);
63  while(i >= 0) {
64  int nLength = cExpression.matchedLength();
65  setFormat(i, nLength, sRule.Format);
66  i = cExpression.indexIn(str_text, i + nLength);
67  }
68  }
69  /*
70  * Apply multi-line comment rules
71  */
72  setCurrentBlockState(NOT_MULTILINE_COMMENT);
73  int nStartIndex = 0;
74  if (previousBlockState() != MULTILINE_COMMENT) {
75  nStartIndex = m_cCommentStartExpression.indexIn(str_text);
76  }
77  while(nStartIndex >= 0) {
78  int nEndIndex = m_cCommentEndExpression.indexIn(str_text, nStartIndex);
79  int nCommentLength;
80  if (nEndIndex == -1) {
81  setCurrentBlockState(MULTILINE_COMMENT);
82  nCommentLength = str_text.length() - nStartIndex;
83  } else {
84  nCommentLength = nEndIndex - nStartIndex
85  + m_cCommentEndExpression.matchedLength();
86  }
87  setFormat(nStartIndex, nCommentLength, m_cMultiLineCommentFormat);
88  nStartIndex = m_cCommentStartExpression.indexIn(str_text, nStartIndex + nCommentLength);
89  }
90  }
91 
92  /****************************************/
93  /****************************************/
94 
95 }
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12