-
Notifications
You must be signed in to change notification settings - Fork 1
/
CodeEditor.h
56 lines (41 loc) · 1.27 KB
/
CodeEditor.h
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
56
#ifndef CODEEDITOR_H
#define CODEEDITOR_H
#include <QWidget>
#include <QRect>
#include <QPainter>
#include <QTextBlock>
#include <QPaintEvent>
#include <QResizeEvent>
#include "completelistwidget.h"
#include "Highlighter.h"
#include <QPlainTextEdit>
#include <QScrollBar>
#include<QCompleter>
class CodeEditor : public QPlainTextEdit {
Q_OBJECT
public:
explicit CodeEditor(QWidget *parent = nullptr);
CodeEditor(const CodeEditor&) = delete;
CodeEditor& operator= (const CodeEditor&) = delete;
~CodeEditor() = default;
void lineNumberAreaPaintEvent(QPaintEvent *event);
int lineNumberAreaWidth();
void setCompleter(QCompleter *c);
QCompleter *completer() const;
QStringList typelist;
QStringList wordlist;
protected:
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *e) override;
void focusInEvent(QFocusEvent *e) override;
private slots:
void updateLineNumberAreaWidth();
void highlightCurrentLine();
void updateLineNumberArea(const QRect &, int);
void insertCompletion(const QString &completion);
private:
QWidget *lineNumberArea;
QString textUnderCursor() const;
QCompleter *c = nullptr;
};
#endif // CODEEDITOR_H