Quoting tim Rowledge tim@rowledge.org:
On 30-Apr-08, at 1:18 PM, itsme213 wrote:
"Gary Chambers" gazzaguru2@btinternet.com wrote in message
Can you explain the general functionality you are hoping to obtain?
Generic undo of arbitrary domain-object actions with no extra effort.
Unless you propose to make a practical completely reversible computational system I suspect you are heading for some disappointment.
Not all actions have trivially derivable inverse actions. Consider a real example from Sophie that occupied me for several days; inserting a character into a paragraph. Sound pathetically simple, doesn't it?
Until you realise that the character might be carrying a style that is not the same as the text where it is being inserted. Or that the insertion point is in between two adjacent pagebreaks. If the character's style matches the style of where it is being inserted, you can simply stick the Character into the relevant String. The undo record would record the insertion index; simple. If the character style doesn't match, then you have to split the string, make a new string for the character, insert that into the paragraph. Of course, the insertion point might be at the very beginning or end of the string and that adds some extra twists. The undo record needs to record that a new string was added instead of merely a Character being put into a String. The undo action has to remove that string and remerge the split halves if needed. Oh, and all cases have to make sure that any annotations like highlighting get updated to account for the splitting, inserting, merging etc.
tim
tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Strange OpCodes: ESBD: Erase System and Burn Documentation
But surely all that logic is built into the application, so the inverse operation is 'delete character at insertion index' - since you obviously need this functionality. Nobody said it was easy or trivial.
David