コード例 #1
0
        public void SimulateProcessed_RaiseEvent()
        {
            var ranStart     = false;
            var ranProcessed = false;
            var ranEnd       = false;

            _vimBuffer.KeyInputStart     += delegate { ranStart = true; };
            _vimBuffer.KeyInputProcessed += delegate { ranProcessed = true; };
            _vimBuffer.KeyInputEnd       += delegate { ranEnd = true; };
            _vimBuffer.SimulateProcessed(KeyInputUtil.CharToKeyInput('c'));
            Assert.IsTrue(ranStart);
            Assert.IsTrue(ranEnd);
            Assert.IsTrue(ranProcessed);
        }
コード例 #2
0
ファイル: VsCommandTarget.cs プロジェクト: bentayloruk/VsVim
        /// <summary>
        /// Try and exec this KeyInput in an intercepted fashion
        /// </summary>
        private bool TryExecIntercepted(ref Guid commandGroup, ref OleCommandData oleCommandData, KeyInput originalKeyInput, KeyInput mappedKeyInput)
        {
            bool           intercepted;
            bool           result;
            Guid           mappedCommandGroup;
            OleCommandData mappedOleCommandData;

            if (originalKeyInput == mappedKeyInput)
            {
                // No changes so just use the original OleCommandData
                result = VSConstants.S_OK == _nextTarget.Exec(
                    ref commandGroup,
                    oleCommandData.CommandId,
                    oleCommandData.CommandExecOpt,
                    oleCommandData.VariantIn,
                    oleCommandData.VariantOut);
                intercepted = true;
            }
            else if (OleCommandUtil.TryConvert(mappedKeyInput, out mappedCommandGroup, out mappedOleCommandData))
            {
                result = VSConstants.S_OK == _nextTarget.Exec(
                    ref mappedCommandGroup,
                    mappedOleCommandData.CommandId,
                    mappedOleCommandData.CommandExecOpt,
                    mappedOleCommandData.VariantIn,
                    mappedOleCommandData.VariantOut);
                intercepted = true;
                OleCommandData.Release(ref mappedOleCommandData);
            }
            else
            {
                // If we couldn't process it using intercepting mechanism then just go straight to the IVimBuffer
                // for processing.
                result      = _buffer.Process(originalKeyInput);
                intercepted = false;
            }

            if (intercepted)
            {
                // We processed the input and bypassed the IVimBuffer instance.  We need to tell IVimBuffer this
                // KeyInput was processed so it can track it for macro purposes.  Make sure to track the mapped
                // KeyInput value.  The SimulateProcessed method does not mapping
                _buffer.SimulateProcessed(mappedKeyInput);
            }

            return(result);
        }