Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!piring.cwi.nl!guido From: guido@piring.cwi.nl (Guido van Rossum) Newsgroups: comp.sys.mac.programmer Subject: Re: Wanted: Code for simple text interface Message-ID: <8299@boring.cwi.nl> Date: 31 Jul 89 21:45:48 GMT References: <9674@phoenix.Princeton.EDU> <43528@bbn.COM> <9676@phoenix.Princeton.EDU> Sender: news@cwi.nl Lines: 33 Well, it seems like you want to write your own textedit-like package, only less fancy, and with some features that textedit doesn't have (or maybe it does, only it's hidden somewhere in the documentation). You could begin by splitting the design in two parts (this is what textedit also does, basically): a data structure to remember the text to be displayed (maybe only the still editable part would be enough, although then you couldn't reconstruct stuff that got temporarily hidden under a desk accessory or some similar thing from outer space, not to mention MultiFinder), and code to display it on the screen, by drawing all characters using quickdraw operations. Editing the buffer is easy: keep a counter of how many characters there are, etc. Conceptually, after each edit operation (append/erase character), you could erase the screen and redraw everything -- if only your code were fast enough to avoid flickering. What you do in practice is keep some extra data around to avoid unnecessary redrawing. The start and ending position of each character in the editable part of the buffer should be sufficient, really. Actually, you can compute this on the fly as well -- quickdraw has some nifty calls to calculate the width of a character. Of course, restricting yourself to a fixed-width font such as monaco would make things a lot easier. Etc., etc.; if you think a bit more about it you'll see it's entirely doable, but you may decide not to implement it as it could be a lot of work (although also a lot of fun). -- Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam guido@cwi.nl or mcvax!guido or guido%cwi.nl@uunet.uu.net "You're so *digital*, girl!" -- Neneh Cherry