예제 #1
0
 public void Edit(int start, int count, char[] text, int textStart, int textLength)
 {
     using (PinnedArray <char> array = new PinnedArray <char>(text))
     {
         Edit(start, count, array, textStart, textLength);
     }
 }
예제 #2
0
        public void Edit(int start, int count, PinnedArray <char> text, int textStart, int textLength)
        {
            int blockOffset = textLength - count;

            for (int i = this.blocks.Count - 1; i >= 0; i--)
            {
                Tuple <int, int> block = this.blocks[i];
                if (start < block.Item2 && start + count > block.Item1)
                {
                    this.blocks.RemoveAt(i);
                }
                else if (start + count <= block.Item1)
                {
                    this.blocks[i] = Tuple.Create(block.Item1 + blockOffset, block.Item2 + blockOffset);
                }
            }

            int newSize  = this.availableCharCount + textLength - count;
            int newBlock = GetBlockSize(newSize);

            if (newBlock > this.charArray.Buffer.Length)
            {
                this.charArray.Resize(newBlock);
            }

            this.charArray.Pinned = true;
            text.Pinned           = true;
            UnsafeMethods.CopyMemory(this.charArray.GetElementAddress(start + textLength), this.charArray.GetElementAddress(start + count), (this.availableCharCount - (start + count)) * sizeof(char));
            UnsafeMethods.CopyMemory(this.charArray.GetElementAddress(start), text.GetElementAddress(textStart), textLength * sizeof(char));
            this.charArray.Pinned   = false;
            text.Pinned             = false;
            this.availableCharCount = newSize;

            if (this.charArray.Buffer.Length - newBlock > BufferBlock)
            {
                this.charArray.Resize(newBlock);
            }
            if (this.colorArray.Length != this.charArray.Buffer.Length)
            {
                this.colorArray  = new int[this.charArray.Buffer.Length];
                this.offsetArray = new int[this.charArray.Buffer.Length];
            }
            else
            {
                for (int i = start; i < this.charArray.Buffer.Length; i++)
                {
                    this.offsetArray[i] = 0;
                }
            }
        }
예제 #3
0
 public TextLine()
 {
     this.charArray   = new PinnedArray <char>(BufferBlock);
     this.colorArray  = new int[BufferBlock];
     this.offsetArray = new int[BufferBlock];
 }
예제 #4
0
 public void Edit(int start, int count, PinnedArray <char> text)
 {
     Edit(start, count, text, 0, text.Buffer.Length);
 }