Merge pull request #4000 from techee/java_triple_quotes
[geany-mirror.git] / scintilla / src / RunStyles.h
blob44367adf748b75fdc4bc1fbb7a6eb018c1144157
1 /** @file RunStyles.h
2 ** Data structure used to store sparse styles.
3 **/
4 // Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
5 // The License.txt file describes the conditions under which this software may be distributed.
7 /// Styling buffer using one element for each run rather than using
8 /// a filled buffer.
10 #ifndef RUNSTYLES_H
11 #define RUNSTYLES_H
13 namespace Scintilla::Internal {
15 // Return for RunStyles::FillRange reports if anything was changed and the
16 // range that was changed. This may be trimmed from the requested range
17 // when some of the requested range already had the requested value.
18 template <typename DISTANCE>
19 struct FillResult {
20 bool changed;
21 DISTANCE position;
22 DISTANCE fillLength;
25 template <typename DISTANCE, typename STYLE>
26 class RunStyles {
27 private:
28 Partitioning<DISTANCE> starts;
29 SplitVector<STYLE> styles;
30 DISTANCE RunFromPosition(DISTANCE position) const noexcept;
31 DISTANCE SplitRun(DISTANCE position);
32 void RemoveRun(DISTANCE run);
33 void RemoveRunIfEmpty(DISTANCE run);
34 void RemoveRunIfSameAsPrevious(DISTANCE run);
35 public:
36 RunStyles();
37 DISTANCE Length() const noexcept;
38 STYLE ValueAt(DISTANCE position) const noexcept;
39 DISTANCE FindNextChange(DISTANCE position, DISTANCE end) const noexcept;
40 DISTANCE StartRun(DISTANCE position) const noexcept;
41 DISTANCE EndRun(DISTANCE position) const noexcept;
42 // Returns changed=true if some values may have changed
43 FillResult<DISTANCE> FillRange(DISTANCE position, STYLE value, DISTANCE fillLength);
44 void SetValueAt(DISTANCE position, STYLE value);
45 void InsertSpace(DISTANCE position, DISTANCE insertLength);
46 void DeleteAll();
47 void DeleteRange(DISTANCE position, DISTANCE deleteLength);
48 DISTANCE Runs() const noexcept;
49 bool AllSame() const noexcept;
50 bool AllSameAs(STYLE value) const noexcept;
51 DISTANCE Find(STYLE value, DISTANCE start) const noexcept;
53 void Check() const;
58 #endif