Undo Management

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

3 posts / 0 new
Last post
Undo Management

Submitted by Anonymous on Wed, 08/01/2001 - 13:42. Developers
How do you achieve undo capability for motif GUI interface. I know viewkit has that capablity.
But our application does not use view kit objects. Currently we have very cumbersome process to maintain one level undo capability.

1. Structure holds original data called Struct1
2. Widget display`s Struct1 data
3. User Modifies the data
4. Make Copy of modified data to Struct 2
5. Compare the diff between Struct1 and Struct2
6. If changed ask user to save the data or not
if yes copy Struct2 to Struct1
else update the widgets with Struct1 data

7. else Do nothing

The above algorithm describes our current un do action.
Since Our data structure are huge, the data comparison and copy becomes cumbersome task.
Is there a simple and efficient way to do the "Undo" action

ICS_support

One way to clean up is to log the changes; that is, have a second structure which simply names (via a flag or some short-hand) the field which the user changed as a result of the action. Then you can revert that field. And, even better, you can have a list of these items, so that you can continue undoing.

The basic problem with "undo" is that some changes are hard to undo. And, depending on the application, it may be better to store the changes as user actions rather than as changes to the application`s data state, as you are doing. That is, you store the fact that the user inserted text into a text field by caching in your undo stack that fact (or caching the previous state of the data there) or the information you need to undo the change -- the delection.

I think ViewKit offers support for this sort of data storage without helping greatly with the implementation.

Anonymous

Do you want undo just for forms or for any notable user modifications?

My rule would be don`t code a higher level of abstraction unless you`ll save coding time using it, of course. If you used a centralized data collection routine, it could log all actions. But would that save you time if your structure is good enough?

On the other hand, why no employ the services of CVS or RCS, which does the dirty revisions work for you? You know, like a "last level default" or a pulldown of revisions. Nah... too greedy, right?