AppKit.TextKit.Formatter.SourceTextView.PerformFormattingCommand C# (CSharp) Method

PerformFormattingCommand() public method

Performs the formatting command on the currectly selected range of text.
public PerformFormattingCommand ( LanguageFormatCommand command ) : void
command LanguageFormatCommand The to apply.
return void
		public void PerformFormattingCommand(LanguageFormatCommand command) {
			NSRange range = SelectedRange;

			// Apply to start of line?
			if (command.Postfix == "") {
				// Yes, find start
				range = Formatter.FindLineBoundries(TextStorage.Value, SelectedRange);
			}

			// Yes, get selected text
			var location = range.Location;
			var line = TextStorage.Value.Substring((int)range.Location, (int)range.Length);

			// Apply command
			var output = command.Prefix;
			output += line;
			output += command.Postfix;
			TextStorage.BeginEditing ();
			Replace(range, output);
			TextStorage.EndEditing ();
			Formatter.HighlightSyntaxRegion(TextStorage.Value, range);
		}
		#endregion