Exemple #1
0
        public OLECMDF QueryCommandStatus(VSConstants.VSStd97CmdID commandId)
        {
            if (commandId != VSConstants.VSStd97CmdID.NextLocation &&
                commandId != VSConstants.VSStd97CmdID.PreviousLocation)
            {
                return(OLECMDF.OLECMDF_INVISIBLE | OLECMDF.OLECMDF_DEFHIDEONCTXTMENU);
            }

            var treeView = FindName("Results") as TreeView;

            if (treeView == null)
            {
                return(OLECMDF.OLECMDF_INVISIBLE | OLECMDF.OLECMDF_DEFHIDEONCTXTMENU);
            }

            var selectedValue = treeView.IsVisible ? treeView.SelectedValue as ResultModelBase : null;

            if (selectedValue == null)
            {
                selectedValue = DataContext as ResultModelBase;
            }

            var nextValue = commandId == VSConstants.VSStd97CmdID.NextLocation
                ? ResultModelHelper.Next(selectedValue) : ResultModelHelper.Previous(selectedValue);

            return(nextValue == null ? OLECMDF.OLECMDF_SUPPORTED : OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED);
        }
Exemple #2
0
        private void AddCommandEventHandler(Guid group, VSConstants.VSStd97CmdID cmdId, _dispCommandEvents_AfterExecuteEventHandler handler)
        {
            var h = dte.Events.CommandEvents[group.ToString("B"), (int)cmdId];

            h.AfterExecute += handler;
            commandsEvents.Add(h);
        }
Exemple #3
0
        public bool HandleCommand(VSConstants.VSStd97CmdID key)
        {
            if (!m_adorned)
            {
                return(false);
            }

            if (_translationAdornmentFocused != null && _translationAdornmentFocused.MenuIsOpen)
            {
                return(true);
            }

            // Debug.WriteLine(">> VSStd2KCmdID: {0}", key);

            switch (key)
            {
            case VSConstants.VSStd97CmdID.Copy:
                if (_translationAdornmentFocused != null)
                {
                    _translationAdornmentFocused.CopyCurrentItemText();
                }
                return(true);
            }

            return(false);
        }
Exemple #4
0
        private void VerifyConvert(VSConstants.VSStd97CmdID cmd, KeyInput ki, EditCommandKind kind)
        {
            EditCommand command;

            Assert.True(OleCommandUtil.TryConvert(VSConstants.GUID_VSStandardCommandSet97, (uint)cmd, IntPtr.Zero, KeyModifiers.None, out command));
            Assert.Equal(ki, command.KeyInput);
            Assert.Equal(kind, command.EditCommandKind);
        }
Exemple #5
0
        private void VerifyConvert(VSConstants.VSStd97CmdID cmd, KeyInput ki, EditCommandKind kind)
        {
            EditCommand command;

            Assert.IsTrue(OleCommandUtil.TryConvert(VSConstants.GUID_VSStandardCommandSet97, (uint)cmd, out command));
            Assert.AreEqual(ki, command.KeyInput);
            Assert.AreEqual(kind, command.EditCommandKind);
        }
        private void AddCommand(VSConstants.VSStd97CmdID command, Action action)
        {
            var id  = new CommandID(typeof(VSConstants.VSStd97CmdID).GUID, (int)command);
            var cmd = new OleMenuCommand(OnReturn, id);

            _commandService.AddCommand(cmd);
            _commands97[command] = action;
        }
 public override string Goto(VSConstants.VSStd97CmdID cmd,
                             IVsTextView textView,
                             int line,
                             int col,
                             out TextSpan span)
 {
     span = new TextSpan();
     return(null);
 }
Exemple #8
0
        internal static bool IsDebugIgnore(VSConstants.VSStd97CmdID commandId)
        {
            switch (commandId)
            {
            case VSConstants.VSStd97CmdID.SolutionCfg:
            case VSConstants.VSStd97CmdID.SearchCombo:
                return(true);
            }

            return(false);
        }
 public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView, int line, int col, out TextSpan span)
 {
     if (cmd != VSConstants.VSStd97CmdID.GotoDefn && cmd != VSConstants.VSStd97CmdID.GotoDecl)
     {
         span = new TextSpan();
         return null;
     }
     var location = DocumentLocation.Build(_req.FileName, textView, line, col);
     span = location.Span;
     return location.Url;
 }
