Article View: comp.sys.mac
Article #18090Re: Tabs in TextEdit
From: Brian H. Powell
Date: Thu, 13 Aug 1987 17:14
Date: Thu, 13 Aug 1987 17:14
53 lines
2729 bytes
2729 bytes
I noticed that my code was pretty slow drawing a line with several tabs
in it, so I made a simple optimization that makes it quite a bit faster.
tabTxMeas still isn't as fast as I want it. If I optimize that much, I'll
post the changes to it, also.
This change keeps tabText from calling tabTxMeas more than once. It used
to call it to measure from the beginning of the line up to every tab. I don't
know why I didn't do this in the first place.
Insert this fragment into the proper place in tabText. You should be
able to figure it out. I put plus signs in front of the new code. (I hope I
got all the plus signs right.)
I pasted this in here, and our ethernet was running slow, so some char-
acters were lost. I think I put them all back right, but no guarantees.
pascal void tabText(byteCount, textBuf, numer, denom)
...
+ register int line_length, line_dh;
...
/* If this is the first tab we've found, we need to go back and find
the beginning of the line so we can figure out how big the tab is
supposed to be. */
if (line_start == NULL) {
line_start = textBuf;
start_limit = *((*current_textedit_hdl)->hText);
while ((*(line_start - 1) != '\r') &&
(line_start > start_limit))
line_start--;
+ line_length = tabTxMeas(traverse_ptr - line_start, line_start,
+ &numer, &denom, &info);
+ } else
+ /* just add in the length of the text we just drew. */
+ line_length += StdTxMeas(traverse_ptr - start_ptr, start_ptr,
+ &numer, &denom, &info);
+
+ /* find the length of the tab. */
+ line_length += line_dh = compute_tab_length(line_length);
+
+ /* Call Move(dh,dv) to move the pen line_dh pixels to the right. */
+ Move(line_dh, 0);
}
...
Brian H. Powell
UUCP: {ihnp4,seismo,ctvax}!ut-sally!brian
ARPA: brian@sally.UTEXAS.EDU
_Work_ _Not Work_
Department of Computer Sciences P.O. Box 5899
Taylor Hall 2.124 Austin, TX 78763-5899
The University of Texas at Austin (512) 346-0835
Austin, TX 78712-1188
(512) 471-9536
Technical Details
Message-ID:
<8730@ut-sally.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!ut-sally!brianReferences:
<8681@ut-sally.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!husc6!ut-sally!brian From: brian@ut-sally.UUCP (Brian H. Powell) Newsgroups: comp.sys.mac Subject: Re: Tabs in TextEdit Message-ID: <8730@ut-sally.UUCP> Date: Thu, 13-Aug-87 13:14:22 EDT Article-I.D.: ut-sally.8730 Posted: Thu Aug 13 13:14:22 1987 Date-Received: Sat, 15-Aug-87 09:40:37 EDT References: <8681@ut-sally.UUCP> Organization: U. Texas CS Dept., Austin, Texas Lines: 53 Summary: small optimization to my code