iLand
jstextarea.h
Go to the documentation of this file.
1#ifndef JSTEXTAREA_H
2#define JSTEXTAREA_H
3
4#include <QWidget>
5#include <QTextEdit>
6#include <QSyntaxHighlighter>
7
8class Highlighter;
9class JSTextArea : public QTextEdit
10{
11 Q_OBJECT
12public:
13 explicit JSTextArea(QWidget *parent = 0);
14
15signals:
16 void executeJS(QString code);
17
18public slots:
19protected:
20 virtual void keyPressEvent ( QKeyEvent * event );
21private:
22 Highlighter *highlighter;
23};
24
25// from Qt-Example:
26class Highlighter : public QSyntaxHighlighter
27 {
28 Q_OBJECT
29
30 public:
31 Highlighter(QTextDocument *parent = 0);
32
33 protected:
34 void highlightBlock(const QString &text) override;
35
36 private:
37 struct HighlightingRule
38 {
39 QRegExp pattern;
40 QTextCharFormat format;
41 };
42 QVector<HighlightingRule> highlightingRules;
43
44 QRegExp commentStartExpression;
45 QRegExp commentEndExpression;
46
47 QTextCharFormat keywordFormat;
48 QTextCharFormat classFormat;
49 QTextCharFormat singleLineCommentFormat;
50 QTextCharFormat multiLineCommentFormat;
51 QTextCharFormat quotationFormat;
52 QTextCharFormat singleQuotationFormat;
53 QTextCharFormat functionFormat;
54 };
55
56#endif // JSTEXTAREA_H
Definition: jstextarea.h:27
void highlightBlock(const QString &text) override
Definition: jstextarea.cpp:71
Highlighter(QTextDocument *parent=0)
Definition: jstextarea.cpp:11
Definition: jstextarea.h:10
virtual void keyPressEvent(QKeyEvent *event)
Definition: jstextarea.cpp:122
void executeJS(QString code)
JSTextArea(QWidget *parent=0)
Definition: jstextarea.cpp:107