X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=src%2Fcodeeditor.h;fp=src%2Fcodeeditor.h;h=7ca78b5c313f4f275ab509b2be234d1fe984b423;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=0000000000000000000000000000000000000000;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git

diff --git a/src/codeeditor.h b/src/codeeditor.h
new file mode 100644
index 0000000..7ca78b5
--- /dev/null
+++ b/src/codeeditor.h
@@ -0,0 +1,57 @@
+#ifndef CODEEDITOR_H
+#define CODEEDITOR_H
+
+#include <QObject>
+#include <QPlainTextEdit>
+
+class QPaintEvent;
+class QResizeEvent;
+class QSize;
+class QWidget;
+
+class LineNumberArea;
+
+class CodeEditor : public QPlainTextEdit {
+    Q_OBJECT
+
+  public:
+    CodeEditor(QWidget *parent = 0);
+
+    void lineNumberAreaPaintEvent(QPaintEvent *event);
+    int lineNumberAreaWidth();
+
+  protected:
+    void resizeEvent(QResizeEvent *event) override;
+
+  private slots:
+    void updateLineNumberAreaWidth(int newBlockCount);
+    void highlightCurrentLine();
+    void updateLineNumberArea(const QRect &, int);
+
+  private:
+    QWidget *lineNumberArea;
+};
+
+class LineNumberArea : public QWidget {
+  public:
+    LineNumberArea(CodeEditor *editor) : QWidget(editor)
+    {
+        codeEditor = editor;
+    }
+
+    QSize sizeHint() const override
+    {
+        return QSize(codeEditor->lineNumberAreaWidth(), 0);
+    }
+
+  protected:
+    void paintEvent(QPaintEvent *event) override
+    {
+        codeEditor->lineNumberAreaPaintEvent(event);
+    }
+
+  private:
+    CodeEditor *codeEditor;
+};
+
+#endif
\ No newline at end of file