# HG changeset patch # User Neil # Date 1517437334 -39600 # Node ID 89d992f380a1ce28a3ba6934230388ffaf1ea611 # Parent 1bd57324aa36e3fce1ed8a2371001b062322884b Templatize RunStyles so it can be over ranges of different types and contain different style types. Currently only instantiated over . diff -r 1bd57324aa36 -r 89d992f380a1 src/ContractionState.cxx --- a/src/ContractionState.cxx Thu Feb 01 09:07:21 2018 +1100 +++ b/src/ContractionState.cxx Thu Feb 01 09:22:14 2018 +1100 @@ -35,9 +35,9 @@ void ContractionState::EnsureData() { if (OneToOne()) { - visible = new RunStyles(); - expanded = new RunStyles(); - heights = new RunStyles(); + visible = new RunStyles(); + expanded = new RunStyles(); + heights = new RunStyles(); foldDisplayTexts = new SparseVector(); displayLines = new Partitioning(4); InsertLines(0, linesInDocument); diff -r 1bd57324aa36 -r 89d992f380a1 src/ContractionState.h --- a/src/ContractionState.h Thu Feb 01 09:07:21 2018 +1100 +++ b/src/ContractionState.h Thu Feb 01 09:22:14 2018 +1100 @@ -17,9 +17,9 @@ */ class ContractionState { // These contain 1 element for every document line. - RunStyles *visible; - RunStyles *expanded; - RunStyles *heights; + RunStyles *visible; + RunStyles *expanded; + RunStyles *heights; SparseVector *foldDisplayTexts; Partitioning *displayLines; Sci::Line linesInDocument; diff -r 1bd57324aa36 -r 89d992f380a1 src/Decoration.h --- a/src/Decoration.h Thu Feb 01 09:07:21 2018 +1100 +++ b/src/Decoration.h Thu Feb 01 09:22:14 2018 +1100 @@ -12,7 +12,7 @@ class Decoration { int indicator; public: Decoration *next; - RunStyles rs; + RunStyles rs; explicit Decoration(int indicator_); diff -r 1bd57324aa36 -r 89d992f380a1 src/RunStyles.cxx --- a/src/RunStyles.cxx Thu Feb 01 09:07:21 2018 +1100 +++ b/src/RunStyles.cxx Thu Feb 01 09:22:14 2018 +1100 @@ -26,8 +26,9 @@ using namespace Scintilla; // Find the first run at a position -int RunStyles::RunFromPosition(int position) const { - int run = starts->PartitionFromPosition(position); +template +DISTANCE RunStyles::RunFromPosition(DISTANCE position) const { + DISTANCE run = starts->PartitionFromPosition(position); // Go to first element with this position while ((run > 0) && (position == starts->PositionFromPartition(run-1))) { run--; @@ -36,11 +37,12 @@ } // If there is no run boundary at position, insert one continuing style. -int RunStyles::SplitRun(int position) { - int run = RunFromPosition(position); - const int posRun = starts->PositionFromPartition(run); +template +DISTANCE RunStyles::SplitRun(DISTANCE position) { + DISTANCE run = RunFromPosition(position); + const DISTANCE posRun = starts->PositionFromPartition(run); if (posRun < position) { - int runStyle = ValueAt(position); + STYLE runStyle = ValueAt(position); run++; starts->InsertPartition(run, position); styles->InsertValue(run, 1, runStyle); @@ -48,12 +50,14 @@ return run; } -void RunStyles::RemoveRun(int run) { +template +void RunStyles::RemoveRun(DISTANCE run) { starts->RemovePartition(run); styles->DeleteRange(run, 1); } -void RunStyles::RemoveRunIfEmpty(int run) { +template +void RunStyles::RemoveRunIfEmpty(DISTANCE run) { if ((run < starts->Partitions()) && (starts->Partitions() > 1)) { if (starts->PositionFromPartition(run) == starts->PositionFromPartition(run+1)) { RemoveRun(run); @@ -61,7 +65,8 @@ } } -void RunStyles::RemoveRunIfSameAsPrevious(int run) { +template +void RunStyles::RemoveRunIfSameAsPrevious(DISTANCE run) { if ((run > 0) && (run < starts->Partitions())) { if (styles->ValueAt(run-1) == styles->ValueAt(run)) { RemoveRun(run); @@ -69,34 +74,39 @@ } } -RunStyles::RunStyles() { - starts = new Partitioning(8); - styles = new SplitVector(); +template +RunStyles::RunStyles() { + starts = new Partitioning(8); + styles = new SplitVector