diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CellBuffer.cxx | 151 | ||||
-rw-r--r-- | src/CellBuffer.h | 18 | ||||
-rw-r--r-- | src/Document.cxx | 47 | ||||
-rw-r--r-- | src/Document.h | 7 | ||||
-rw-r--r-- | src/Editor.cxx | 45 | ||||
-rw-r--r-- | src/Editor.h | 1 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 2 | ||||
-rw-r--r-- | src/SplitVector.h | 2 |
8 files changed, 125 insertions, 148 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 7096d4419..b7c7c06e0 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -560,7 +560,7 @@ CellBuffer::~CellBuffer() { } char CellBuffer::CharAt(int position) { - return ByteAt(position*2); + return substance.ValueAt(position); } void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) { @@ -568,35 +568,34 @@ void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) { return; if (position < 0) return; - int bytePos = position * 2; - if ((bytePos + lengthRetrieve * 2) > body.Length()) { - Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", bytePos, - lengthRetrieve, body.Length()); + if ((position + lengthRetrieve) > substance.Length()) { + Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", position, + lengthRetrieve, substance.Length()); return; } - int i = bytePos; - while (lengthRetrieve--) { - *buffer++ = body.ValueAt(i); - i += 2; + + for (int i=0; i<lengthRetrieve; i++) { + *buffer++ = substance.ValueAt(position + i); } } char CellBuffer::StyleAt(int position) { - return ByteAt(position*2 + 1); + return style.ValueAt(position); } -const char *CellBuffer::InsertString(int position, char *s, int insertLength, bool &startSequence) { +// The char* returned is to an allocation owned by the undo history +const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) { char *data = 0; // InsertString and DeleteChars are the bottleneck though which all changes occur if (!readOnly) { if (collectingUndo) { // Save into the undo/redo stack, but only the characters - not the formatting // This takes up about half load time - data = new char[insertLength / 2]; - for (int i = 0; i < insertLength / 2; i++) { - data[i] = s[i * 2]; + data = new char[insertLength]; + for (int i = 0; i < insertLength; i++) { + data[i] = s[i]; } - uh.AppendAction(insertAction, position / 2, data, insertLength / 2, startSequence); + uh.AppendAction(insertAction, position, data, insertLength, startSequence); } BasicInsertString(position, s, insertLength); @@ -604,33 +603,33 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength, bo return data; } -bool CellBuffer::SetStyleAt(int position, char style, char mask) { - style &= mask; - char curVal = ByteAt(position * 2 + 1); - if ((curVal & mask) != style) { - body.SetValueAt(position*2 + 1, static_cast<char>((curVal & ~mask) | style)); +bool CellBuffer::SetStyleAt(int position, char styleValue, char mask) { + styleValue &= mask; + char curVal = style.ValueAt(position); + if ((curVal & mask) != styleValue) { + style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue)); return true; } else { return false; } } -bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mask) { - int bytePos = position * 2 + 1; +bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue, char mask) { bool changed = false; PLATFORM_ASSERT(lengthStyle == 0 || - (lengthStyle > 0 && lengthStyle + position < body.Length())); + (lengthStyle > 0 && lengthStyle + position <= style.Length())); while (lengthStyle--) { - char curVal = ByteAt(bytePos); - if ((curVal & mask) != style) { - body.SetValueAt(bytePos, static_cast<char>((curVal & ~mask) | style)); + char curVal = style.ValueAt(position); + if ((curVal & mask) != styleValue) { + style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue)); changed = true; } - bytePos += 2; + position++; } return changed; } +// The char* returned is to an allocation owned by the undo history const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) { // InsertString and DeleteChars are the bottleneck though which all changes occur PLATFORM_ASSERT(deleteLength > 0); @@ -638,11 +637,11 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startS if (!readOnly) { if (collectingUndo) { // Save into the undo/redo stack, but only the characters - not the formatting - data = new char[deleteLength / 2]; - for (int i = 0; i < deleteLength / 2; i++) { - data[i] = ByteAt(position + i * 2); + data = new char[deleteLength]; + for (int i = 0; i < deleteLength; i++) { + data[i] = substance.ValueAt(position + i); } - uh.AppendAction(removeAction, position / 2, data, deleteLength / 2, startSequence); + uh.AppendAction(removeAction, position, data, deleteLength, startSequence); } BasicDeleteChars(position, deleteLength); @@ -650,17 +649,13 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startS return data; } -int CellBuffer::ByteLength() { - return body.Length(); -} - int CellBuffer::Length() { - return ByteLength() / 2; + return substance.Length(); } - void CellBuffer::Allocate(int newSize) { - body.ReAllocate(newSize); + substance.ReAllocate(newSize); + style.ReAllocate(newSize); } int CellBuffer::Lines() { @@ -727,45 +722,46 @@ int CellBuffer::LineFromHandle(int markerHandle) { // Without undo -void CellBuffer::BasicInsertString(int position, char *s, int insertLength) { +void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) { if (insertLength == 0) return; PLATFORM_ASSERT(insertLength > 0); - body.InsertFromArray(position, s, 0, insertLength); + substance.InsertFromArray(position, s, 0, insertLength); + style.InsertValue(position, insertLength, 0); - int lineInsert = lv.LineFromPosition(position / 2) + 1; + int lineInsert = lv.LineFromPosition(position) + 1; // Point all the lines after the insertion point further along in the buffer - lv.InsertText(lineInsert-1, insertLength / 2); + lv.InsertText(lineInsert-1, insertLength); char chPrev = ' '; - if ((position - 2) >= 0) - chPrev = ByteAt(position - 2); + if ((position - 1) >= 0) + chPrev = substance.ValueAt(position - 1); char chAfter = ' '; - if ((position + insertLength) < body.Length()) - chAfter = ByteAt(position + insertLength); + if ((position + insertLength) < substance.Length()) + chAfter = substance.ValueAt(position + insertLength); if (chPrev == '\r' && chAfter == '\n') { // Splitting up a crlf pair at position - lv.InsertLine(lineInsert, position / 2); + lv.InsertLine(lineInsert, position); lineInsert++; } char ch = ' '; - for (int i = 0; i < insertLength; i += 2) { + for (int i = 0; i < insertLength; i++) { ch = s[i]; if (ch == '\r') { - lv.InsertLine(lineInsert, (position + i) / 2 + 1); + lv.InsertLine(lineInsert, (position + i) + 1); lineInsert++; } else if (ch == '\n') { if (chPrev == '\r') { // Patch up what was end of line - lv.SetLineStart(lineInsert - 1, (position + i) / 2 + 1); + lv.SetLineStart(lineInsert - 1, (position + i) + 1); } else { - lv.InsertLine(lineInsert, (position + i) / 2 + 1); + lv.InsertLine(lineInsert, (position + i) + 1); lineInsert++; } } chPrev = ch; } - // Joining two lines where last insertion is cr and following text starts with lf + // Joining two lines where last insertion is cr and following substance starts with lf if (chAfter == '\n') { if (ch == '\r') { // End of line already in buffer so drop the newly created one @@ -778,7 +774,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) { if (deleteLength == 0) return; - if ((position == 0) && (deleteLength == body.Length())) { + if ((position == 0) && (deleteLength == substance.Length())) { // If whole buffer is being deleted, faster to reinitialise lines data // than to delete each line. lv.Init(); @@ -786,28 +782,28 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) { // Have to fix up line positions before doing deletion as looking at text in buffer // to work out which lines have been removed - int lineRemove = lv.LineFromPosition(position / 2) + 1; - lv.InsertText(lineRemove-1, - (deleteLength / 2)); + int lineRemove = lv.LineFromPosition(position) + 1; + lv.InsertText(lineRemove-1, - (deleteLength)); char chPrev = ' '; - if (position >= 2) - chPrev = ByteAt(position - 2); + if (position >= 1) + chPrev = substance.ValueAt(position - 1); char chBefore = chPrev; char chNext = ' '; - if (position < body.Length()) - chNext = ByteAt(position); + if (position < substance.Length()) + chNext = substance.ValueAt(position); bool ignoreNL = false; if (chPrev == '\r' && chNext == '\n') { // Move back one - lv.SetLineStart(lineRemove, position / 2); + lv.SetLineStart(lineRemove, position); lineRemove++; ignoreNL = true; // First \n is not real deletion } char ch = chNext; - for (int i = 0; i < deleteLength; i += 2) { + for (int i = 0; i < deleteLength; i++) { chNext = ' '; - if ((position + i + 2) < body.Length()) - chNext = ByteAt(position + i + 2); + if ((position + i + 1) < substance.Length()) + chNext = substance.ValueAt(position + i + 1); if (ch == '\r') { if (chNext != '\n') { lv.RemoveLine(lineRemove); @@ -825,15 +821,16 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) { // May have to fix up end if last deletion causes cr to be next to lf // or removes one of a crlf pair char chAfter = ' '; - if ((position + deleteLength) < body.Length()) - chAfter = ByteAt(position + deleteLength); + if ((position + deleteLength) < substance.Length()) + chAfter = substance.ValueAt(position + deleteLength); if (chBefore == '\r' && chAfter == '\n') { // Using lineRemove-1 as cr ended line before start of deletion lv.RemoveLine(lineRemove - 1); - lv.SetLineStart(lineRemove - 1, position / 2 + 1); + lv.SetLineStart(lineRemove - 1, position + 1); } } - body.DeleteRange(position, deleteLength); + substance.DeleteRange(position, deleteLength); + style.DeleteRange(position, deleteLength); } bool CellBuffer::SetUndoCollection(bool collectUndo) { @@ -873,15 +870,9 @@ const Action &CellBuffer::GetUndoStep() const { void CellBuffer::PerformUndoStep() { const Action &actionStep = uh.GetUndoStep(); if (actionStep.at == insertAction) { - BasicDeleteChars(actionStep.position*2, actionStep.lenData*2); + BasicDeleteChars(actionStep.position, actionStep.lenData); } else if (actionStep.at == removeAction) { - char *styledData = new char[actionStep.lenData * 2]; - for (int i = 0; i < actionStep.lenData; i++) { - styledData[i*2] = actionStep.data[i]; - styledData[i*2 + 1] = 0; - } - BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2); - delete []styledData; + BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); } uh.CompletedUndoStep(); } @@ -901,15 +892,9 @@ const Action &CellBuffer::GetRedoStep() const { void CellBuffer::PerformRedoStep() { const Action &actionStep = uh.GetRedoStep(); if (actionStep.at == insertAction) { - char *styledData = new char[actionStep.lenData * 2]; - for (int i = 0; i < actionStep.lenData; i++) { - styledData[i*2] = actionStep.data[i]; - styledData[i*2 + 1] = 0; - } - BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2); - delete []styledData; + BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); } else if (actionStep.at == removeAction) { - BasicDeleteChars(actionStep.position*2, actionStep.lenData*2); + BasicDeleteChars(actionStep.position, actionStep.lenData); } uh.CompletedRedoStep(); } diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 7faeecd23..9cece4854 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -147,7 +147,8 @@ public: */ class CellBuffer { private: - SplitVector<char> body; + SplitVector<char> substance; + SplitVector<char> style; bool readOnly; bool collectingUndo; @@ -157,10 +158,6 @@ private: SVector lineStates; - char ByteAt(int position) { - return body.ValueAt(position); - } - public: CellBuffer(); @@ -171,18 +168,17 @@ public: void GetCharRange(char *buffer, int position, int lengthRetrieve); char StyleAt(int position); - int ByteLength(); int Length(); void Allocate(int newSize); int Lines(); int LineStart(int line); int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } - const char *InsertString(int position, char *s, int insertLength, bool &startSequence); + const char *InsertString(int position, const char *s, int insertLength, bool &startSequence); /// Setting styles for positions outside the range of the buffer is safe and has no effect. /// @return true if the style of a character is changed. - bool SetStyleAt(int position, char style, char mask='\377'); - bool SetStyleFor(int position, int length, char style, char mask); + bool SetStyleAt(int position, char styleValue, char mask='\377'); + bool SetStyleFor(int position, int length, char styleValue, char mask); const char *DeleteChars(int position, int deleteLength, bool &startSequence); @@ -203,7 +199,7 @@ public: int LineFromHandle(int markerHandle); /// Actions without undo - void BasicInsertString(int position, char *s, int insertLength); + void BasicInsertString(int position, const char *s, int insertLength); void BasicDeleteChars(int position, int deleteLength); bool SetUndoCollection(bool collectUndo); @@ -232,6 +228,4 @@ public: void ClearLevels(); }; -#define CELL_SIZE 2 - #endif diff --git a/src/Document.cxx b/src/Document.cxx index 2e21cfe7b..6e8d2cc44 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -360,10 +360,9 @@ void Document::CheckReadOnly() { } } -// Document only modified by gateways DeleteChars, InsertStyledString, Undo, Redo, and SetStyleAt. +// Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt. // SetStyleAt does not change the persistent state of a document -// Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number bool Document::DeleteChars(int pos, int len) { if (len == 0) return false; @@ -383,7 +382,7 @@ bool Document::DeleteChars(int pos, int len) { int prevLinesTotal = LinesTotal(); bool startSavePoint = cb.IsSavePoint(); bool startSequence = false; - const char *text = cb.DeleteChars(pos * 2, len * 2, startSequence); + const char *text = cb.DeleteChars(pos, len, startSequence); if (startSavePoint && cb.IsCollectingUndo()) NotifySavePoint(!startSavePoint); if ((pos < Length()) || (pos == 0)) @@ -402,9 +401,12 @@ bool Document::DeleteChars(int pos, int len) { } /** - * Insert a styled string (char/style pairs) with a length. + * Insert a string with a length. */ -bool Document::InsertStyledString(int position, char *s, int insertLength) { +bool Document::InsertString(int position, const char *s, int insertLength) { + if (insertLength <= 0) { + return false; + } CheckReadOnly(); if (enteredCount != 0) { return false; @@ -414,7 +416,7 @@ bool Document::InsertStyledString(int position, char *s, int insertLength) { NotifyModified( DocModification( SC_MOD_BEFOREINSERT | SC_PERFORMED_USER, - position / 2, insertLength / 2, + position, insertLength, 0, s)); int prevLinesTotal = LinesTotal(); bool startSavePoint = cb.IsSavePoint(); @@ -422,11 +424,11 @@ bool Document::InsertStyledString(int position, char *s, int insertLength) { const char *text = cb.InsertString(position, s, insertLength, startSequence); if (startSavePoint && cb.IsCollectingUndo()) NotifySavePoint(!startSavePoint); - ModifiedAt(position / 2); + ModifiedAt(position); NotifyModified( DocModification( SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0), - position / 2, insertLength / 2, + position, insertLength, LinesTotal() - prevLinesTotal, text)); } enteredCount--; @@ -548,39 +550,18 @@ int Document::Redo() { * Insert a single character. */ bool Document::InsertChar(int pos, char ch) { - char chs[2]; + char chs[1]; chs[0] = ch; - chs[1] = 0; - return InsertStyledString(pos*2, chs, 2); + return InsertString(pos, chs, 1); } /** * Insert a null terminated string. */ -bool Document::InsertString(int position, const char *s) { +bool Document::InsertCString(int position, const char *s) { return InsertString(position, s, strlen(s)); } -/** - * Insert a string with a length. - */ -bool Document::InsertString(int position, const char *s, size_t insertLength) { - bool changed = false; - if (insertLength > 0) { - char *sWithStyle = new char[insertLength * 2]; - if (sWithStyle) { - for (size_t i = 0; i < insertLength; i++) { - sWithStyle[i*2] = s[i]; - sWithStyle[i*2 + 1] = 0; - } - changed = InsertStyledString(position*2, sWithStyle, - static_cast<int>(insertLength*2)); - delete []sWithStyle; - } - } - return changed; -} - void Document::ChangeChar(int pos, char ch) { DeleteChars(pos, 1); InsertChar(pos, ch); @@ -657,7 +638,7 @@ void Document::SetLineIndentation(int line, int indent) { int indentPos = GetLineIndentPosition(line); BeginUndoAction(); DeleteChars(thisLineStart, indentPos - thisLineStart); - InsertString(thisLineStart, linebuf); + InsertCString(thisLineStart, linebuf); EndUndoAction(); } } diff --git a/src/Document.h b/src/Document.h index d774d5664..730b033f3 100644 --- a/src/Document.h +++ b/src/Document.h @@ -136,7 +136,7 @@ public: // Gateways to modifying document void ModifiedAt(int pos); bool DeleteChars(int pos, int len); - bool InsertStyledString(int position, char *s, int insertLength); + bool InsertString(int position, const char *s, int insertLength); int Undo(); int Redo(); bool CanUndo() { return cb.CanUndo(); } @@ -163,8 +163,7 @@ public: bool IsReadOnly() { return cb.IsReadOnly(); } bool InsertChar(int pos, char ch); - bool InsertString(int position, const char *s); - bool InsertString(int position, const char *s, size_t insertLength); + bool InsertCString(int position, const char *s); void ChangeChar(int pos, char ch); void DelChar(int pos); void DelCharBack(int pos); @@ -197,7 +196,7 @@ public: int NextWordStart(int pos, int delta); int NextWordEnd(int pos, int delta); int Length() { return cb.Length(); } - void Allocate(int newSize) { cb.Allocate(newSize*2); } + void Allocate(int newSize) { cb.Allocate(newSize); } long FindText(int minPos, int maxPos, const char *s, bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length); long FindText(int iMessage, unsigned long wParam, long lParam); diff --git a/src/Editor.cxx b/src/Editor.cxx index b0bd99e83..14906f523 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1663,7 +1663,7 @@ void Editor::LinesSplit(int pixelWidth) { unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, pixelWidth); for (int subLine = 1; subLine < ll->lines; subLine++) { - pdoc->InsertString(posLineStart + (subLine - 1) * strlen(eol) + + pdoc->InsertCString(posLineStart + (subLine - 1) * strlen(eol) + ll->LineStart(subLine), eol); targetEnd += static_cast<int>(strlen(eol)); } @@ -4115,7 +4115,7 @@ void Editor::Duplicate(bool forLine) { char *text = CopyRange(start, end); if (forLine) { const char *eol = StringFromEOLMode(pdoc->eolMode); - pdoc->InsertString(end, eol); + pdoc->InsertCString(end, eol); pdoc->InsertString(end + istrlen(eol), text, end - start); } else { pdoc->InsertString(end, text, end - start); @@ -4135,7 +4135,7 @@ void Editor::NewLine() { } else if (pdoc->eolMode == SC_EOL_CR) { eol = "\r"; } // else SC_EOL_LF -> "\n" already set - if (pdoc->InsertString(currentPos, eol)) { + if (pdoc->InsertCString(currentPos, eol)) { SetEmptySelection(currentPos + istrlen(eol)); while (*eol) { NotifyChar(*eol); @@ -4994,7 +4994,7 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul SetEmptySelection(position); } else { position = MovePositionOutsideChar(position, currentPos - position); - if (pdoc->InsertString(position, value)) { + if (pdoc->InsertCString(position, value)) { SetSelection(position + istrlen(value), position); } pdoc->EndUndoAction(); @@ -5700,6 +5700,26 @@ int Editor::WrapCount(int line) { } } +void Editor::AddStyledText(char *buffer, int appendLength) { + // The buffer consists of alternating character bytes and style bytes + size_t textLength = appendLength / 2; + char *text = new char[textLength]; + if (text) { + size_t i; + for (i=0;i<textLength;i++) { + text[i] = buffer[i*2]; + } + pdoc->InsertString(CurrentPosition(), text, textLength); + for (i=0;i<textLength;i++) { + text[i] = buffer[i*2+1]; + } + pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff)); + pdoc->SetStyles(textLength, text); + delete []text; + } + SetEmptySelection(currentPos + textLength); +} + static bool ValidMargin(unsigned long wParam) { return wParam < ViewStyle::margins; } @@ -5736,7 +5756,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { pdoc->BeginUndoAction(); pdoc->DeleteChars(0, pdoc->Length()); SetEmptySelection(0); - pdoc->InsertString(0, CharPtrFromSPtr(lParam)); + pdoc->InsertCString(0, CharPtrFromSPtr(lParam)); pdoc->EndUndoAction(); return 1; } @@ -5886,7 +5906,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { pdoc->BeginUndoAction(); ClearSelection(); char *replacement = CharPtrFromSPtr(lParam); - pdoc->InsertString(currentPos, replacement); + pdoc->InsertCString(currentPos, replacement); pdoc->EndUndoAction(); SetEmptySelection(currentPos + istrlen(replacement)); EnsureCaretVisible(); @@ -6042,13 +6062,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; } - case SCI_ADDSTYLEDTEXT: { - if (lParam == 0) - return 0; - pdoc->InsertStyledString(CurrentPosition() * 2, CharPtrFromSPtr(lParam), wParam); - SetEmptySelection(currentPos + wParam / 2); - return 0; - } + case SCI_ADDSTYLEDTEXT: + if (lParam) + AddStyledText(CharPtrFromSPtr(lParam), wParam); + return 0; case SCI_INSERTTEXT: { if (lParam == 0) @@ -6058,7 +6075,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); char *sz = CharPtrFromSPtr(lParam); - pdoc->InsertString(insertPos, sz); + pdoc->InsertCString(insertPos, sz); if (newCurrent > insertPos) newCurrent += istrlen(sz); SetEmptySelection(newCurrent); diff --git a/src/Editor.h b/src/Editor.h index fe7be268a..e1065bf04 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -527,6 +527,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int CodePage() const; virtual bool ValidCodePage(int /* codePage */) const { return true; } int WrapCount(int line); + void AddStyledText(char *buffer, int appendLength); virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0; diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index e43411261..0f3b3c093 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -358,7 +358,7 @@ void ScintillaBase::AutoCompleteCompleted() { SetEmptySelection(ac.posStart); if (item != -1) { SString piece = selected; - pdoc->InsertString(firstPos, piece.c_str()); + pdoc->InsertCString(firstPos, piece.c_str()); SetEmptySelection(firstPos + static_cast<int>(piece.length())); } pdoc->EndUndoAction(); diff --git a/src/SplitVector.h b/src/SplitVector.h index 2847108fa..46cdc2bbb 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -175,7 +175,7 @@ public: } /// Insert text into the buffer from an array. - void InsertFromArray(int positionToInsert, T s[], int positionFrom, int insertLength) { + void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) { if (insertLength > 0) { if ((positionToInsert < 0) || (positionToInsert > lengthBody)) { return; |