42 lines
801 B
C++
42 lines
801 B
C++
#ifndef CODEEDITOR_H
|
|
#define CODEEDITOR_H
|
|
|
|
#include <QPlainTextEdit>
|
|
#include <set>
|
|
|
|
class CodeEditor : public QPlainTextEdit
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit CodeEditor(QWidget *parent = nullptr);
|
|
|
|
void gutterAreaPaintEvent(QPaintEvent *event);
|
|
int gutterAreaWidth();
|
|
|
|
void addErrorMarker(int position, int length);
|
|
void clearErrorMarkers();
|
|
protected:
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
signals:
|
|
|
|
public slots:
|
|
|
|
private slots:
|
|
void updateGutterAreaWidth(int newBlockCount);
|
|
void highlightCurrentLine();
|
|
void updateGutterArea(const QRect &, int);
|
|
void onTextChanged();
|
|
|
|
private:
|
|
QWidget *gutterArea;
|
|
|
|
QTextEdit::ExtraSelection currentLine;
|
|
QList<QTextEdit::ExtraSelection> errorMarkers;
|
|
|
|
std::set<int> errorLines;
|
|
|
|
void updateExtraSelections();
|
|
};
|
|
|
|
#endif // CODEEDITOR_H
|