aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2001-04-04 13:36:39 +0000
committernyamatongwe <unknown>2001-04-04 13:36:39 +0000
commit9b04df8e99b54645a92580712a6551b39ac511f5 (patch)
tree402c5ace645cc7865f51d360d1de055628d3967b
parent93b871d1d8fbb076510e2c410ba57a0980a22ec8 (diff)
downloadscintilla-mirror-9b04df8e99b54645a92580712a6551b39ac511f5.tar.gz
Target API for changing document withot visible changes: SetTargetStart,
SetTargetEnd, and ReplaceTarget.
-rw-r--r--include/Scintilla.h3
-rw-r--r--include/Scintilla.iface11
-rw-r--r--src/Editor.cxx34
-rw-r--r--src/Editor.h2
4 files changed, 46 insertions, 4 deletions
diff --git a/include/Scintilla.h b/include/Scintilla.h
index cc9eeb593..fa1003ab4 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -277,6 +277,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETOVERTYPE 2187
#define SCI_SETCARETWIDTH 2188
#define SCI_GETCARETWIDTH 2189
+#define SCI_SETTARGETSTART 2190
+#define SCI_SETTARGETEND 2191
+#define SCI_REPLACETARGET 2192
#define SCI_CALLTIPSHOW 2200
#define SCI_CALLTIPCANCEL 2201
#define SCI_CALLTIPACTIVE 2202
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index cb524f185..8fdbdedcc 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -708,6 +708,17 @@ set void SetCaretWidth=2188(int pixelWidth,)
# Returns the width of the insert mode caret
get int GetCaretWidth=2189(,)
+# Sets the position that starts the target which is used for updating the
+# document without affecting the scroll position.
+set void SetTargetStart=2190(position pos,)
+
+# Sets the position that ends the target which is used for updating the
+# document without affecting the scroll position.
+set void SetTargetEnd=2191(position pos,)
+
+# Replace the target text with the argument text.
+fun void ReplaceTarget=2192(, string text)
+
# Show a call tip containing a definition near position pos.
fun void CallTipShow=2200(position pos, string definition)
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;