home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / mac / programm / 18516 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  2.8 KB

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