AvalonStudio.TextEditor.Document.TextUtilities.FindNextNewLine C# (CSharp) Method

FindNextNewLine() public static method

Finds the next new line character starting at offset.
public static FindNextNewLine ( ITextSource text, int offset, string &newLineType ) : int
text ITextSource The text source to search in.
offset int The starting offset for the search.
newLineType string The string representing the new line that was found, or null if no new line was found.
return int
		public static int FindNextNewLine(ITextSource text, int offset, out string newLineType)
		{
			if (text == null)
				throw new ArgumentNullException("text");
			if (offset < 0 || offset > text.TextLength)
				throw new ArgumentOutOfRangeException("offset", offset, "offset is outside of text source");
			var s = NewLineFinder.NextNewLine(text, offset);
			if (s == SimpleSegment.Invalid)
			{
				newLineType = null;
				return -1;
			}
			if (s.Length == 2)
			{
				newLineType = "\r\n";
			}
			else if (text.GetCharAt(s.Offset) == '\n')
			{
				newLineType = "\n";
			}
			else
			{
				newLineType = "\r";
			}
			return s.Offset;
		}