aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/RunStyles.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-02-01 09:22:14 +1100
committerNeil <nyamatongwe@gmail.com>2018-02-01 09:22:14 +1100
commit36e4a162b950bcee61f0fe27cbacd3e85a7bdb55 (patch)
treea68c95ca6f86006e39eeda67c2d9f32fa21ccb35 /src/RunStyles.h
parent171899690407c0c81e0444478cb7ef64a9291c11 (diff)
downloadscintilla-mirror-36e4a162b950bcee61f0fe27cbacd3e85a7bdb55.tar.gz
Templatize RunStyles so it can be over ranges of different types and contain
different style types. Currently only instantiated over <int, int>.
Diffstat (limited to 'src/RunStyles.h')
-rw-r--r--src/RunStyles.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/RunStyles.h b/src/RunStyles.h
index 84221d512..c28621334 100644
--- a/src/RunStyles.h
+++ b/src/RunStyles.h
@@ -12,36 +12,37 @@
namespace Scintilla {
+template <typename DISTANCE, typename STYLE>
class RunStyles {
private:
- std::unique_ptr<Partitioning<int>> starts;
- std::unique_ptr<SplitVector<int>> styles;
- int RunFromPosition(int position) const;
- int SplitRun(int position);
- void RemoveRun(int run);
- void RemoveRunIfEmpty(int run);
- void RemoveRunIfSameAsPrevious(int run);
+ std::unique_ptr<Partitioning<DISTANCE>> starts;
+ std::unique_ptr<SplitVector<STYLE>> styles;
+ DISTANCE RunFromPosition(DISTANCE position) const;
+ DISTANCE SplitRun(DISTANCE position);
+ void RemoveRun(DISTANCE run);
+ void RemoveRunIfEmpty(DISTANCE run);
+ void RemoveRunIfSameAsPrevious(DISTANCE run);
public:
RunStyles();
// Deleted so RunStyles objects can not be copied.
RunStyles(const RunStyles &) = delete;
void operator=(const RunStyles &) = delete;
~RunStyles();
- int Length() const;
- int ValueAt(int position) const;
- int FindNextChange(int position, int end) const;
- int StartRun(int position) const;
- int EndRun(int position) const;
+ DISTANCE Length() const;
+ STYLE ValueAt(DISTANCE position) const;
+ DISTANCE FindNextChange(DISTANCE position, DISTANCE end) const;
+ DISTANCE StartRun(DISTANCE position) const;
+ DISTANCE EndRun(DISTANCE position) const;
// Returns true if some values may have changed
- bool FillRange(int &position, int value, int &fillLength);
- void SetValueAt(int position, int value);
- void InsertSpace(int position, int insertLength);
+ bool FillRange(DISTANCE &position, STYLE value, DISTANCE &fillLength);
+ void SetValueAt(DISTANCE position, STYLE value);
+ void InsertSpace(DISTANCE position, DISTANCE insertLength);
void DeleteAll();
- void DeleteRange(int position, int deleteLength);
- int Runs() const;
+ void DeleteRange(DISTANCE position, DISTANCE deleteLength);
+ DISTANCE Runs() const;
bool AllSame() const;
- bool AllSameAs(int value) const;
- int Find(int value, int start) const;
+ bool AllSameAs(STYLE value) const;
+ DISTANCE Find(STYLE value, DISTANCE start) const;
void Check() const;
};