Changeset View
Changeset View
Standalone View
Standalone View
src/render/katerenderrange.h
Show All 19 Lines | |||||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #ifndef KATERENDERRANGE_H | 22 | #ifndef KATERENDERRANGE_H | ||
23 | #define KATERENDERRANGE_H | 23 | #define KATERENDERRANGE_H | ||
24 | 24 | | |||
25 | #include <ktexteditor/range.h> | 25 | #include <ktexteditor/range.h> | ||
26 | #include <ktexteditor/attribute.h> | 26 | #include <ktexteditor/attribute.h> | ||
27 | 27 | | |||
28 | #include <QList> | 28 | #include <utility> | ||
29 | #include <QPair> | 29 | #include <vector> | ||
30 | 30 | | |||
31 | class KateRenderRange | 31 | class NormalRenderRange | ||
32 | { | | |||
33 | public: | | |||
34 | virtual ~KateRenderRange() {} | | |||
35 | virtual KTextEditor::Cursor nextBoundary() const = 0; | | |||
36 | virtual bool advanceTo(const KTextEditor::Cursor &pos) = 0; | | |||
37 | virtual KTextEditor::Attribute::Ptr currentAttribute() const = 0; | | |||
38 | virtual bool isReady() const; | | |||
39 | }; | | |||
40 | | ||||
41 | typedef QPair<KTextEditor::Range *, KTextEditor::Attribute::Ptr> pairRA; | | |||
42 | | ||||
43 | class NormalRenderRange : public KateRenderRange | | |||
44 | { | 32 | { | ||
45 | public: | 33 | public: | ||
46 | NormalRenderRange(); | 34 | NormalRenderRange(); | ||
47 | ~NormalRenderRange() override; | | |||
48 | 35 | | |||
49 | void addRange(KTextEditor::Range *range, KTextEditor::Attribute::Ptr attribute); | 36 | void addRange(const KTextEditor::Range &range, KTextEditor::Attribute::Ptr attribute); | ||
50 | 37 | | |||
51 | KTextEditor::Cursor nextBoundary() const override; | 38 | KTextEditor::Cursor nextBoundary() const; | ||
52 | bool advanceTo(const KTextEditor::Cursor &pos) override; | 39 | bool advanceTo(const KTextEditor::Cursor &pos); | ||
53 | KTextEditor::Attribute::Ptr currentAttribute() const override; | 40 | KTextEditor::Attribute::Ptr currentAttribute() const; | ||
54 | 41 | | |||
55 | private: | 42 | private: | ||
56 | QVector<pairRA> m_ranges; | 43 | std::vector<std::pair<KTextEditor::Range, KTextEditor::Attribute::Ptr>> m_ranges; | ||
57 | KTextEditor::Cursor m_nextBoundary; | 44 | KTextEditor::Cursor m_nextBoundary; | ||
58 | KTextEditor::Attribute::Ptr m_currentAttribute; | 45 | KTextEditor::Attribute::Ptr m_currentAttribute; | ||
59 | int m_currentRange = 0; | 46 | size_t m_currentRange = 0; | ||
60 | }; | 47 | }; | ||
61 | 48 | | |||
62 | class RenderRangeList : public QVector<KateRenderRange *> | 49 | class RenderRangeVector | ||
63 | { | 50 | { | ||
64 | public: | 51 | public: | ||
65 | ~RenderRangeList(); | | |||
66 | KTextEditor::Cursor nextBoundary() const; | 52 | KTextEditor::Cursor nextBoundary() const; | ||
67 | void advanceTo(const KTextEditor::Cursor &pos); | 53 | void advanceTo(const KTextEditor::Cursor &pos); | ||
68 | bool hasAttribute() const; | 54 | bool hasAttribute() const; | ||
69 | KTextEditor::Attribute::Ptr generateAttribute() const; | 55 | KTextEditor::Attribute::Ptr generateAttribute() const; | ||
56 | NormalRenderRange &pushNewRange(); | ||||
57 | bool isEmpty() const | ||||
58 | { | ||||
59 | return m_ranges.empty(); | ||||
60 | } | ||||
70 | 61 | | |||
71 | private: | 62 | private: | ||
63 | std::vector<NormalRenderRange> m_ranges; | ||||
72 | KTextEditor::Cursor m_currentPos; | 64 | KTextEditor::Cursor m_currentPos; | ||
73 | }; | 65 | }; | ||
74 | 66 | | |||
75 | #endif | 67 | #endif |