[ont.micro.mac] Optimizing the TextBox routine

info-mac@utcsrgv.UUCP (info-mac) (07/12/84)

Date: 11 Jul 1984 1008-PDT
Subject: Optimizing the TextBox routine
From: Mike Schuster <uw-beaver!MIKES@CIT-20.ARPA>
To: info-mac@SUMEX-AIM.ARPA

The TextBox(text, length, box, j) routine evidently operates by first
calling EraseRect to erase the box, then calling TENew to allocate a
TERecord, then calling TESetText to stuff the text into the TERecord,
then calling TEUpdate to draw the text, and finally calling TEDispose
to deallocate everything.  Unfortunately, TESetText creates a copy of
the text.  

So, TextBox should not be used as is to draw your private scrap into a
'clipboard' window, especially if your scrap is long.  As an alternative,
you can write your own TextBox that first stuffs the handle to your
private scrap into the hText field of the TERecord, then stuffs the
length of the handle into the TELength field, and finally calls
TECalText to recalculate the lineStarts array, as suggested in Inside
Mac.

The problem with this alternative is that the lineStarts array can get
long.  As a second alternative, you might figure out how many lines will
fit into the box by using information returned by GetFontInfo, and then
scan down your private scrap to find an upper bound on the number of 
characters that will be drawn, by counting end-of-line characters.
Finally, you supply this upper bound as the TElength field.

Mike
(mikes@cit-20,mikes@cit-vax)
-------