aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx34
-rw-r--r--src/Editor.h2
2 files changed, 32 insertions, 4 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 479157e39..9f65203d2 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -92,6 +92,9 @@ Editor::Editor() {
currentPos = 0;
anchor = 0;
+ targetStart = 0;
+ targetEnd = 0;
+
topLine = 0;
posTopLine = 0;
@@ -1570,7 +1573,7 @@ void Editor::AddCharUTF(char *s, unsigned int len) {
void Editor::ClearSelection() {
if (selType == selRectangle) {
- pdoc->BeginUndoAction();
+ pdoc->BeginUndoAction();
int lineStart = pdoc->LineFromPosition(SelectionStart());
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
int startPos = SelectionStart();
@@ -1582,16 +1585,16 @@ void Editor::ClearSelection() {
}
}
SetEmptySelection(startPos);
- pdoc->EndUndoAction();
+ pdoc->EndUndoAction();
selType = selStream;
} else {
int startPos = SelectionStart();
unsigned int chars = SelectionEnd() - startPos;
SetEmptySelection(startPos);
if (0 != chars) {
- pdoc->BeginUndoAction();
+ pdoc->BeginUndoAction();
pdoc->DeleteChars(startPos, chars);
- pdoc->EndUndoAction();
+ pdoc->EndUndoAction();
}
}
}
@@ -3555,6 +3558,29 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
break;
+ case SCI_SETTARGETSTART:
+ targetStart = wParam;
+ break;
+
+ case SCI_SETTARGETEND:
+ targetEnd = wParam;
+ break;
+
+ case SCI_REPLACETARGET: {
+ if (lParam == 0)
+ return 0;
+ pdoc->BeginUndoAction();
+ unsigned int chars = targetEnd - targetStart;
+ if (targetStart != targetEnd)
+ pdoc->DeleteChars(targetStart, chars);
+ targetEnd = targetStart;
+ char *replacement = reinterpret_cast<char *>(lParam);
+ pdoc->InsertString(targetStart, replacement);
+ targetEnd = targetStart + strlen(replacement);
+ pdoc->EndUndoAction();
+ }
+ break;
+
case EM_LINESCROLL:
case SCI_LINESCROLL:
ScrollTo(topLine + lParam);
diff --git a/src/Editor.h b/src/Editor.h
index cf3996ffa..e82496663 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -116,6 +116,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
int originalAnchorPos;
int currentPos;
int anchor;
+ int targetStart;
+ int targetEnd;
int topLine;
int posTopLine;