| 1: | // UndoableInsert.cs | |
| 2: | // Copyright (c) 2000 Mike Krueger | |
| 3: | // | |
| 4: | // This program is free software; you can redistribute it and/or modify | |
| 5: | // it under the terms of the GNU General Public License as published by | |
| 6: | // the Free Software Foundation; either version 2 of the License, or | |
| 7: | // (at your option) any later version. | |
| 8: | // | |
| 9: | // This program is distributed in the hope that it will be useful, | |
| 10: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12: | // GNU General Public License for more details. | |
| 13: | // | |
| 14: | // You should have received a copy of the GNU General Public License | |
| 15: | // along with this program; if not, write to the Free Software | |
| 16: | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 17: | ||
| 18: | using System; | |
| 19: | using System.Diagnostics; | |
| 20: | using System.Drawing; | |
| 21: | ||
| 22: | using SharpDevelop.DefaultEditor.Text; | |
| 23: | using SharpDevelop.Internal.Undo; | |
| 24: | ||
| 25: | namespace SharpDevelop.DefaultEditor.Undo { | |
| 26: | ||
| 27: | /// <summary> | |
| 28: | /// This class is for the undo of Document insert operations | |
| 29: | /// </summary> | |
| 30: | public class UndoableDelete : IUndoableOperation | |
| 31: | { | |
| 32: | IDocument document; | |
| 33: | int offset; | |
| 34: | string text; | |
| 35: | ||
| 36: | public UndoableDelete(IDocument document, int offset, string text) | |
| 37: | { | |
| 38: | if (document == null) { | |
| 39: | throw new ArgumentNullException("document"); | |
| 40: | } | |
| 41: | if (offset < 0 || offset > document.TextLength) { | |
| 42: | throw new ArgumentOutOfRangeException("offset"); | |
| 43: | } | |
| 44: | ||
| 45: | Debug.Assert(text != null, "text can't be null"); | |
| 46: | this.document = document; | |
| 47: | this.offset = offset; | |
| 48: | this.text = text; | |
| 49: | } | |
| 50: | ||
| 51: | public void Undo() | |
| 52: | { | |
| 53: | document.UndoStack.AcceptChanges = false; | |
| 54: | document.Insert(offset, text); | |
| 55: | document.UndoStack.AcceptChanges = true; | |
| 56: | } | |
| 57: | public void Redo() | |
| 58: | { | |
| 59: | document.UndoStack.AcceptChanges = false; | |
| 60: | document.Remove(offset, text.Length); | |
| 61: | document.UndoStack.AcceptChanges = true; | |
| 62: | } | |
| 63: | } | |
| 64: | } |
This page was automatically generated by SharpDevelop.