/
n-dimens
/
pascalabcnet
Обзор
Документация
Войти
/
n-dimens
/
pascalabcnet
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ICSharpCode.TextEditorLinux/Src/Undo/UndoableInsert.cs
73 строки
2 KB
Mikhalkovich Stanislav
Для Linux-версии исправлен DockContent, редактор (показ всплывающего окна)
30 июн 2022, 09:47
30 июн 2022, 09:47
3072383
Код
Авторство
О чём код?
// <file> // <copyright see="prj:///doc/copyright.txt"/> // <license see="prj:///doc/license.txt"/> // <owner name="Mike Krüger" email="mike@icsharpcode.net"/> // <version>$Revision: 1965 $</version> // </file> using System; using System.Diagnostics; using ICSharpCode.TextEditor.Document; namespace ICSharpCode.TextEditor.Undo { /// <summary> /// This class is for the undo of Document insert operations /// </summary> public class UndoableInsert : IUndoableOperation { IDocument document; // int oldCaretPos; int offset; string text; /// <summary> /// Creates a new instance of <see cref="UndoableInsert"/> /// </summary> public UndoableInsert(IDocument document, int offset, string text) { if (document == null) { throw new ArgumentNullException("document"); } if (offset < 0 || offset > document.TextLength) { throw new ArgumentOutOfRangeException("offset"); } Debug.Assert(text != null, "text can't be null"); // oldCaretPos = document.Caret.Offset; this.document = document; this.offset = offset; this.text = text; } /// <remarks> /// Undo last operation /// </remarks> public void Undo() { // we clear all selection direct, because the redraw // is done per refresh at the end of the action // document.SelectionCollection.Clear(); document.UndoStack.AcceptChanges = false; document.Remove(offset, text.Length); // document.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, oldCaretPos)); document.UndoStack.AcceptChanges = true; } /// <remarks> /// Redo last undone operation /// </remarks> public void Redo() { // we clear all selection direct, because the redraw // is done per refresh at the end of the action // document.SelectionCollection.Clear(); document.UndoStack.AcceptChanges = false; document.Insert(offset, text); // document.Caret.Offset = Math.Min(document.TextLength, Math.Max(0, document.Caret.Offset)); document.UndoStack.AcceptChanges = true; } } }