diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/CellBuffer.cxx | 27 | ||||
| -rw-r--r-- | src/CellBuffer.h | 3 | ||||
| -rw-r--r-- | src/Document.cxx | 3 | ||||
| -rw-r--r-- | src/Document.h | 2 | ||||
| -rw-r--r-- | src/EditModel.cxx | 2 | ||||
| -rw-r--r-- | src/Editor.cxx | 6 | 
6 files changed, 31 insertions, 12 deletions
| diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 1884a497a..513c9a9b8 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -342,7 +342,8 @@ void UndoHistory::CompletedRedoStep() {  	currentAction++;  } -CellBuffer::CellBuffer() { +CellBuffer::CellBuffer(bool hasStyles_) : +	hasStyles(hasStyles_) {  	readOnly = false;  	utf8LineEnds = 0;  	collectingUndo = true; @@ -369,7 +370,7 @@ void CellBuffer::GetCharRange(char *buffer, Sci::Position position, Sci::Positio  }  char CellBuffer::StyleAt(Sci::Position position) const { -	return style.ValueAt(position); +	return hasStyles ? style.ValueAt(position) : 0;  }  void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const { @@ -377,6 +378,10 @@ void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sc  		return;  	if (position < 0)  		return; +	if (!hasStyles) { +		std::fill(buffer, buffer + lengthRetrieve, static_cast<unsigned char>(0)); +		return; +	}  	if ((position + lengthRetrieve) > style.Length()) {  		Platform::DebugPrintf("Bad GetStyleRange %d for %d of %d\n", position,  		                      lengthRetrieve, style.Length()); @@ -414,6 +419,9 @@ const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci:  }  bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) { +	if (!hasStyles) { +		return false; +	}  	const char curVal = style.ValueAt(position);  	if (curVal != styleValue) {  		style.SetValueAt(position, styleValue); @@ -424,6 +432,9 @@ bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {  }  bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) { +	if (!hasStyles) { +		return false; +	}  	bool changed = false;  	PLATFORM_ASSERT(lengthStyle == 0 ||  		(lengthStyle > 0 && lengthStyle + position <= style.Length())); @@ -462,7 +473,9 @@ Sci::Position CellBuffer::Length() const {  void CellBuffer::Allocate(Sci::Position newSize) {  	substance.ReAllocate(newSize); -	style.ReAllocate(newSize); +	if (hasStyles) { +		style.ReAllocate(newSize); +	}  }  void CellBuffer::SetLineEndTypes(int utf8LineEnds_) { @@ -608,7 +621,9 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P  	}  	substance.InsertFromArray(position, s, 0, insertLength); -	style.InsertValue(position, insertLength, 0); +	if (hasStyles) { +		style.InsertValue(position, insertLength, 0); +	}  	Sci::Line lineInsert = lv.LineFromPosition(position) + 1;  	bool atLineStart = lv.LineStart(lineInsert-1) == position; @@ -738,7 +753,9 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe  		}  	}  	substance.DeleteRange(position, deleteLength); -	style.DeleteRange(position, deleteLength); +	if (hasStyles) { +		style.DeleteRange(position, deleteLength); +	}  }  bool CellBuffer::SetUndoCollection(bool collectUndo) { diff --git a/src/CellBuffer.h b/src/CellBuffer.h index a12dc207f..7c999a36e 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -133,6 +133,7 @@ public:   */  class CellBuffer {  private: +	bool hasStyles;  	SplitVector<char> substance;  	SplitVector<char> style;  	bool readOnly; @@ -151,7 +152,7 @@ private:  public: -	CellBuffer(); +	CellBuffer(bool hasStyles_);  	// Deleted so CellBuffer objects can not be copied.  	CellBuffer(const CellBuffer &) = delete;  	void operator=(const CellBuffer &) = delete; diff --git a/src/Document.cxx b/src/Document.cxx index 30295ae04..2f1bd2e69 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -94,7 +94,8 @@ int LexInterface::LineEndTypesSupported() {  	return 0;  } -Document::Document() { +Document::Document(int options) : +	cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0) {  	refCount = 0;  #ifdef _WIN32  	eolMode = SC_EOL_CRLF; diff --git a/src/Document.h b/src/Document.h index 7b6921e21..f69c2a34e 100644 --- a/src/Document.h +++ b/src/Document.h @@ -265,7 +265,7 @@ public:  	DecorationList decorations; -	Document(); +	Document(int options);  	// Deleted so Document objects can not be copied.  	Document(const Document &) = delete;  	void operator=(const Document &) = delete; diff --git a/src/EditModel.cxx b/src/EditModel.cxx index 7dfd90e37..f7f73e178 100644 --- a/src/EditModel.cxx +++ b/src/EditModel.cxx @@ -68,7 +68,7 @@ EditModel::EditModel() {  	hotspot = Range(Sci::invalidPosition);  	hoverIndicatorPos = Sci::invalidPosition;  	wrapWidth = LineLayout::wrapWidthInfinite; -	pdoc = new Document(); +	pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);  	pdoc->AddRef();  } diff --git a/src/Editor.cxx b/src/Editor.cxx index a292a957c..75b3859e0 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -5162,7 +5162,7 @@ void Editor::SetDocPointer(Document *document) {  	pdoc->RemoveWatcher(this, 0);  	pdoc->Release();  	if (document == NULL) { -		pdoc = new Document(); +		pdoc = new Document(SC_DOCUMENTOPTION_DEFAULT);  	} else {  		pdoc = document;  	} @@ -7545,7 +7545,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		return 0;  	case SCI_CREATEDOCUMENT: { -			Document *doc = new Document(); +			Document *doc = new Document(static_cast<int>(lParam));  			doc->AddRef();  			doc->Allocate(static_cast<int>(wParam));  			return reinterpret_cast<sptr_t>(doc); @@ -7560,7 +7560,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		break;  	case SCI_CREATELOADER: { -			Document *doc = new Document(); +			Document *doc = new Document(static_cast<int>(lParam));  			doc->AddRef();  			doc->Allocate(static_cast<int>(wParam));  			doc->SetUndoCollection(false); | 
