a = (struct do_text_args *)cookie;
static pascal void do_text_for_device(short depth, short devflags,				      GDHandle device, long cookie) {    struct do_text_args *a;    int bgcolour, fgcolour, bright, reverse, tmp;#if TARGET_API_MAC_CARBON    CQDProcsPtr gp = GetPortGrafProcs(GetWindowPort(a->s->window));#else    QDProcsPtr gp = a->s->window->grafProcs;#endif    a = (struct do_text_args *)cookie;    bright = (a->attr & ATTR_BOLD) && a->s->cfg.bold_colour;    reverse = a->attr & ATTR_REVERSE;    if (depth == 1 && (a->attr & TATTR_ACTCURS))	reverse = !reverse;    if (HAVE_COLOR_QD()) {	if (depth > 2) {	    fgcolour = ((a->attr & ATTR_FGMASK) >> ATTR_FGSHIFT);	    fgcolour = (fgcolour & 0xF) * 2 + (fgcolour & 0x10 ? 1 : 0);	    bgcolour = ((a->attr & ATTR_BGMASK) >> ATTR_BGSHIFT);	    bgcolour = (bgcolour & 0xF) * 2 + (bgcolour & 0x10 ? 1 : 0);	} else {	    /*	     * NB: bold reverse in 2bpp breaks with the usual PuTTY model and	     * boldens the background, because that's all we can do.	     */	    fgcolour = bright ? DEFAULT_FG_BOLD : DEFAULT_FG;	    bgcolour = DEFAULT_BG;	}	if (reverse) {	    tmp = fgcolour;	    fgcolour = bgcolour;	    bgcolour = tmp;	}	if (bright && depth > 2)	    fgcolour |= 1;	if ((a->attr & TATTR_ACTCURS) && depth > 1) {	    fgcolour = CURSOR_FG;	    bgcolour = CURSOR_BG;	}	PmForeColor(fgcolour);	PmBackColor(bgcolour);    } else { /* No Color Quickdraw */	/* XXX This should be done with a _little_ more configurability */	if (reverse) {	    ForeColor(blackColor);	    BackColor(whiteColor);	} else {	    ForeColor(whiteColor);	    BackColor(blackColor);	}    }    EraseRect(&a->textrect);    switch (a->lattr & LATTR_MODE) {      case LATTR_NORM:      case LATTR_WIDE:	MoveTo(a->textrect.left, a->textrect.top + a->s->font_ascent);	break;      case LATTR_TOP:	MoveTo(a->textrect.left, a->textrect.top + a->s->font_ascent * 2);	break;      case LATTR_BOT:	MoveTo(a->textrect.left,	       a->textrect.top - a->s->font_height + a->s->font_ascent * 2);	break;    }    /* FIXME: Sort out bold width adjustments on Original QuickDraw. */    if (gp != NULL)	InvokeQDTextUPP(a->len, a->text, a->numer, a->denom, gp->textProc);    else	StdText(a->len, a->text, a->numer, a->denom);    if (a->attr & TATTR_PASCURS) {	PenNormal();	switch (depth) {	  case 1:	    PenMode(patXor);	    break;	  default:	    PmForeColor(CURSOR_BG);	    break;	}	FrameRect(&a->textrect);    }}