Alsing.Windows.Forms.SyntaxBox.Caret.CropPosition C# (CSharp) Method

CropPosition() public method

Confines the caret to a valid position within the active document
public CropPosition ( ) : void
return void
        public void CropPosition()
        {
            if (Position.X < 0)
                Position.X = 0;

            if (Position.Y >= Control.Document.Count)
                Position.Y = Control.Document.Count - 1;

            if (Position.Y < 0)
                Position.Y = 0;

            Row xtr = CurrentRow;

            if (Position.X > xtr.Text.Length && !Control.VirtualWhitespace)
                Position.X = xtr.Text.Length;
        }