Home Forums General XMetaL Discussion Undo/Redo clearing of a specific item Reply To: Undo/Redo clearing of a specific item

Derek Read

Reply to: Undo/Redo clearing of a specific item

I'll see if I can get XMetaLOldTimer to comment here, but…

I think you misunderstand the purpose of the BeginMutation & EndMutations APIs. They allow a group actions performed in a script to be grouped and undone all as one Undo action.

There is no way to skip over actions when performing an Undo. What makes the software so flexible (that any number of customizations might be added to it to extend or alter its behaviour) requires some fundamental limitations to be in place and one of those is currently that an Undo undoes whatever was done last, including changes made via script. At least that's my take on it.

When it comes to view switches being included in Undo, that is just something people using the software need to get used to, even if it is seen as a quirk unique to XMetaL Author. Tags On and Normal view are using the same DOM but a particular set of user interactions (keyboard and / or mouse input) might do something slightly different in each view (this includes many APIs that mimic these user interactions). This is true in general, but your specific case highlights this perhaps. You have PIs hidden in one view but not in the other so it would be possible for the user to select a PI in one view but not possible to select it in the other view.

Many APIs that function in these two views cannot be used in Plain Text view at all, primarily because Plain Text view does not use a DOM but also because it has a completely different rendering model. Switching from Plain Text view into one of the other views is effectively the same as opening the file from disk (the entire DOM is recreated during the view switch, just as it is built when reading a file in). Probably most important (or most obvious) is that in addition to these things, switching views triggers a bunch of events, inside any of which an application-level macro (often created by a partner) or a document-level macro might run script which might alter the document. So, because a view change might alter the document the entire thing (whatever might have run during the view switch, but including the view switch) is undone when the user asks to Undo.