Exemple #1
0
 public void RemoveAt(int i)
 {
     lock (EditMutex) {
         lines.RemoveAt(i);
         LineRemoveEvent.Raise(this, new CodeBufferEventArgs(i));
     }
 }
Exemple #2
0
 public void RemoveAt(int i)
 {
     editMutex.EnterWriteLock();
     lines.RemoveAt(i);
     editMutex.ExitWriteLock();
     LineRemoveEvent.Raise(this, new CodeBufferEventArgs(i));
 }
Exemple #3
0
 /// <summary>
 /// remove line number i
 /// </summary>
 /// <param name="i">index of the line</param>
 public void RemoveLine(int i)
 {
     editMutex.EnterWriteLock();
     buffer.Remove(GetBufferIndexOfLine(i), lineLength [i]);
     lineLength.RemoveAt(i);
     editMutex.ExitWriteLock();
     LineRemoveEvent.Raise(this, new TextBufferEventArgs(i));
 }
Exemple #4
0
        public void Delete()
        {
            editMutex.EnterWriteLock();
            if (SelectionIsEmpty)
            {
                if (CurrentColumn == 0)
                {
                    if (CurrentLine == 0)
                    {
                        editMutex.ExitWriteLock();
                        return;
                    }

                    buffer.Remove(this [CurrentLine] - 1, 1);

                    int col = lineLength [CurrentLine - 1] - 1;
                    lineLength [CurrentLine - 1] += lineLength [CurrentLine] - 1;
                    lineLength.RemoveAt(CurrentLine);

                    CurrentLine--;
                    CurrentColumn = col;

                    editMutex.ExitWriteLock();
                    LineRemoveEvent.Raise(this, null);
                    return;
                }
                CurrentColumn--;
                buffer.Remove(this [CurrentLine] + CurrentColumn, 1);
                lineLength [CurrentLine]--;
            }
            else
            {
                int linesToRemove = SelectionEnd.Y - SelectionStart.Y;
                int ptr           = this [SelectionStart.Y] + SelectionStart.X;
                int length        = lineLength [SelectionStart.Y] - SelectionStart.X;
                int l             = 1;
                while (l <= linesToRemove)
                {
                    length += lineLength [SelectionStart.Y + l];
                    l++;
                }
                length -= lineLength [SelectionEnd.Y] - SelectionEnd.X;
                buffer.Remove(ptr, length);
                lineLength [SelectionStart.Y] = SelectionStart.X + lineLength [SelectionEnd.Y] - SelectionEnd.X;
                lineLength.RemoveRange(SelectionStart.Y + 1, linesToRemove);

                CurrentLine   = SelectionStart.Y;
                CurrentColumn = SelectionStart.X;
                ResetSelection();

                if (linesToRemove > 0)
                {
                    LineRemoveEvent.Raise(this, null);
                }
                else
                {
                    LineUpadateEvent.Raise(this, null);
                }
            }
            editMutex.ExitWriteLock();
        }