Interest in undo/redo framework
Hello all, I'd just like to make a general survey over whether or not anyone has or has had any interest in an undo/redo framework? Similar in scope to what the Qt Undo Framework (http://doc.trolltech.com/4.2/qundo.html) hopes to achieve? Benjamin Lau
I would definitely be interested in such a framework FWIW. Also happy to test!
Yay! That's nice to note. I'm actually in the midst of designing an undo/redo framework and was thinking of submitting it to Boost once it is done. It's fairly simple in design and only needs 1 source file! Basically, it works like this: 1. Create 3 functions (or function-like entities) which perform an action, undo this action, and redo the action, based on a single change-parameter (any arbitrary data type of the user's choice T). 2. Create an undo redo stack 3. Pass the 3 functions and the undo redo stack to a free function that will return a boost:: function that when called with the change-parameter, will perform the specified action, push the undo and redo functions and the change-parameter onto the undo stack of the undo redo stack object. 4. Undo and redo actions can hence be performed by calling undo/redo member functions on the undo redo stack object This is basically how I intend it to work, but I don't know if it will suit any of your means, since I don't want to over-generalize, but neither do I want to be overly specific. Any comments? Thanks for showing interest. Benjamin Lau P/s I may disappear off spontaneously because my exams are going to begin soon. But rest assured I will be a responsible OP and respond to this thread when I can.
G'day all.
Quoting Benjamin Lau
Yay! That's nice to note. I'm actually in the midst of designing an undo/redo framework and was thinking of submitting it to Boost once it is done. It's fairly simple in design and only needs 1 source file!
I'm also interested, but my needs are a bit more sophisticated. Imagine, for a moment, an application with a soft scripting layer. User interface components (e.g. menu items) can activate scripts written by the user. When the user tries to "undo", what they would expect is for all "primitive" operations to be undone. The same applies to "redo". I therefore think that any Boost.Undo would need to be able to handle this. And what I'd like to write is something along these lines: boost::undo::undo_manager s_undoManager; void activate_script() { boost::undo::transaction ut(s_undoManager); run_script(); } While the boost::undo::transaction object is alive, the undo_manager should treat all operations as a unit. Then when I call s_undoManager.undo() (or whatever it's called), it will undo all of the primitive operations done by the script in one go. Other desirable features: - The ability to name transactions/operations. - The ability to iterate through the undo/redo stacks and undo/redo up to an iterator. - The ability to create undo/redo "checkpoints" which only invalidate if the point truly no longer exists (e.g. if you undo past the checkpoint and subsequently "do" a new operation). Cheers, Andrew Bromage
G'day all.
Quoting Benjamin Lau
So you're saying that the transaction object in this case keeps track of everything the script does without any additional code?
Yes. Everything the script does (apart from I/O, which we can ignore) must eventually come down to some application-specific primitives. If those primitives are undoable and redoable, then the effect of script as a whole is undoable and redoable. There are a bunch of assumptions here, such as that any access to global state by the script is undoable. For many interesting scripting systems, that assumption is true. Cheers, Andrew Bromage
participants (3)
-
ajb@spamcop.net
-
Benjamin Lau
-
Rob Caldecott