#include <QPainter>
#include <QTextBlock>
#include "util/Colors.h"

#pragma once

class CodeEditor;
class QPaintEvent;

class GutterPainter
{
public:
    GutterPainter(CodeEditor *editor, QPaintEvent *event);

    void Paint();
private:

    CodeEditor *editor;
    QPainter painter;
    QPaintEvent *event;
    QFontMetrics fontMetrics;
    const ColorTheme &colorTheme;


    struct LoopState {
        CodeEditor *editor;
        QTextBlock block;
        int top;
        int bottom;

        LoopState(CodeEditor *editor);

        int blockNumber() const;

        void advanceToNextLine();
    };

    void drawLineNumber(const LoopState &loopState);

    void drawGutterErrorMarker(const LoopState &loopState);
};
