]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/QViewSource.h
Add vertical spacer.
[lyx.git] / src / frontends / qt4 / QViewSource.h
1 // -*- C++ -*-
2 /**
3  * \file QViewSource.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  * \author Bo Peng
9  * \author Abdelrazak Younes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef QVIEWSOURCE_H
15 #define QVIEWSOURCE_H
16
17 #include "frontends/controllers/ControlViewSource.h"
18
19 #include <QObject>
20 #include <QSyntaxHighlighter>
21 #include <QTextCharFormat>
22 #include <QTextDocument>
23
24 namespace lyx {
25 namespace frontend {
26
27 /// LaTeX syntax highlighting.
28 /// \todo FIXME: extract the latexHighlighter class into its 
29 /// own .[Ch] files.
30 class latexHighlighter : public QSyntaxHighlighter
31 {
32         Q_OBJECT        
33 public:
34         latexHighlighter(QTextDocument * parent);
35
36 protected:
37         void highlightBlock(QString const & text);
38
39 private:
40         QTextCharFormat commentFormat;
41         QTextCharFormat keywordFormat;
42         QTextCharFormat mathFormat;
43 };
44
45 ///
46 class QViewSource: public QObject, public ControlViewSource
47 {
48         Q_OBJECT
49 public:
50         QViewSource(Dialog &);
51         virtual ~QViewSource() {}
52
53         QTextDocument * document() { return document_; }
54
55         void update(bool full_source);
56
57 private:
58         ///
59         QTextDocument * document_;
60
61         /// latex syntax highlighter
62         latexHighlighter * highlighter_;
63 };
64
65
66 } // namespace frontend
67 } // namespace lyx
68
69 #endif // QVIEWSOURCE_H