internal WordCompletionPresenter(IPopupIntellisensePresenter source) { _popupIntellisensePresenter = source; _intellisenseCommandTarget = source as IIntellisenseCommandTarget; _mouseProcessor = source as IMouseProcessor; _disposable = source as IDisposable; _componentConnector = source as IComponentConnector; }
public bool ExecuteKeyboardCommand(IntellisenseKeyboardCommand command) { IIntellisenseCommandTarget target = Content as IIntellisenseCommandTarget; if (target != null) { return(target.ExecuteKeyboardCommand(command)); } return(false); }
/// <summary> /// Calls each of the stack's session presenters, in order, to see if they want to handle the keyboard command /// </summary> public bool ExecuteKeyboardCommand(IntellisenseKeyboardCommand command) { // We don't care if there's a keyboard session here or not. If someone has captured the keyboard, this should only get // called if the capturer has decided not to handle the command. // Run through the sessions from the topmost to the bottom-most. foreach (IIntellisenseSession session in _sessions) { IIntellisenseCommandTarget commandTarget = session.Presenter as IIntellisenseCommandTarget; if (commandTarget != null) { if (commandTarget.ExecuteKeyboardCommand(command)) { return(true); } } } return(false); }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, uint executionOptions, IntPtr pvaIn, IntPtr pvaOut) { bool handled = Controller.PreprocessCommand(ref commandGroup, commandId, (OLECMDEXECOPT)executionOptions, pvaIn, pvaOut); try { if (!handled) { IIntellisenseCommandTarget sessionStack = Controller.IntellisenseSessionStack as IIntellisenseCommandTarget; IntellisenseKeyboardCommand?command = TranslateKeyboardCommand(commandGroup, commandId); if (sessionStack != null && command.HasValue) { handled = sessionStack.ExecuteKeyboardCommand(command.Value); } } if (commandGroup == VsMenus.guidStandardCommandSet97) { VSOBJGOTOSRCTYPE?gotoSourceType = null; switch ((VSConstants.VSStd97CmdID)commandId) { case VSConstants.VSStd97CmdID.GotoDecl: { if (!Controller.SupportsGotoDeclaration) { throw new NotSupportedException("The IntelliSense controller does not support the Go To Declaration operation."); } gotoSourceType = VSOBJGOTOSRCTYPE.GS_DECLARATION; handled = true; break; } case VSConstants.VSStd97CmdID.GotoDefn: { if (!Controller.SupportsGotoDefinition) { throw new NotSupportedException("The IntelliSense controller does not support the Go To Definition operation."); } gotoSourceType = VSOBJGOTOSRCTYPE.GS_DEFINITION; handled = true; break; } case VSConstants.VSStd97CmdID.GotoRef: { if (!Controller.SupportsGotoReference) { throw new NotSupportedException("The IntelliSense controller does not support the Go To Reference operation."); } gotoSourceType = VSOBJGOTOSRCTYPE.GS_REFERENCE; handled = true; break; } default: break; } if (gotoSourceType.HasValue) { ITextView textView = Controller.TextView; SnapshotPoint? point = textView.Caret.Position.Point.GetPoint(textView.TextBuffer, PositionAffinity.Predecessor); ITrackingPoint triggerPoint = textView.TextBuffer.CurrentSnapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); Controller.GoToSource(gotoSourceType.Value, triggerPoint); handled = true; } } else if (commandGroup == VsMenus.guidStandardCommandSet2K) { switch ((VSConstants.VSStd2KCmdID)commandId) { case VSConstants.VSStd2KCmdID.UP_EXT: if (DismissAllCompletionSessions() || AnySignatureHelpSessions()) { commandId = (uint)VSConstants.VSStd2KCmdID.UP; handled = false; } break; case VSConstants.VSStd2KCmdID.DOWN_EXT: if (DismissAllCompletionSessions() || AnySignatureHelpSessions()) { commandId = (uint)VSConstants.VSStd2KCmdID.DOWN; handled = false; } break; case ECMD_SMARTTASKS: ExpandSmartTagUnderCaret(); handled = true; break; case VSConstants.VSStd2KCmdID.SHOWMEMBERLIST: CompletionHelper.DoTriggerCompletion(Controller, CompletionInfoType.ContextInfo, false, IntellisenseInvocationType.Default); handled = true; break; case VSConstants.VSStd2KCmdID.COMPLETEWORD: CompletionHelper.DoTriggerCompletion(Controller, CompletionInfoType.GlobalInfo, false, IntellisenseInvocationType.Default); handled = true; break; case VSConstants.VSStd2KCmdID.PARAMINFO: CompletionHelper.DoTriggerCompletion(Controller, CompletionInfoType.ContextInfo, true, IntellisenseInvocationType.Default); handled = true; break; case VSConstants.VSStd2KCmdID.QUICKINFO: throw new NotImplementedException(); case VSConstants.VSStd2KCmdID.ToggleConsumeFirstCompletionMode: _isInConsumeFirstCompletionMode = !_isInConsumeFirstCompletionMode; handled = true; break; default: break; } } } catch (Exception e) { Controller.PostprocessCommand(); e.PreserveStackTrace(); throw; } if (handled) { Controller.PostprocessCommand(); } return(handled); }