Article View: net.micro.mac
Article #1117SetStdProcs to impliment tabs
From: VICTOR ROMANO
Date: Fri, 19 Apr 1985 22:51
Date: Fri, 19 Apr 1985 22:51
87 lines
3503 bytes
3503 bytes
S
I am trying to impliment tabs in a TextEdit window, similar
to the Consulair's Edit program. I don't know exactly how
to do it, but I have tried using SetStdProcs to change
the standard text measuring and text drawing routines for
that window. The following is my section of code (in MegaMax C):
#define TABSTOP 100 /* In units of pixels, not char widths */
mystdtxmeas (info, denom, numer, textbuf, bytecount)
/* Parameters are normally reversed in
MegaMax C */
reg char *textbuf;
point *numer, *denom;
finfo *finfo;
reg int bytecount;
{
reg int size;
reg char *s;
size = theport->pnloc.a.h; /* Actually, the pen
location isn't always
right, but I have a way
to make it so. */
s = textbuf; /* We start at beginning
of buffer */
/* Scan each character in buffer for tabs */
while (bytecount--)
{
/* If tab occurs, bring to next tabstop */
if (*textbuf++ == '\t')
{
/* <<< */
size += stdtxmeas(info, denom, numer,
s, textbuf-s-1) + TABSTOP+1;
size -= size % TABSTOP + 1;
s = textbuf;
/* >>> */
}
}
size += stdtxmeas(info, denom, numer, s, textbuf-s)
- theport->pnloc.a.h;
return (size); /* Returning is really a little
more involved in MegaMax.
This isn't the problem. */
}
Of course, then I make the qdprocs pointer txmeas in theport
point to this procedure. This works great, EXCEPT, that it
is very slow. I looked at the code, and it looked very
optimal. I even hand-optimized it, and it is STILL slow.
To test the speed of the division, I replace the lines between
<<< and >>> with:
size += stdtxmeas(info, denom, numer,
s, textbuf-s);
This simulates the normal stdtxmeas, but without tabstops,
and it is STILL slow. Then, I replaced the "if" statement
with if(0) and it became fast. It told me that calling
stdtxmeas several times slows it down considerable, even
though I am still measuring the size of each character
only once.
What can I do, then, to speed up this whole operation?
Obviously, Consulair did it, so it must be possible.
Maybe there is a better way to begin with?
Incidently, I disassembled some of the code in ROM's
stdtxmeas, and it looks like there is a lot of setting up
of things before any measuring of text begins. I think
this is what is slowing everything down -- my way causes
this initialization to occur repetitively. Is there perhaps
a way to bypass the initializing routines?
Incidently, I have a fast working version that only works
for fixed fonts. This was easy because I don't have
to call stdtxmeas at all. But I need to do all this
with proportional fonts as well.
Thanks very much for any help anyone can give.
Victor Romano
Technical Details
Message-ID:
<202@sdcc13.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!harpo!decvax!ittvax!dcdwest!sdcsvax!sdcc3!sdcc13!ee163aheShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site sdcc13.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!harpo!decvax!ittvax!dcdwest!sdcsvax!sdcc3!sdcc13!ee163ahe From: ee163ahe@sdcc13.UUCP (VICTOR ROMANO) Newsgroups: net.micro.mac Subject: SetStdProcs to impliment tabs Message-ID: <202@sdcc13.UUCP> Date: Fri, 19-Apr-85 17:51:16 EST Article-I.D.: sdcc13.202 Posted: Fri Apr 19 17:51:16 1985 Date-Received: Sun, 21-Apr-85 06:03:44 EST Organization: U.C. San Diego, Academic Computer Center Lines: 87 Keywords: tabs,stdprocs,txmeas