show location of error in gutter and as selection

Close #3
This commit is contained in:
eelke 2018-04-09 21:44:00 +02:00
parent 47ee1857cd
commit 45b7d4fcbc
4 changed files with 105 additions and 14 deletions

View file

@ -2,6 +2,7 @@
#define CODEEDITOR_H
#include <QPlainTextEdit>
#include <set>
class CodeEditor : public QPlainTextEdit
{
@ -12,6 +13,8 @@ public:
void gutterAreaPaintEvent(QPaintEvent *event);
int gutterAreaWidth();
void addErrorMarker(int position, int length);
void clearErrorMarkers();
protected:
void resizeEvent(QResizeEvent *event) override;
@ -23,9 +26,17 @@ 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