OpenChartProject / OpenChart

✨ NEW REPO ✨ https://github.com/OpenChartProject/OpenChart-web
https://github.com/OpenChartProject/OpenChart-web
Other
8 stars 3 forks source link

Implement undo/redo #75

Open Kangaroux opened 4 years ago

Kangaroux commented 4 years ago

📖 Overview

Depends on #74

We need to store a history of user actions. The history should be stored as two stacks: an undo stack and a redo stack. The history should be fully encapsulated in a single class so we can make one for each chart.

Stack Behavior:

  1. Performing an action pushes it to the undo stack
  2. Undoing an action pops it from the undo stack and pushes it to the redo stack
  3. Redoing an action pops it from the redo stack and pushes it to the undo stack
  4. If the redo stack isn't empty when the user performs a new action, the redo stack should be cleared
  5. The undo stack should have a large limit, such as 200. When a new item is pushed onto the stack that exceeds the limit, the oldest item at the bottom of the stack should be removed.