AppKit.TextKit.Formatter.LanguageFormatter.FindLineBoundries C# (CSharp) Method

FindLineBoundries() public method

Finds the line boundries as defined by the NewLine, LineSeparator and ParagraphSeparator characters.
public FindLineBoundries ( string text, NSRange position ) : NSRange
text string The string to be searched.
position NSRange The NSRange specifying the starting location of a possible /// line of text.
return NSRange
		public virtual NSRange FindLineBoundries(string text, NSRange position) {
			NSRange results = position;
			var found = false;

			// Find starting line boundry
			while(results.Location > 0 && !found) {
				var c = text [(int)results.Location - 1];
				found = (c == Newline || c == LineSeparator || c == ParagraphSeparator);
				if (!found) results.Location -= 1;
			};

			// Find ending line boundry
			found = false;
			while((int)(results.Location + results.Length) < text.Length && !found) {
				var c = text [(int)(results.Location + results.Length)];
				found = (c == Newline || c == LineSeparator || c == ParagraphSeparator);
				if (!found) results.Length += 1;
			};

			return results;
		}