/// <summary> /// Updates a location to point to the next character /// </summary> /// <param name="Location">The location to update</param> public void MoveNext(ref TextLocation Location) { MoveNext(ref Location.LineIdx, ref Location.ColumnIdx); }
/// <summary> /// Reads a single character from a text buffer, and updates the current position /// </summary> /// <param name="Location">Location to read from</param> /// <returns>The character at the given position</returns> public char ReadCharacter(ref TextLocation Location) { return(ReadCharacter(ref Location.LineIdx, ref Location.ColumnIdx)); }
/// <summary> /// Extract a portion of the file as an array of strings /// </summary> /// <param name="Begin">Start of the range to extract</param> /// <param name="End">End of the range to extract, exclusive</param> /// <returns>Array of lines extracted from the file</returns> public string[] Extract(TextLocation Begin, TextLocation End) { return(Extract(Begin.LineIdx, Begin.ColumnIdx, End.LineIdx, End.ColumnIdx)); }
/// <summary> /// Access a single character within the file /// </summary> /// <param name="Location">Location of the character to return</param> /// <returns>The character at the given location</returns> public char this[TextLocation Location] { get { return(this[Location.LineIdx, Location.ColumnIdx]); } }
/// <summary> /// Copies an excerpt from a file to a TextWriter, commenting each output line /// </summary> /// <param name="Text">The text buffer to copy from</param> /// <param name="Location">The initial location</param> /// <param name="EndLocation">The final location</param> /// <param name="Writer">The writer to receive the excerpt</param> public static void CopyCommentedExcerpt(TextWriter Writer, TextBuffer Text, TextLocation Location, TextLocation EndLocation) { string[] CommentLines = Text.Extract(Location, EndLocation); for (int Idx = 0; Idx < CommentLines.Length - 1; Idx++) { string CommentLine = CommentLines[Idx]; if (CommentLine.EndsWith("\\")) { CommentLine = CommentLine.Substring(CommentLine.Length - 1); } Writer.WriteLine("// {0}", CommentLine); } }