Exemple #10
0
 private void RaiseCommand(VSConstants.VSStd97CmdID command)
 {
     try
     {
         object customIn  = null;
         object customOut = null;
         _dte.Commands.Raise(VSConstants.GUID_VSStandardCommandSet97.ToString(), (int)command, ref customIn, ref customOut);
     }
     catch (Exception ex)
     {
         ex.TraceUnknownException();
     }
 }
Exemple #11
0
        //public override string Goto(Microsoft.VisualStudio.VSConstants cmd, IVsTextView textView, int line, int col, out TextSpan span)
        //{
        //    span = SourceSpan;

        //    //when it's a valid sourcespan, return filepath, otherwise return nothing
        //    if (SourceSpanValid)
        //        return Source.GetFilePath();

        //    //returning nothing doesn't change the caret-position, returning the filename for an invalid source-span would the caret to be set to the beginning of the file
        //    return string.Empty;
        //}

        public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView, int line, int col, out TextSpan span)
        {
            span = SourceSpan;

            //when it's a valid sourcespan, return filepath, otherwise return nothing
            if (SourceSpanValid)
            {
                return(Source.GetFilePath());
            }

            //returning nothing doesn't change the caret-position, returning the filename for an invalid source-span would the caret to be set to the beginning of the file
            return(string.Empty);
        }
Exemple #12
0
 private void RaiseCommand(VSConstants.VSStd97CmdID command)
 {
     try
     {
         object customIn  = null;
         object customOut = null;
         var    dte       = _serviceProvider.GetService <DTE>();
         dte.Commands.Raise(VSConstants.GUID_VSStandardCommandSet97.ToString(), (int)command, ref customIn, ref customOut);
     }
     catch (Exception ex)
     {
         _logger.Error(ex, "Raising command {Command} failed.", command);
     }
 }
Exemple #13
0
        public void ExecuteCommand(VSConstants.VSStd97CmdID commandId)
        {
            if (commandId != VSConstants.VSStd97CmdID.NextLocation &&
                commandId != VSConstants.VSStd97CmdID.PreviousLocation)
            {
                return;
            }

            var treeView = FindName("Results") as TreeView;

            if (treeView == null)
            {
                return;
            }

            var selectedItem = treeView.SelectedItem as ResultModelBase;

            if (selectedItem == null)
            {
                selectedItem = DataContext as ResultModelBase;
            }

            var nextItem = commandId == VSConstants.VSStd97CmdID.NextLocation
                ? ResultModelHelper.Next(selectedItem) : ResultModelHelper.Previous(selectedItem);

            TreeViewHelper.ExpandTreeViewItemModel(treeView, nextItem);

            var treeViewItem = TreeViewHelper.TreeViewItemFromModel(treeView, nextItem);

            if (treeViewItem != null)
            {
                treeViewItem.IsSelected = true;

                treeViewItem.BringIntoView();
                var scrollViewer = treeView.Template.FindName("_tv_scrollviewer_", treeView) as ScrollViewer;
                if (scrollViewer != null)
                {
                    scrollViewer.ScrollToLeftEnd();
                }

                ResultModelHelper.Edit(nextItem);
            }
        }
Exemple #14
0
        public override CommandStatus Status(Guid group, int id)
        {
            if (group == VSConstants.GUID_VSStandardCommandSet97)
            {
                VSConstants.VSStd97CmdID vsCmdID = (VSConstants.VSStd97CmdID)id;

                switch (vsCmdID)
                {
                case VSConstants.VSStd97CmdID.F1Help:
                    if (!string.IsNullOrEmpty(GetHelpTopic()))
                    {
                        return(CommandStatus.Supported | CommandStatus.Enabled);
                    }
                    break;
                }
            }

            return(CommandStatus.NotSupported);
        }
