multiple undo/redo
-
Hi ! I'd like to get some hints or suggestions from you on how ot implement a multiple-undo/redo. I'vew been thinking about that for some time, but cannot figure out how a central undo/redo can work with many different objets. Some will be destroyed, some action will delete things in memory, other in the database...Or, when a user change some data in an object through a dialog box, what to I have to do : do I have to keep a copy of the objet before the modification ? Do I have to implement an unique object handling the history and being able to undo any change ? Well, as you can see, this subject is quite obscure to me !!! Thank you for your help ! Jerome
-
Hi ! I'd like to get some hints or suggestions from you on how ot implement a multiple-undo/redo. I'vew been thinking about that for some time, but cannot figure out how a central undo/redo can work with many different objets. Some will be destroyed, some action will delete things in memory, other in the database...Or, when a user change some data in an object through a dialog box, what to I have to do : do I have to keep a copy of the objet before the modification ? Do I have to implement an unique object handling the history and being able to undo any change ? Well, as you can see, this subject is quite obscure to me !!! Thank you for your help ! Jerome
I suggest that : first way: maybe you can use IStorage and IStream; before user change the object, you create IStorage object and save user's object data to Storage. if user undo his change, load this object. secondly: use clipboard, you can create the different clip tags but the tags have the same letter such as "'object1', 'object2','object3'...." if user undo object3, you can load object2. certainly, the memory is limmitted. so can set fixed num for operatoring. hope helpful for you. good luck dupengfei
-
Hi ! I'd like to get some hints or suggestions from you on how ot implement a multiple-undo/redo. I'vew been thinking about that for some time, but cannot figure out how a central undo/redo can work with many different objets. Some will be destroyed, some action will delete things in memory, other in the database...Or, when a user change some data in an object through a dialog box, what to I have to do : do I have to keep a copy of the objet before the modification ? Do I have to implement an unique object handling the history and being able to undo any change ? Well, as you can see, this subject is quite obscure to me !!! Thank you for your help ! Jerome
Think about the operations you are doing as commands, each command need to be self-contained. for example, drawing a square in a drawing program, what is the undo ? cut ? ok, but what is the redo ? paste or just the same command that you originally draw the square ? and from the other side, if you cut a square, what is the undo ? paste or juste drawing back the square ? from my experience, each command should be able to generate it's onw undo command from the data it uses to generate the command. It can be simple or hard.
Maximilien Lincourt "Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
-
Hi ! I'd like to get some hints or suggestions from you on how ot implement a multiple-undo/redo. I'vew been thinking about that for some time, but cannot figure out how a central undo/redo can work with many different objets. Some will be destroyed, some action will delete things in memory, other in the database...Or, when a user change some data in an object through a dialog box, what to I have to do : do I have to keep a copy of the objet before the modification ? Do I have to implement an unique object handling the history and being able to undo any change ? Well, as you can see, this subject is quite obscure to me !!! Thank you for your help ! Jerome
A better approach would be store the delta. After a particular operation, save only the changes the user has made to the document, and when he wants to undo it, apply the changes, and thats it "A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."