static PyObject *TEObj_TECalText(TEObject *_self, PyObject *_args) { PyObject *_res = NULL; #ifndef TECalText PyMac_PRECHECK(TECalText); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; TECalText(_self->ob_itself); Py_INCREF(Py_None); _res = Py_None; return _res; }
static int message_LogWin(int message, long /*param*/) { Rect rect; switch(message){ case MW_GROW: rect=win.ref->portRect; //rect.right-=15; rect.bottom-=15; rect = win.ref->portRect; rect.right -= 15; //rect.bottom -= 15; (**gLogTE).viewRect= (**gLogTE).destRect= rect; (**gLogTE).destRect.right = (**gLogTE).destRect.right - 14; TECalText(gLogTE); TESetSelect((**gLogTE).teLength, (**gLogTE).teLength, gLogTE); return 0; } return -1; //not supported }
static int message_DocWin(int message, long param) { switch(message){ case MW_GROW: { Rect rect; rect=win.ref->portRect; //rect.right-=15; rect.bottom-=15; rect = win.ref->portRect; rect.right -= 16; //rect.bottom -= 15; (**gDocTE).viewRect= (**gDocTE).destRect= rect; //(**gDocTE).destRect.right = (**gDocTE).destRect.right - 14; TECalText(gDocTE); TESetSelect((**gDocTE).teLength, (**gDocTE).teLength, gDocTE); return 0; } case MW_DOC_SET: { const char *midiname=(char*)param; char *p, docname[256]; //midiname= (char*)param; strncpy(docname, midiname, sizeof docname - 1); docname[sizeof docname - 1] = '\0'; if((p = strrchr(docname, '.')) == NULL){ return 0; } else if(p - docname >= sizeof docname - 4) { return 0; /* cannot strcpy: that cause buffer overrun */ } if('A' <= p[1] && p[1] <= 'Z') strcpy(p + 1, "DOC"); else strcpy(p + 1, "doc"); TEReadFile( docname, gDocTE ); break; } } return -1; //not supported }
/* Update procedure for textedit window */ short NATEupdatep(na_win *winp, Boolean newsize) { TEHandle hTE = teinfo->hTE; WindowPtr window = winp->pwin; Rect prect, vrect, hrect, drect; prect = window->portRect; prect.top += teinfo->topoff; EraseRect(&prect); hrect = vrect = prect; vrect.top--; hrect.left--; vrect.left = ++vrect.right - 16; hrect.top = ++hrect.bottom - 16; vrect.bottom -= 14; hrect.right -= 14; InsetRect(&prect, 4, 4); prect.right -= 15; if (!(winp->flags & NATE_NOHSCROLL)) prect.bottom -= 15; prect.bottom -= (prect.bottom - prect.top) % teinfo->lheight; if (newsize) { drect = (*hTE)->viewRect = prect; drect.right = drect.left + (short) teinfo->docwidth; (*hTE)->destRect = drect; RectRgn(winp->cursorRgn, &prect); OffsetRgn(winp->cursorRgn, -window->portBits.bounds.left, -window->portBits.bounds.top); TECalText(hTE); TESelView(hTE); if (teinfo->hctrl != (ControlHandle) NULL) HideControl(teinfo->hctrl); if (teinfo->vctrl != (ControlHandle) NULL) HideControl(teinfo->vctrl); } TEUpdate(&prect, hTE); if (newsize) NATEsetscroll(winp, true, &hrect, &vrect); return (NA_NOTPROCESSED); }
/****adjusttext()************************************************************/ void adjusttext(int iforce) /*must call this with iforce==0 before iforce==1 to get calc right*/ { if (Lquiet == 0) { if (iforce > 0) { if(thenoldLines+iforce >= theviewLines) /* would be off the bottom now*/ {/*force a scroll if line would be off bottom from earlier calculation*/ /*m*/ TEScroll(0,-(iforce*textHeight),textText); /* scroll iforce number of lines */ /*m*/ SetControlValue(vtextScroll,maxValue); } thenoldLines = thenoldLines + iforce; } else /*calculate number of lines needed for a scroll to stay on screen*/ { /*m*/ TECalText(textText); thenLines = (*textText)->nLines; /* total lines of text */ thendiff = thenLines - thenoldLines; /*number of lines moved since last adjustment*/ theviewLines = (textdRect.bottom - textdRect.top)/textHeight; /* lines viewed in window */ thenoldLines = thenLines; if (thenLines >= (theviewLines)) { /*m*/ TEScroll(0,-(thendiff*textHeight),textText); /* scroll ndiff lines */ /*m*/ SetControlValue(vtextScroll,maxValue); } } } }