public static string GetSelectedOrAllText(this NSTextView textView) { var range = textView.SelectedRange; return(range.Length == 0 ? textView.GetAllText() : textView.GetTextRange(range)); }