예제 #1
0
        void ITextAreaInputHandler.Detach()
        {
            textArea.PreviewKeyDown   -= textArea_PreviewKeyDown;
            textArea.TextEntering     -= textArea_TextEntering;
            textArea.LostFocus        -= textArea_LostFocus;
            textArea.PreviewMouseDown -= textArea_PreviewMouseDown;

            DisableIncrementalSearchCursor();
            ClearStatusBarMessage();
            ViSDGlobalCount.Process();
        }
예제 #2
0
        public void StopReplace()
        {
            int len = textArea.Caret.Offset - curbegin;

            if (len > 0)
            {
                ViSDGlobalText.Text = textArea.Document.GetText(curbegin, len);
            }
            textArea.Caret.Offset = curbegin;
            ViSDGlobalCount.UpdLastUsed(new ViSD.Modes.ViCommadns.CmdRepeatReplace(), textArea);
            ViSDGlobalState.State = ViSDGlobalState.PrevState;
        }
예제 #3
0
        void textArea_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            RemoveSelection();
            switch (e.Key)
            {
            case Key.Enter:
                ViSDGlobalWordSearch.SearchedWord = searchText.ToString();
                if (direction == LogicalDirection.Forward)
                {
                    ViSDGlobalCount.UpdLastUsed(new ViSD.Modes.ViCommadns.CmdGoToNextFindResult(), textArea);
                }
                else
                {
                    ViSDGlobalCount.UpdLastUsed(new ViSD.Modes.ViCommadns.CmdGoToPrevFindResult(), textArea);
                }
                e.Handled = true;
                StopIncrementalSearch();
                break;

            case Key.Escape:
                ViSDGlobalCount.ResetAll();
                e.Handled = true;
                StopIncrementalSearch();
                break;

            case Key.Back:
                // Remove last search char an try search again.
                int length = searchText.Length;
                if (length > 0)
                {
                    searchText.Remove(length - 1, 1);
                    // Run search back at original starting point.
                    startIndex          = originalStartIndex;
                    passedEndOfDocument = false;
                    RunSearch();
                    e.Handled = true;
                }
                else
                {
                    StopIncrementalSearch();
                }
                break;

            case Key.Up:
                e.Handled = true;
                if (HistoryIdx > 0)
                {
                    HistoryIdx--;
                    searchText = new StringBuilder(ViSDGlobalWordSearch.History[HistoryIdx]);
                }
                RunSearch();
                break;

            case Key.Down:
                e.Handled = true;
                if (HistoryIdx < (ViSDGlobalWordSearch.History.Count - 1))
                {
                    HistoryIdx++;
                    searchText = new StringBuilder(ViSDGlobalWordSearch.History[HistoryIdx]);
                }
                RunSearch();
                break;

            default:
                TextAreaInputHandler[] rootHandlers = { textArea.DefaultInputHandler };
                var allHandlers = rootHandlers.Flatten(h => h.NestedInputHandlers.OfType <TextAreaInputHandler>());
                var keyGestures = allHandlers.SelectMany(h => h.InputBindings).Select(h => h.Gesture).OfType <KeyGesture>();
                foreach (KeyGesture gesture in keyGestures)
                {
                    if (gesture.Key == e.Key)
                    {
                        StopIncrementalSearch();
                        break;
                    }
                }
                break;
            }
        }