Friday, February 18, 2005

Friday 18th

Today saw me tackling the Undo / Redo routine head-on, but didn't manage to get much done due to being chronically tired. I started off by putting in the basic code to store and recall a buffer, then added the key presses to activate these. However, there was still a slight problem with the Redo part of the routine.

After a great deal of head scratching - which involved me simultaneously stepping through the code on-screen and on paper - it suddenly dawned on me why the routine wasn't working: when an action is performed, the map is saved to a buffer before the program draws to it. This is fine for the Undo, because you simply recall the saved buffer. However, should you then try to Redo what you just did, the results are quirky because there is no buffer to recall.

Therefore, whenever an action is performed the program needs to save both the map before the edit (for the Undo) and the map after the edit (for the Redo). Hopefully I can crack the routine tomorrow. :)