1 | /* |
---|---|
2 | SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <rodda@kde.org> |
3 | SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef KATERENDERRANGE_H |
9 | #define KATERENDERRANGE_H |
10 | |
11 | #include <ktexteditor/attribute.h> |
12 | #include <ktexteditor/range.h> |
13 | |
14 | #include <utility> |
15 | #include <vector> |
16 | |
17 | class NormalRenderRange |
18 | { |
19 | public: |
20 | void addRange(KTextEditor::Range range, KTextEditor::Attribute::Ptr attribute); |
21 | |
22 | KTextEditor::Cursor nextBoundary() const; |
23 | bool advanceTo(const KTextEditor::Cursor pos); |
24 | KTextEditor::Attribute::Ptr currentAttribute() const; |
25 | |
26 | private: |
27 | std::vector<std::pair<KTextEditor::Range, KTextEditor::Attribute::Ptr>> m_ranges; |
28 | KTextEditor::Cursor m_nextBoundary; |
29 | KTextEditor::Attribute::Ptr m_currentAttribute; |
30 | size_t m_currentRange = 0; |
31 | }; |
32 | |
33 | class RenderRangeVector |
34 | { |
35 | public: |
36 | KTextEditor::Cursor nextBoundary() const; |
37 | void advanceTo(const KTextEditor::Cursor pos); |
38 | bool hasAttribute() const; |
39 | KTextEditor::Attribute::Ptr generateAttribute() const; |
40 | NormalRenderRange &pushNewRange(); |
41 | bool isEmpty() const |
42 | { |
43 | return m_ranges.empty(); |
44 | } |
45 | void reserve(size_t size) |
46 | { |
47 | m_ranges.reserve(n: size); |
48 | } |
49 | |
50 | private: |
51 | std::vector<NormalRenderRange> m_ranges; |
52 | KTextEditor::Cursor m_currentPos; |
53 | }; |
54 | |
55 | #endif |
56 |