QtiPlot
0.9.8.2
Main Page
Related Pages
Classes
Files
File List
File Members
qtiplot
src
scripting
PythonSyntaxHighlighter.h
Go to the documentation of this file.
1
/***************************************************************************
2
File : PythonSyntaxHighlighter.h
3
Project : QtiPlot
4
--------------------------------------------------------------------
5
Copyright : (C) 2008 by Ion Vasilief
6
Email (use @ for *) : ion_vasilief*yahoo.fr
7
Description : Python Syntax Highlighting based on the Qt Syntax Highlighter Example
8
(http://doc.trolltech.com/4.4/richtext-syntaxhighlighter.html)
9
10
***************************************************************************/
11
12
/***************************************************************************
13
* *
14
* This program is free software; you can redistribute it and/or modify *
15
* it under the terms of the GNU General Public License as published by *
16
* the Free Software Foundation; either version 2 of the License, or *
17
* (at your option) any later version. *
18
* *
19
* This program is distributed in the hope that it will be useful, *
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22
* GNU General Public License for more details. *
23
* *
24
* You should have received a copy of the GNU General Public License *
25
* along with this program; if not, write to the Free Software *
26
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27
* Boston, MA 02110-1301 USA *
28
* *
29
***************************************************************************/
30
31
#ifndef PYTHON_HIGHLIGHTER_H
32
#define PYTHON_HIGHLIGHTER_H
33
34
#include <QSyntaxHighlighter>
35
#include <QHash>
36
#include <QTextCharFormat>
37
38
#include "
ScriptEdit.h
"
39
40
QT_BEGIN_NAMESPACE
41
class
QTextDocument;
42
QT_END_NAMESPACE
43
44
class
SyntaxHighlighter
:
public
QSyntaxHighlighter
45
{
46
Q_OBJECT
47
48
public
:
49
SyntaxHighlighter
(
ScriptEdit
* parent);
50
51
protected
:
52
void
highlightBlock
(
const
QString &text);
53
54
struct
HighlightingRule
55
{
56
QRegExp
pattern
;
57
QTextCharFormat
format
;
58
};
59
60
QVector<HighlightingRule>
highlightingRules
;
61
62
QTextCharFormat
commentFormat
;
63
QTextCharFormat
quotationFormat
;
64
QTextCharFormat
functionFormat
;
65
QTextCharFormat
numericFormat
;
66
};
67
68
class
PythonSyntaxHighlighter
:
public
SyntaxHighlighter
69
{
70
Q_OBJECT
71
72
public
:
73
PythonSyntaxHighlighter
(
ScriptEdit
*parent);
74
75
static
QStringList
keywordsList
(){
return
d_keywords
;};
76
77
protected
:
78
void
highlightBlock
(
const
QString &text);
79
80
private
:
81
QVector<HighlightingRule>
pythonHighlightingRules
;
82
83
QTextCharFormat
keywordFormat
;
84
QTextCharFormat
classFormat
;
85
86
static
const
QStringList
d_keywords
;
87
};
88
89
#endif
Generated on Tue Sep 17 2013 18:53:45 for QtiPlot by
1.8.4