⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 macint.c

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 C
📖 第 1 页 / 共 2 页
字号:
/* macint.c - macintosh interface routines for xlisp 2.1e *//* Written by Brian Kendig. *//* The functions here are only called by macstuff.c. */#include <Events.h>#include <Gestalt.h>#include <Memory.h>#include <Menus.h>#include <Events.h>#include <Quickdraw.h>#include <StandardFile.h>#include <TextEdit.h>#include <ToolUtils.h>#include <Traps.h>#include <Windows.h>#include <Controls.h>/* #include <ControlDefinitions.h> */#include <SIOUX.h>#include <AppleEvents.h>#include "macint.h"/* #define FALSE 0#define TRUE 1 */#define NIL ((void *) 0)#include "MacCommandWin.h"#include "macaboutbox.h"#include "MacDrag.h"#include "MacHandleEv.h"#include "macstuff.h"#include "stdio.h"#define TEXTREC		(*hTERec)  /* the command window text record */#define TEXTCHAR(i)	((*(TEXTREC->hText))[i])// Struct for apple event handlingtypedef struct AEventList {    AEEventClass evclass;    AEEventID evid;    void *handler;    long refcon;} AEventList, *AEventListPtr;//===========================================================================// GLOBALS DEFINED HERE USE MacGlobals.h FOR ACCESS//===========================================================================// Menu handlesMenuHandle appleMenu, fileMenu, editMenu, controlMenu;/* command and graphics windows */WindowPtr		gCommandWin, gGraphicsWin;WindowRecord	commandWinRec, bwGraphicsWinRec;CWindowRecord	colorGraphicsWinRec;Boolean			gGraphicsShown, gCommandWinResized = false;// Screen size stuffRect dragRect, sizeRect;int screenWidth, screenHeight;					/* screen dimensions */int sHorizontal, sVertical, sWidth, sHeight;	/* command win, split screen */int gHorizontal, gVertical, gWidth, gHeight;	/* graphics win, split screen */// The Text handleTEHandle hTERec;/* output is buffered *///Handle hOutputBuffer = NULL;int outputBufferLength = 0;// Allocate space for UPPsControlActionUPP uppScrollProc;	TEClickLoopUPP uppScrollClickLoop;//AEEventHandlerUPP uppAEOpenFiles, uppAEQuit;// Text related globalsCharsHandle	pastedTextH = NULL;					/* a handle to pasted text */int			pastedLength = 0;					/* how many chars there are in the paste buffer */int			flashTime = 0, cursorBeforeFlash;	/* for flashing cursor when parens match */char		recentChar;							/* the last character typed */RgnHandle		gMouseRgn;						// holds current mouse regin/* miscellaneous stuff */Boolean		gInBackground;						/* are we in background or not */int wneImplemented;unsigned long startupTicks;Boolean hasColorQD;short howManyFiles = 0, whichFile = 0;  /* keep track of files opened from Finder */// Prototypesstatic pascal OSErr AEQuit (AppleEvent *theAppleEvent, AppleEvent *theReply, long Refcon);static pascal OSErr AEOpenFiles (AppleEvent *theAppleEvent, AppleEvent *theReply, long Refcon);pascal Boolean ScrollClickLoop (void);pascal void ScrollProc (ControlHandle control, short thePart);Rect SetTERect (void);void FlushOutput (void);void ShowGrafWin (void) {    /* make the graphics window visible */    ShowWindow (gGraphicsWin);    SelectWindow (gGraphicsWin);    SetMenuItemText (controlMenu, SHOW_GRAPHICS, "\pHide Graphics");    //AdjustCursor ();    gGraphicsShown = true;}void HideGrafWin (void) {    /* hide the graphics window */    HideWindow (gGraphicsWin);    SetMenuItemText (controlMenu, SHOW_GRAPHICS, "\pShow Graphics");    gGraphicsShown = false;}static void UpdateGraphWindow (){    BeginUpdate (gGraphicsWin);    EndUpdate (gGraphicsWin);}void InitMac (void) {//	{  /* set up memory properly *///		int i;        // fix this later. -EAD        //if (DefltStack < STACKMIN) SetApplLimit (CurStackBase - STACKMIN); //		MaxApplZone ();//		for (i = 0; i < MASTERS; i++) MoreMasters ();//	}    AEventListPtr theAppleEvent;    AEventList theEventList[] = {    { kCoreEventClass, kAEOpenDocuments, AEOpenFiles, 0 },    { kCoreEventClass, kAEQuitApplication, AEQuit, 0 },    { 0, 0, nil, 0 }    };    int i;    /* do all the necessary initialization mumbo-jumbo */    if (StackSpace() < STACKMIN)         SetApplLimit(GetApplLimit() - STACKMIN);    MaxApplZone();    /* printf("New StackSpace %lx GetApplLimit %lx\n",        StackSpace(), GetApplLimit()); */    for (i = 0; i < MASTERS; i++) MoreMasters ();    /* getchar(); */            /* initialize the toolbox */    InitGraf (&qd.thePort);    InitFonts ();    FlushEvents (everyEvent, 0);    InitWindows ();    InitMenus ();    TEInit ();    InitDialogs (NIL);    InitCursor ();    // Setup Callbacks    uppScrollClickLoop = NewTEClickLoopProc(ScrollClickLoop);    uppScrollProc = NewControlActionProc(ScrollProc);        // Handlers for core apple events		    for (theAppleEvent = theEventList; theAppleEvent->handler; theAppleEvent++)        if (AEInstallEventHandler(theAppleEvent->evclass, theAppleEvent->evid, NewAEEventHandlerProc((ProcPtr)theAppleEvent->handler),                    theAppleEvent->refcon, 0) != noErr);        // Set up the SIOUX window    SIOUXSettings.initializeTB = FALSE;			//Toolbox is alread inited    SIOUXSettings.setupmenus = FALSE;			//keep the csound menus    SIOUXSettings.autocloseonquit = TRUE;		//close sioux without asking for save    SIOUXSettings.showstatusline = FALSE;		//no status line    SIOUXSettings.asktosaveonclose = FALSE;		//don't ask to save    SIOUXSettings.toppixel = 40;    SIOUXSettings.leftpixel = 5;        /* see if we have WaitNextEvent and Color Quickdraw */    wneImplemented = (NGetTrapAddress (_WaitNextEvent, ToolTrap) != NGetTrapAddress (_Unimplemented, ToolTrap));    if (NGetTrapAddress ((short) Gestalt, ToolTrap) != NGetTrapAddress (_Unimplemented, ToolTrap)) {        long returnCode;        OSErr err = Gestalt (gestaltQuickdrawVersion, &returnCode);        hasColorQD = ((err == noErr) && (returnCode >= gestalt8BitQD));    } else hasColorQD = false;    {  /* set up menus */        Handle theMenuBar = GetNewMBar (MBAR_RES);        SetMenuBar (theMenuBar);        appleMenu = (MenuHandle)GetMenuHandle (APPLE_MENU_RES);        fileMenu = (MenuHandle)GetMenuHandle (FILE_MENU_RES);        editMenu = (MenuHandle)GetMenuHandle (EDIT_MENU_RES);        controlMenu = (MenuHandle)GetMenuHandle (CONTROL_MENU_RES);        AppendResMenu (appleMenu, 'DRVR');        DrawMenuBar ();    }    /* get the size of the main screen */    screenWidth  = qd.screenBits.bounds.right  - qd.screenBits.bounds.left;    screenHeight = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;    /* compute the size of the graphics window in split-screen mode */    gHorizontal = SCREEN_MARGIN;    gVertical = MBAR_HEIGHT + TITLEBAR_HEIGHT - 1;    gWidth = screenWidth - (SCREEN_MARGIN * 2);    gHeight = GRAFWIN_HEIGHT;    /* compute the size of the command window in split-screen mode */    sHorizontal = SCREEN_MARGIN;    sVertical = MBAR_HEIGHT + TITLEBAR_HEIGHT - 1 + SCREEN_MARGIN + GRAFWIN_HEIGHT;    sWidth = screenWidth - (SCREEN_MARGIN * 2);    sHeight = screenHeight - MBAR_HEIGHT - TITLEBAR_HEIGHT - (SCREEN_MARGIN * 2) - GRAFWIN_HEIGHT - 1;        /* set up size and drag rects */    dragRect = (*GetGrayRgn ())->rgnBBox;//	dragRect.left += DRAG_THRESHOLD;//	dragRect.right -= DRAG_THRESHOLD;//	dragRect.bottom -= DRAG_THRESHOLD;    sizeRect.top = MIN_WIN_HEIGHT;    sizeRect.left = MIN_WIN_WIDTH;    sizeRect.bottom = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top;    sizeRect.right = qd.screenBits.bounds.right - qd.screenBits.bounds.left;        /* create the command window */    gCommandWin = GetNewWindow (CWINRES, &commandWinRec, (WindowPtr) -1L);    SetPort (gCommandWin);    /* create the graphics window */    if (hasColorQD) gGraphicsWin = GetNewCWindow (GWINRES, &colorGraphicsWinRec, (WindowPtr) -1L);    else gGraphicsWin = GetNewWindow (GWINRES, &bwGraphicsWinRec, (WindowPtr) -1L);    startupTicks = TickCount ();  /* take note of what time we're starting up */        // Create mouse regin    gMouseRgn = NewRgn();        // Initalize some command window stuff    InitalizeCmdWindow();        // Turn on text outlineing    TEFeatureFlag(teFOutlineHilite, teBitSet, hTERec);        HideGrafWin ();    {  /* see if the user launched the app by opening text files from the Finder */        short doWhat;\// call to CountAppFiles was commented out, but that left doWhat uninitialized// RBD added this ifdef, I wonder where CountAppFiles came from?#ifdef CountAppFilesDefined        CountAppFiles (&doWhat, &howManyFiles);        if (doWhat != appOpen) howManyFiles = 0;#else        howManyFiles = 0;#endif    }    UpdateCmdWindow ();}static void DoAppleMenu (int theItem) {    switch (theItem) {        case ABOUT_ITEM:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -