예제 #1
0
/* append text at the end of a TextEdit window
 */
void NATEappend(na_win *winp, char *data, long len)
{
	TEHandle	hTE = ((nate_win*) winp)->hTE;
	
	TESetSelect(32767, 32767, hTE);
	TEInsert(data, len, hTE);
	TESelView(hTE);
	NATEsetscroll(winp, false, (Rect*) NULL, (Rect*) NULL);
}
예제 #2
0
static void	PrintDocStr(char str[])
{
	if( (**gDocTE).teLength > 10000)	/* clear first half*/
	{
		TESetSelect(0, 5000, gDocTE);
		TEDelete(gDocTE);
	}
	
	TESetSelect((**gDocTE).teLength, (**gDocTE).teLength, gDocTE); /* move to end*/
	TEInsert(str, strlen(str), gDocTE);
	TESelView(gDocTE);
}
예제 #3
0
static PyObject *TEObj_TESelView(TEObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
#ifndef TESelView
    PyMac_PRECHECK(TESelView);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    TESelView(_self->ob_itself);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}
예제 #4
0
static void	PrintLogStr(char str[])
{
	int len=strlen(str);
	
	if( !mac_LogWindow.show ) return;
	
	if( (**gLogTE).teLength > 10000)	/* clear first half*/
	{
		TEFeatureFlag(teFAutoScroll, teBitClear, gLogTE);
		TESetSelect(0, 5000, gLogTE);
		TEDelete(gLogTE);
	}
	
	TESetSelect((**gLogTE).teLength, (**gLogTE).teLength, gLogTE); /* move to end*/
	if( len>=1 && str[len-1]=='\n' ){
		str[len-1]=0; len--;	//convert dos return code to mac's
	}
	TEInsert(str, len, gLogTE);
	TESelView(gLogTE);
	TEFeatureFlag(teFAutoScroll, teBitSet, gLogTE);
}
예제 #5
0
/* 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);
}
예제 #6
0
/* an edit menu handler for TextEdit
 */
short NATEmenup(na_win *winp, WORD menuid, WORD itemno)
{
	MenuHandle	mh = NAmenuh(mEdit);
	TEHandle	hTE = teinfo->hTE;
	TEPtr		pte;
	short		status = NA_NOTPROCESSED;
	
	switch (menuid) {
		case 0:
			pte = *hTE;
			if (pte->selStart != pte->selEnd) {
				EnableItem(mh, iCopy);
				if (!(winp->flags & NATE_READONLY)) {
					EnableItem(mh, iCut);
					EnableItem(mh, iClear);
				}
			} else {
				DisableItem(mh, iCopy);
				if (!(winp->flags & NATE_READONLY)) {
					DisableItem(mh, iCut);
					DisableItem(mh, iClear);
				}
			}
			EnableItem(mh, iSelAll);
			if (!(winp->flags & NATE_READONLY)) {
				EnableItem(mh, iPaste);
			}
			break;

		case mEdit:
			switch (itemno) {
				case iCut:
					TECut(hTE);
					goto DOSCRAP;
					
				case iCopy:
					TECopy(hTE);
				DOSCRAP:
					ZeroScrap();
					TEToScrap();
					goto EDITDONE;
					
				case iPaste:
					TEFromScrap();
					TEPaste(hTE);
					goto EDITDONE;
					
				case iClear:
					TEDelete(hTE);
					goto EDITDONE;
				
				case iSelAll:
					TESetSelect(0, 32767, hTE);
					TESelView(hTE);
				EDITDONE:
					status = NA_PROCESSED;
					NATEsetscroll(winp, false, (Rect*) NULL, (Rect*) NULL);
					break;
			}
		default:
			DisableItem(mh, iSelAll);
			break;
	}
	
	return (status);
}