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

HighlightSyntax() public method

Uses the current Language (AppKit.TextKit.Formatter.LanguageDescriptor) to syntax highlight the given word in the attached TextEditor (NSTextView) at the given character locations.
TODO: The Text Kit SetTemporaryAttributes routines are handiling the format of character strings such as HTML or XML tag incorrectly.
public HighlightSyntax ( string word, NSRange range ) : void
word string The possible keyword to highlight.
range NSRange An NSRange specifying the starting and ending character locations /// for the word to highlight.
return void
		public virtual void HighlightSyntax(string word, NSRange range) {

			try {
				// Found a keyword?
				KeywordDescriptor info;
				if (Language.Keywords.TryGetValue(word,out info)) {
					// Yes, adjust attributes
					TextEditor.LayoutManager.SetTemporaryAttributes(new NSDictionary(NSStringAttributeKey.ForegroundColor, info.Color),range);
				} else {
					TextEditor.LayoutManager.RemoveTemporaryAttribute(NSStringAttributeKey.ForegroundColor,range);
				}
			} catch {
				// Ignore any exceptions at this point
			}

		}