diff options
author | nyamatongwe <unknown> | 2001-04-05 01:58:04 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-04-05 01:58:04 +0000 |
commit | 508b1b5ca03dffc1ec2d5a98a378da4cdd30ef84 (patch) | |
tree | 7141531f889b0ffe3a3b262faa9ef8924fa17018 /src/Editor.cxx | |
parent | 9b04df8e99b54645a92580712a6551b39ac511f5 (diff) | |
download | scintilla-mirror-508b1b5ca03dffc1ec2d5a98a378da4cdd30ef84.tar.gz |
Replace target functionality to make find and replace operations faster
by diminishing screen updates and allow for \d patterns in the replacement
text.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 9f65203d2..8590c362f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -3246,6 +3246,23 @@ void Editor::EnsureLineVisible(int lineDoc) { } } +int Editor::ReplaceTarget(bool replacePatterns, const char *text) { + pdoc->BeginUndoAction(); + if (replacePatterns) { + text = pdoc->SubstituteByPosition(text); + if (!text) + return 0; + } + if (targetStart != targetEnd) + pdoc->DeleteChars(targetStart, targetEnd - targetStart); + targetEnd = targetStart; + unsigned int len = strlen(text); + pdoc->InsertString(targetStart, text); + targetEnd = targetStart + len; + pdoc->EndUndoAction(); + return len; +} + static bool ValidMargin(unsigned long wParam) { return wParam < ViewStyle::margins; } @@ -3566,20 +3583,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { 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 SCI_REPLACETARGET: + PLATFORM_ASSERT(lParam); + return ReplaceTarget(wParam, reinterpret_cast<char *>(lParam)); case EM_LINESCROLL: case SCI_LINESCROLL: |