home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!acorn!pcolmer
- From: pcolmer@acorn.co.uk (Philip Colmer)
- Newsgroups: comp.sys.acorn
- Subject: How *does* one write a good text editor?
- Message-ID: <18053@acorn.co.uk>
- Date: 26 Aug 92 11:35:59 GMT
- Sender: pcolmer@acorn.co.uk
- Organization: Acorn Computers Ltd, Cambridge, England
- Lines: 36
-
- [ Apologies if you've already read this on comp.sys.acorn.tech, but I
- didn't get many responses and there MUST be someone out there who has
- some suggestions ]
-
- If you were writing a text editor which allowed text effects (eg font
- changes, colour changes, etc) to be applied, how would you hold the
- data? My initial thoughts are:
-
- * keep the text as one contiguous block of memory
- * keep a linked list of effects, specifying the effect to be applied
- and the start and end character offset for the effect
- * keep a linked list of line start offsets.
-
- The line start offsets are calculated using the font manager to format
- the text into a given width.
-
- When the text is rendered, for a given line, the linked list of
- effects is checked and any that need to be applied are applied to that
- line of text. By keeping the effects in this manner, it makes it
- easier for the code to cope with effects which last more than one
- line.
-
- Does this seem efficient? It certainly seems to work for a fixed block
- of text, but what happens when the user wants to change the text, or
- the effects? Doing the formatting can take some time using my
- approach.
-
- Are there any "standard approaches" for this sort of thing?
-
- --Philip
-
- ------------------------------------------------------------------------------
- Recommended reading: Rising Sun by Michael Crichton ... a frightening vision
-
- ------------------------------------------------------------------------------
- Recommended reading: Rising Sun by Michael Crichton ... a frightening vision
-