annotate gui/src/TerminalHighlighter.h @ 13668:421afeae929b

Added a settings wizard that appears at first startup of Octave GUI.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sat, 10 Sep 2011 18:33:58 +0200
parents 68c50b393f1d
children c0e66d6e3dc8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13665
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
1 /* OctaveGUI - A graphical user interface for Octave
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
2 * Copyright (C) 2011 Jacob Dawid
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
3 * jacob.dawid@googlemail.com
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
4 *
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
8 * (at your option) any later version.
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
9 *
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
14 *
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
17 */
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
18
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
19 #ifndef TERMINALHIGHLIGHTER_H
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
20 #define TERMINALHIGHLIGHTER_H
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
21
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22 #include <QSyntaxHighlighter>
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
24 #include <QHash>
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
25 #include <QTextCharFormat>
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
26
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
27 class QTextDocument;
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
28
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
29 class TerminalHighlighter : public QSyntaxHighlighter
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
30 {
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
31 Q_OBJECT
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
32
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
33 public:
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
34 TerminalHighlighter(QTextDocument *parent = 0);
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
35
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
36 protected:
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
37 void highlightBlock(const QString &text);
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
38
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
39 private:
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
40 struct HighlightingRule
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
41 {
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
42 QRegExp pattern;
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
43 QTextCharFormat format;
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
44 };
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
45
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
46 QVector<HighlightingRule> highlightingRules;
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
47 QTextCharFormat keywordFormat;
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
48 QTextCharFormat doubleQouteFormat;
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
49 QTextCharFormat functionFormat;
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
50 QTextCharFormat urlFormat;
13666
68c50b393f1d Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13665
diff changeset
51 QTextCharFormat captionFormat;
68c50b393f1d Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13665
diff changeset
52 QTextCharFormat subCaptionFormat;
68c50b393f1d Improved highlighting and incremented version.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13665
diff changeset
53 QTextCharFormat numberFormat;
13665
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
54 };
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
55
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
56
ddc3c20d0e2f Implemented highlighting of octave keywords in terminal.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
57 #endif // TERMINALHIGHLIGHTER_H