Пример #1
0
        public override void TextInput(TextCompositionEventArgs args)
        {
            try {
                VimKeyEventArgs vim_args = new VimKeyEventArgs(new VimKeyInput(args.Text));

                if (!String.IsNullOrEmpty(args.Text) && 1 == args.Text.Length) {
                    // Only want to intercept text coming from the keyboard.  Let other
                    // components edit without having to come through us
                    var keyboard = args.Device as KeyboardDevice;
                    if (keyboard != null) {
                        if (_host.CanProcess(vim_args.KeyInput)) {
                            _host.KeyDown(vim_args);
                        }
                    }
                }

                if (vim_args.Handled) {
                    args.Handled = true;
                }
                else {
                    base.TextInput(args);
                }
            }
            catch (Exception ex) {
            #if DEBUG
                System.Windows.MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            #endif
            }
        }
Пример #2
0
        int IOleCommandTarget.Exec(ref Guid commandGroup, uint commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            try {
                if (commandGroup == VSConstants.VSStd2K) {
                    switch ((VSConstants.VSStd2KCmdID)commandId) {
                        case VSConstants.VSStd2KCmdID.INSERTSNIPPET:
                        case VSConstants.VSStd2KCmdID.SnippetProp:
                        case VSConstants.VSStd2KCmdID.SnippetRef:
                        case VSConstants.VSStd2KCmdID.SnippetRepl:
                        case VSConstants.VSStd2KCmdID.ECMD_INVOKESNIPPETFROMSHORTCUT:
                        case VSConstants.VSStd2KCmdID.ECMD_CREATESNIPPET:
                        case VSConstants.VSStd2KCmdID.ECMD_INVOKESNIPPETPICKER2:
                            break;
                    }
                }

                bool handled = true;
                VimKeyInput key_input = null;

                if (this.IsDebugIgnore(commandGroup, commandId)) {
                    handled = false;
                }
                else if (!this.TryConvert(commandGroup, commandId, pvaIn, out key_input)) {
                    handled = false;
                }
                else if (!_host.CanProcess(key_input)) {
                    handled = false;
                }

                if (handled) {
                    VimKeyEventArgs args = new VimKeyEventArgs(key_input);
                    _host.KeyDown(args);
                    if (args.Handled) {
                        return VSConstants.S_OK;
                    }
                }

                return _nextTarget.Exec(commandGroup, commandId, nCmdexecopt, pvaIn, pvaOut);
            }
            catch (Exception ex) {
            #if DEBUG
                System.Windows.MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            #endif
                return -1;
            }
        }