|
|
|
|
|
by smallduck
1522 days ago
|
|
It would be nice if this was a common OS feature. For some platforms however, system APIs implement the undo stack by way of pointers into runtime objects. A macOS application, for example, has model functions for each kind of document change, and these end with constructing an undo stack item. This contains pointers to the model object and inverse model function, plus captured parameters for that function to perform the undo. (Elegantly, when the inverse functions are called during an undo, the undo stack items they make effectively build a redo stack) To save this undo stack on this and similar platforms would also require changing the undo mechanism entirely, from using pointers into using static references having meaning across instances of the document model. The inverse model function would have to be identified by an enumeration, the object to change would have to be identified by a kind of search path. The details about saving the data, and where to save it, would be the tiniest part of this problem. But even on these platforms, if an individual app wishes to implement a custom undo stack which supported this feature, that would be very possible. If cross-platform frameworks implemented support for this that could be a definite advantage over native APIs. |
|