-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeeditor.h
63 lines (53 loc) · 1.6 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
57
58
59
60
61
62
63
#ifndef CODEEDITOR_H
#define CODEEDITOR_H
#include <QPlainTextEdit>
#include <QWidget>
#include <QSize>
#include <QResizeEvent>
#include <QPaintEvent>
#include <QMouseEvent>
#include <QTextCursor>
#include <QPainter>
#include <QRect>
#include <QTextBlock>
#include <QColor>
#include <QDebug>
#include <QRegExp>
#include <QLabel>
#include "linenumberarea.h"
#include "colorlabel.h"
#include "consts.h"
class LineNumberArea;
class CodeEditor : public QPlainTextEdit
{
Q_OBJECT
public:
explicit CodeEditor(QWidget *parent = nullptr);
~CodeEditor();
void lineNumberAreaPaintEvent(QPaintEvent *event);
int lineNumberAreaWidth();
void setLineNumberColor(QColor &color);
void setCurrentLineColor(QColor &color);
void setBackgroundColor(QColor &color);
void setTextColor(QColor &color);
void applyColorTheme();
protected:
void resizeEvent(QResizeEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *mouseEvent) override;
private slots:
void updateLineNumberAreaWidth(int newBlockCount);
void highlightCurrentLine();
void updateLineNumberArea(const QRect &rect, int dy);
private:
LineNumberArea *lineNumberArea;
QColor *lineNumberColor = nullptr;
QColor *currentLineColor = nullptr;
QColor *backgroundColor = nullptr;
QColor *textColor = nullptr;
ColorLabel *colorLabel = nullptr;
int stringPosition = -1;
QRegExp rx/*("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$")*/;
int oldX = 0;
int oldY = 0;
};
#endif // CODEEDITOR_H