🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #17735

Re: Tabs in TextEdit

#17735
From: Brian H. Powell
Date: Thu, 30 Jul 1987 17:41
48 lines
3546 bytes
In article <1041@vaxb.calgary.UUCP>, radford@calgary.UUCP (Radford Neal) writes:
> I don't know what the ultimate purpose of all this is, but if it's part
> of a serious program, it seems rather chancy. Where does it say that
> TextEdit won't copy some text to a temporary area and call the text
> measurement routine for that? Searching backwards for the beginning of
> the line certainly won't work then. I don't know why Apple might make
> a change of this sort, but it's certainly not impossible.
     I thought of this, too, so I checked when I first started to make sure
they didn't.  I seriously doubt TE would ever not work on the text in-place.
(after all, when they call StdTxMeas, it's almost always in relation to a
lineStart.  It doesn't make much sense, if you've got all those lineStarts
pointing to the right place, to copy text out to measure it.  Of course, there
may be a good reason five years from now.  Oh well, my program won't run on
that machine.)
     To do anything this deep, you're going to run into cases where IM doesn't
assure you of certain behavior.  (Or in the case of StdTxMeas, at least, they
don't tell you of certain behavior.)  Sure we're living on the edge, but I
think this is a safe solution to the tab problem.  There are several other
ways to do it, and I considered many of them.  Some are safer, but at the
expense of hundreds of lines of code at least, and many have a high
performance overhead.  (my opinion, of course.)  In short, you've got to take
chances when you program on the Mac.  By following IM and the TechNotes to the
letter, you will improve your odds, but if you need to go beyond what IM and
the TN's talk about, you shouldn't just stop programming.  You need to move
with at least as much care as when you were following IM.

> As I recall, the MacTutor stuff had some dicey stuff too, but did rely
> only on features that were at least mentioned in IM.
     Actually, they used some undocumented low-memory globals to call
undocumented TE support routines.  My stuff is UL-approved compared to that.
I relied on two instances of undocumented behavior:
	* that the text I'd measure and draw was not a copy, but that I was
	  looking at part of the whole text.
	* that TE would already have the fontinfo before I'd have to measure
	  a line that consisted only of tabs.  I think this is safe because
	  TE has to show the insertion point before I can enter the tabs.
	  This implies that TE already knows the fontinfo.  This is the reason
	  why StdTxMeas gets called early with byteCount==0 and textAddr==0,
	  by the way.  Even if this changes, you can take out one line of code
	  and my stuff will start working again.  (It's a performance issue.)
There may be others, but I can't think of any right off the top of my head
like this.

     You are right to challenge my work.  Tabs, like marriages, are not
something to be entered into lightly.  Let these comments serve as warning to
those who intend to use my algorithm.

Brian
Technical Details
Message-ID: <8616@ut-sally.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!ut-sally!brian
References: <8587@ut-sally.UUCP> <1041@vaxb.calgary.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!ut-sally!brian
From: brian@ut-sally.UUCP (Brian H. Powell)
Newsgroups: comp.sys.mac
Subject: Re: Tabs in TextEdit
Message-ID: <8616@ut-sally.UUCP>
Date: Thu, 30-Jul-87 13:41:37 EDT
Article-I.D.: ut-sally.8616
Posted: Thu Jul 30 13:41:37 1987
Date-Received: Sat, 1-Aug-87 09:58:19 EDT
References: <8587@ut-sally.UUCP> <1041@vaxb.calgary.UUCP>
Organization: U. Texas CS Dept., Austin, Texas
Lines: 48