Exemple #15
0
        public override CommandResult Invoke(Guid group, int id, object inputArg, ref object outputArg)
        {
            if (group == VSConstants.GUID_VSStandardCommandSet97)
            {
                VSConstants.VSStd97CmdID vsCmdID = (VSConstants.VSStd97CmdID)id;

                switch (vsCmdID)
                {
                // If this list of commands gets large, then maybe there's a better way to know when to dismiss
                case VSConstants.VSStd97CmdID.Paste:
                    DismissAllSessions();
                    break;
                }
            }
            else if (group == VSConstants.VSStd2K)
            {
                VSConstants.VSStd2KCmdID vsCmdID = (VSConstants.VSStd2KCmdID)id;

                switch (vsCmdID)
                {
                case VSConstants.VSStd2KCmdID.PASTE:
                    DismissAllSessions();
                    break;

                case VSConstants.VSStd2KCmdID.TAB:
                    // Check if there is selection. If so, TAB will translate to 'indent lines' command
                    // and hence we don't want to trigger intellisense on it.
                    var typedChar = GetTypedChar(group, id, inputArg);
                    if (TextView.Selection.SelectedSpans.Count > 0)
                    {
                        if (TextView.Selection.SelectedSpans[0].Length > 0)
                        {
                            typedChar = '\0';
                        }
                    }
                    break;
                }
            }

            return(HandleCompletion(group, id, inputArg));
        }
Exemple #16
0
 public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView,
                             int line, int col, out TextSpan span)
 {
     if (_lines != null && (cmd == VSConstants.VSStd97CmdID.GotoDefn ||
                            cmd == VSConstants.VSStd97CmdID.GotoDecl))
     {
         // Parse for any identifier that may be at the cursor.  If the is one,
         // find the variable or function definition for that identifier and jump
         // to it.
         bool   isVariable = false;
         string identifier = CMakeParsing.ParseForIdentifier(_lines, line, col,
                                                             out isVariable);
         if (identifier != null)
         {
             if (isVariable)
             {
                 if (CMakeParsing.ParseForVariableDefinition(_lines, identifier,
                                                             out span))
                 {
                     span.iEndIndex++;
                     return(_fileName);
                 }
             }
             else
             {
                 if (CMakeParsing.ParseForFunctionDefinition(_lines, identifier,
                                                             out span))
                 {
                     span.iEndIndex++;
                     return(_fileName);
                 }
             }
         }
     }
     span = new TextSpan();
     return(null);
 }
 private void VerifyConvert(VSConstants.VSStd97CmdID cmd, VimKey vimKey, EditCommandKind kind)
 {
     VerifyConvert(cmd, KeyInputUtil.VimKeyToKeyInput(vimKey), kind);
 }
Exemple #18
0
 public EmacsCommandAttribute(VSConstants.VSStd97CmdID command)
     : this((int)command, typeof(VSConstants.VSStd97CmdID).GUID)
 {
 }
Exemple #19
0
 internal OleCommandData(VSConstants.VSStd97CmdID id)
     : this(VSConstants.GUID_VSStandardCommandSet97, (uint)id)
 {
 }
Exemple #20
0
        public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView, int line, int col, out TextSpan span)
        {
            span = new Microsoft.VisualStudio.TextManager.Interop.TextSpan();

            return(null);
        }
