-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeEditor.hpp
More file actions
55 lines (35 loc) · 1.07 KB
/
CodeEditor.hpp
File metadata and controls
55 lines (35 loc) · 1.07 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef CODE_EDITOR_H_
#define CODE_EDITOR_H_
#include <QPlainTextEdit>
#include <QPainter>
#include <QTextBlock>
#include "SyntaxHighlighter.hpp"
#include "Language.hpp"
using namespace Language;
class LineNumberArea;
class CodeEditor : public QPlainTextEdit
{
Q_OBJECT
public:
CodeEditor(QWidget* parent = nullptr);
void lineNumberAreaPaintEvent(QPaintEvent* event);
int lineNumberAreaWidth();
void setLanguage(Lang lang);
inline Lang getLanguage() const { return lang; }
void setModifiedState(bool modified) { document()->setModified(modified); }
inline bool isUnsaved() const { return document()->isModified(); }
~CodeEditor();
protected:
void resizeEvent(QResizeEvent* event) override;
bool eventFilter(QObject* object, QEvent* event) override;
private slots:
void updateLineNumberAreaWidth(int newBlockCount);
void highlightCurrentLine();
void updateLineNumberArea(const QRect& rect, int dy);
private:
QWidget* lineNumberArea;
Lang lang;
SyntaxHighLighter *highlighter;
SyntaxHighLighter *generateHighlighter(Lang lang);
};
#endif // !CODE_EDITOR_H_