Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
ParenMatcherHighlighter.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 /**
21  *
22  * This file is part of Tulip (www.tulip-software.org)
23  *
24  * Authors: David Auber and the Tulip development Team
25  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
26  *
27  * Tulip is free software; you can redistribute it and/or modify
28  * it under the terms of the GNU Lesser General Public License
29  * as published by the Free Software Foundation, either version 3
30  * of the License, or (at your option) any later version.
31  *
32  * Tulip is distributed in the hope that it will be useful,
33  * but WITHOUT ANY WARRANTY; without even the implied warranty of
34  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35  * See the GNU General Public License for more details.
36  *
37  */
38 
39 #ifndef PARENMATCHERHIGHLIGHTER_H_
40 #define PARENMATCHERHIGHLIGHTER_H_
41 
42 #include <QSyntaxHighlighter>
43 #include <QVector>
44 
45 class QTextDocument;
46 
47 struct ParenInfo {
48  char character;
49  int position;
50 
51  bool operator<(const ParenInfo &info) const {
52  return position < info.position;
53  }
54 
55 };
56 
57 class ParenInfoTextBlockData : public QTextBlockUserData {
58 
59  QVector<ParenInfo> _parenInfos;
60 
61 public:
62 
63  ParenInfoTextBlockData();
64 
65  QVector<ParenInfo> parens();
66  void insert(const ParenInfo &parenInfo);
67  void sortParenInfos();
68 
69 };
70 
71 class ParenMatcherHighlighter : public QSyntaxHighlighter {
72 
73  QVector<char> _leftParensToMatch;
74  QVector<char> _rightParensToMatch;
75 
76 public:
77 
78  explicit ParenMatcherHighlighter(QTextDocument *parent = 0);
79 
80 protected:
81 
82  void highlightBlock(const QString &text);
83 
84 };
85 
86 #endif /* PARENMATCHERHIGHLIGHTER_H_ */