[squeak-dev] Re: Re: Undoable environment ?
tim Rowledge
tim at rowledge.org
Wed Apr 30 20:49:20 UTC 2008
On 30-Apr-08, at 1:18 PM, itsme213 wrote:
> "Gary Chambers" <gazzaguru2 at 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 at rowledge.org; http://www.rowledge.org/tim
Strange OpCodes: ESBD: Erase System and Burn Documentation
More information about the Squeak-dev
mailing list
|