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

FindWordBoundries() public method

Finds the word boundries as defined by the LanguageSeparators in the AppKit.TextKit.Formatter.LanguageDescriptor that is currently being syntax highlighted.
public FindWordBoundries ( string text, NSRange position ) : NSRange
text string The string to be searched.
position NSRange The NSRange specifying the starting location of a possible word.
return NSRange
		public virtual NSRange FindWordBoundries(string text, NSRange position) {
			NSRange results = new NSRange(position.Location, 0);
			var found = false;

			// Find starting "word" boundry
			while(results.Location > 0 && !found) {
				var c = text [(int)results.Location - 1];
				found = char.IsWhiteSpace (c) || IsLanguageSeparator(c);
				if (!found) results.Location -= 1;
			};

			// Find ending "word" boundry
			found = false;
			while((int)(results.Location + results.Length) < text.Length && !found) {
				var c = text [(int)(results.Location + results.Length)];
				found = char.IsWhiteSpace (c) || IsLanguageSeparator(c);
				if (!found) results.Length += 1;
			};

			return results;
		}