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