home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!haven.umd.edu!umd5!mac19-pg2.umd.edu!user
- From: de19@umail.umd.edu (Dana S Emery)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Undo Hints
- Message-ID: <de19-171192065952@mac19-pg2.umd.edu>
- Date: 17 Nov 92 12:39:37 GMT
- References: <1992Nov13.200442.29821@cs.uoregon.edu>
- Sender: news@umd5.umd.edu
- Followup-To: comp.sys.mac.programmer
- Organization: personal
- Lines: 44
-
- In article <1992Nov13.200442.29821@cs.uoregon.edu>,
- alana@majestix.cs.uoregon.edu (Thomas Alan Akins) wrote:
- >
- > Tips on how to "remember" the last edit command and the storage of a string of
- > text that the user may wish to undo (Undo Typing), etc.
-
- You dont state your development tools. If they are Think Pascal, or Think
- C, you should look at the code of CSwitchboard, CAbstractText,
- CTextEditTask, CTextStyleTask and CEditText for how this is done in the
- TCL. If you intend to use TE for your text engine, this would be a good
- model (whether or not you are using objects). If you intend to use styled
- TE, then you will also need to look at CStyledText and the styledTE task
- objects as well. if you want to see these in action, build the
- NewClassDemo project, it showcases both forms of TE based editors. Of
- course, that will limit you to 32000 character files.
-
- The TCL alters the actual data, but remembers how to undo the alteration.
- It is arguably better to provide a means of describing the underlying data
- which allows you to specify changes in a nondestructive manner.
-
- For non TE displayed text, one might establish an array of
- handle/offset/run triplets (frags) which together comprise a virtual
- buffer. This would allow the original text to exist in a handle, with
- subsequent revision text existing in other handles, and the array
- determines which fragments are readout in what order. Any deleted text
- will split its frag into 2, any added text will add a frag. ancilliary
- lists might be used to track the frags of each handle, so that one can
- determine when it contributes nothing. Your undo would track the changes
- made to the frag list, and would itself be part of the filter used in
- reading out the text. You are on your own as to what to do for style
- changes, IM 6:15.38 has a very nice picture of how a styled TE tracks data,
- you could take it for a model (but useing 24 or even 32 bit offsets),
- unless your chosen text engine already has something better.
-
- When your user does a Save, you would readout the frags into a new handle,
- and reduce the array to a single frag again. Obviously, all those handles
- will need locking from time-time, so this is a major exercise in paranoia.
- You will want to have continuous typing be directed into one handle, as it
- should be considered one undo.
-
- Oh, BTW, good luck.
- --
-
- Dana S Emery <de19@umail.umd.edu>
-