diff options
author | Bram Moolenaar <Bram@vim.org> | 2004-06-20 12:51:53 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2004-06-20 12:51:53 +0000 |
commit | 69a7cb473ceae109b61fae9aa04ee0c29afba5d9 (patch) | |
tree | 04bd3292cc6c2317842d7a46ae3ab11e9956ed99 /src/gui_mac.c | |
parent | ed20346f0b81d1d89c22c9616abe8e47b4c17f08 (diff) |
updated for version 7.0002v7.0002
Diffstat (limited to 'src/gui_mac.c')
-rw-r--r-- | src/gui_mac.c | 907 |
1 files changed, 478 insertions, 429 deletions
diff --git a/src/gui_mac.c b/src/gui_mac.c index 2b74c63281..e6a8433493 100644 --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -74,6 +74,9 @@ static OSType _ftype = 'TEXT'; # endif #endif +/* Vim's Scrap flavor. */ +#define VIMSCRAPFLAVOR 'VIM!' + /* CARBON version only tested with Project Builder under MacOS X */ #undef USE_CARBONIZED #if (defined(__APPLE_CC__) || defined(__MRC__)) && defined(TARGET_API_MAC_CARBON) @@ -326,7 +329,7 @@ static struct */ #ifdef USE_AEVENT -OSErr HandleUnusedParms (const AppleEvent *theAEvent); +OSErr HandleUnusedParms(const AppleEvent *theAEvent); #endif /* @@ -511,7 +514,7 @@ char_u **new_fnames_from_AEDesc(AEDesc *theList, long *numFiles, OSErr *error) if (*error) { #ifdef USE_SIOUX - printf ("fname_from_AEDesc: AECountItems error: %d\n", error); + printf("fname_from_AEDesc: AECountItems error: %d\n", error); #endif return(fnames); } @@ -535,13 +538,13 @@ char_u **new_fnames_from_AEDesc(AEDesc *theList, long *numFiles, OSErr *error) /* Caller is able to clean up */ /* TODO: Should be clean up or not? For safety. */ #ifdef USE_SIOUX - printf ("aevt_odoc: AEGetNthPtr error: %d\n", newError); + printf("aevt_odoc: AEGetNthPtr error: %d\n", newError); #endif return(fnames); } /* Convert the FSSpec to a pathname */ - fnames[fileCount - 1] = FullPathFromFSSpec_save (fileToOpen); + fnames[fileCount - 1] = FullPathFromFSSpec_save(fileToOpen); } return (fnames); @@ -574,7 +577,7 @@ char_u **new_fnames_from_AEDesc(AEDesc *theList, long *numFiles, OSErr *error) * When the editor receives this event, determine whether the specified * file is open. If it is, return the modification date/time for that file * in the appropriate location specified in the structure. If the file is - * not opened, put the value fnfErr (file not found) in that location. + * not opened, put the value fnfErr(file not found) in that location. * */ @@ -591,7 +594,8 @@ struct WindowSearch /* for handling class 'KAHL', event 'SRCH', keyDirectObject # pragma options align=reset #endif -pascal OSErr Handle_KAHL_SRCH_AE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +Handle_KAHL_SRCH_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { OSErr error = noErr; buf_T *buf; @@ -604,16 +608,16 @@ pascal OSErr Handle_KAHL_SRCH_AE (const AppleEvent *theAEvent, AppleEvent *theRe if (error) { #ifdef USE_SIOUX - printf ("KAHL_SRCH: AEGetParamPtr error: %d\n", error); + printf("KAHL_SRCH: AEGetParamPtr error: %d\n", error); #endif return(error); } - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { #ifdef USE_SIOUX - printf ("KAHL_SRCH: HandleUnusedParms error: %d\n", error); + printf("KAHL_SRCH: HandleUnusedParms error: %d\n", error); #endif return(error); } @@ -634,10 +638,10 @@ pascal OSErr Handle_KAHL_SRCH_AE (const AppleEvent *theAEvent, AppleEvent *theRe *SearchData.theDate = buf->b_mtime; #ifdef USE_SIOUX - printf ("KAHL_SRCH: file \"%#s\" {%d}", SearchData.theFile.name,SearchData.theFile.parID); + printf("KAHL_SRCH: file \"%#s\" {%d}", SearchData.theFile.name,SearchData.theFile.parID); if (foundFile == false) - printf (" NOT"); - printf (" found. [date %lx, %lx]\n", *SearchData.theDate, buf->b_mtime_read); + printf(" NOT"); + printf(" found. [date %lx, %lx]\n", *SearchData.theDate, buf->b_mtime_read); #endif return error; @@ -684,7 +688,8 @@ struct ModificationInfo /* for replying to class 'KAHL', event 'MOD ', keyDirect # pragma options align=reset #endif -pascal OSErr Handle_KAHL_MOD_AE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +Handle_KAHL_MOD_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { OSErr error = noErr; AEDescList replyList; @@ -694,11 +699,11 @@ pascal OSErr Handle_KAHL_MOD_AE (const AppleEvent *theAEvent, AppleEvent *theRep theFile.saved = 0; - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { #ifdef USE_SIOUX - printf ("KAHL_MOD: HandleUnusedParms error: %d\n", error); + printf("KAHL_MOD: HandleUnusedParms error: %d\n", error); #endif return(error); } @@ -712,7 +717,7 @@ pascal OSErr Handle_KAHL_MOD_AE (const AppleEvent *theAEvent, AppleEvent *theRep if (error) { #ifdef USE_SIOUX - printf ("KAHL_MOD: AECreateList error: %d\n", error); + printf("KAHL_MOD: AECreateList error: %d\n", error); #endif return(error); } @@ -720,12 +725,12 @@ pascal OSErr Handle_KAHL_MOD_AE (const AppleEvent *theAEvent, AppleEvent *theRep #if 0 error = AECountItems(&replyList, &numFiles); #ifdef USE_SIOUX - printf ("KAHL_MOD ReplyList: %x %x\n", replyList.descriptorType, replyList.dataHandle); - printf ("KAHL_MOD ItemInList: %d\n", numFiles); + printf("KAHL_MOD ReplyList: %x %x\n", replyList.descriptorType, replyList.dataHandle); + printf("KAHL_MOD ItemInList: %d\n", numFiles); #endif - /* AEPutKeyDesc (&replyList, keyAEPnject, &aDesc) - * AEPutKeyPtr (&replyList, keyAEPosition, typeChar, (Ptr)&theType, + /* AEPutKeyDesc(&replyList, keyAEPnject, &aDesc) + * AEPutKeyPtr(&replyList, keyAEPosition, typeChar, (Ptr)&theType, * sizeof(DescType)) */ @@ -739,37 +744,37 @@ pascal OSErr Handle_KAHL_MOD_AE (const AppleEvent *theAEvent, AppleEvent *theRep /* Add this file to the list */ theFile.theFile = buf->b_FSSpec; theFile.theDate = buf->b_mtime; -/* theFile.theDate = time (NULL) & (time_t) 0xFFFFFFF0; */ - error = AEPutPtr (&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile)); +/* theFile.theDate = time(NULL) & (time_t) 0xFFFFFFF0; */ + error = AEPutPtr(&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile)); #ifdef USE_SIOUX if (numFiles == 0) - printf ("KAHL_MOD: "); + printf("KAHL_MOD: "); else - printf (", "); - printf ("\"%#s\" {%d} [date %lx, %lx]", theFile.theFile.name, theFile.theFile.parID, theFile.theDate, buf->b_mtime_read); + printf(", "); + printf("\"%#s\" {%d} [date %lx, %lx]", theFile.theFile.name, theFile.theFile.parID, theFile.theDate, buf->b_mtime_read); if (error) - printf (" (%d)", error); + printf(" (%d)", error); numFiles++; #endif }; #ifdef USE_SIOUX - printf ("\n"); + printf("\n"); #endif #if 0 error = AECountItems(&replyList, &numFiles); #ifdef USE_SIOUX - printf ("KAHL_MOD ItemInList: %d\n", numFiles); + printf("KAHL_MOD ItemInList: %d\n", numFiles); #endif #endif /* We can add data only if something to reply */ - error = AEPutParamDesc (theReply, keyDirectObject, &replyList); + error = AEPutParamDesc(theReply, keyDirectObject, &replyList); #ifdef USE_SIOUX if (error) - printf ("KAHL_MOD: AEPutParamDesc error: %d\n", error); + printf("KAHL_MOD: AEPutParamDesc error: %d\n", error); #endif if (replyList.dataHandle) @@ -819,7 +824,8 @@ struct CW_GetText /* for handling class 'KAHL', event 'GTTX', keyDirectObject ty # pragma options align=reset #endif -pascal OSErr Handle_KAHL_GTTX_AE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +Handle_KAHL_GTTX_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { OSErr error = noErr; buf_T *buf; @@ -839,7 +845,7 @@ pascal OSErr Handle_KAHL_GTTX_AE (const AppleEvent *theAEvent, AppleEvent *theRe if (error) { #ifdef USE_SIOUX - printf ("KAHL_GTTX: AEGetParamPtr error: %d\n", error); + printf("KAHL_GTTX: AEGetParamPtr error: %d\n", error); #endif return(error); } @@ -854,7 +860,7 @@ pascal OSErr Handle_KAHL_GTTX_AE (const AppleEvent *theAEvent, AppleEvent *theRe if (foundFile) { - BufferSize = 0; /* GetHandleSize (GetTextData.theText); */ + BufferSize = 0; /* GetHandleSize(GetTextData.theText); */ for (lineno = 0; lineno <= buf->b_ml.ml_line_count; lineno++) { /* Must use the right buffer */ @@ -863,48 +869,48 @@ pascal OSErr Handle_KAHL_GTTX_AE (const AppleEvent *theAEvent, AppleEvent *theRe lineStart = BufferSize; BufferSize += linesize; /* Resize handle to linesize+1 to include the linefeed */ - SetHandleSize (GetTextData.theText, BufferSize); - if (GetHandleSize (GetTextData.theText) != BufferSize) + SetHandleSize(GetTextData.theText, BufferSize); + if (GetHandleSize(GetTextData.theText) != BufferSize) { #ifdef USE_SIOUX - printf ("KAHL_GTTX: SetHandleSize increase: %d, size %d\n", + printf("KAHL_GTTX: SetHandleSize increase: %d, size %d\n", linesize, BufferSize); #endif break; /* Simple handling for now */ } else { - HLock (GetTextData.theText); + HLock(GetTextData.theText); fullbuffer = (char_u *) *GetTextData.theText; - STRCPY ((char_u *) (fullbuffer + lineStart), line); + STRCPY((char_u *)(fullbuffer + lineStart), line); fullbuffer[BufferSize-1] = '\r'; - HUnlock (GetTextData.theText); + HUnlock(GetTextData.theText); } } if (fullbuffer != NULL) { - HLock (GetTextData.theText); + HLock(GetTextData.theText); fullbuffer[BufferSize-1] = 0; - HUnlock (GetTextData.theText); + HUnlock(GetTextData.theText); } if (foundFile == false) *GetTextData.theDate = fnfErr; else -/* *GetTextData.theDate = time (NULL) & (time_t) 0xFFFFFFF0;*/ +/* *GetTextData.theDate = time(NULL) & (time_t) 0xFFFFFFF0;*/ *GetTextData.theDate = buf->b_mtime; } #ifdef USE_SIOUX - printf ("KAHL_GTTX: file \"%#s\" {%d} [date %lx, %lx]", GetTextData.theFile.name, GetTextData.theFile.parID, *GetTextData.theDate, buf->b_mtime_read); + printf("KAHL_GTTX: file \"%#s\" {%d} [date %lx, %lx]", GetTextData.theFile.name, GetTextData.theFile.parID, *GetTextData.theDate, buf->b_mtime_read); if (foundFile == false) - printf (" NOT"); - printf (" found. (BufferSize = %d)\n", BufferSize); + printf(" NOT"); + printf(" found. (BufferSize = %d)\n", BufferSize); #endif - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { #ifdef USE_SIOUX - printf ("KAHL_GTTX: HandleUnusedParms error: %d\n", error); + printf("KAHL_GTTX: HandleUnusedParms error: %d\n", error); #endif return(error); } @@ -917,48 +923,45 @@ pascal OSErr Handle_KAHL_GTTX_AE (const AppleEvent *theAEvent, AppleEvent *theRe */ /* Taken from MoreAppleEvents:ProcessHelpers*/ -pascal OSErr FindProcessBySignature( const OSType targetType, +pascal OSErr FindProcessBySignature(const OSType targetType, const OSType targetCreator, - ProcessSerialNumberPtr psnPtr ) + ProcessSerialNumberPtr psnPtr) { OSErr anErr = noErr; Boolean lookingForProcess = true; ProcessInfoRec infoRec; - infoRec.processInfoLength = sizeof( ProcessInfoRec ); + infoRec.processInfoLength = sizeof(ProcessInfoRec); infoRec.processName = nil; infoRec.processAppSpec = nil; psnPtr->lowLongOfPSN = kNoProcess; psnPtr->highLongOfPSN = kNoProcess; - while ( lookingForProcess ) + while (lookingForProcess) { - anErr = GetNextProcess( psnPtr ); - if ( anErr != noErr ) - { + anErr = GetNextProcess(psnPtr); + if (anErr != noErr) lookingForProcess = false; - } else { - anErr = GetProcessInformation( psnPtr, &infoRec ); - if ( ( anErr == noErr ) - && ( infoRec.processType == targetType ) - && ( infoRec.processSignature == targetCreator ) ) - { + anErr = GetProcessInformation(psnPtr, &infoRec); + if ((anErr == noErr) + && (infoRec.processType == targetType) + && (infoRec.processSignature == targetCreator)) lookingForProcess = false; - } } } return anErr; }//end FindProcessBySignature -void Send_KAHL_MOD_AE (buf_T *buf) + void +Send_KAHL_MOD_AE(buf_T *buf) { - OSErr anErr = noErr; - AEDesc targetAppDesc = { typeNull, nil }; + OSErr anErr = noErr; + AEDesc targetAppDesc = { typeNull, nil }; ProcessSerialNumber psn = { kNoProcess, kNoProcess }; AppleEvent theReply = { typeNull, nil }; AESendMode sendMode; @@ -967,48 +970,48 @@ void Send_KAHL_MOD_AE (buf_T *buf) ModificationInfo ModData; - anErr = FindProcessBySignature( 'APPL', 'CWIE', &psn ); + anErr = FindProcessBySignature('APPL', 'CWIE', &psn); #ifdef USE_SIOUX - printf ("CodeWarrior is"); + printf("CodeWarrior is"); if (anErr != noErr) - printf (" NOT"); - printf (" running\n"); + printf(" NOT"); + printf(" running\n"); #endif - if ( anErr == noErr ) + if (anErr == noErr) { - anErr = AECreateDesc (typeProcessSerialNumber, &psn, - sizeof( ProcessSerialNumber ), &targetAppDesc); + anErr = AECreateDesc(typeProcessSerialNumber, &psn, + sizeof(ProcessSerialNumber), &targetAppDesc); - if ( anErr == noErr ) + if (anErr == noErr) { anErr = AECreateAppleEvent( 'KAHL', 'MOD ', &targetAppDesc, kAutoGenerateReturnID, kAnyTransactionID, &theEvent); } - AEDisposeDesc( &targetAppDesc ); + AEDisposeDesc(&targetAppDesc); /* Add the parms */ ModData.theFile = buf->b_FSSpec; ModData.theDate = buf->b_mtime; if (anErr == noErr) - anErr =AEPutParamPtr (&theEvent, keyDirectObject, typeChar, &ModData, sizeof(ModData)); + anErr = AEPutParamPtr(&theEvent, keyDirectObject, typeChar, &ModData, sizeof(ModData)); - if ( idleProcUPP == nil ) + if (idleProcUPP == nil) sendMode = kAENoReply; else sendMode = kAEWaitReply; - if ( anErr == noErr ) - anErr = AESend( &theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil ); - if ( anErr == noErr && sendMode == kAEWaitReply ) + if (anErr == noErr) + anErr = AESend(&theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil); + if (anErr == noErr && sendMode == kAEWaitReply) { #ifdef USE_SIOUX - printf ("KAHL_MOD: Send error: %d\n", anErr); + printf("KAHL_MOD: Send error: %d\n", anErr); #endif -/* anErr = AEHGetHandlerError( &theReply );*/ +/* anErr = AEHGetHandlerError(&theReply);*/ } - (void) AEDisposeDesc( &theReply ); + (void) AEDisposeDesc(&theReply); } } #endif /* FEAT_CW_EDITOR */ @@ -1024,7 +1027,8 @@ void Send_KAHL_MOD_AE (buf_T *buf) * Handle the Unused parms of an AppleEvent */ -OSErr HandleUnusedParms (const AppleEvent *theAEvent) + OSErr +HandleUnusedParms(const AppleEvent *theAEvent) { OSErr error; long actualSize; @@ -1086,7 +1090,8 @@ struct SelectionRange /* for handling kCoreClassEvent:kOpenDocuments:keyAEPositi endRange are all negative, there is no selection range specified. */ -pascal OSErr HandleODocAE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { /* * TODO: Clean up the code with convert the AppleEvent into @@ -1107,7 +1112,7 @@ pascal OSErr HandleODocAE (const AppleEvent *theAEvent, AppleEvent *theReply, lo long lnum; #ifdef USE_SIOUX - printf ("aevt_odoc:\n"); + printf("aevt_odoc:\n"); #endif /* the direct object parameter is the list of aliases to files (one or more) */ @@ -1115,7 +1120,7 @@ pascal OSErr HandleODocAE (const AppleEvent *theAEvent, AppleEvent *theReply, lo if (error) { #ifdef USE_SIOUX - printf ("aevt_odoc: AEGetParamDesc error: %d\n", error); + printf("aevt_odoc: AEGetParamDesc error: %d\n", error); #endif return(error); } @@ -1129,13 +1134,13 @@ pascal OSErr HandleODocAE (const AppleEvent *theAEvent, AppleEvent *theReply, lo if (error) { #ifdef USE_SIOUX - printf ("aevt_odoc: AEGetParamPtr error: %d\n", error); + printf("aevt_odoc: AEGetParamPtr error: %d\n", error); #endif return(error); } #ifdef USE_SIOUX - printf ("aevt_odoc: lineNum: %d, startRange %d, endRange %d, [date %lx]\n", + printf("aevt_odoc: lineNum: %d, startRange %d, endRange %d, [date %lx]\n", thePosition.lineNum, thePosition.startRange, thePosition.endRange, thePosition.theDate); #endif @@ -1216,11 +1221,11 @@ pascal OSErr HandleODocAE (const AppleEvent *theAEvent, AppleEvent *theReply, lo finished: AEDisposeDesc(&theList); /* dispose what we allocated */ - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { #ifdef USE_SIOUX - printf ("aevt_odoc: HandleUnusedParms error: %d\n", error); + printf("aevt_odoc: HandleUnusedParms error: %d\n", error); #endif return(error); } @@ -1231,15 +1236,16 @@ pascal OSErr HandleODocAE (const AppleEvent *theAEvent, AppleEvent *theReply, lo * */ -pascal OSErr Handle_aevt_oapp_AE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +Handle_aevt_oapp_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { OSErr error = noErr; #ifdef USE_SIOUX - printf ("aevt_oapp:\n"); + printf("aevt_oapp:\n"); #endif - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { return(error); @@ -1252,15 +1258,16 @@ pascal OSErr Handle_aevt_oapp_AE (const AppleEvent *theAEvent, AppleEvent *theRe * */ -pascal OSErr Handle_aevt_quit_AE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +Handle_aevt_quit_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { OSErr error = noErr; #ifdef USE_SIOUX - printf ("aevt_quit\n"); + printf("aevt_quit\n"); #endif - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { return(error); @@ -1276,15 +1283,16 @@ pascal OSErr Handle_aevt_quit_AE (const AppleEvent *theAEvent, AppleEvent *theRe * */ -pascal OSErr Handle_aevt_pdoc_AE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +Handle_aevt_pdoc_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { OSErr error = noErr; #ifdef USE_SIOUX - printf ("aevt_pdoc:\n"); + printf("aevt_pdoc:\n"); #endif - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { return(error); @@ -1298,15 +1306,16 @@ pascal OSErr Handle_aevt_pdoc_AE (const AppleEvent *theAEvent, AppleEvent *theRe * * (Just get rid of all the parms) */ -pascal OSErr Handle_unknown_AE (const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) + pascal OSErr +Handle_unknown_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) { OSErr error = noErr; #ifdef USE_SIOUX - printf ("Unknown Event: %x\n", theAEvent->descriptorType); + printf("Unknown Event: %x\n", theAEvent->descriptorType); #endif - error = HandleUnusedParms (theAEvent); + error = HandleUnusedParms(theAEvent); if (error) { return(error); @@ -1324,7 +1333,8 @@ pascal OSErr Handle_unknown_AE (const AppleEvent *theAEvent, AppleEvent *theRepl /* * Install the various AppleEvent Handlers */ -OSErr InstallAEHandlers (void) + OSErr +InstallAEHandlers(void) { OSErr error; @@ -1438,7 +1448,7 @@ OSErr InstallAEHandlers (void) * Returns the index inside the menu wher */ short /* Shoulde we return MenuItemIndex? */ -gui_mac_get_menu_item_index (pMenu) +gui_mac_get_menu_item_index(pMenu) vimmenu_T *pMenu; { short index; @@ -1475,7 +1485,7 @@ gui_mac_get_menu_item_index (pMenu) } static vimmenu_T * -gui_mac_get_vim_menu (menuID, itemIndex, pMenu) +gui_mac_get_vim_menu(menuID, itemIndex, pMenu) short menuID; short itemIndex; vimmenu_T *pMenu; @@ -1529,7 +1539,7 @@ gui_mac_get_vim_menu (menuID, itemIndex, pMenu) */ pascal void -gui_mac_drag_thumb (ControlHandle theControl, short partCode) +gui_mac_drag_thumb(ControlHandle theControl, short partCode) { scrollbar_T *sb; int value, dragging; @@ -1538,13 +1548,13 @@ gui_mac_drag_thumb (ControlHandle theControl, short partCode) theControlToUse = dragged_sb; - sb = gui_find_scrollbar((long) GetControlReference (theControlToUse)); + sb = gui_find_scrollbar((long) GetControlReference(theControlToUse)); if (sb == NULL) return; /* Need to find value by diff between Old Poss New Pos */ - value = GetControl32BitValue (theControlToUse); + value = GetControl32BitValue(theControlToUse); dragging = (partCode != 0); /* When "allow_scrollbar" is FALSE still need to remember the new @@ -1556,7 +1566,7 @@ gui_mac_drag_thumb (ControlHandle theControl, short partCode) pascal void -gui_mac_scroll_action (ControlHandle theControl, short partCode) +gui_mac_scroll_action(ControlHandle theControl, short partCode) { /* TODO: have live support */ scrollbar_T *sb, *sb_info; @@ -1566,7 +1576,7 @@ gui_mac_scroll_action (ControlHandle theControl, short partCode) int dragging = FALSE; int dont_scroll_save = dont_scroll; - sb = gui_find_scrollbar((long) GetControlReference (theControl)); + sb = gui_find_scrollbar((long)GetControlReference(theControl)); if (sb == NULL) return; @@ -1648,7 +1658,7 @@ gui_mac_scroll_action (ControlHandle theControl, short partCode) * TODO: Add support for potential TOOLBAR */ void -gui_mac_doInContentClick (theEvent, whichWindow) +gui_mac_doInContentClick(theEvent, whichWindow) EventRecord *theEvent; WindowPtr whichWindow; { @@ -1660,10 +1670,10 @@ gui_mac_doInContentClick (theEvent, whichWindow) short dblClick; thePoint = theEvent->where; - GlobalToLocal (&thePoint); - SelectWindow (whichWindow); + GlobalToLocal(&thePoint); + SelectWindow(whichWindow); - thePortion = FindControl (thePoint, whichWindow, &theControl); + thePortion = FindControl(thePoint, whichWindow, &theControl); if (theControl != NUL) { @@ -1685,7 +1695,7 @@ gui_mac_doInContentClick (theEvent, whichWindow) #endif /* pass 0 as the part to tell gui_mac_drag_thumb, that the mouse * button has been released */ - gui_mac_drag_thumb (theControl, 0); /* Should it be thePortion ? (Dany) */ + gui_mac_drag_thumb(theControl, 0); /* Should it be thePortion ? (Dany) */ dragged_sb = NULL; } } @@ -1731,7 +1741,7 @@ gui_mac_doInContentClick (theEvent, whichWindow) #endif #endif { - SetRect (&dragRect, FILL_X(X_2_COL(thePoint.h)), + SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), FILL_Y(Y_2_ROW(thePoint.v)), FILL_X(X_2_COL(thePoint.h)+1), FILL_Y(Y_2_ROW(thePoint.v)+1)); @@ -1746,7 +1756,7 @@ gui_mac_doInContentClick (theEvent, whichWindow) * Handle the click in the titlebar (to move the window) */ void -gui_mac_doInDragClick (where, whichWindow) +gui_mac_doInDragClick(where, whichWindow) Point where; WindowPtr whichWindow; { @@ -1755,11 +1765,11 @@ gui_mac_doInDragClick (where, whichWindow) /* TODO: may try to prevent move outside screen? */ #ifdef USE_CARBONIZED - movingLimitsPtr = GetRegionBounds ( GetGrayRgn(), &movingLimits ); + movingLimitsPtr = GetRegionBounds(GetGrayRgn(), &movingLimits); #else movingLimitsPtr = &(*GetGrayRgn())->rgnBBox; #endif - DragWindow (whichWindow, where, movingLimitsPtr); + DragWindow(whichWindow, where, movingLimitsPtr); } /* @@ -1779,7 +1789,7 @@ gui_mac_doInGrowClick(where, whichWindow) #ifdef USE_CARBONIZED Rect NewContentRect; - resizeLimitsPtr = GetRegionBounds ( GetGrayRgn(), &resizeLimits ); + resizeLimitsPtr = GetRegionBounds(GetGrayRgn(), &resizeLimits); #else resizeLimits = qd.screenBits.bounds; #endif @@ -1919,17 +1929,17 @@ gui_mac_doUpdateEvent(event) whichWindow = (WindowPtr) event->message; /* Save Current Port */ - GetPort (&savePort); + GetPort(&savePort); /* Select the Window's Port */ #ifdef USE_CARBONIZED - SetPortWindowPort (whichWindow); + SetPortWindowPort(whichWindow); #else - SetPort (whichWindow); + SetPort(whichWindow); #endif /* Let's update the window */ - BeginUpdate (whichWindow); + BeginUpdate(whichWindow); /* Redraw the biggest rectangle covering the area * to be updated. */ @@ -1945,9 +1955,9 @@ gui_mac_doUpdateEvent(event) updateRgn = whichWindow->visRgn; #endif /* Use the HLock useless in Carbon? Is it harmful?*/ - HLock ((Handle) updateRgn); + HLock((Handle) updateRgn); #ifdef USE_CARBONIZED - updateRectPtr = GetRegionBounds ( updateRgn, &updateRect ); + updateRectPtr = GetRegionBounds(updateRgn, &updateRect); # if 0 /* Code from original Carbon Port (using GetWindowRegion. * I believe the UpdateRgn is already in local (Dany) @@ -1966,33 +1976,33 @@ gui_mac_doUpdateEvent(event) gui_mch_set_bg_color(gui.back_pixel); if (updateRectPtr->left < FILL_X(0)) { - SetRect (&rc, 0, 0, FILL_X(0), FILL_Y(Rows)); - EraseRect (&rc); + SetRect(&rc, 0, 0, FILL_X(0), FILL_Y(Rows)); + EraseRect(&rc); } if (updateRectPtr->top < FILL_Y(0)) { - SetRect (&rc, 0, 0, FILL_X(Columns), FILL_Y(0)); - EraseRect (&rc); + SetRect(&rc, 0, 0, FILL_X(Columns), FILL_Y(0)); + EraseRect(&rc); } if (updateRectPtr->right > FILL_X(Columns)) { - SetRect (&rc, FILL_X(Columns), 0, + SetRect(&rc, FILL_X(Columns), 0, FILL_X(Columns) + gui.border_offset, FILL_Y(Rows)); - EraseRect (&rc); + EraseRect(&rc); } if (updateRectPtr->bottom > FILL_Y(Rows)) { - SetRect (&rc, 0, FILL_Y(Rows), FILL_X(Columns) + gui.border_offset, + SetRect(&rc, 0, FILL_Y(Rows), FILL_X(Columns) + gui.border_offset, FILL_Y(Rows) + gui.border_offset); - EraseRect (&rc); + EraseRect(&rc); } - HUnlock ((Handle) updateRgn); + HUnlock((Handle) updateRgn); #ifdef USE_CARBONIZED - DisposeRgn (updateRgn); + DisposeRgn(updateRgn); #endif /* Update scrollbars */ - DrawControls (whichWindow); + DrawControls(whichWindow); /* Update the GrowBox */ /* Taken from FAQ 33-27 */ @@ -2004,15 +2014,15 @@ gui_mac_doUpdateEvent(event) growRect.top = growRect.bottom - 15; growRect.left = growRect.right - 15; #endif - GetClip (saveRgn); - ClipRect (&growRect); - DrawGrowIcon (whichWindow); - SetClip (saveRgn); - DisposeRgn (saveRgn); - EndUpdate (whichWindow); + GetClip(saveRgn); + ClipRect(&growRect); + DrawGrowIcon(whichWindow); + SetClip(saveRgn); + DisposeRgn(saveRgn); + EndUpdate(whichWindow); /* Restore original Port */ - SetPort (savePort); + SetPort(savePort); } /* @@ -2040,8 +2050,8 @@ gui_mac_doActivateEvent(event) #if 0 /* Removed by Dany as per above June 2001 */ a_bool = false; - SetPreserveGlyph (a_bool); - SetOutlinePreferred (a_bool); + SetPreserveGlyph(a_bool); + SetOutlinePreferred(a_bool); #endif } } @@ -2099,8 +2109,20 @@ gui_mac_doKeyEvent(EventRecord *theEvent) /* Intercept CTRL-C */ if (theEvent->modifiers & controlKey) + { if (key_char == Ctrl_C && ctrl_c_interrupts) got_int = TRUE; + else if ((theEvent->modifiers & ~(controlKey|shiftKey)) == 0 + && (key_char == '2' || key_char == '6')) + { + /* CTRL-^ and CTRL-@ don't work in the normal way. */ + if (key_char == '2') + key_char = Ctrl_AT; + else + key_char = Ctrl_HAT; + theEvent->modifiers = 0; + } + } /* Intercept CMD-. */ if (theEvent->modifiers & cmdKey) @@ -2143,8 +2165,8 @@ gui_mac_doKeyEvent(EventRecord *theEvent) key_char = special_keys[i].vim_code0; else # endif - key_char = TO_SPECIAL( special_keys[i].vim_code0, - special_keys[i].vim_code1 ); + key_char = TO_SPECIAL(special_keys[i].vim_code0, + special_keys[i].vim_code1); key_char = simplify_key(key_char,&modifiers); break; } @@ -2162,36 +2184,38 @@ gui_mac_doKeyEvent(EventRecord *theEvent) { #if 1 /* Clear modifiers when only one modifier is set */ - if( (modifiers == MOD_MASK_SHIFT) || - (modifiers == MOD_MASK_CTRL) || - (modifiers == MOD_MASK_ALT)) + if ((modifiers == MOD_MASK_SHIFT) + || (modifiers == MOD_MASK_CTRL) + || (modifiers == MOD_MASK_ALT)) modifiers = 0; #else - if( modifiers & MOD_MASK_CTRL) + if (modifiers & MOD_MASK_CTRL) modifiers = modifiers & ~MOD_MASK_CTRL; - if( modifiers & MOD_MASK_ALT) + if (modifiers & MOD_MASK_ALT) modifiers = modifiers & ~MOD_MASK_ALT; - if( modifiers & MOD_MASK_SHIFT) + if (modifiers & MOD_MASK_SHIFT) modifiers = modifiers & ~MOD_MASK_SHIFT; #endif } - if( modifiers ) + if (modifiers) { - string[ len++ ] = CSI; - string[ len++ ] = KS_MODIFIER; - string[ len++ ] = modifiers; + string[len++] = CSI; + string[len++] = KS_MODIFIER; + string[len++] = modifiers; } - if( IS_SPECIAL( key_char ) ) + if (IS_SPECIAL(key_char)) { - string[ len++ ] = CSI; - string[ len++ ] = K_SECOND( key_char ); - string[ len++ ] = K_THIRD( key_char ); + string[len++] = CSI; + string[len++] = K_SECOND(key_char); + string[len++] = K_THIRD(key_char); } else { #ifdef FEAT_MBYTE - if (input_conv.vc_type != CONV_NONE) + /* Convert characters when needed (e.g., from MacRoman to latin1). + * This doesn't work for the NUL byte. */ + if (input_conv.vc_type != CONV_NONE && key_char > 0) { char_u from[2], *to; int l; @@ -2236,13 +2260,13 @@ gui_mac_doKeyEvent(EventRecord *theEvent) * Handle MouseClick */ void -gui_mac_doMouseDownEvent (theEvent) +gui_mac_doMouseDownEvent(theEvent) EventRecord *theEvent; { short thePart; WindowPtr whichWindow; - thePart = FindWindow (theEvent->where, &whichWindow); + thePart = FindWindow(theEvent->where, &whichWindow); switch (thePart) { @@ -2251,19 +2275,19 @@ gui_mac_doMouseDownEvent (theEvent) break; case (inMenuBar): - gui_mac_handle_menu(MenuSelect (theEvent->where)); + gui_mac_handle_menu(MenuSelect(theEvent->where)); break; case (inContent): - gui_mac_doInContentClick (theEvent, whichWindow); + gui_mac_doInContentClick(theEvent, whichWindow); break; case (inDrag): - gui_mac_doInDragClick (theEvent->where, whichWindow); + gui_mac_doInDragClick(theEvent->where, whichWindow); break; case (inGrow): - gui_mac_doInGrowClick (theEvent->where, whichWindow); + gui_mac_doInGrowClick(theEvent->where, whichWindow); break; case (inGoAway): @@ -2285,18 +2309,18 @@ gui_mac_doMouseDownEvent (theEvent) * [this event is a moving in and out of a region] */ void -gui_mac_doMouseMovedEvent (event) +gui_mac_doMouseMovedEvent(event) EventRecord *event; { Point thePoint; int_u vimModifiers; thePoint = event->where; - GlobalToLocal (&thePoint); + GlobalToLocal(&thePoint); vimModifiers = EventModifiers2VimMouseModifiers(event->modifiers); if (!Button()) - gui_mouse_moved (thePoint.h, thePoint.v); + gui_mouse_moved(thePoint.h, thePoint.v); else #ifdef USE_CTRLCLICKMENU if (!clickIsPopup) @@ -2305,7 +2329,7 @@ gui_mac_doMouseMovedEvent (event) thePoint.v, FALSE, vimModifiers); /* Reset the region from which we move in and out */ - SetRect (&dragRect, FILL_X(X_2_COL(thePoint.h)), + SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), FILL_Y(Y_2_ROW(thePoint.v)), FILL_X(X_2_COL(thePoint.h)+1), FILL_Y(Y_2_ROW(thePoint.v)+1)); @@ -2319,7 +2343,7 @@ gui_mac_doMouseMovedEvent (event) * Handle the mouse release */ void -gui_mac_doMouseUpEvent (theEvent) +gui_mac_doMouseUpEvent(theEvent) EventRecord *theEvent; { Point thePoint; @@ -2331,7 +2355,7 @@ gui_mac_doMouseUpEvent (theEvent) dragRectEnbl = FALSE; dragRectControl = kCreateEmpty; thePoint = theEvent->where; - GlobalToLocal (&thePoint); + GlobalToLocal(&thePoint); vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers); #ifdef USE_CTRLCLICKMENU @@ -2341,8 +2365,7 @@ gui_mac_doMouseUpEvent (theEvent) clickIsPopup = FALSE; } #endif - gui_send_mouse_event - (MOUSE_RELEASE, thePoint.h, thePoint.v, FALSE, vimModifiers); + gui_send_mouse_event(MOUSE_RELEASE, thePoint.h, thePoint.v, FALSE, vimModifiers); } #ifdef USE_MOUSEWHEEL @@ -2431,7 +2454,7 @@ gui_mac_handle_contextual_menu(event) /* Handle the menu CntxMenuID, CntxMenuItem */ /* The submenu can be handle directly by gui_mac_handle_menu */ /* But what about the current menu, is the meny changed by ContextualMenuSelect */ - gui_mac_handle_menu ((CntxMenuID << 16) + CntxMenuItem); + gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); } else if (CntxMenuID == kCMShowHelpSelected) { @@ -2464,9 +2487,9 @@ gui_mac_handle_menu(menuChoice) { #ifndef USE_CARBONIZED /* Desk Accessory doesn't exist in Carbon */ - appleMenu = GetMenuHandle (menu); - GetMenuItemText (appleMenu, item, itemName); - (void) OpenDeskAcc (itemName); + appleMenu = GetMenuHandle(menu); + GetMenuItemText(appleMenu, item, itemName); + (void) OpenDeskAcc(itemName); #endif } } @@ -2477,7 +2500,7 @@ gui_mac_handle_menu(menuChoice) if (theVimMenu) gui_menu_cb(theVimMenu); } - HiliteMenu (0); + HiliteMenu(0); } /* @@ -2485,7 +2508,7 @@ gui_mac_handle_menu(menuChoice) */ void -gui_mac_handle_event (event) +gui_mac_handle_event(event) EventRecord *event; { OSErr error; @@ -2509,7 +2532,7 @@ gui_mac_handle_event (event) { case (keyDown): case (autoKey): - gui_mac_doKeyEvent (event); + gui_mac_doKeyEvent(event); break; case (keyUp): @@ -2525,7 +2548,7 @@ gui_mac_handle_event (event) break; case (updateEvt): - gui_mac_doUpdateEvent (event); + gui_mac_doUpdateEvent(event); break; case (diskEvt): @@ -2533,17 +2556,17 @@ gui_mac_handle_event (event) break; case (activateEvt): - gui_mac_doActivateEvent (event); + gui_mac_doActivateEvent(event); break; case (osEvt): switch ((event->message >> 24) & 0xFF) { case (0xFA): /* mouseMovedMessage */ |