[comp.sys.mac.programmer] TextEdit as a paragraph engine

gjditchfield@watmsg.waterloo.edu (Glen Ditchfield) (08/11/89)

I've heard suggestions that, if plain TextEdit is too simple for your
editing needs, then somewhat fancier editors can be built by using TextEdit
as a "paragraph engine".  I haven't heard any details.  Would anyone here
like to explain, ramble, froth, or otherwise expand on this topic?
   For instance, is this done by using one smallish TE record per editor
window and copying text in and out of the record as needed?  What problems
besides TextEdit size limits does it solve?

    Glen Ditchfield  gjditchfield@violet.uwaterloo.ca  Office: DC 2517
Dept. of Computer Science, U of Waterloo, Waterloo, Ontario, Canada, N2L 3G1
	"... and the rest, we will spend foolishly!" -- _Svengali_

minow@mountn.dec.com (Martin Minow) (08/12/89)

In article <28299@watmath.waterloo.edu> gjditchfield@watmsg.waterloo.edu
(Glen Ditchfield) writes:
>
>I've heard suggestions that, if plain TextEdit is too simple for your
>editing needs, then somewhat fancier editors can be built by using TextEdit
>as a "paragraph engine".

TextEdit has a number of internal values stored as signed 16-bit integers.
This limits it to 32K bytes of data and (because there are pixel positions
also stored in 16-bit Points) about 2000 lines (32K / 16 pixel/line).
(This is explained in a recent Inside Mac).  There is also a limit to
the length of a line due to the 16-bit limit.

If you are willing to position paragraphs on the screen, and do a lot
of the scrolling effort yourself, and not allow text selections  to extend
beyond one paragraph, you could "probably" create a separate TextEdit
record for each paragraph of your data.  It's a lot of work, though.

You could even create a TextEdit record for the window, adding and
removing chunks of text from the edit record as lines scroll in
and out of the screen.  Of course, with huge screens and tiny fonts,
you may still exceed TextEdit's limitations.

I've written a TextEdit replacement (coming to MacTutor in the near
future) that doesn't have this limitation.  (It doesn't do styles
or ScriptManager stuff either.)  It took me about a month of evenings
to get it working.  (No, I won't post it to the net before the MacTutor
article is published.)

Martin Minow
minow%thundr.dec@decwrl.dec.com

gf0c+@andrew.cmu.edu (Gregory S. Fox) (08/16/89)

On 11 Aug 89, gjditchfield@watmsg.waterloo.edu (Glen Ditchfield) asks:

> I've heard suggestions that, if plain TextEdit is too simple for your
> editing needs, then somewhat fancier editors can be built by using TextEdit
> as a "paragraph engine".  I haven't heard any details.  Would anyone here
> like to explain, ramble, froth, or otherwise expand on this topic?

Yes.  Don't do it.  It seems really tempting, but you can do better on your
own. Initially, it seemed to me that what you describe could be done-  I was
going to create multiple text handles and two TE records and write
specialized scrolling and clikloops to cross the boundries.  I figured by
keeping the text blocks small, TE wouldn't be too dreadfully slow.  But
there's a problem if one of the records doesn't fill the screen.  The
alternative was, as you say, to keep a central record and copy text in and
out.  Either path is rife with limitations. The biggest problem are the
boundries between chunks of text, esp. if the user is working right at a
break.  You have to call TECalText whenever you swap in, which slows you
down, unless you maintain the line table yourself.

There is more grief to be had, but it's mostly faded from my memory.  I am
also working on a TextEdit replacement.  Most of the calls should be very
similar to TE.  It will handle styles, though probably not the
ScriptManager, and I will post it when I'm satisfied it's working.

Using the Text Manager for > 32k editing is a good example of sunk cost.
You figure, "Hey, there's all this stuff already done.  I'll put in a little
effort patching things together."  But the cost-benefit just isn't there.
The big advantage of doing it yourself is that you've got control over
everything, and you can add whatever whizzy features you like  [eg- PICTs],
instead of constantly discovering new limitations.

My advise to you is to stay away from TE as a serious editor.  Like the Tech
Note says-  it's not a word processor.

--Greg
gf0c@andrew.cmu.edu
Mac II Project programmer