This is a "pure Ruby" implementation of the FXUndoList and
FXCommand classes from the standard FOX distribution. Since those classes
are independent of the rest of FOX this is a simpler (and probably more
efficient) approach than trying to wrap the original C++ classes.
Notes (by Jeroen, lifted from FXUndoList.cpp):
- When a command is undone, it's moved to the redo list.
- When a command is redone, it's moved back to the undo list.
- Whenever adding a new command, the redo list is deleted.
- At any time, you can trim down the undo list down to a given maximum size
or a given number of undo records. This should keep the memory overhead
within sensible bounds.
- To keep track of when we get back to an "unmodified" state, a
mark can be set. The mark is basically a counter which is
incremented with every undo record added, and decremented when undoing a
command. When we get back to 0, we are back to the unmodified state.
If, after setting the mark, we have called FXUndoList#undo, then the mark
can be reached by calling FXUndoList#redo.
If the marked position is in the redo-list, then adding a new undo record
will cause the redo-list to be deleted, and the marked position will become
The marked state may also become unreachable when the undo list is trimmed.
- You can call also kill the redo list without adding a new command to the
undo list, although this may cause the marked position to become
- We measure the size of the undo-records in the undo-list; when the records
are moved to the redo-list, they usually contain different information!