示例#1
0
        // Token: 0x06003DB0 RID: 15792 RVA: 0x0011C904 File Offset: 0x0011AB04
        internal static void Remove(TextTreeTextBlock firstNode, TextTreeTextBlock lastNode)
        {
            SplayTreeNode previousNode = firstNode.GetPreviousNode();
            SplayTreeNode splayTreeNode;

            if (previousNode != null)
            {
                previousNode.Split();
                splayTreeNode           = previousNode.ParentNode;
                previousNode.ParentNode = null;
            }
            else
            {
                splayTreeNode = firstNode.GetContainingNode();
            }
            SplayTreeNode rightSubTree   = lastNode.Split();
            SplayTreeNode splayTreeNode2 = SplayTreeNode.Join(previousNode, rightSubTree);

            if (splayTreeNode != null)
            {
                splayTreeNode.ContainedNode = splayTreeNode2;
            }
            if (splayTreeNode2 != null)
            {
                splayTreeNode2.ParentNode = splayTreeNode;
            }
        }
示例#2
0
        // Helper for InsertText.  Inserts text to the left of an existing block.
        private static void InsertTextLeft(TextTreeTextBlock rightBlock, object text, int textOffset)
        {
            int newBlockCount;
            TextTreeTextBlock leftBlock;
            TextTreeTextBlock neighborBlock;
            TextTreeTextBlock newBlock;
            int count;
            int textEndOffset = -1;
            int i;
            int length;

            length = TextContainer.GetTextLength(text);

            if (rightBlock.GapOffset == 0)
            {
                // Try to fill neighbor block.
                neighborBlock = (TextTreeTextBlock)rightBlock.GetPreviousNode();
                if (neighborBlock != null)
                {
                    textOffset += neighborBlock.InsertText(neighborBlock.Count, text, textOffset, length);
                }
            }

            if (textOffset < length)
            {
                // Try adding just one block.
                newBlockCount = 1;

                leftBlock = rightBlock.SplitBlock();

                // Fill up the left block.
                textOffset += leftBlock.InsertText(leftBlock.Count, text, textOffset, length);

                if (textOffset < length)
                {
                    // Fill up the larger block.
                    // We need to copy from the end of the text here.
                    count         = Math.Min(rightBlock.FreeCapacity, length - textOffset);
                    textEndOffset = length - count;
                    rightBlock.InsertText(0, text, textEndOffset, length);

                    if (textOffset < textEndOffset)
                    {
                        // We've filled both blocks, and there's still more text to copy.
                        // Prepare to allocate some more blocks.
                        newBlockCount += (textEndOffset - textOffset + TextTreeTextBlock.MaxBlockSize - 1) / TextTreeTextBlock.MaxBlockSize;
                    }
                }

                for (i = 1; i < newBlockCount; i++)
                {
                    newBlock    = new TextTreeTextBlock(TextTreeTextBlock.MaxBlockSize);
                    textOffset += newBlock.InsertText(0, text, textOffset, textEndOffset);
                    newBlock.InsertAtNode(leftBlock, false /* insertBefore */);
                    leftBlock = newBlock;
                }
                Invariant.Assert(newBlockCount == 1 || textOffset == textEndOffset, "Not all text copied!");
            }
        }
示例#3
0
        // Token: 0x06003DA7 RID: 15783 RVA: 0x0011C4CC File Offset: 0x0011A6CC
        internal static void RemoveText(TextTreeRootTextBlock rootTextBlock, int offset, int count)
        {
            if (count == 0)
            {
                return;
            }
            int num;
            TextTreeTextBlock textTreeTextBlock = TextTreeText.FindBlock(rootTextBlock, offset, out num);

            if (textTreeTextBlock.Count == num)
            {
                textTreeTextBlock = (TextTreeTextBlock)textTreeTextBlock.GetNextNode();
                Invariant.Assert(textTreeTextBlock != null);
                num = 0;
            }
            int num2;
            TextTreeTextBlock textTreeTextBlock2 = TextTreeText.FindBlock(rootTextBlock, offset + count, out num2);
            int           num3;
            SplayTreeNode splayTreeNode;

            if (num > 0 || count < textTreeTextBlock.Count)
            {
                num3 = Math.Min(count, textTreeTextBlock.Count - num);
                textTreeTextBlock.RemoveText(num, num3);
                splayTreeNode = textTreeTextBlock.GetNextNode();
            }
            else
            {
                num3          = 0;
                splayTreeNode = textTreeTextBlock;
            }
            if (count > num3)
            {
                int           num4;
                SplayTreeNode splayTreeNode2;
                if (num2 < textTreeTextBlock2.Count)
                {
                    num4 = num2;
                    textTreeTextBlock2.RemoveText(0, num2);
                    splayTreeNode2 = textTreeTextBlock2.GetPreviousNode();
                }
                else
                {
                    num4           = 0;
                    splayTreeNode2 = textTreeTextBlock2;
                }
                if (num3 + num4 < count)
                {
                    TextTreeText.Remove((TextTreeTextBlock)splayTreeNode, (TextTreeTextBlock)splayTreeNode2);
                }
            }
        }
