aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 8081dcdd6..389b25346 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1137,7 +1137,7 @@ void Editor::MoveSelectedLines(int lineDelta) {
pdoc->InsertCString(pdoc->Length(), eol);
GoToLine(currentLine + lineDelta);
- pdoc->InsertCString(CurrentPosition(), selectedText.s);
+ pdoc->InsertCString(CurrentPosition(), selectedText.Data());
if (appendEol) {
pdoc->InsertCString(CurrentPosition() + selectionLength, eol);
selectionLength += istrlen(eol);
@@ -6053,7 +6053,7 @@ void Editor::CopyRangeToClipboard(int start, int end) {
void Editor::CopyText(int length, const char *text) {
SelectionText selectedText;
- selectedText.Copy(text, length + 1,
+ selectedText.Copy(std::string(text, length),
pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false);
CopyToClipboard(selectedText);
}
@@ -6092,7 +6092,7 @@ void Editor::StartDrag() {
//DisplayCursor(Window::cursorArrow);
}
-void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) {
+void Editor::DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular) {
//Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position);
if (inDragDrop == ddDragging)
dropWentOutside = false;
@@ -6133,15 +6133,15 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving,
position = positionAfterDeletion;
if (rectangular) {
- PasteRectangular(position, value, istrlen(value));
+ PasteRectangular(position, value, static_cast<int>(lengthValue));
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetEmptySelection(position);
} else {
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace()));
- if (pdoc->InsertCString(position.Position(), value)) {
+ if (pdoc->InsertString(position.Position(), value, static_cast<int>(lengthValue))) {
SelectionPosition posAfterInsertion = position;
- posAfterInsertion.Add(istrlen(value));
+ posAfterInsertion.Add(static_cast<int>(lengthValue));
SetSelection(posAfterInsertion, position);
}
}
@@ -6150,6 +6150,10 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving,
}
}
+void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) {
+ DropAt(position, value, strlen(value), moving, rectangular);
+}
+
/**
* @return true if given position is inside the selection,
*/
@@ -6655,26 +6659,26 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
SelectionPosition selStart = SelectionStart();
SelectionPosition selEnd = SelectionEnd();
if (selStart < selEnd) {
- if (drag.len) {
+ if (drag.Length()) {
if (ctrl) {
- if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) {
- SetSelection(newPos.Position(), newPos.Position() + drag.len);
+ if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
+ SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
}
} else if (newPos < selStart) {
- pdoc->DeleteChars(selStart.Position(), drag.len);
- if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) {
- SetSelection(newPos.Position(), newPos.Position() + drag.len);
+ pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
+ if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
+ SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
}
} else if (newPos > selEnd) {
- pdoc->DeleteChars(selStart.Position(), drag.len);
- newPos.Add(-drag.len);
- if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) {
- SetSelection(newPos.Position(), newPos.Position() + drag.len);
+ pdoc->DeleteChars(selStart.Position(), static_cast<int>(drag.Length()));
+ newPos.Add(-static_cast<int>(drag.Length()));
+ if (pdoc->InsertString(newPos.Position(), drag.Data(), static_cast<int>(drag.Length()))) {
+ SetSelection(newPos.Position(), newPos.Position() + static_cast<int>(drag.Length()));
}
} else {
SetEmptySelection(newPos.Position());
}
- drag.Free();
+ drag.Clear();
}
selectionType = selChar;
}
@@ -7512,13 +7516,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
SelectionText selectedText;
CopySelectionRange(&selectedText);
if (lParam == 0) {
- return selectedText.len ? selectedText.len : 1;
+ return selectedText.LengthWithTerminator();
} else {
char *ptr = CharPtrFromSPtr(lParam);
- int iChar = 0;
- if (selectedText.len) {
- for (; iChar < selectedText.len; iChar++)
- ptr[iChar] = selectedText.s[iChar];
+ unsigned int iChar = 0;
+ if (selectedText.Length()) {
+ for (; iChar < selectedText.LengthWithTerminator(); iChar++)
+ ptr[iChar] = selectedText.Data()[iChar];
} else {
ptr[0] = '\0';
}