Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 UW 5/3/83; site uw-beaver
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!info-mac
From: info-mac@uw-beaver (info-mac)
Newsgroups: fa.info-mac
Subject: Optimizing the TextBox routine
Message-ID:
Date: Wed, 11-Jul-84 14:04:49 EDT
Article-I.D.: uw-beaver>.1197
Posted: Wed Jul 11 14:04:49 1984
Date-Received: Thu, 12-Jul-84 05:20:53 EDT
Sender: daemon@uw-beave
Organization: U of Washington Computer Science
Lines: 26
From: Mike Schuster
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)
-------
