Ejemplo n.º 1
0
        /// <summary>
        /// Handle the case where we need to process a KeyDown but it will be swallowed by the
        /// TranslateAccelorator chain of input
        ///
        /// Must be **very** careful here because of international key board issues.  The base
        /// KeyProcessor in VimWPF has ample documentation on why this is dangerous.  In short
        /// though we must be as specific as possible when choosing keys to filter out because
        /// mapping a Key at this level to a Vim KeyInput with 100% accuracey is not possible
        /// </summary>
        public override void KeyDown(KeyEventArgs args)
        {
            base.KeyDown(args);
            if (args.Handled)
            {
                return;
            }

            // Don't attempt to handle this if we're in an incremental search
            if (_adapter.IsIncrementalSearchActive(TextView))
            {
                return;
            }

            // Don't process anything unless we're in a case where TranslateAccelorator would
            // win.  Also get rid of the problem cases from the start
            if (!_adapter.IsReadOnly(TextBuffer) ||
                !KeyUtil.IsInputKey(args.Key) ||
                KeyUtil.IsAltGr(args.KeyboardDevice.Modifiers))
            {
                return;
            }

            var      handled = false;
            KeyInput keyInput;

            if (KeyUtil.TryConvertToKeyInput(args.Key, args.KeyboardDevice.Modifiers, out keyInput))
            {
                // We only want to process input characters here.  All other input will eventually
                // be routed along a more reliable route for us to convert back to Vim KeyInput
                if (keyInput.KeyModifiers == KeyModifiers.None && KeyUtil.IsMappedByChar(keyInput.Key) && CoreCharacterSet.Contains(keyInput.Char))
                {
                    // We intentionally avoid using the TryProcess version here.  This is one case
                    // we don't want to defer to Visual Studio.  It thinks the buffer is readonly and
                    // will react as such while we want to do actual commands here
                    handled = VimBuffer.CanProcess(keyInput) && VimBuffer.Process(keyInput).IsAnyHandled;
                }
            }

            args.Handled = handled;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handle the case where we need to process a KeyDown but it will be swallowed by the
        /// TranslateAccelorator chain of input
        ///
        /// Must be **very** careful here because of international key board issues.  The base
        /// KeyProcessor in VimWPF has ample documentation on why this is dangerous.  In short
        /// though we must be as specific as possible when choosing keys to filter out because
        /// mapping a Key at this level to a Vim KeyInput with 100% accuracey is not possible
        /// </summary>
        public override void KeyDown(KeyEventArgs args)
        {
            // Don't intercept keystrokse if Visual Studio IncrementalSearch is active
            if (_adapter.IsIncrementalSearchActive(TextView))
            {
                return;
            }

            base.KeyDown(args);
            if (args.Handled)
            {
                return;
            }

            // Don't process anything unless we're in a case where TranslateAccelorator would
            // win.  Also get rid of the problem cases from the start
            if (!_adapter.IsReadOnly(TextBuffer) ||
                !KeyUtil.IsInputKey(args.Key) ||
                KeyUtil.IsAltGr(args.KeyboardDevice.Modifiers))
            {
                return;
            }

            var      handled = false;
            KeyInput ki;

            if (KeyUtil.TryConvertToKeyInput(args.Key, args.KeyboardDevice.Modifiers, out ki))
            {
                // We only want to process input characters here.  All other input will eventually
                // be routed along a more reliable route for us to convert back to Vim KeyInput
                if (ki.KeyModifiers == KeyModifiers.None && KeyUtil.IsMappedByChar(ki.Key) && CoreCharacterSet.Contains(ki.Char))
                {
                    handled = VimBuffer.CanProcess(ki) && VimBuffer.Process(ki);
                }
            }

            args.Handled = handled;
        }