diff options
Diffstat (limited to 'src/scintilla_backports/6445_89d992f380a1.patch')
-rw-r--r-- | src/scintilla_backports/6445_89d992f380a1.patch | 418 |
1 files changed, 418 insertions, 0 deletions
diff --git a/src/scintilla_backports/6445_89d992f380a1.patch b/src/scintilla_backports/6445_89d992f380a1.patch new file mode 100644 index 00000000..b0b9acae --- /dev/null +++ b/src/scintilla_backports/6445_89d992f380a1.patch @@ -0,0 +1,418 @@ +# HG changeset patch +# User Neil <nyamatongwe@gmail.com> +# 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 <int, int>. + +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<int, int>(); ++ expanded = new RunStyles<int, int>(); ++ heights = new RunStyles<int, int>(); + foldDisplayTexts = new SparseVector<const char *>(); + displayLines = new Partitioning<int>(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<int, int> *visible; ++ RunStyles<int, int> *expanded; ++ RunStyles<int, int> *heights; + SparseVector<const char *> *foldDisplayTexts; + Partitioning<int> *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<int, int> 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 <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::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 <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::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 <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::RemoveRun(DISTANCE run) { + starts->RemovePartition(run); + styles->DeleteRange(run, 1); + } + +-void RunStyles::RemoveRunIfEmpty(int run) { ++template <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::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 <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::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<int>(8); +- styles = new SplitVector<int>(); ++template <typename DISTANCE, typename STYLE> ++RunStyles<DISTANCE, STYLE>::RunStyles() { ++ starts = new Partitioning<DISTANCE>(8); ++ styles = new SplitVector<STYLE>(); + styles->InsertValue(0, 2, 0); + } + +-RunStyles::~RunStyles() { ++template <typename DISTANCE, typename STYLE> ++RunStyles<DISTANCE, STYLE>::~RunStyles() { + delete starts; + starts = NULL; + delete styles; + styles = NULL; + } + +-int RunStyles::Length() const { ++template <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::Length() const { + return starts->PositionFromPartition(starts->Partitions()); + } + +-int RunStyles::ValueAt(int position) const { ++template <typename DISTANCE, typename STYLE> ++STYLE RunStyles<DISTANCE, STYLE>::ValueAt(DISTANCE position) const { + return styles->ValueAt(starts->PartitionFromPosition(position)); + } + +-int RunStyles::FindNextChange(int position, int end) const { +- const int run = starts->PartitionFromPosition(position); ++template <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::FindNextChange(DISTANCE position, DISTANCE end) const { ++ const DISTANCE run = starts->PartitionFromPosition(position); + if (run < starts->Partitions()) { +- const int runChange = starts->PositionFromPartition(run); ++ const DISTANCE runChange = starts->PositionFromPartition(run); + if (runChange > position) + return runChange; +- const int nextChange = starts->PositionFromPartition(run + 1); ++ const DISTANCE nextChange = starts->PositionFromPartition(run + 1); + if (nextChange > position) { + return nextChange; + } else if (position < end) { +@@ -105,23 +115,26 @@ + } + } + +-int RunStyles::StartRun(int position) const { ++template <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::StartRun(DISTANCE position) const { + return starts->PositionFromPartition(starts->PartitionFromPosition(position)); + } + +-int RunStyles::EndRun(int position) const { ++template <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::EndRun(DISTANCE position) const { + return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1); + } + +-bool RunStyles::FillRange(int &position, int value, int &fillLength) { ++template <typename DISTANCE, typename STYLE> ++bool RunStyles<DISTANCE, STYLE>::FillRange(DISTANCE &position, STYLE value, DISTANCE &fillLength) { + if (fillLength <= 0) { + return false; + } +- int end = position + fillLength; ++ DISTANCE end = position + fillLength; + if (end > Length()) { + return false; + } +- int runEnd = RunFromPosition(end); ++ DISTANCE runEnd = RunFromPosition(end); + if (styles->ValueAt(runEnd) == value) { + // End already has value so trim range. + end = starts->PositionFromPartition(runEnd); +@@ -133,7 +146,7 @@ + } else { + runEnd = SplitRun(end); + } +- int runStart = RunFromPosition(position); ++ DISTANCE runStart = RunFromPosition(position); + if (styles->ValueAt(runStart) == value) { + // Start is in expected value so trim range. + runStart++; +@@ -148,7 +161,7 @@ + if (runStart < runEnd) { + styles->SetValueAt(runStart, value); + // Remove each old run over the range +- for (int run=runStart+1; run<runEnd; run++) { ++ for (DISTANCE run=runStart+1; run<runEnd; run++) { + RemoveRun(runStart+1); + } + runEnd = RunFromPosition(end); +@@ -162,20 +175,22 @@ + } + } + +-void RunStyles::SetValueAt(int position, int value) { +- int len = 1; ++template <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::SetValueAt(DISTANCE position, STYLE value) { ++ DISTANCE len = 1; + FillRange(position, value, len); + } + +-void RunStyles::InsertSpace(int position, int insertLength) { +- int runStart = RunFromPosition(position); ++template <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::InsertSpace(DISTANCE position, DISTANCE insertLength) { ++ DISTANCE runStart = RunFromPosition(position); + if (starts->PositionFromPartition(runStart) == position) { +- int runStyle = ValueAt(position); ++ STYLE runStyle = ValueAt(position); + // Inserting at start of run so make previous longer + if (runStart == 0) { + // Inserting at start of document so ensure 0 + if (runStyle) { +- styles->SetValueAt(0, 0); ++ styles->SetValueAt(0, STYLE()); + starts->InsertPartition(1, 0); + styles->InsertValue(1, 1, runStyle); + starts->InsertText(0, insertLength); +@@ -195,20 +210,22 @@ + } + } + +-void RunStyles::DeleteAll() { ++template <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::DeleteAll() { + delete starts; + starts = NULL; + delete styles; + styles = NULL; +- starts = new Partitioning<int>(8); +- styles = new SplitVector<int>(); ++ starts = new Partitioning<DISTANCE>(8); ++ styles = new SplitVector<STYLE>(); + styles->InsertValue(0, 2, 0); + } + +-void RunStyles::DeleteRange(int position, int deleteLength) { +- int end = position + deleteLength; +- int runStart = RunFromPosition(position); +- int runEnd = RunFromPosition(end); ++template <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::DeleteRange(DISTANCE position, DISTANCE deleteLength) { ++ DISTANCE end = position + deleteLength; ++ DISTANCE runStart = RunFromPosition(position); ++ DISTANCE runEnd = RunFromPosition(end); + if (runStart == runEnd) { + // Deleting from inside one run + starts->InsertText(runStart, -deleteLength); +@@ -214,7 +231,7 @@ + runEnd = SplitRun(end); + starts->InsertText(runStart, -deleteLength); + // Remove each old run over the range +- for (int run=runStart; run<runEnd; run++) { ++ for (DISTANCE run=runStart; run<runEnd; run++) { + RemoveRun(runStart); + } + RemoveRunIfEmpty(runStart); +@@ -222,11 +239,13 @@ + } + } + +-int RunStyles::Runs() const { ++template <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::Runs() const { + return starts->Partitions(); + } + +-bool RunStyles::AllSame() const { ++template <typename DISTANCE, typename STYLE> ++bool RunStyles<DISTANCE, STYLE>::AllSame() const { + for (int run = 1; run < starts->Partitions(); run++) { + if (styles->ValueAt(run) != styles->ValueAt(run - 1)) + return false; +@@ -234,13 +253,15 @@ + return true; + } + +-bool RunStyles::AllSameAs(int value) const { ++template <typename DISTANCE, typename STYLE> ++bool RunStyles<DISTANCE, STYLE>::AllSameAs(STYLE value) const { + return AllSame() && (styles->ValueAt(0) == value); + } + +-int RunStyles::Find(int value, int start) const { ++template <typename DISTANCE, typename STYLE> ++DISTANCE RunStyles<DISTANCE, STYLE>::Find(STYLE value, DISTANCE start) const { + if (start < Length()) { +- int run = start ? RunFromPosition(start) : 0; ++ DISTANCE run = start ? RunFromPosition(start) : 0; + if (styles->ValueAt(run) == value) + return start; + run++; +@@ -253,7 +274,8 @@ + return -1; + } + +-void RunStyles::Check() const { ++template <typename DISTANCE, typename STYLE> ++void RunStyles<DISTANCE, STYLE>::Check() const { + if (Length() < 0) { + throw std::runtime_error("RunStyles: Length can not be negative."); + } +@@ -263,9 +285,9 @@ + if (starts->Partitions() != styles->Length()-1) { + throw std::runtime_error("RunStyles: Partitions and styles different lengths."); + } +- int start=0; ++ DISTANCE start=0; + while (start < Length()) { +- const int end = EndRun(start); ++ const DISTANCE end = EndRun(start); + if (start >= end) { + throw std::runtime_error("RunStyles: Partition is 0 length."); + } +@@ -280,3 +302,9 @@ + } + } + } ++ ++#ifdef SCI_NAMESPACE ++template class Scintilla::RunStyles<int, int>; ++#else ++template class RunStyles<int, int>; ++#endif +diff -r 1bd57324aa36 -r 89d992f380a1 src/RunStyles.h +--- a/src/RunStyles.h Thu Feb 01 09:07:21 2018 +1100 ++++ b/src/RunStyles.h Thu Feb 01 09:22:14 2018 +1100 +@@ -12,35 +12,36 @@ + namespace Scintilla { + #endif + ++template <typename DISTANCE, typename STYLE> + class RunStyles { + private: +- Partitioning<int> *starts; +- SplitVector<int> *styles; +- int RunFromPosition(int position) const; +- int SplitRun(int position); +- void RemoveRun(int run); +- void RemoveRunIfEmpty(int run); +- void RemoveRunIfSameAsPrevious(int run); ++ Partitioning<DISTANCE> *starts; ++ SplitVector<STYLE> *styles; ++ DISTANCE RunFromPosition(DISTANCE position) const; ++ DISTANCE SplitRun(DISTANCE position); ++ void RemoveRun(DISTANCE run); ++ void RemoveRunIfEmpty(DISTANCE run); ++ void RemoveRunIfSameAsPrevious(DISTANCE run); + // Private so RunStyles objects can not be copied + RunStyles(const RunStyles &); + public: + RunStyles(); + ~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; + }; +diff -r 1bd57324aa36 -r 89d992f380a1 test/unit/testRunStyles.cxx +--- a/test/unit/testRunStyles.cxx Thu Feb 01 09:07:21 2018 +1100 ++++ b/test/unit/testRunStyles.cxx Thu Feb 01 09:22:14 2018 +1100 +@@ -22,7 +22,7 @@ + + TEST_CASE("RunStyles") { + +- RunStyles rs; ++ RunStyles<int, int> rs; + + SECTION("IsEmptyInitially") { + REQUIRE(0 == rs.Length()); |