Congratulations on enabling undo / redo. This is a great feature in any editor. It can get complicated, still. Here are some thoughts for you (all manual, no code).
I recommend that you familiarize yourself with the team design pattern . What you want to do is create a class “Command”, an instance of which can “execute” one command (for example, insert the letter “A”), as well as “Cancel”.
When the user invokes some command (for example, to add the letter "A"), you are "new", the command "Define" to insert "A" to insert "A", also define it "Cancel" to delete A, then add it at the top of your cancellation list, and then do.
Do not limit your cancellations to only 10. Why not make it endless?
Regardless of the structure you use to compile the list of canceled commands, the usual behavior is that if you cancel a level and then start editing at that point, then all repetitions above the current level should be discarded.
Detmar 05 Oct '10 at 3:29 2010-10-05 03:29
source share