ICSharpCode.TextEditor.Caret.ValidatePosition C# (CSharp) Method

ValidatePosition() public method

public ValidatePosition ( TextLocation pos ) : TextLocation
pos TextLocation
return TextLocation
		public TextLocation ValidatePosition(TextLocation pos)
		{
			int line   = Math.Max(0, Math.Min(textArea.Document.TotalNumberOfLines - 1, pos.Y));
			int column = Math.Max(0, pos.X);
			
			if (column == int.MaxValue || !textArea.TextEditorProperties.AllowCaretBeyondEOL) {
				LineSegment lineSegment = textArea.Document.GetLineSegment(line);
				column = Math.Min(column, lineSegment.Length);
			}
			return new TextLocation(column, line);
		}