Beispiel #1
0
        public TextBuffer NewLine(long newLineSize = ResizeColumnDelta, long howManyLines = 1)
        {
            BufferLine[] tmp = new BufferLine[_buffer.LongLength + howManyLines];
            BufferLine   newLine;

            if (_pos.Column < _buffer[_pos.Line].TextLength)
            {
                newLine = new BufferLine(_buffer[_pos.Line].TextLength - _pos.Column + newLineSize);
                newLine.CopyFrom(_buffer[_pos.Line], 0, _pos.Column);
                _buffer[_pos.Line].Erase(_pos.Column);
            }
            else
            {
                newLine = new BufferLine(newLineSize);
            }
            long l, dl;

            for (l = 0; l <= _pos.Line && l < _buffer.LongLength; ++l)
            {
                tmp[l] = _buffer[l];
            }
            for (dl = 0; dl < howManyLines; ++dl)
            {
                tmp[l + dl] = newLine;
            }
            for (; l < _buffer.LongLength; ++l)
            {
                tmp[l + dl] = _buffer[l];
            }

            _buffer = tmp;
            return(this);
        }
Beispiel #2
0
        public BufferLine Merge(BufferLine source)
        {
            if ((TextLength + source.TextLength + 1) >= LongLength)
            {
                Resize(TextLength + source.LongLength + 1);
            }
            CopyFrom(source, TextLength);

            return(this);
        }
Beispiel #3
0
        public TextBuffer(long lines, long columns)
        {
            _maxCol  = columns;
            _maxLine = lines;

            _buffer = new BufferLine[_maxLine];
            for (int l = 0; l < _maxLine; ++l)
            {
                _buffer[l] = new BufferLine(_maxCol);
            }
        }
Beispiel #4
0
        public void CopyFrom(BufferLine source, long dstIndex, long srcIndex = 0L)
        {
            if (LongLength <= dstIndex + source.TextLength - srcIndex)
            {
                throw new IndexOutOfRangeException("Copied content is too big for destination!");
            }

            for (long c = 0; c + srcIndex < source.TextLength && c + dstIndex < _bufferLine.LongLength; ++c)
            {
                _bufferLine[dstIndex + c] = source[c + srcIndex];
            }
            _occupyBajts = dstIndex + source.TextLength - srcIndex;
        }
Beispiel #5
0
 public void CopyTo(BufferLine destination, long dstIndex, long srcIndex = 0L)
 {
     destination.CopyFrom(this, dstIndex, srcIndex);
 }