Пример #1
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);
                }
            }
        }
Пример #2
0
        // Helper for InsertText.  Inserts text to the right of an existing block.
        private static void InsertTextRight(TextTreeTextBlock leftBlock, object text, int textOffset)
        {
            int newBlockCount;
            TextTreeTextBlock rightBlock;
            TextTreeTextBlock neighborBlock;
            TextTreeTextBlock newBlock;
            int count;
            int textEndOffset;
            int i;

            textEndOffset = TextContainer.GetTextLength(text);

            if (leftBlock.GapOffset == leftBlock.Count)
            {
                // Try to fill neighbor block.
                neighborBlock = (TextTreeTextBlock)leftBlock.GetNextNode();
                if (neighborBlock != null)
                {
                    count = Math.Min(neighborBlock.FreeCapacity, textEndOffset - textOffset);
                    neighborBlock.InsertText(0, text, textEndOffset - count, textEndOffset);
                    textEndOffset -= count;
                }
            }

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

                rightBlock = leftBlock.SplitBlock();

                // Fill up the right block.
                count = Math.Min(rightBlock.FreeCapacity, textEndOffset - textOffset);
                rightBlock.InsertText(0, text, textEndOffset - count, textEndOffset);
                textEndOffset -= count;

                if (textOffset < textEndOffset)
                {
                    // Fill up the larger block.
                    // We need to copy from the end of the text here.
                    textOffset += leftBlock.InsertText(leftBlock.Count, text, textOffset, textEndOffset);

                    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 = 0; i < newBlockCount - 1; i++)
                {
                    newBlock    = new TextTreeTextBlock(TextTreeTextBlock.MaxBlockSize);
                    textOffset += newBlock.InsertText(0, text, textOffset, textEndOffset);
                    newBlock.InsertAtNode(leftBlock, false /* insertBefore */);
                    leftBlock = newBlock;
                }
                Invariant.Assert(textOffset == textEndOffset, "Not all text copied!");
            }
        }
Пример #3
0
 // Token: 0x06003DA9 RID: 15785 RVA: 0x0011C5B8 File Offset: 0x0011A7B8
 internal static void ReadText(TextTreeRootTextBlock rootTextBlock, int offset, int count, char[] chars, int startIndex)
 {
     if (count > 0)
     {
         int logicalOffset;
         TextTreeTextBlock textTreeTextBlock = TextTreeText.FindBlock(rootTextBlock, offset, out logicalOffset);
         for (;;)
         {
             Invariant.Assert(textTreeTextBlock != null, "Caller asked for too much text!");
             int num = textTreeTextBlock.ReadText(logicalOffset, count, chars, startIndex);
             logicalOffset = 0;
             count        -= num;
             if (count == 0)
             {
                 break;
             }
             startIndex       += num;
             textTreeTextBlock = (TextTreeTextBlock)textTreeTextBlock.GetNextNode();
         }
     }
 }
Пример #4
0
        // Token: 0x06003DAF RID: 15791 RVA: 0x0011C7F8 File Offset: 0x0011A9F8
        private static void InsertTextRight(TextTreeTextBlock leftBlock, object text, int textOffset)
        {
            int num = TextContainer.GetTextLength(text);

            if (leftBlock.GapOffset == leftBlock.Count)
            {
                TextTreeTextBlock textTreeTextBlock = (TextTreeTextBlock)leftBlock.GetNextNode();
                if (textTreeTextBlock != null)
                {
                    int num2 = Math.Min(textTreeTextBlock.FreeCapacity, num - textOffset);
                    textTreeTextBlock.InsertText(0, text, num - num2, num);
                    num -= num2;
                }
            }
            if (textOffset < num)
            {
                int num3 = 1;
                TextTreeTextBlock textTreeTextBlock2 = leftBlock.SplitBlock();
                int num2 = Math.Min(textTreeTextBlock2.FreeCapacity, num - textOffset);
                textTreeTextBlock2.InsertText(0, text, num - num2, num);
                num -= num2;
                if (textOffset < num)
                {
                    textOffset += leftBlock.InsertText(leftBlock.Count, text, textOffset, num);
                    if (textOffset < num)
                    {
                        num3 += (num - textOffset + 4096 - 1) / 4096;
                    }
                }
                for (int i = 0; i < num3 - 1; i++)
                {
                    TextTreeTextBlock textTreeTextBlock3 = new TextTreeTextBlock(4096);
                    textOffset += textTreeTextBlock3.InsertText(0, text, textOffset, num);
                    textTreeTextBlock3.InsertAtNode(leftBlock, false);
                    leftBlock = textTreeTextBlock3;
                }
                Invariant.Assert(textOffset == num, "Not all text copied!");
            }
        }
Пример #5
0
        // Helper for InsertText.  Inserts text to the right of an existing block.
        private static void InsertTextRight(TextTreeTextBlock leftBlock, object text, int textOffset)
        {
            int newBlockCount;
            TextTreeTextBlock rightBlock;
            TextTreeTextBlock neighborBlock;
            TextTreeTextBlock newBlock;
            int count;
            int textEndOffset;
            int i;

            textEndOffset = TextContainer.GetTextLength(text);

            if (leftBlock.GapOffset == leftBlock.Count)
            {
                // Try to fill neighbor block.
                neighborBlock = (TextTreeTextBlock)leftBlock.GetNextNode();
                if (neighborBlock != null)
                {
                    count = Math.Min(neighborBlock.FreeCapacity, textEndOffset - textOffset);
                    neighborBlock.InsertText(0, text, textEndOffset - count, textEndOffset);
                    textEndOffset -= count;
                }
            }
            
            if (textOffset < textEndOffset)
            {
                // Try adding just one block.
                newBlockCount = 1;

                rightBlock = leftBlock.SplitBlock();

                // Fill up the right block.
                count = Math.Min(rightBlock.FreeCapacity, textEndOffset - textOffset);
                rightBlock.InsertText(0, text, textEndOffset - count, textEndOffset);
                textEndOffset -= count;

                if (textOffset < textEndOffset)
                {
                    // Fill up the larger block.
                    // We need to copy from the end of the text here.
                    textOffset += leftBlock.InsertText(leftBlock.Count, text, textOffset, textEndOffset);

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