Exemplo n.º 1
0
        public PreparedDecorationCollection Prepare(string text)
        {
            PreparedDecorationCollection prepared = new PreparedDecorationCollection();

            foreach (Decoration d in mDecorations)
            {
                prepared.Add(d, d.Ranges(text));
            }
            return(prepared);
        }
Exemplo n.º 2
0
        public static PreparedDecorationCollection Merge(PreparedDecorationCollection previous, PreparedDecorationCollection current, TextDelta td)
        {
            if (previous.mDecorations.Count == 0)
            {
                current.mDifferenceRange = current.Bounds();
                return(current);
            }
            if (AreDecorationsSame(previous, current))
            {
                PreparedDecorationCollection merged = new PreparedDecorationCollection();
                TextIndexList differenceRanges      = new TextIndexList();
                for (int i = 0; i < previous.Count; i++)
                {
                    TextIndexList previousIndex   = previous.Index(i);
                    TextIndexList currentIndex    = current.Index(i);
                    TextIndex     differenceRange = currentIndex.RangeDifferentFrom(previousIndex);
                    if (differenceRange != null && differenceRange.Length > 0)
                    {
                        differenceRanges.Add(differenceRange);
                    }
                }
                differenceRanges.Add(td.TextIndex);

                merged.mDifferenceRange = differenceRanges.Bounds;
                TextIndex activeArea = differenceRanges.Bounds;
                if (activeArea != null)
                {
                    for (int i = 0; i < previous.Count; i++)
                    {
                        TextIndexList currentIndex = current.Index(i);
                        TextIndexList projected    = currentIndex.Projection(activeArea);

                        if (projected.IndexLengthUpperBound() > 0)// Are there and textindexes in projected that have a length > 0
                        {
                            merged.Add(current.Decoration(i), projected);
                        }
                    }
                }

                return(merged);
            }
            else
            {
                current.mAreDecorationsChanged = true;
                return(current);
            }
        }