Example #1
0
        int RunAllInSelection(int action)
        {
            var startOffset = Math.Min(_selection.Offset, _selection.EndOffset);
            var endOffset   = Math.Max(_selection.Offset, _selection.EndOffset);

            SearchReplaceUtilities.SelectText(_textEditor, startOffset, endOffset);
            SetCaretPosition(_textEditor.ActiveTextAreaControl.TextArea, startOffset);

            try
            {
                _ignoreSelectionChanges = true;
                var count = 0;
                if (action == 1)
                {
                    count = SearchReplaceManager.MarkAll(startOffset, endOffset - startOffset);
                }
                else if (action == 2)
                {
                    count = SearchReplaceManager.ReplaceAll(startOffset, endOffset - startOffset);
                }
                SearchReplaceUtilities.SelectText(_textEditor, startOffset, endOffset);
                return(count);
            }
            finally
            {
                _ignoreSelectionChanges = false;
            }
        }
Example #2
0
        bool ReplaceInSelection()
        {
            var startOffset = Math.Min(_selection.Offset, _selection.EndOffset);
            var endOffset   = Math.Max(_selection.Offset, _selection.EndOffset);

            if (_findFirst)
            {
                SetCaretPosition(_textEditor.ActiveTextAreaControl.TextArea, startOffset);
            }

            try
            {
                _ignoreSelectionChanges = true;
                if (_findFirst)
                {
                    _findFirst = false;
                    return(SearchReplaceManager.ReplaceFirstInSelection(startOffset, endOffset - startOffset));
                }
                else
                {
                    _findFirst = !SearchReplaceManager.ReplaceNextInSelection();
                    if (_findFirst)
                    {
                        SearchReplaceUtilities.SelectText(_textEditor, startOffset, endOffset);
                    }
                    return(_findFirst);
                }
            }
            finally
            {
                _ignoreSelectionChanges = false;
            }
        }