Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2002-06

Form editing: Undo/Redo

8 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner
to Mattias Gaertner: I want to implement Undo/Redo for the form editing, but I'm not sure how this should be…
Show quoted text 13 lines
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?

Mattias

Reply by email

Florian Klaempfl
to Mattias Gaertner: I want to implement Undo/Redo for the form editing, but I'm not sure how this should be…
you wrote 8 lines
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?

Reply by email

Mattias Gaertner

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?

Mattias

Reply by email

Martyn Ranyard
to Mattias Gaertner
Mattias Gaertner wrote 8 lines
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?

Bear in mind that certainly in D5 and earlier, moving a control could not be undone, nor could creating one, only deletions were undoable.

Anything you do will almost certainly be better than Borland's "Ahh, it doesn't matter" attitude.

Mattias

Martyn Ranyard
Free Software Advocate

icq - 122500800
irc - Joran on OPN
msn -
y! - ranyardm
e -

Reply by email

Mattias Gaertner
to Mattias Gaertner: On Thu, 20 Jun 2002 12:35:30 +0200 You already answered: inefficient. Forms can contain…
Show quoted text 19 lines
> > >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? [...] > 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).

AFAIK this is only done for standard types. The big data (e.g. images, nodes) is stored via DefineProperties, which seldom support ancestor comparison. And I'm not sure if the ancestor technique can be would need a copy to compare. And creating a copy means stream writing, stream reading, component creating and destroying the copy.

Mattias

Reply by email

Mattias Gaertner
to Mattias Gaertner
Show quoted text 42 lines
On Thu, 20 Jun 2002, Mattias Gaertner wrote: > On Thu, 20 Jun 2002 15:57:00 +0200 (W. Europe Daylight Time) > Michael Van Canneyt wrote: > > > > > >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? > > [...] > > > 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). > > AFAIK this is only done for standard types. Yes. > The big data (e.g. images, nodes) is stored via DefineProperties, > which seldom support ancestor comparison. True. > And I'm not sure if the ancestor technique can be used at all. > We would need a copy to compare. And creating a copy means stream > writing, stream reading, component creating and destroying the copy. That is what I meant with the two copies. I didn't say it would be easy, I just wanted to indicate that maybe this technique can be looked at.

Ok.
But it seems to me, that this comparison technique, would be slower, more complex and needs more memory than the dumb stream technique. BTW, does someone knows, how do RADs other than Delphi do this?

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner: On Thu, 20 Jun 2002 12:35:30 +0200 You already answered: inefficient. Forms can contain…
Mattias Gaertner wrote 20 lines
On Thu, 20 Jun 2002 12:35:30 +0200 Florian Klaempfl 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.

Michael.

Reply by email

Unknown author
to Mattias Gaertner: On Thu, 20 Jun 2002 15:57:00 +0200 (W. Europe Daylight Time) AFAIK this is only done for…
Mattias Gaertner wrote 24 lines
On Thu, 20 Jun 2002 15:57:00 +0200 (W. Europe Daylight Time) Michael Van Canneyt wrote: > > > >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? > [...] > > 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). AFAIK this is only done for standard types.

Yes.

The big data (e.g. images, nodes) is stored via DefineProperties, which seldom support ancestor comparison.

True.

And I'm not sure if the ancestor technique can be used at all. We would need a copy to compare. And creating a copy means stream writing, stream reading, component creating and destroying the copy.

That is what I meant with the two copies. I didn't say it would be easy, I just wanted to indicate that maybe this technique can be looked at.

Michael.

Reply by email