File indexing completed on 2024-04-14 03:55:15
0001 /* 0002 SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <rodda@kde.org> 0003 SPDX-FileCopyrightText: 2008 David Nolden <david.nolden.kdevelop@art-master.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KATERENDERRANGE_H 0009 #define KATERENDERRANGE_H 0010 0011 #include <ktexteditor/attribute.h> 0012 #include <ktexteditor/range.h> 0013 0014 #include <utility> 0015 #include <vector> 0016 0017 class NormalRenderRange 0018 { 0019 public: 0020 void addRange(KTextEditor::Range range, KTextEditor::Attribute::Ptr attribute); 0021 0022 KTextEditor::Cursor nextBoundary() const; 0023 bool advanceTo(const KTextEditor::Cursor pos); 0024 KTextEditor::Attribute::Ptr currentAttribute() const; 0025 0026 private: 0027 std::vector<std::pair<KTextEditor::Range, KTextEditor::Attribute::Ptr>> m_ranges; 0028 KTextEditor::Cursor m_nextBoundary; 0029 KTextEditor::Attribute::Ptr m_currentAttribute; 0030 size_t m_currentRange = 0; 0031 }; 0032 0033 class RenderRangeVector 0034 { 0035 public: 0036 KTextEditor::Cursor nextBoundary() const; 0037 void advanceTo(const KTextEditor::Cursor pos); 0038 bool hasAttribute() const; 0039 KTextEditor::Attribute::Ptr generateAttribute() const; 0040 NormalRenderRange &pushNewRange(); 0041 bool isEmpty() const 0042 { 0043 return m_ranges.empty(); 0044 } 0045 void reserve(size_t size) 0046 { 0047 m_ranges.reserve(size); 0048 } 0049 0050 private: 0051 std::vector<NormalRenderRange> m_ranges; 0052 KTextEditor::Cursor m_currentPos; 0053 }; 0054 0055 #endif