[comp.sys.mac] bug in text drawing in MicroEmacs 3.8 code

earleh@dartvax.UUCP (Earle R. Horton) (11/01/87)

There is a bug in some of the source code disks for microemacs 3.8 which
I have sent out, due to an error in the definition of StdText in the
Phone Book edition of Inside Macintosh (and due perhaps to my failure to
look it up in the latest edition!)  This bug results in text drawn on a
Mac II screen being zero pixels high.  If I had a Mac II, I probably would
have noticed it, sooner or later, myself!

Earle

/*
 * Replace the function TTY_WPutText() in TTY_Windows.c with this.
 */
/*
 * TTY_WPutText()	- 	Put a character to the given TTY_Window at the 
 *				current cursor location, advance the cursor. 
 *
 *	ttywPtr 	-	TTY_WindowPtr to be drawn in.
 *	arow, acol	-	position of first character to draw.
 *	n		-	number of characters to draw.
 *	buf		-	ptr to buffer containing the characters.
 */
 
VOID TTY_WPutText(ttywPtr, arow, acol, n, buf)
	TTY_WindowPtr	ttywPtr;
	int16			arow, acol, n;
	char			*buf;
{
	Point 	oldpen_pt;
	register TTY_WindowPeek	ttywPeek;
	GrafPtr	oldPort;

	if(n <= 0) return;
	
	GetPort(&oldPort);
	SetTTY_WPort(ttywPtr);
	
	ttywPeek = (TTY_WindowPeek) ttywPtr;
	
	if(IS_64K_ROM) {
		TTY_WMoveCursAbs(ttywPtr, arow, acol); 
		TTY_WEraseEOL(ttywPtr);
	}

	/* save pen position and move to new point */
	GetPen(&oldpen_pt);
	
	SetPt(&ttywPeek->pen_pt, 
		ttywPeek->left_offset+(acol*ttywPeek->curs_width), 
		ttywPeek->top_offset+ttywPeek->char_ascent+
			(arow*ttywPeek->curs_height));
	MoveTo(ttywPeek->pen_pt.h, ttywPeek->pen_pt.v);
	
	TTY_WBlinkCurs(ttywPeek, CURS_INVIS);

	/* Oops! */
/*	StdText(n-1,buf,0x0101,0x0101);	*/

	StdText(n-1,buf,0x00010001,0x00010001);

	/* Original Inside Macintosh said these were integers. */
	
	/* restore pen position */
	MoveTo(oldpen_pt.h, oldpen_pt.v);
	GetPen(&ttywPeek->pen_pt);
	
	SetPort(oldPort);
}


-- 
*********************************************************************
*Earle R. Horton, H.B. 8000, Dartmouth College, Hanover, NH 03755   *
*********************************************************************