Esempio n. 1
0
        /// <summary>
        /// If we're in command mode and a key is processed which effects the edit we should handle
        /// it here
        /// </summary>
        private void CheckEnableCommandLineEdit(KeyInputStartEventArgs args)
        {
            if (_vimBuffer.ModeKind != ModeKind.Command)
            {
                return;
            }

            switch (args.KeyInput.Key)
            {
            case VimKey.Home:
                // Enable command line edition
                _margin.FocusCommandLine(moveCaretToEnd: false);
                args.Handled = true;
                break;

            case VimKey.Left:
                _margin.FocusCommandLine(moveCaretToEnd: true);
                args.Handled = true;
                break;

            case VimKey.Up:
            case VimKey.Down:
                // User is navigation through history, move caret to the end of the entry
                _margin.UpdateCaretPosition(true);
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// If we're in command mode and a key is processed which effects the edit we should handle
        /// it here
        /// </summary>
        private void CheckEnableCommandLineEdit(KeyInputStartEventArgs args)
        {
            if (_editKind != EditKind.None)
            {
                return;
            }

            var commandLineEditKind = CalculateCommandLineEditKind();

            if (commandLineEditKind == EditKind.None)
            {
                return;
            }

            switch (args.KeyInput.Key)
            {
            case VimKey.Home:
                // Enable command line edition
                ChangeEditKind(commandLineEditKind);
                _margin.UpdateCaretPosition(EditPosition.Start);
                args.Handled = true;
                break;

            case VimKey.Left:
                ChangeEditKind(commandLineEditKind);
                _margin.UpdateCaretPosition(EditPosition.BeforeLastCharacter);
                args.Handled = true;
                break;

            case VimKey.Up:
            case VimKey.Down:
                // User is navigation through history, move caret to the end of the entry
                _margin.UpdateCaretPosition(EditPosition.End);
                break;
            }
        }
        /// <summary>
        /// This method handles keeping the history buffer in sync with the commandline display text
        /// which do not happen otherwise for EditKind.None.
        /// </summary>
        private bool HandleHistoryNavigation(KeyInput keyInput)
        {
            var handled    = _vimBuffer.Process(keyInput).IsAnyHandled;
            var prefixChar = GetPrefixChar(_editKind);

            if (handled && _editKind != EditKind.None && prefixChar.HasValue)
            {
                switch (_editKind)
                {
                case EditKind.Command:
                    UpdateCommandLine(prefixChar.ToString() + _vimBuffer.CommandMode.Command);
                    break;

                case EditKind.SearchForward:
                case EditKind.SearchBackward:
                    UpdateCommandLine(prefixChar.ToString() + _vimBuffer.IncrementalSearch.CurrentSearchText);
                    break;
                }
                _margin.UpdateCaretPosition(EditPosition.End);
            }
            return(handled);
        }