Ejemplo n.º 1
0
 public void Append(string str, StateHistory history)
 {
     undoStack.Push(history);
     OnAppend?.Invoke(str);
     if (history.PushState != null)
     {
         PushState(history.PushState);
     }
     InputField.text += str;
     DisableInvalidButtons();
 }
Ejemplo n.º 2
0
        public void Undo()
        {
            if (undoStack.Count > 0)
            {
                string       currentExp = InputField.text;
                StateHistory popped     = undoStack.Pop();
                InputField.text = string.Join("", undoStack.Reverse().Select(s => s.ExpressionPart));

                OnUndo?.Invoke(currentExp.Substring(InputField.text.Length));

                if (popped.PushState != null)
                {
                    PopState(true);
                }
                if (popped.PopState != null)
                {
                    PushState(popped.PopState);
                }

                DisableInvalidButtons();
                SetDebugText();
            }
        }