class EE::UI::Doc::DocumentView

#include <documentview.hpp>

class DocumentView {
public:
    // structs

    struct Config;
    struct LineWrapInfo;
    struct VisibleLineInfo;
    struct VisibleLineRange;

    // construction

    DocumentView(std::shared_ptr<TextDocument> doc, FontStyleConfig fontStyle, Config config);

    // methods

    static LineWrapMode toLineWrapMode(std::string mode);
    static std::string fromLineWrapMode(LineWrapMode mode);
    static LineWrapType toLineWrapType(std::string type);
    static std::string fromLineWrapType(LineWrapType type);

    static LineWrapInfo computeLineBreaks(
        const String::View& string,
        const FontStyleConfig& fontStyle,
        Float maxWidth,
        LineWrapMode mode,
        bool keepIndentation,
        Uint32 tabWidth = 4,
        Float whiteSpaceWidth = 0.f
    );

    static LineWrapInfo computeLineBreaks(
        const String& string,
        const FontStyleConfig& fontStyle,
        Float maxWidth,
        LineWrapMode mode,
        bool keepIndentation,
        Uint32 tabWidth = 4,
        Float whiteSpaceWidth = 0.f
    );

    static LineWrapInfo computeLineBreaks(
        const TextDocument& doc,
        size_t line,
        const FontStyleConfig& fontStyle,
        Float maxWidth,
        LineWrapMode mode,
        bool keepIndentation,
        Uint32 tabWidth = 4,
        Float whiteSpaceWidth = 0.f
    );

    static Float computeOffsets(const String::View& string, const FontStyleConfig& fontStyle, Uint32 tabWidth, Float maxWidth = 0.f);
    bool isWrapEnabled() const;
    size_t getVisibleLinesCount() const;
    const Config& config() const;
    void invalidateCache();
    void updateCache(Int64 fromLine, Int64 toLine, Int64 numLines);
    Config getConfig() const;
    void setConfig(Config config);
    void setMaxWidth(Float maxWidth, bool forceReconstructBreaks = false);
    void setFontStyle(FontStyleConfig fontStyle);
    void setLineWrapMode(LineWrapMode mode);
    TextPosition getVisibleIndexPosition(VisibleIndex visibleIndex) const;
    Float getLinePadding(Int64 docIdx) const;
    VisibleIndex toVisibleIndex(Int64 docIdx, bool retLast = false) const;
    bool isWrappedLine(Int64 docIdx) const;
    VisibleLineInfo getVisibleLineInfo(Int64 docIdx) const;
    VisibleLineRange getVisibleLineRange(const TextPosition& pos, bool allowVisualLineEnd = false) const;
    TextRange getVisibleIndexRange(VisibleIndex visibleIndex) const;
    std::shared_ptr<TextDocument> getDocument() const;
    void setDocument(const std::shared_ptr<TextDocument>& doc);
    bool isPendingReconstruction() const;
    void setPendingReconstruction(bool pendingReconstruction);
    void clear();
    void clearCache();
    double getLineYOffset(VisibleIndex visibleIndex, Float lineHeight) const;
    double getLineYOffset(Int64 docIdx, Float lineHeight) const;
    bool isLineVisible(Int64 docIdx) const;
    bool isFolded(Int64 docIdx, bool andNotFirstLine = false) const;
    std::optional<TextRange> isInFoldedRange(TextRange range, bool andNotFirstLine) const;
    void foldRegion(Int64 foldDocIdx);
    void unfoldRegion(Int64 foldDocIdx);
    bool isOneToOne() const;
    std::vector<TextRange> intersectsFoldedRegions(const TextRange& range) const;
    Float getWhiteSpaceWidth() const;
    void ensureCursorVisibility();
    const std::vector<TextRange> getFoldedRegions() const;
    void onFoldRegionsUpdated();
};