📄 macint.c
字号:
DoAboutBox (); break; default: { Str255 name; GetMenuItemText (appleMenu, theItem, name); OpenDeskAcc (name); break; } }}/* this should really be in a header for MacFileUtils.c */ extern xlload (char *, int, int); extern xlabort(char *); extern xlisp_wrapup (void); StandardFileReply theFile; SFTypeList fileTypes; Point pt = { 100, 100 }; fileTypes[0] = 'TEXT'; switch (theItem) { case LOAD: case LOAD_NOISILY: StopPasting (); StandardGetFile(NIL, 1, fileTypes, &theFile); if (theFile.sfGood) { Str255 theFullPath; OSErr err; err = OpenWD(theFile.sfFile.vRefNum, theFile.sfFile.parID, 'Nyqu', &wdRefNum); err = SetVol(NIL, wdRefNum); GetFullPath(&theFile.sfFile, theFullPath); if ((xlload((char *) theFullPath, 1, (theItem == LOAD_NOISILY))) == 0) { PrepareForInput (); } break; case QUIT: xlisp_wrapup (); }}static void DoEditMenu (int theItem) { if (SystemEdit (theItem-1) == false) switch (theItem) { case CUT: case COPY: if (ZeroScrap () == noErr) { TECopy (hTERec); /* after copying, export the TE scrap */ if (TEToScrap () != noErr) ZeroScrap (); } if (theItem == CUT) DeleteRange (); break; case PASTE: { long scrapOffset; if (pastedTextH) DisposeHandle (pastedTextH); pastedTextH = (CharsHandle) NewHandle (0); pastedLength = GetScrap (pastedTextH, 'TEXT', &scrapOffset); if (pastedLength < 0) pastedLength = 0; /* error */ else { SetHandleSize (pastedTextH, pastedLength + 1); HLock (pastedTextH); ((char *)(*pastedTextH))[pastedLength] = '\0'; HUnlock (pastedTextH); } } /* and fall through ... */ case CLEAR: DeleteRange (); break; }}static void DoControlMenu (int theItem) { extern xlbreak (char *, char *); extern char *s_unbound; extern xlcontinue (void); extern xlcleanup (void); extern xlabort (char *); extern xltoplevel (void); scrflush (); HiliteMenu (0); switch (theItem) { case BREAK: StopPasting (); xlbreak ("user break", s_unbound); PrepareForInput (); break; case CONTINUE: StopPasting (); xlcontinue (); PrepareForInput (); break; case CLEAN_UP: StopPasting (); xlcleanup (); PrepareForInput (); break; case CANCEL_INPUT: StopPasting (); xlabort ("input canceled"); PrepareForInput (); break; case TOP_LEVEL: StopPasting (); xltoplevel (); PrepareForInput (); break; case SHOW_GRAPHICS: if (gGraphicsShown) HideGrafWin (); else ShowGrafWin (); break; case SPLIT_SCREEN: MoveWindow (gCommandWin, sHorizontal, sVertical, -1); SizeWindow (gCommandWin, sWidth, sHeight, -1); InvalRect (&gCommandWin->portRect); SetTERect (); SetScrollRect (); ShowGrafWin (); MoveWindow (gGraphicsWin, gHorizontal, gVertical, -1); SizeWindow (gGraphicsWin, gWidth, gHeight, -1); break; }}void DoMenu (long choice) { int theMenu = HiWord (choice), theItem = LoWord (choice); HiliteMenu (theMenu); switch (theMenu) { case APPLE_MENU_RES: DoAppleMenu (theItem); break; case FILE_MENU_RES: DoFileMenu (theItem); break; case EDIT_MENU_RES: DoEditMenu (theItem); break; case CONTROL_MENU_RES: DoControlMenu (theItem); break; } HiliteMenu (0);}void AdjustMenus (void) { /* turn the stuff in the Edit menu on and off as necessary */ long temp; DisableItem (editMenu, UNDO); if (TEXTREC->selStart != TEXTREC->selEnd) { EnableItem (editMenu, CUT); EnableItem (editMenu, COPY); EnableItem (editMenu, CLEAR); } else { DisableItem (editMenu, CUT); DisableItem (editMenu, COPY); DisableItem (editMenu, CLEAR); } if (GetScrap (NIL, 'TEXT', &temp) > 0) EnableItem (editMenu, PASTE); else DisableItem (editMenu, PASTE);}RgnHandle rgn = nil;void DoContent (EventRecord *theEvent) { /* handle a click in a window's content region */ ControlHandle theScrollBar; GrafPtr oldPort; int scrollValue; Point mouse = theEvent->where; int thePart;// RgnHandle rgn = nil; GetPort (&oldPort); SetPort (gCommandWin); GlobalToLocal (&mouse); // Get Selected text rgn = NewRgn(); TEGetHiliteRgn(rgn, hTERec); if (thePart = FindControl (mouse, gCommandWin, &theScrollBar)) { switch (thePart) { case kControlUpButtonPart: case kControlDownButtonPart: case kControlPageUpPart: case kControlPageDownPart: scrollValue = TrackControl (theScrollBar, mouse, uppScrollProc); break; case kControlIndicatorPart: scrollValue = GetControlValue (theScrollBar); thePart = TrackControl (theScrollBar, mouse, NIL); if (thePart) { scrollValue -= GetControlValue (theScrollBar); if (scrollValue) TEScroll (0, scrollValue * LINEHEIGHT, hTERec); } break; } } else if (PtInRgn(mouse, rgn)) { if (!DragText(theEvent)) { TEClick(mouse, false, hTERec); } } else if (PtInRect (mouse, &(TEXTREC->viewRect))) { TEClick (mouse, (theEvent->modifiers & shiftKey) != 0, hTERec); } SetPort (oldPort); DisposeRgn(rgn);}void DoEvent (void) { EventRecord theEvent; if ((flashTime) && (--flashTime == 0)) SetSelection (cursorBeforeFlash, cursorBeforeFlash); if (outputBufferLength) FlushOutput (); if (FrontWindow () == gCommandWin) TEIdle (hTERec); recentChar = '\0'; if (WaitNextEvent (everyEvent, &theEvent, 0, gMouseRgn)) { AdjustCursor (theEvent.where, gMouseRgn); switch (theEvent.what) { case kHighLevelEvent: AEProcessAppleEvent(&theEvent); break; case mouseDown: DoMouseDown (&theEvent); break; case keyDown: case autoKey: DoKeyPress (&theEvent); break; case activateEvt: { WindowPtr whichWindow = (WindowPtr)theEvent.message; SetPort (whichWindow); if (whichWindow == gCommandWin) { if ((theEvent.modifiers & activeFlag) == 1) { ActivateCmdWindow(); } else { DeactivateCmdWindow(); } } break; } case updateEvt: { if ((WindowPtr)theEvent.message == gCommandWin) UpdateCmdWindow (); if ((WindowPtr)theEvent.message == gGraphicsWin) UpdateGraphWindow (); break; } case osEvt: if (((theEvent.message >> 24) & 0xff) == suspendResumeMessage) { if (theEvent.message & resumeFlag) { gInBackground = false; if (FrontWindow () == gCommandWin) { ActivateCmdWindow(); } } else { gInBackground = true; if (FrontWindow () == gCommandWin) { SetPort (gCommandWin); DeactivateCmdWindow(); } } } break; } } AdjustCursor (theEvent.where, gMouseRgn);}void MacWrapUp (void) { /* take everything down in preparation for quitting */ CleanupCmdWindow(); CloseWindow (gGraphicsWin);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -