SetPort(GetWindowPort(window));
SetPort((GrafPtr)GetWindowPort(window));
void mac_clickterm(WindowPtr window, EventRecord *event) {    Session *s;    Point mouse;    ControlHandle control;    int part;    static ControlActionUPP mac_scrolltracker_upp = NULL;    s = (Session *)GetWRefCon(window);    SetPort(GetWindowPort(window));    mouse = event->where;    GlobalToLocal(&mouse);    part = FindControl(mouse, window, &control);    if (control == s->scrollbar) {	switch (part) {	  case kControlIndicatorPart:	    if (TrackControl(control, mouse, NULL) == kControlIndicatorPart)		term_scroll(s->term, +1, GetControlValue(control));	    break;	  case kControlUpButtonPart:	  case kControlDownButtonPart:	  case kControlPageUpPart:	  case kControlPageDownPart:	    if (mac_scrolltracker_upp == NULL)		mac_scrolltracker_upp =		    NewControlActionUPP(&mac_scrolltracker);	    TrackControl(control, mouse, mac_scrolltracker_upp);	    break;	}    } else {	text_click(s, event);    }}