示例#4
0
        // Token: 0x06003DAD RID: 15789 RVA: 0x0011C690 File Offset: 0x0011A890
        private static TextTreeTextBlock FindBlock(TextTreeRootTextBlock rootTextBlock, int offset, out int localOffset)
        {
            int num;
            TextTreeTextBlock textTreeTextBlock = (TextTreeTextBlock)rootTextBlock.ContainedNode.GetSiblingAtOffset(offset, out num);

            if (textTreeTextBlock.LeftSymbolCount == offset)
            {
                TextTreeTextBlock textTreeTextBlock2 = (TextTreeTextBlock)textTreeTextBlock.GetPreviousNode();
                if (textTreeTextBlock2 != null)
                {
                    textTreeTextBlock = textTreeTextBlock2;
                    num -= textTreeTextBlock.SymbolCount;
                    Invariant.Assert(num >= 0);
                }
            }
            localOffset = offset - num;
            Invariant.Assert(localOffset >= 0 && localOffset <= textTreeTextBlock.Count);
            return(textTreeTextBlock);
        }
示例#5
0
        // Removes a run of nodes from a tree.
        internal static void Remove(TextTreeTextBlock firstNode, TextTreeTextBlock lastNode)
        {
            SplayTreeNode leftTree;
            SplayTreeNode rightTree;
            SplayTreeNode rootNode;
            SplayTreeNode containerNode;

            //
            // Break the tree into three subtrees.
            //

            leftTree = firstNode.GetPreviousNode();
            if (leftTree != null)
            {
                // Splitting moves leftTree to local root.
                leftTree.Split();
                containerNode       = leftTree.ParentNode;
                leftTree.ParentNode = null; // We'll fixup leftTree.ParentNode.ContainedNode below.
                // Join requires that leftTree has a null ParentNode.
            }
            else
            {
                // There are no preceeding nodes.
                containerNode = firstNode.GetContainingNode();
            }

            rightTree = lastNode.Split();

            //
            // Recombine the two outer trees.
            //
            rootNode = SplayTreeNode.Join(leftTree, rightTree);

            if (containerNode != null)
            {
                containerNode.ContainedNode = rootNode;
            }
            if (rootNode != null)
            {
                rootNode.ParentNode = containerNode;
            }
        }
示例#6
0
        // Token: 0x06003DAE RID: 15790 RVA: 0x0011C700 File Offset: 0x0011A900
        private static void InsertTextLeft(TextTreeTextBlock rightBlock, object text, int textOffset)
        {
            int num        = -1;
            int textLength = TextContainer.GetTextLength(text);

            if (rightBlock.GapOffset == 0)
            {
                TextTreeTextBlock textTreeTextBlock = (TextTreeTextBlock)rightBlock.GetPreviousNode();
                if (textTreeTextBlock != null)
                {
                    textOffset += textTreeTextBlock.InsertText(textTreeTextBlock.Count, text, textOffset, textLength);
                }
            }
            if (textOffset < textLength)
            {
                int num2 = 1;
                TextTreeTextBlock textTreeTextBlock2 = rightBlock.SplitBlock();
                textOffset += textTreeTextBlock2.InsertText(textTreeTextBlock2.Count, text, textOffset, textLength);
                if (textOffset < textLength)
                {
                    int num3 = Math.Min(rightBlock.FreeCapacity, textLength - textOffset);
                    num = textLength - num3;
                    rightBlock.InsertText(0, text, num, textLength);
                    if (textOffset < num)
                    {
                        num2 += (num - textOffset + 4096 - 1) / 4096;
                    }
                }
                for (int i = 1; i < num2; i++)
                {
                    TextTreeTextBlock textTreeTextBlock3 = new TextTreeTextBlock(4096);
                    textOffset += textTreeTextBlock3.InsertText(0, text, textOffset, num);
                    textTreeTextBlock3.InsertAtNode(textTreeTextBlock2, false);
                    textTreeTextBlock2 = textTreeTextBlock3;
                }
                Invariant.Assert(num2 == 1 || textOffset == num, "Not all text copied!");
            }
        }
