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 | 4b450a69452a14fd9af6c426b91d04165fedc94a (patch) | |
| tree | 47c4806178b43f175f56433b7ed1ebafb0446f1e /src | |
| parent | b24183b5a90b4ebeb951668d48f0e95a1a2819dd (diff) | |
| download | scintilla-mirror-4b450a69452a14fd9af6c426b91d04165fedc94a.tar.gz | |
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.
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 2382e1c21..ff009ee3e 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -178,6 +178,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 a1d9ff7c2..2ff0e8b27 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 47556f3ae..c7204e31a 100644 --- a/src/PerLine.cxx +++ b/src/PerLine.cxx @@ -102,6 +102,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()) { @@ -219,7 +225,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);  	}  } @@ -281,6 +294,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); @@ -343,6 +364,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(); @@ -459,6 +487,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; | 
