From 529ea750b146c23bd1f8c0ec0b3bbeb64689a736 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 5 Apr 2001 01:58:04 +0000 Subject: Replace target functionality to make find and replace operations faster by diminishing screen updates and allow for \d patterns in the replacement text. --- src/Editor.cxx | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/Editor.cxx') 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(lParam); - pdoc->InsertString(targetStart, replacement); - targetEnd = targetStart + strlen(replacement); - pdoc->EndUndoAction(); - } - break; + case SCI_REPLACETARGET: + PLATFORM_ASSERT(lParam); + return ReplaceTarget(wParam, reinterpret_cast(lParam)); case EM_LINESCROLL: case SCI_LINESCROLL: -- cgit v1.2.3