Exemple #21
0
        int IOleCommandTarget.Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            int hr = VSErr.OLECMDERR_E_NOTSUPPORTED;

            if (!Enabled)
            {
                return(hr);
            }

            if (_ctList != null)
            {
                foreach (IOleCommandTarget ct in _ctList)
                {
                    hr = ct.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

                    if (((hr != VSErr.OLECMDERR_E_NOTSUPPORTED) && (hr != VSErr.OLECMDERR_E_UNKNOWNGROUP)))
                    {
                        break;
                    }
                }
            }

            if (!VSErr.Succeeded(hr))
            {
                bool skipProcessing = false;
                if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
                {
                    VSConstants.VSStd97CmdID id = (VSConstants.VSStd97CmdID)nCmdID;
                    switch (id)
                    {
                    case VSConstants.VSStd97CmdID.SearchCombo:
                    case VSConstants.VSStd97CmdID.SearchGetList:
                    case VSConstants.VSStd97CmdID.SearchSetCombo:
                    case VSConstants.VSStd97CmdID.SolutionCfg:
                    case VSConstants.VSStd97CmdID.SolutionCfgGetList:
                        break;

                    default:
                        skipProcessing = (nCmdID <= (uint)VSConstants.VSStd97CmdID.StandardMax);
                        break;
                    }
                }
                else if (pguidCmdGroup == VSConstants.VSStd2K)
                {
                    VSConstants.VSStd2KCmdID id = (VSConstants.VSStd2KCmdID)nCmdID;

                    switch (id)
                    {
                    case VSConstants.VSStd2KCmdID.STYLE:
                    case VSConstants.VSStd2KCmdID.STYLEGETLIST:
                    case VSConstants.VSStd2KCmdID.FONTSTYLE:
                    case VSConstants.VSStd2KCmdID.FONTSTYLEGETLIST:
                    case VSConstants.VSStd2KCmdID.SolutionPlatform:
                    case VSConstants.VSStd2KCmdID.SolutionPlatformGetList:
                        break;

                    default:
                        skipProcessing = true;
                        break;
                    }
                }

                if (skipProcessing)
                {
                    return(VSErr.S_OK);
                }
            }

            return(hr);
        }
Exemple #22
0
        public static char GetTypedChar(Guid group, int commandId, object variantIn)
        {
            char typedChar = '\0';

            if (group == VSConstants.GUID_VSStandardCommandSet97)
            {
                VSConstants.VSStd97CmdID vsCmdID = (VSConstants.VSStd97CmdID)commandId;

                switch (vsCmdID)
                {
                case VSConstants.VSStd97CmdID.Delete:
                    typedChar = '\b';
                    break;

                case VSConstants.VSStd97CmdID.Escape:
                case VSConstants.VSStd97CmdID.Cancel:
                    typedChar = (char)0x1B;     // ESC
                    break;
                }
            }
            else if (group == VSConstants.VSStd2K)
            {
                VSConstants.VSStd2KCmdID vsCmdID = (VSConstants.VSStd2KCmdID)commandId;

                switch (vsCmdID)
                {
                case VSConstants.VSStd2KCmdID.DELETE:
                    typedChar = '\b';
                    break;

                case VSConstants.VSStd2KCmdID.BACKSPACE:
                    typedChar = '\b';
                    break;

                case VSConstants.VSStd2KCmdID.RETURN:
                    typedChar = '\n';
                    break;

                case VSConstants.VSStd2KCmdID.TAB:
                    typedChar = '\t';
                    break;

                case VSConstants.VSStd2KCmdID.Cancel:
                case VSConstants.VSStd2KCmdID.CANCEL:
                    typedChar = (char)0x1B;     // ESC
                    break;

                case VSConstants.VSStd2KCmdID.TYPECHAR:
                    if (variantIn is char)
                    {
                        typedChar = (char)variantIn;
                    }
                    else
                    {
                        typedChar = (char)(ushort)variantIn;
                    }
                    break;
                }
            }

            return(typedChar);
        }
Exemple #23
0
 /// <summary>
 /// Gets status of a VS command with classic VSConstants.GUID_VSStandardCommandSet97 GUID
 /// </summary>
 /// <param name="cmdID">ID of the command</param>
 public virtual COMMAND_STATUS GetSystemCommandStatus(VSConstants.VSStd97CmdID cmdID)
 {
     return(COMMAND_STATUS.UNSUPPORTED);
 }
Exemple #24
0
 /// <summary>
 /// Executes VS command with classic VSConstants.GUID_VSStandardCommandSet97 GUID
 /// </summary>
 /// <param name="cmdID">Command ID</param>
 /// <returns>True if the execution was actually performed</returns>
 public virtual bool ExecuteSystemCommand(VSConstants.VSStd97CmdID cmdID)
 {
     return(false);
 }
 /// <summary>
 /// Intercept any command before it is being handled by other command handlers.
 /// </summary>
 public Task InterceptAsync(VSConstants.VSStd97CmdID command, Func <CommandProgression> func)
 => InterceptAsync(typeof(VSConstants.VSStd97CmdID).GUID, (int)command, func);