示例#7
0
        // Removes a run of nodes from a tree.
        internal static void Remove(TextTreeTextBlock firstNode, TextTreeTextBlock lastNode)
        {
            SplayTreeNode leftTree;
            SplayTreeNode rightTree;
            SplayTreeNode rootNode;
            SplayTreeNode containerNode;

            //
            // Break the tree into three subtrees.
            //

            leftTree = firstNode.GetPreviousNode();
            if (leftTree != null)
            {
                // Splitting moves leftTree to local root.
                leftTree.Split();
                containerNode = leftTree.ParentNode;
                leftTree.ParentNode = null; // We'll fixup leftTree.ParentNode.ContainedNode below.
                // Join requires that leftTree has a null ParentNode.
            }
            else
            {
                // There are no preceeding nodes.
                containerNode = firstNode.GetContainingNode();
            }

            rightTree = lastNode.Split();

            //
            // Recombine the two outer trees.
            //
            rootNode = SplayTreeNode.Join(leftTree, rightTree);

            if (containerNode != null)
            {
                containerNode.ContainedNode = rootNode;
            }
            if (rootNode != null)
            {
                rootNode.ParentNode = containerNode;
            }
        }
示例#8
0
        // Helper for InsertText.  Inserts text to the left of an existing block.
        private static void InsertTextLeft(TextTreeTextBlock rightBlock, object text, int textOffset)
        {
            int newBlockCount;
            TextTreeTextBlock leftBlock;
            TextTreeTextBlock neighborBlock;
            TextTreeTextBlock newBlock;
            int count;
            int textEndOffset = -1;
            int i;
            int length;

            length = TextContainer.GetTextLength(text);

            if (rightBlock.GapOffset == 0)
            {
                // Try to fill neighbor block.
                neighborBlock = (TextTreeTextBlock)rightBlock.GetPreviousNode();
                if (neighborBlock != null)
                {
                    textOffset += neighborBlock.InsertText(neighborBlock.Count, text, textOffset, length);
                }
            }

            if (textOffset < length)
            {
                // Try adding just one block.
                newBlockCount = 1;

                leftBlock = rightBlock.SplitBlock();

                // Fill up the left block.
                textOffset += leftBlock.InsertText(leftBlock.Count, text, textOffset, length);

                if (textOffset < length)
                {
                    // Fill up the larger block.
                    // We need to copy from the end of the text here.
                    count = Math.Min(rightBlock.FreeCapacity, length - textOffset);
                    textEndOffset = length - count;
                    rightBlock.InsertText(0, text, textEndOffset, length);

                    if (textOffset < textEndOffset)
                    {
                        // We've filled both blocks, and there's still more text to copy.
                        // Prepare to allocate some more blocks.
                        newBlockCount += (textEndOffset - textOffset + TextTreeTextBlock.MaxBlockSize - 1) / TextTreeTextBlock.MaxBlockSize;
                    }
                }

                for (i = 1; i < newBlockCount; i++)
                {
                    newBlock = new TextTreeTextBlock(TextTreeTextBlock.MaxBlockSize);
                    textOffset += newBlock.InsertText(0, text, textOffset, textEndOffset);
                    newBlock.InsertAtNode(leftBlock, false /* insertBefore */);
                    leftBlock = newBlock;
                }
                Invariant.Assert(newBlockCount == 1 || textOffset == textEndOffset, "Not all text copied!");
            }
        }