SetPort(GetWindowPort(window));
SetPort((GrafPtr)GetWindowPort(window));
void mac_adjusttermcursor(WindowPtr window, Point mouse, RgnHandle cursrgn) {    Session *s;    ControlHandle control;    short part;    int x, y;#if TARGET_API_MAC_CARBON    Cursor arrow;    Rect rect;    RgnHandle visrgn;#endif    SetPort(GetWindowPort(window));    s = (Session *)GetWRefCon(window);    GlobalToLocal(&mouse);    part = FindControl(mouse, window, &control);    if (control == s->scrollbar) {#if TARGET_API_MAC_CARBON	SetCursor(GetQDGlobalsArrow(&arrow));	RectRgn(cursrgn, GetControlBounds(s->scrollbar, &rect));#else	SetCursor(&qd.arrow);	RectRgn(cursrgn, &(*s->scrollbar)->contrlRect);#endif    } else {	x = mouse.h / s->font_width;	y = mouse.v / s->font_height;	if (s->raw_mouse) {#if TARGET_API_MAC_CARBON	    SetCursor(GetQDGlobalsArrow(&arrow));#else	    SetCursor(&qd.arrow);#endif	} else	    SetCursor(*GetCursor(iBeamCursor));	/* Ask for shape changes if we leave this character cell. */	SetRectRgn(cursrgn, x * s->font_width, y * s->font_height,		   (x + 1) * s->font_width, (y + 1) * s->font_height);    }#if TARGET_API_MAC_CARBON    visrgn = NewRgn();    GetPortVisibleRegion(GetWindowPort(window), visrgn);    SectRgn(cursrgn, visrgn, cursrgn);    DisposeRgn(visrgn);#else	    SectRgn(cursrgn, window->visRgn, cursrgn);#endif}