Exemple #26
0
 public override string Goto(
     VSConstants.VSStd97CmdID cmd,
     IVsTextView textView, int line,
     int col,
     out TextSpan span) => throw new NotImplementedException();
Exemple #27
0
        /// <summary>
        /// Try and convert the Visual Studio 97 based command into KeyInput and EditCommandKind values
        /// </summary>
        internal static bool TryConvert(VSConstants.VSStd97CmdID cmdId, IntPtr variantIn, out KeyInput ki, out EditCommandKind kind, out bool isRawText)
        {
            ki        = null;
            kind      = EditCommandKind.UserInput;
            isRawText = false;

            switch (cmdId)
            {
            case VSConstants.VSStd97CmdID.SingleChar:
                var obj = Marshal.GetObjectForNativeVariant(variantIn);
                var c   = (char)(ushort)obj;
                ki        = KeyInputUtil.CharToKeyInput(c);
                kind      = EditCommandKind.UserInput;
                isRawText = true;
                break;

            case VSConstants.VSStd97CmdID.Escape:
                ki   = KeyInputUtil.EscapeKey;
                kind = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd97CmdID.Delete:
                ki   = KeyInputUtil.VimKeyToKeyInput(VimKey.Delete);
                kind = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd97CmdID.F1Help:
                ki   = KeyInputUtil.VimKeyToKeyInput(VimKey.F1);
                kind = EditCommandKind.UserInput;
                break;

            case VSConstants.VSStd97CmdID.Undo:
                ki   = KeyInput.DefaultValue;
                kind = EditCommandKind.Undo;
                break;

            case VSConstants.VSStd97CmdID.Redo:
                ki   = KeyInput.DefaultValue;
                kind = EditCommandKind.Redo;
                break;

            case VSConstants.VSStd97CmdID.MultiLevelUndo:
                // This occurs when the undo button is pressed.  If it's just simply pressed we get
                // a IntPtr.Zero 'variantIn' value and can proceed with Vim undo.  Else user selected
                // a very specific undo point and we shouldn't mess with it
                if (variantIn == IntPtr.Zero)
                {
                    ki   = KeyInput.DefaultValue;
                    kind = EditCommandKind.Undo;
                }
                break;

            case VSConstants.VSStd97CmdID.MultiLevelRedo:
                // This occurs when the redo button is pressed.  If it's just simply pressed we get
                // a IntPtr.Zero 'variantIn' value and can proceed with Vim redo .  Else user selected
                // a very specific redo point and we shouldn't mess with it
                if (variantIn == IntPtr.Zero)
                {
                    ki   = KeyInput.DefaultValue;
                    kind = EditCommandKind.Redo;
                }
                break;

            case VSConstants.VSStd97CmdID.GotoDecl:
            case VSConstants.VSStd97CmdID.GotoDefn:
                ki   = KeyInput.DefaultValue;
                kind = EditCommandKind.GoToDefinition;
                break;

            case VSConstants.VSStd97CmdID.Paste:
                ki   = KeyInput.DefaultValue;
                kind = EditCommandKind.Paste;
                break;
            }

            return(ki != null);
        }
 protected virtual void HandleGoto(VSConstants.VSStd97CmdID vSStd97CmdID)
 {
     throw new NotImplementedException();
 }
Exemple #29
0
 // ParseReason.Goto
 public override string Goto(VSConstants.VSStd97CmdID cmd, IVsTextView textView, int line, int col, out TextSpan span)
 {
     // throw new System.NotImplementedException();
     span = new TextSpan();
     return(null);
 }
 /// <summary>
 /// Executes a command from the <see cref="VSConstants.VSStd97CmdID"/> collection of built in commands.
 /// </summary>
 /// <returns>Returns <see langword="true"/> if the command was succesfully executed; otherwise <see langword="false"/>.</returns>
 public Task <bool> ExecuteAsync(VSConstants.VSStd97CmdID command, string argument = "")
 => ExecuteAsync(typeof(VSConstants.VSStd97CmdID).GUID, (int)command, argument);