Overte C++ Documentation
ScriptHighlighting.h
1 //
2 // ScriptHighlighting.h
3 // interface/src
4 //
5 // Created by Thijs Wenker on 4/15/14.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_ScriptHighlighting_h
13 #define hifi_ScriptHighlighting_h
14 
15 #include <QSyntaxHighlighter>
16 
17 class ScriptHighlighting : public QSyntaxHighlighter {
18  Q_OBJECT
19 
20 public:
21  ScriptHighlighting(QTextDocument* parent = NULL);
22 
23  enum BlockState {
24  BlockStateClean,
25  BlockStateInMultiComment
26  };
27 
28 protected:
29  void highlightBlock(const QString& text) override;
30  void highlightKeywords(const QString& text);
31  void formatComments(const QString& text);
32  void formatQuotedText(const QString& text);
33  void formatNumbers(const QString& text);
34  void formatTrueFalse(const QString& text);
35 
36 private:
37  QRegExp _alphacharRegex;
38  QRegExp _keywordRegex;
39  QRegExp _quotedTextRegex;
40  QRegExp _multiLineCommentBegin;
41  QRegExp _multiLineCommentEnd;
42  QRegExp _numberRegex;
43  QRegExp _singleLineComment;
44  QRegExp _truefalseRegex;
45 };
46 
47 #endif // hifi_ScriptHighlighting_h