public void Replace(int offset, int length, string text)
        {
            if (!ReadOnly)
            {
                DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length, Text = text
                });
                UndoStack.Push(new UndoableReplace(this, offset, GetText(offset, length), text));

                TextBuffer.Replace(offset, length, text);
                LineManager.Replace(offset, length, text);

                DocumentChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length, Text = text
                });
            }
        }
        public void Remove(int offset, int length)
        {
            if (!ReadOnly)
            {
                DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length
                });
                UndoStack.Push(new UndoableDelete(this, offset, GetText(offset, length)));

                TextBuffer.Remove(offset, length);
                LineManager.Remove(offset, length);

                DocumentChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = length
                });
            }
        }
        public void Insert(int offset, string text)
        {
            if (!ReadOnly)
            {
                DocumentAboutToBeChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = -1, Text = text
                });

                TextBuffer.Insert(offset, text);
                LineManager.Insert(offset, text);

                UndoStack.Push(new UndoableInsert(this, offset, text));

                DocumentChanged?.Invoke(this, new DocumentEventArgs()
                {
                    Document = this, Offset = offset, Length = -1, Text = text
                });
            }
        }
Exemple #4
0
 void OnDocumentAboutToBeChanged(DocumentEventArgs e)
 {
     DocumentAboutToBeChanged?.Invoke(this, e);
 }