public TextAction PeekIf(TextCursor cursor, TextAction.ActionType type, Func <TextAction, bool> condition) { if (UndoActions.Any() && UndoActions.Peek().Match(cursor, type) && condition(UndoActions.Peek())) { return(UndoActions.Peek()); } else { return(Add(cursor, type)); } }
public TextAction PeekOrAdd(TextCursor cursor, TextAction.ActionType type) { if (UndoActions.Any() && UndoActions.Peek().Match(cursor, type)) { return(UndoActions.Peek()); } else { return(Add(cursor, type)); } }
public bool Undo(out TextCursor cursor) { cursor = null; if (!UndoActions.Any()) { return(false); } var action = UndoActions.Pop(); cursor = action.Cursor; cursor.Undo(action); RedoActions.Push(action); return(UndoActions.Any()); }