Пример #1
0
        /// <summary>
        /// Is called after a newline was inserted into this line, splitting it into this and followingLine.
        /// </summary>
        internal void SplitTo(LineSegment followingLine)
        {
            //Console.WriteLine("SplitTo");

            if (anchors != null)
            {
                List <TextAnchor> movedAnchors = null;
                foreach (TextAnchor a in anchors)
                {
                    if (a.MovementType == AnchorMovementType.BeforeInsertion
                                            ? a.ColumnNumber > this.Length
                                            : a.ColumnNumber >= this.Length)
                    {
                        a.Line = followingLine;
                        followingLine.AddAnchor(a);
                        a.ColumnNumber -= this.Length;

                        if (movedAnchors == null)
                        {
                            movedAnchors = new List <TextAnchor>();
                        }
                        movedAnchors.Add(a);
                    }
                }
                if (movedAnchors != null)
                {
                    foreach (TextAnchor a in movedAnchors)
                    {
                        anchors.Remove(a);
                    }
                }
            }
        }