Re: Implementing Undo.

The undo/redo architecture in dia is quite nice.  Each object has a method
get_state that when called returns a structure storing the state of that
object.  There is another method called set_state that will set the state
from the structure.

For gnumeric, these objects would probably be cells, ranges, drawing
shapes, etc.

When an object is about to be changed, get its state and save it to the
undo stack.  This way you can roll back the saved states of the individual
objects to get the previous state.  To do redos, just save the state
before each undo operation.

To simplify things, dia requires that the saved state structures be flat,
so they can be discarded with g_free when not needed anymore.

This method seems to work quite nicely in dia (for the objects that
support it -- some haven't had undo support added yet).



On Fri, 27 Aug 1999, Miguel de Icaza wrote:

> 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.
> Miguel.
> -- 
> To unsubscribe: mail with "unsubscribe"
> as the Subject.

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