Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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]);
 }
Ejemplo n.º 3
0
        // This method simulates what VS does in debug mode so that we can catch the
        // errors in managed code before they go to the native debug assert.
        public static bool ValidSpan(Source src, TextSpan span)
        {
            if (!ValidCoord(src, span.iStartLine, span.iStartIndex))
            {
                return(false);
            }

            if (!ValidCoord(src, span.iEndLine, span.iEndIndex))
            {
                return(false);
            }

            // end must be >= start
            if (!TextSpanHelper.IsPositive(span))
            {
                return(false);
            }

            return(true);
        }