[lazarus] Form editing: Undo/Redo

Michael Van Canneyt michael.vancanneyt at wisa.be
Thu Jun 20 09:44:41 EDT 2002

On Thu, 20 Jun 2002, Mattias Gaertner wrote:

> On Thu, 20 Jun 2002 12:35:30 +0200
> Florian Klaempfl <Florian.Klaempfl at gmx.de> wrote:
> > At 00:01 20.06.2002 +0200, you wrote:
> > >Hi all,
> > >
> > >I want to implement Undo/Redo for the form editing, but I'm not sure how
> > >this should be done.
> > >Normally an undolist just keeps tracks of the changes. But for example
> > >moving a control can result in changing other controls and many other
> > >things. So, for a correct undo, one have to stream the form after every
> > >move/resize/add/delete/change property operation. Or is there a better way?
> >
> > Hmmm, the stream seems to be a little bit inefficient :) but it should give
> > a very good result
> > (not very "error prone") and it should be easy to implement. So why not?
> You already answered: inefficient.
> Forms can contain images and I want undo/redo for at least 10 open forms and 100 steps and, as Martyn mentioned, for almost all kinds of form editing, not just like Delphi.
> The needed memory should be reduced by saving only the diffs between the streams. Does anybody know a unit for diffing/patching?

The streaming method contains some functionality for streaming diffs.
The problem is that you need 2 instances of one object for this to work.
The 'root' object and the 'child' object.

To produce a diff stream, it should be sufficient to have the 'root'
object as the form before the operation, and the child object as the
form after the operation. The streaming method should then only record
differences. (this is, BTW, how form inheritance works: root is the
parent form, and the child form is the descendent form).

This is the theory. In practice, it has never been tested. This would be
a good and thorough test of the streaming code, though.


More information about the Lazarus mailing list