Re: Implementing Undo.





>  >> Hello hackers,
>  >> 
>  >> Does anyone know of software patterns for implementing Undo with
>  >> different kind of changes in a document?  I want to implement
>  >> Undo/Redo in Gnumeric.

Have you had a look at the Design Patterns Book by Erich Gamma et al.?
(Book is available in HTML *somewhere*, can't find it now, sorry)
Check the "Memento"-pattern. 

I did a related implementation sometime (closed source), where I kept a
stack of "ChangeObject"s. Each of these encapsulated both the action
performed and the inverse action. Now it's easy to traverse the list up
and down. The hard thing for something like Gnumeric would be to keep the
mem usage of these changeobjects under control, as some inverse operation
may require *huge* amounts of mem. 

Hope this helps.
	Dirk-Jan.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]