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); }
static PyObject *TEObj_TEPaste(TEObject *_self, PyObject *_args) { PyObject *_res = NULL; #ifndef TEPaste PyMac_PRECHECK(TEPaste); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; TEPaste(_self->ob_itself); Py_INCREF(Py_None); _res = Py_None; return _res; }
/* 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); }