コード例 #1
0
ファイル: OleCommandUtil.cs プロジェクト: aesire/VsVim
        internal static bool TryConvert(Guid commandGroup, uint commandId, IntPtr pVariableIn, KeyModifiers modifiers, out EditCommand command)
        {
            KeyInput keyInput;
            EditCommandKind kind;
            bool isRawText;
            if (!TryConvert(commandGroup, commandId, pVariableIn, out keyInput, out kind, out isRawText))
            {
                command = null;
                return false;
            }

            // When raw text is provided it already includes the active keyboard modifiers. Don't reapply them
            // here else it can incorrectly modify the provided character.
            if (!isRawText && keyInput != KeyInput.DefaultValue)
            {
                keyInput = KeyInputUtil.ApplyModifiers(keyInput, modifiers);
            }

            command = new EditCommand(keyInput, kind, commandGroup, commandId);
            return true;
        }
コード例 #2
0
ファイル: OleCommandUtil.cs プロジェクト: aesire/VsVim
 internal static bool TryConvert(EditCommand editCommand, out OleCommandData oleCommandData)
 {
     switch (editCommand.EditCommandKind)
     {
         case EditCommandKind.GoToDefinition:
             oleCommandData = new OleCommandData(VSConstants.VSStd97CmdID.GotoDecl);
             return true;
         case EditCommandKind.Paste:
             oleCommandData = new OleCommandData(VSConstants.VSStd2KCmdID.PASTE);
             return true;
         case EditCommandKind.Undo:
             oleCommandData = new OleCommandData(VSConstants.VSStd2KCmdID.UNDO);
             return true;
         case EditCommandKind.Redo:
             oleCommandData = new OleCommandData(VSConstants.VSStd2KCmdID.REDO);
             return true;
         case EditCommandKind.Comment:
             oleCommandData = new OleCommandData(VSConstants.VSStd2KCmdID.COMMENTBLOCK);
             return true;
         case EditCommandKind.Uncomment:
             oleCommandData = new OleCommandData(VSConstants.VSStd2KCmdID.UNCOMMENTBLOCK);
             return true;
         case EditCommandKind.UserInput:
             return TryConvert(editCommand.KeyInput, out oleCommandData);
         case EditCommandKind.VisualStudioCommand:
         default:
             oleCommandData = OleCommandData.Empty;
             return false;
     }
 }
コード例 #3
0
ファイル: VsCommandTarget.cs プロジェクト: Yzzl/VsVim
        private CommandStatus QueryStatus(EditCommand editCommand)
        {
            VimTrace.TraceInfo("VsCommandTarget::QueryStatus {0}", editCommand);

            var action = CommandStatus.PassOn;
            foreach (var commandTarget in _commandTargets)
            {
                action = commandTarget.QueryStatus(editCommand);
                if (action != CommandStatus.PassOn)
                {
                    break;
                }
            }

            VimTrace.TraceInfo("VsCommandTarget::QueryStatus ", action);
            return action;
        }
コード例 #4
0
ファイル: VsCommandTarget.cs プロジェクト: Yzzl/VsVim
        internal bool Exec(EditCommand editCommand, out Action action)
        {
            VimTrace.TraceInfo("VsCommandTarget::Exec {0}", editCommand);
            action = null;

            // If the KeyInput was already handled then pretend we handled it here 
            if (editCommand.HasKeyInput && _vimBufferCoordinator.IsDiscarded(editCommand.KeyInput))
            {
                return true;
            }

            var result = false;
            foreach (var commandTarget in _commandTargets)
            {
                if (commandTarget.Exec(editCommand, out action))
                {
                    result = true;
                    break;
                }
            }

            return result;
        }
コード例 #5
0
ファイル: VsCommandTarget.cs プロジェクト: Yzzl/VsVim
        /// <summary>
        /// Try and convert the Visual Studio command to it's equivalent KeyInput
        /// </summary>
        internal bool TryConvert(Guid commandGroup, uint commandId, IntPtr variantIn, out EditCommand editCommand)
        {
            editCommand = null;

            // Don't ever process a command when we are in an automation function.  Doing so will cause VsVim to 
            // intercept items like running Macros and certain wizard functionality
            if (_vsAdapter.InAutomationFunction)
            {
                return false;
            }

            // Don't intercept commands while incremental search is active.  Don't want to interfere with it
            if (_vsAdapter.IsIncrementalSearchActive(_vimBuffer.TextView))
            {
                return false;
            }

            var modifiers = _keyUtil.GetKeyModifiers(_vsAdapter.KeyboardDevice.Modifiers);
            if (!OleCommandUtil.TryConvert(commandGroup, commandId, variantIn, modifiers, out editCommand))
            {
                return false;
            }

            // Don't process Visual Studio commands.  If the key sequence is mapped to a Visual Studio command
            // then that command wins.
            if (editCommand.EditCommandKind == EditCommandKind.VisualStudioCommand)
            {
                return false;
            }

            return true;
        }
コード例 #6
0
        internal static bool TryConvert(Guid commandGroup, uint commandId, IntPtr pVariableIn, VimKeyModifiers modifiers, out EditCommand command)
        {
            KeyInput        keyInput;
            EditCommandKind kind;
            bool            isRawText;

            if (!TryConvert(commandGroup, commandId, pVariableIn, out keyInput, out kind, out isRawText))
            {
                command = null;
                return(false);
            }

            // When raw text is provided it already includes the active keyboard modifiers. Don't reapply them
            // here else it can incorrectly modify the provided character.
            if (!isRawText && keyInput != KeyInput.DefaultValue)
            {
                keyInput = KeyInputUtil.ApplyKeyModifiers(keyInput, modifiers);
            }

            command = new EditCommand(keyInput, kind, commandGroup, commandId);
            return(true);
        }
コード例 #7
0
        /// <summary>
        /// Try and convert the Visual Studio command to it's equivalent KeyInput
        /// </summary>
        internal bool TryConvert(Guid commandGroup, uint commandId, IntPtr variantIn, out EditCommand editCommand)
        {
            editCommand = null;

            // Don't ever process a command when we are in an automation function.  Doing so will cause VsVim to
            // intercept items like running Macros and certain wizard functionality
            if (_vsAdapter.InAutomationFunction)
            {
                return(false);
            }

            // Don't intercept commands while incremental search is active.  Don't want to interfere with it
            if (_vsAdapter.IsIncrementalSearchActive(_vimBuffer.TextView))
            {
                return(false);
            }

            var modifiers = _keyUtil.GetKeyModifiers(_vsAdapter.KeyboardDevice.Modifiers);

            if (!OleCommandUtil.TryConvert(commandGroup, commandId, variantIn, modifiers, out editCommand))
            {
                return(false);
            }

            // Don't process Visual Studio commands.  If the key sequence is mapped to a Visual Studio command
            // then that command wins.
            if (editCommand.EditCommandKind == EditCommandKind.VisualStudioCommand)
            {
                return(false);
            }

            return(true);
        }