Пример #1
0
        /// <include file='doc\DocumentTask.uex' path='docs/doc[@for="DocumentTask.OnNavigate"]/*' />
        protected override void OnNavigate(EventArgs e)
        {
            TextSpan span = this.span;

            if (textLineMarker != null)
            {
                TextSpan[] spanArray = new TextSpan[1];
                NativeMethods.ThrowOnFailure(textLineMarker.GetCurrentSpan(spanArray));
                span = spanArray[0];
            }

            IVsUIHierarchy hierarchy;
            uint           itemID;
            IVsWindowFrame docFrame;
            IVsTextView    textView;

            VsShell.OpenDocument(this.site, this.fileName, NativeMethods.LOGVIEWID_Code, out hierarchy, out itemID, out docFrame, out textView);
            NativeMethods.ThrowOnFailure(docFrame.Show());
            if (textView != null)
            {
                NativeMethods.ThrowOnFailure(textView.SetCaretPos(span.iStartLine, span.iStartIndex));
                TextSpanHelper.MakePositive(ref span);
                NativeMethods.ThrowOnFailure(textView.SetSelection(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex));
                NativeMethods.ThrowOnFailure(textView.EnsureSpanVisible(span));
            }
            base.OnNavigate(e);
        }
Пример #2
0
        /// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.HandleGoto"]/*' />
        /// <summary>Handles VsCommands.GotoDefn, VsCommands.GotoDecl and VsCommands.GotoRef by
        /// calling OnSyncGoto on the Source object and opening the text editor on the resulting
        /// URL, then scrolling to the resulting span.</summary>
        public virtual void HandleGoto(VsCommands cmd)
        {
            TextSpan ts = new TextSpan();

            // Get the caret position
            NativeMethods.ThrowOnFailure(this.textView.GetCaretPos(out ts.iStartLine, out ts.iStartIndex));
            ts.iEndLine  = ts.iStartLine;
            ts.iEndIndex = ts.iStartIndex;

            // Get the tip text at that location.
            // Wait, since the user specifically requested this one...
            TextSpan span;
            string   url = this.source.OnSyncGoto(cmd, this.textView, ts.iEndLine, ts.iEndIndex, out span);

            if (url == null || url.Trim().Length == 0)   // nothing to show
            {
                return;
            }

            // Open the referenced document, and scroll to the given location.
            IVsUIHierarchy hierarchy;
            uint           itemID;
            IVsWindowFrame frame;
            IVsTextView    view;

            VsShell.OpenDocument(this.service.Site, url, NativeMethods.LOGVIEWID_Code, out hierarchy, out itemID, out frame, out view);
            if (view != null)
            {
                TextSpanHelper.MakePositive(ref span);
                NativeMethods.ThrowOnFailure(view.EnsureSpanVisible(span));
                NativeMethods.ThrowOnFailure(view.SetSelection(span.iStartLine, span.iStartIndex, span.iEndLine, span.iEndIndex));
            }
        }
Пример #3
0
        /// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.GetWordExtent"]/*' />
        /// <summary>Returns the result of Source.GetWordExtent.</summary>
        public virtual int GetWordExtent(int line, int index, uint flags, TextSpan[] span)
        {
            Debug.Assert(line >= 0 && index >= 0);
            if (span == null)
            {
                NativeHelpers.RaiseComError(NativeMethods.E_INVALIDARG);
            }
            else
            {
                span[0] = new TextSpan();
            }

            span[0].iStartLine  = span[0].iEndLine = line;
            span[0].iStartIndex = span[0].iEndIndex = index;

            int start, end;

            if (!this.source.GetWordExtent(line, index, (WORDEXTFLAGS)flags, out start, out end))
            {
                return(NativeMethods.S_FALSE);
            }

            span[0].iStartIndex = start;
            span[0].iEndIndex   = end;
            TextSpanHelper.MakePositive(ref span[0]);
            return(NativeMethods.S_OK);
        }
Пример #4
0
 /// <include file='doc\EditArray.uex' path='docs/doc[@for="EditSpan.EditSpan"]/*' />
 /// <summary>
 /// Construct a new edit span object
 /// </summary>
 /// <param name="toReplace">The text span to remove from the buffer (can be empty)</param>
 /// <param name="insertText">The text to insert in it's place (can be null)</param>
 public EditSpan(TextSpan toReplace, string insertText)
 {
     if (!TextSpanHelper.IsPositive(toReplace))
     {
         TextSpanHelper.MakePositive(ref toReplace);
     }
     this.span      = toReplace;
     this.text      = insertText;
     this.lineCount = -1;
 }
Пример #5
0
 /// <include file='doc\Source.uex' path='docs/doc[@for="ViewFilter.GetSelection"]/*' />
 /// <summary>Returns the current selection, adjusted to become a positive text span</summary>
 public TextSpan GetSelection()
 {
     //get text range
     TextSpan[] aspan = new TextSpan[1];
     NativeMethods.ThrowOnFailure(this.textView.GetSelectionSpan(aspan));
     if (!TextSpanHelper.IsPositive(aspan[0]))
     {
         TextSpanHelper.MakePositive(ref aspan[0]);
     }
     return(aspan[0]);
 }
Пример #6
0
        /// <include file='doc\ViewFilter.uex' path='docs/doc[@for="ViewFilter.GetPairExtents"]/*' />
        public virtual int GetPairExtents(int line, int index, TextSpan[] span)
        {
            Debug.Assert(line >= 0 && index >= 0);
            if (span == null)
            {
                return(NativeMethods.E_INVALIDARG);
            }

            this.source.GetPairExtents(this.textView, line, index, out span[0]);
            TextSpanHelper.MakePositive(ref span[0]);
            return(NativeMethods.S_OK);
        }