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 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 Add(TextCursor cursor, TextAction.ActionType type) { TextAction action = new TextAction(cursor, type); UndoActions.Push(action); if (RedoActions.Any()) { RedoActions.Clear(); } return(action); }