-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsyntaxhighlighter.h
37 lines (31 loc) · 958 Bytes
/
syntaxhighlighter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef SYNTAXHIGHLIGHTER_H
#define SYNTAXHIGHLIGHTER_H
#include <QString>
#include <QObject>
#define REPLACE(format, rep, len)\
reg=QRegExp(format);\
s = -1;\
while((s = reg.indexIn(source, s+1))>=0){\
source.replace(s, reg.cap(0).length(), rep);\
s+= len;\
}\
// reg.setMinimal(true);\
// source.replace(reg, rep);
//#define REPLACE(format, rep, len)\
// reg=QRegExp(format);\
// reg.setMinimal(true);\
// s = -1;\
// while((s = reg.indexIn(source, s+1))>=0){\
// source.replace(s, reg.cap(0).length(), rep);\
// s+= len;\
// }
class SyntaxHighlighter : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE QString analyse(QString source);
private:
// Q_INVOKABLE QString replace(QString format, QString& source, void (*function)(QString &source, int seed, QRegExp regex));
// Q_INVOKABLE QString test(QString &source, int seed, QRegExp regex);
};
#endif // SYNTAXHIGHLIGHTER_H