示例#1
0
        List <LineSegment> RemoveInternal(int offset, int length)
        {
            Debug.Assert(length >= 0);
            if (length == 0)
            {
                return(null);
            }
            LineSegmentTree.Enumerator it  = lineCollection.GetEnumeratorForOffset(offset);
            LineSegment startSegment       = it.Current;
            int         startSegmentOffset = startSegment.Offset;

            if (offset + length < startSegmentOffset + startSegment.TotalLength)
            {
                // just removing a part of this line segment
                startSegment.RemovedLinePart(offset - startSegmentOffset, length);
                SetSegmentLength(startSegment, startSegment.TotalLength - length);
                return(null);
            }
            // merge startSegment with another line segment because startSegment's delimiter was deleted
            // possibly remove lines in between if multiple delimiters were deleted
            int charactersRemovedInStartLine = startSegmentOffset + startSegment.TotalLength - offset;

            Debug.Assert(charactersRemovedInStartLine > 0);
            startSegment.RemovedLinePart(offset - startSegmentOffset, charactersRemovedInStartLine);


            LineSegment endSegment = lineCollection.GetByOffset(offset + length);

            if (endSegment == startSegment)
            {
                // special case: we are removing a part of the last line up to the
                // end of the document
                SetSegmentLength(startSegment, startSegment.TotalLength - length);
                return(null);
            }
            int endSegmentOffset        = endSegment.Offset;
            int charactersLeftInEndLine = endSegmentOffset + endSegment.TotalLength - (offset + length);

            endSegment.RemovedLinePart(0, endSegment.TotalLength - charactersLeftInEndLine);
            startSegment.MergedWith(endSegment, offset - startSegmentOffset);
            SetSegmentLength(startSegment, startSegment.TotalLength - charactersRemovedInStartLine + charactersLeftInEndLine);
            startSegment.DelimiterLength = endSegment.DelimiterLength;
            // remove all segments between startSegment (excl.) and endSegment (incl.)
            it.MoveNext();
            List <LineSegment> removedLines = new List <LineSegment>();
            LineSegment        segmentToRemove;

            do
            {
                segmentToRemove = it.Current;
                it.MoveNext();
                lineCollection.RemoveSegment(segmentToRemove);
                removedLines.Add(segmentToRemove);
                segmentToRemove.Deleted();
            } while (segmentToRemove != endSegment);
            return(removedLines);
        }
 internal void Deleted(ref DeferredEventList deferredEventList)
 {
     this.treeEntry = LineSegmentTree.Enumerator.Invalid;
     if (this.anchors != null)
     {
         foreach (TextAnchor anchor in this.anchors)
         {
             anchor.Delete(ref deferredEventList);
         }
         this.anchors = null;
     }
 }
示例#3
0
 /// <summary>
 /// Is called when the LineSegment is deleted.
 /// </summary>
 internal void Deleted()
 {
     //Console.WriteLine("Deleted");
     treeEntry = LineSegmentTree.Enumerator.Invalid;
     if (anchors != null)
     {
         foreach (TextAnchor a in anchors)
         {
             a.Deleted();
         }
         anchors = null;
     }
 }
示例#4
0
 /// <summary>
 /// Is called when the LineSegment is deleted.
 /// </summary>
 internal void Deleted(ref DeferredEventList deferredEventList)
 {
     //Console.WriteLine("Deleted");
     _treeEntry = LineSegmentTree.Enumerator.Invalid;
     if (_anchors != null)
     {
         foreach (TextAnchor a in _anchors)
         {
             a.Delete(ref deferredEventList);
         }
         _anchors = null;
     }
 }
示例#5
0
 void RunHighlighter(int firstLine, int lineCount)
 {
     if (highlightingStrategy != null)
     {
         List <LineSegment>         markLines = new List <LineSegment>();
         LineSegmentTree.Enumerator it        = lineCollection.GetEnumeratorForIndex(firstLine);
         for (int i = 0; i < lineCount && it.IsValid; i++)
         {
             markLines.Add(it.Current);
             it.MoveNext();
         }
         highlightingStrategy.MarkTokens(document, markLines);
     }
 }
 private void RunHighlighter(int firstLine, int lineCount)
 {
     if (this.highlightingStrategy != null)
     {
         List <LineSegment>         lineSegments       = new List <LineSegment>();
         LineSegmentTree.Enumerator enumeratorForIndex = this.lineCollection.GetEnumeratorForIndex(firstLine);
         for (int i = 0; i < lineCount && enumeratorForIndex.IsValid; i++)
         {
             lineSegments.Add(enumeratorForIndex.Current);
             enumeratorForIndex.MoveNext();
         }
         this.highlightingStrategy.MarkTokens(this.document, lineSegments);
     }
 }
        private void RemoveInternal(ref DeferredEventList deferredEventList, int offset, int length)
        {
            LineSegment current;

            if (length == 0)
            {
                return;
            }
            LineSegmentTree.Enumerator enumeratorForOffset = this.lineCollection.GetEnumeratorForOffset(offset);
            LineSegment delimiterLength = enumeratorForOffset.Current;
            int         num             = delimiterLength.Offset;

            if (offset + length < num + delimiterLength.TotalLength)
            {
                delimiterLength.RemovedLinePart(ref deferredEventList, offset - num, length);
                this.SetSegmentLength(delimiterLength, delimiterLength.TotalLength - length);
                return;
            }
            int totalLength = num + delimiterLength.TotalLength - offset;

            delimiterLength.RemovedLinePart(ref deferredEventList, offset - num, totalLength);
            LineSegment byOffset = this.lineCollection.GetByOffset(offset + length);

            if (byOffset == delimiterLength)
            {
                this.SetSegmentLength(delimiterLength, delimiterLength.TotalLength - length);
                return;
            }
            int num1         = byOffset.Offset;
            int totalLength1 = num1 + byOffset.TotalLength - (offset + length);

            byOffset.RemovedLinePart(ref deferredEventList, 0, byOffset.TotalLength - totalLength1);
            delimiterLength.MergedWith(byOffset, offset - num);
            this.SetSegmentLength(delimiterLength, delimiterLength.TotalLength - totalLength + totalLength1);
            delimiterLength.DelimiterLength = byOffset.DelimiterLength;
            enumeratorForOffset.MoveNext();
            do
            {
                current = enumeratorForOffset.Current;
                enumeratorForOffset.MoveNext();
                this.lineCollection.RemoveSegment(current);
                current.Deleted(ref deferredEventList);
            }while (current != byOffset);
        }