[plt-scheme] hooking add-to-undo-stack
At Mon, 27 Apr 2009 13:26:04 +0530, Martin DeMello wrote:
> My app has a lot of editors embedded in a pasteboard, and I would like
> undo and redo to be global operations rather than per-editor. What
> I've done is added an undo and redo stack to my application% object,
> and methods add-undo, undo and redo. The idea is that when something
> changes in an editor, it will call (send application add-undo this),
> and calling undo will call (send (pop-undo-stack) undo). Is there any
> way to get a callback when something is added to an editor's undo
> stack, so that I can call add-undo? on-change is the closest I could
> find, but from the docs that also pulls in non-editing events like
> resizing and reflowing.
I don't have a good answer for implementing this, at least not in a
backward-compatible way. As you've seen, there're aren't enough of the
right kind of hooks in place.
We've long recognized that support for chained undo stack is missing in
the core, but we never got around to adding it. So, one option is to
just add it now (which is a lot easier in the SVN trunk than in 4.1.5
and earlier, since the relevant code is now in Scheme instead of C++).
I think the addition would involve new undo-related methods in the
`editor-admin%' and `snip-admin%' classes, and probably also
undo-related methods in `snip%'. I can look into those additions
sometime soon. Or, if you're game, you can jump into the code in
"collects/mred/private/wxme" an send me a patch!