NCL Composer  0.1.5
 All Classes Functions Variables Pages
MyLexer.h
1 /*
2  * Copyright 2011 TeleMidia/PUC-Rio.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18 #ifndef MYLEXER_H
19 #define MYLEXER_H
20 
21 #include <vector>
22 #include <algorithm>
23 using namespace std;
24 
25 #include <QObject>
26 #include <QDebug>
27 #include <QColor>
28 #include <QFont>
29 #include <Qsci/qscilexercustom.h>
30 #include <Qsci/qscistyle.h>
31 #include <Qsci/qsciscintilla.h>
32 
33 class QsciStyle;
34 
35 
36 typedef struct {
37  int begin, end, id;
39 
40 class MyLexer : public QsciLexerCustom {
41  Q_OBJECT
42 
43 private:
44  QMap <int, QRegExp > partition_regex;
45  QMap <int, QsciStyle > partition_style;
46 
47 public:
48  enum {
49  Default = 0,
50  Comment = 1,
51  MaxStyle
52  };
53 
54  MyLexer(QObject *parent = 0);
55  ~MyLexer();
56  const char *language() const;
57  QString description(int) const;
58  void styleText(int start, int end);
59 
60  //TODO: PARTITIONS INSIDE PARTITION
61  bool addTextPartition ( int partition_id,
62  const QRegExp &regex,
63  const QsciStyle &style);
64 
65 
66  QColor defaultColor(int);
67  QFont defaultFont(int);
68  QColor defaultPaper(int);
69 
70 private:
71  vector <text_partition> makePartitions(char * chars, int begin, int end);
72  QsciStyle getStyle(int);
73 
74 };
75 
76 #endif // MYLEXER_H