| [Home] [Tutorials] |
|
|
| Previous | Contents | Next |
Once an operation has been successfully performed, it needs to register itself with Sweep's undo handler. This involves:
The apply() method of a proc usually does these things, does its actual work, registers the operation then returns the sw_op_instance created.
An operation given by (sw_op_instance * inst) is undone by calling
inst->op->undo (sample, inst->undo_data);
and redone by calling
inst->op->redo (sample, inst->redo_data);
When an operation instance can be discarded (eg. if only a finite number of recent operations are remembered), the undo_data and redo_data members are purged by calling
inst->op->purge_undo (inst->undo_data); inst->op->purge_redo (inst->redo_data);
Thus, if any memory was allocated to create undo_data or redo_data it should be freed in the purge functions.
Some stock undo and redo methods exist for handling operations which
need to paste new data over the selected region, or which need to splice
data into the sample. These are outlined in
| Previous | Contents | Next |
|