Alsing.SourceCode.SyntaxDocument.PointToIntPos C# (CSharp) Метод

PointToIntPos() публичный Метод

Converts a Column/Row index position into a char index
public PointToIntPos ( TextPoint pos ) : int
pos TextPoint TextPoint where x is column and y is row index
Результат int
        public int PointToIntPos(TextPoint pos)
        {
            int y = 0;
            int p = 0;
            foreach (Row r in this)
            {
                if (y == pos.Y)
                    break;
                p += r.Text.Length + Environment.NewLine.Length;
                y++;
            }

            // Not sure why but if I paste multiple lines
            // then this causes a crash because pos.Y is greater
            // than the number of elements available through the []
            // operator.
            int yToUse = Math.Min(this.Count-1, pos.Y);

            return p + Math.Min(pos.X, this[yToUse].Text.Length);
        }