Re: Multiple Undo devours RAM
Re: Multiple Undo devours RAM
- Subject: Re: Multiple Undo devours RAM
- From: Kyle Moffett <email@hidden>
- Date: Sun, 1 Feb 2004 15:21:33 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Jan 31, 2004, at 14:00, Erez Anzel wrote:
Back in the earlier MacApp days, if I remember correctly, I did it the
way that you mentioned that you did it: I would store a command, and
the Undo or Redo would apply to the current selection. In my simple
approach (for a simple app), there wasn't an Undo stack in the same
sense. Each object stored not only its current state (color, position,
etc.), but also its previous state. Undo/Redo would simply toggle back
and forth. This obviously did not allow for multiple Undo, but it sure
was simple.
A modification on this handles multiple undo fairly well for large
numbers
of objects. Essentially there were "UndoableValue" classes, and the
setter
and getter methods pushed the changed value on the top of the stack.
The
global undo stack merely consisted of a collection of the UndoableValue
objects that had changed during that operation. To undo any action, you
just popped the most recent operation (array of UndoableValues) off the
global undo stack and sent a "popChange" message to each UndoableValue.
You can even use this to implement a preference "Save X undos to disk",
so
that even after saving and quitting you could still go back and undo
the last
several changes.
Cheers,
Kyle Moffett
- -----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCM/CS/IT/U d- s++: a17 C++++>$ UB/L/X/*++++(+)>$ P+++(++++)>$
L++++(+++) E W++(+) N+++(++) o? K? w--- O? M++ V? PS+() PE+(-) Y+
PGP+++ t+(+++) 5 X R? tv-(--) b++++(++) DI+ D+ G e->++++$ h!*()>++$ r
!y?(-)
- ------END GEEK CODE BLOCK------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFAHV/Nag7LSGnFq10RAs4kAKCvZ8wr83rr6lrA2Df+oYYTVrNmPACglx2u
VmTh06nnXjffBMS2tQohJGM=
=LhmZ
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.