public static string GetLineText(this EnvDTE.TextPoint point)
 {
     var start = point.CreateEditPoint();
     start.StartOfLine();
     var endP = point.CreateEditPoint();
     endP.EndOfLine();
     return start.GetText(endP);
 }
		public static string GetLineText(this EditPoint point)
		{
			point.StartOfLine();
			var start = point.CreateEditPoint();

			point.EndOfLine();
			var end = point.CreateEditPoint();

			return start.GetText(end);
		}
		public static string GetNextLineText(this EditPoint point)
		{
			point.LineDown();
			point.StartOfLine();
			var start = point.CreateEditPoint();

			point.EndOfLine();
			var end = point.CreateEditPoint();

			string text = start.GetText(end);
			point.LineUp();

			return text;
		}
        /// <summary>
        /// Gets an edit point at the cursor for the specified text document.
        /// </summary>
        /// <param name="textDocument">The text document.</param>
        /// <returns>An edit point at the cursor.</returns>
        internal static EditPoint GetEditPointAtCursor(this TextDocument textDocument)
        {
            var cursor = textDocument.CreateEditPoint();
            cursor.MoveToPoint(textDocument.Selection.ActivePoint);

            return cursor;
        }
		public static void DeleteCurrentLine(this EditPoint start)
		{
			start.StartOfLine();
			var point = start.CreateEditPoint();
			start.LineDown();
			start.StartOfLine();
			point.Delete(start);
		}
		/// <summary>
		/// Creates an edit point to the end of line position of the specified point.
		/// </summary>
		public static EditPoint  CreateEolEditPoint ( this EditPoint  ep )
		   {
			EditPoint	new_ep		=  ep. CreateEditPoint ( ) ;

			new_ep. EndOfLine ( ) ;

			return ( new_ep ) ;
		    }
		/// <summary>
		/// Creates an edit point for the specified line and column.
		/// </summary>
		public static EditPoint  CreateEditPoint ( this EditPoint  ep, int  line, int  column )
		   {
			EditPoint	new_ep		=  ep. CreateEditPoint ( ) ;

			new_ep. MoveToLineAndOffset ( line, column ) ;

			return ( new_ep ) ;
		    }
 public static EditPoint CreateEditPoint(this IVsTextLines buffer, int line, int column)
 {
     object tempPointer;
     buffer.CreateEditPoint(line, column, out tempPointer);
     return tempPointer as EditPoint;
 }
        public static string GetLineTextAndNeighbor(this TextPoint point)
        {
            var start = point.CreateEditPoint();
            start.LineUp(1);
            start.StartOfLine();
            var endP = point.CreateEditPoint();
            endP.LineDown(1);
            endP.EndOfLine();

            return start.GetText(endP);
        }
 /// <summary>
 /// Inserts text and format the text (=Format Selection command)
 /// </summary>
 /// <param name="tp"></param>
 /// <param name="text"></param>
 /// <returns></returns>
 /// <remarks></remarks>
 public static TextPoint InsertAndFormat(this TextPoint tp, string text)
 {
     var start = tp.CreateEditPoint();
     //preserve editPoint
     var ep = tp.CreateEditPoint();
     ep.Insert(text);
     start.SmartFormat(ep);
     return ep;
 }
Beispiel #11
0
        /// <summary>
        /// Inserts text and format the text (=Format Selection command)
        /// </summary>
        /// <param name="tp"></param>
        /// <param name="text"></param>
        /// <param name="formatEndPoint"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static EnvDTE.TextPoint InsertAndFormat(this EnvDTE.TextPoint tp, string text, EnvDTE.TextPoint formatEndPoint = null)
        {
            //preserve editPoint
            var start = tp.CreateEditPoint();

            var activePoint = tp.CreateEditPoint();
            start.DeleteWhitespace(vsWhitespaceOptions.vsWhitespaceOptionsVertical);
            activePoint.Insert(text);
            var endPoint = formatEndPoint ?? activePoint;
            endPoint.CreateEditPoint().DeleteWhitespace(vsWhitespaceOptions.vsWhitespaceOptionsVertical);
            start.SmartFormat(endPoint);
            return activePoint;
        }