void DoCommand(long mResult) { short theItem; short theMenu; Str255 daName; short daRefNum; theItem = LoWord(mResult); theMenu = HiWord(mResult); switch (theMenu) { case appleID: { if (theItem == 1) { Alert(rUserAlert, nil); } else { /* all non-About items in this menu are DAs */ /* type Str255 is an array in MPW 3 */ GetMenuItemText(GetMenuHandle(appleID), theItem, daName); daRefNum = OpenDeskAcc(daName); } break; } case fileID: { quit = 1; break; } case editID: { if (!SystemEdit(theItem-1)) // call Desk Manager to handle editing command if desk accessory window is the active window { switch (theItem) { case cutCommand: TECut(textH); break; case copyCommand: TECopy(textH); break; case pasteCommand: TEPaste(textH); break; case clearCommand: TEDelete(textH); break; default: break; } } } default: break; } HiliteMenu(0); }
/****pkintextreplace()******************************************************/ void pkintextreplace(char string[256]) { long newend; if (Lquiet == 0) { newend = (*textText)->selEnd; TESetSelect(mactextselect,newend,textText); TEDelete(textText); TEInsert(string,strlen(string), textText); } }
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); }
static PyObject *TEObj_TEDelete(TEObject *_self, PyObject *_args) { PyObject *_res = NULL; #ifndef TEDelete PyMac_PRECHECK(TEDelete); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; TEDelete(_self->ob_itself); Py_INCREF(Py_None); _res = Py_None; return _res; }
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); }
/* 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); }