home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / acorn / 8358 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1.8 KB

  1. Path: sparky!uunet!mcsun!uknet!acorn!pcolmer
  2. From: pcolmer@acorn.co.uk (Philip Colmer)
  3. Newsgroups: comp.sys.acorn
  4. Subject: How *does* one write a good text editor?
  5. Message-ID: <18053@acorn.co.uk>
  6. Date: 26 Aug 92 11:35:59 GMT
  7. Sender: pcolmer@acorn.co.uk
  8. Organization: Acorn Computers Ltd, Cambridge, England
  9. Lines: 36
  10.  
  11. [ Apologies if you've already read this on comp.sys.acorn.tech, but I
  12. didn't get many responses and there MUST be someone out there who has
  13. some suggestions ]
  14.  
  15. If you were writing a text editor which allowed text effects (eg font
  16. changes, colour changes, etc) to be applied, how would you hold the
  17. data? My initial thoughts are:
  18.   
  19.   * keep the text as one contiguous block of memory
  20.   * keep a linked list of effects, specifying the effect to be applied
  21.     and the start and end character offset for the effect
  22.   * keep a linked list of line start offsets.
  23.  
  24. The line start offsets are calculated using the font manager to format
  25. the text into a given width.
  26.  
  27. When the text is rendered, for a given line, the linked list of
  28. effects is checked and any that need to be applied are applied to that
  29. line of text. By keeping the effects in this manner, it makes it
  30. easier for the code to cope with effects which last more than one
  31. line.
  32.  
  33. Does this seem efficient? It certainly seems to work for a fixed block
  34. of text, but what happens when the user wants to change the text, or
  35. the effects? Doing the formatting can take some time using my
  36. approach.
  37.  
  38. Are there any "standard approaches" for this sort of thing?
  39.  
  40. --Philip
  41.  
  42. ------------------------------------------------------------------------------
  43.  Recommended reading: Rising Sun by Michael Crichton ... a frightening vision
  44.  
  45. ------------------------------------------------------------------------------
  46.  Recommended reading: Rising Sun by Michael Crichton ... a frightening vision
  47.