diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-05-03 19:40:15 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-05-03 19:40:15 +1000 |
| commit | 60cd87963a771c22eda56365f4059c1fa117e3a3 (patch) | |
| tree | 640b935cdb4b5587ee9b0c1de08f42560c0ba387 /src | |
| parent | 69db1ffbcab52381b4f6e04bb5cb64eeba838225 (diff) | |
| download | scintilla-mirror-60cd87963a771c22eda56365f4059c1fa117e3a3.tar.gz | |
Backport: Feature [feature-requests:1347]. Add InsertLines method to PerLine interface and
all implementations. This will allow insertion of lines in batches in a future
change set.
Added tests for PerLine implementations.
Backport of changeset 8227:9fc611fc6848.
Diffstat (limited to 'src')
| -rw-r--r-- | src/CellBuffer.h | 1 | ||||
| -rw-r--r-- | src/Document.cxx | 7 | ||||
| -rw-r--r-- | src/Document.h | 1 | ||||
| -rw-r--r-- | src/PerLine.cxx | 37 | ||||
| -rw-r--r-- | src/PerLine.h | 5 |
5 files changed, 50 insertions, 1 deletions
diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 5138fd0aa..3e16bcdc8 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -16,6 +16,7 @@ public: virtual ~PerLine() {} virtual void Init()=0; virtual void InsertLine(Sci::Line line)=0; + virtual void InsertLines(Sci::Line line, Sci::Line lines) = 0; virtual void RemoveLine(Sci::Line line)=0; }; diff --git a/src/Document.cxx b/src/Document.cxx index 98746f2f2..b3ff671da 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -181,6 +181,13 @@ void Document::InsertLine(Sci::Line line) { } } +void Document::InsertLines(Sci::Line line, Sci::Line lines) { + for (const auto &pl : perLineData) { + if (pl) + pl->InsertLines(line, lines); + } +} + void Document::RemoveLine(Sci::Line line) { for (const std::unique_ptr<PerLine> &pl : perLineData) { if (pl) diff --git a/src/Document.h b/src/Document.h index 64ce2728d..87582a26e 100644 --- a/src/Document.h +++ b/src/Document.h @@ -298,6 +298,7 @@ public: // From PerLine void Init() override; void InsertLine(Sci::Line line) override; + void InsertLines(Sci::Line line, Sci::Line lines) override; void RemoveLine(Sci::Line line) override; int LineEndTypesSupported() const; diff --git a/src/PerLine.cxx b/src/PerLine.cxx index b729386a5..3c8272372 100644 --- a/src/PerLine.cxx +++ b/src/PerLine.cxx @@ -101,6 +101,12 @@ void LineMarkers::InsertLine(Sci::Line line) { } } +void LineMarkers::InsertLines(Sci::Line line, Sci::Line lines) { + if (markers.Length()) { + markers.InsertEmpty(line, lines); + } +} + void LineMarkers::RemoveLine(Sci::Line line) { // Retain the markers from the deleted line by oring them into the previous line if (markers.Length()) { @@ -218,7 +224,14 @@ void LineLevels::Init() { void LineLevels::InsertLine(Sci::Line line) { if (levels.Length()) { const int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE; - levels.InsertValue(line, 1, level); + levels.Insert(line, level); + } +} + +void LineLevels::InsertLines(Sci::Line line, Sci::Line lines) { + if (levels.Length()) { + const int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE; + levels.InsertValue(line, lines, level); } } @@ -280,6 +293,14 @@ void LineState::InsertLine(Sci::Line line) { } } +void LineState::InsertLines(Sci::Line line, Sci::Line lines) { + if (lineStates.Length()) { + lineStates.EnsureLength(line); + const int val = (line < lineStates.Length()) ? lineStates[line] : 0; + lineStates.InsertValue(line, lines, val); + } +} + void LineState::RemoveLine(Sci::Line line) { if (lineStates.Length() > line) { lineStates.Delete(line); @@ -350,6 +371,13 @@ void LineAnnotation::InsertLine(Sci::Line line) { } } +void LineAnnotation::InsertLines(Sci::Line line, Sci::Line lines) { + if (annotations.Length()) { + annotations.EnsureLength(line); + annotations.InsertEmpty(line, lines); + } +} + void LineAnnotation::RemoveLine(Sci::Line line) { if (annotations.Length() && (line > 0) && (line <= annotations.Length())) { annotations[line-1].reset(); @@ -466,6 +494,13 @@ void LineTabstops::InsertLine(Sci::Line line) { } } +void LineTabstops::InsertLines(Sci::Line line, Sci::Line lines) { + if (tabstops.Length()) { + tabstops.EnsureLength(line); + tabstops.InsertEmpty(line, lines); + } +} + void LineTabstops::RemoveLine(Sci::Line line) { if (tabstops.Length() > line) { tabstops[line].reset(); diff --git a/src/PerLine.h b/src/PerLine.h index b6565fcc1..b43b0a18b 100644 --- a/src/PerLine.h +++ b/src/PerLine.h @@ -59,6 +59,7 @@ public: ~LineMarkers() override; void Init() override; void InsertLine(Sci::Line line) override; + void InsertLines(Sci::Line line, Sci::Line lines) override; void RemoveLine(Sci::Line line) override; int MarkValue(Sci::Line line) const noexcept; @@ -85,6 +86,7 @@ public: ~LineLevels() override; void Init() override; void InsertLine(Sci::Line line) override; + void InsertLines(Sci::Line line, Sci::Line lines) override; void RemoveLine(Sci::Line line) override; void ExpandLevels(Sci::Line sizeNew=-1); @@ -106,6 +108,7 @@ public: ~LineState() override; void Init() override; void InsertLine(Sci::Line line) override; + void InsertLines(Sci::Line line, Sci::Line lines) override; void RemoveLine(Sci::Line line) override; int SetLineState(Sci::Line line, int state); @@ -126,6 +129,7 @@ public: ~LineAnnotation() override; void Init() override; void InsertLine(Sci::Line line) override; + void InsertLines(Sci::Line line, Sci::Line lines) override; void RemoveLine(Sci::Line line) override; bool MultipleStyles(Sci::Line line) const noexcept; @@ -155,6 +159,7 @@ public: ~LineTabstops() override; void Init() override; void InsertLine(Sci::Line line) override; + void InsertLines(Sci::Line line, Sci::Line lines) override; void RemoveLine(Sci::Line line) override; bool ClearTabstops(Sci::Line line) noexcept; |
