diff options
| author | nyamatongwe <devnull@localhost> | 2001-04-05 01:58:04 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2001-04-05 01:58:04 +0000 | 
| commit | 529ea750b146c23bd1f8c0ec0b3bbeb64689a736 (patch) | |
| tree | 7141531f889b0ffe3a3b262faa9ef8924fa17018 /src/Editor.cxx | |
| parent | a9318190f7318a86b272f23132126a45c8111dce (diff) | |
| download | scintilla-mirror-529ea750b146c23bd1f8c0ec0b3bbeb64689a736.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: | 
