Loading ...
Sorry, an error occurred while loading the content.

tiny subset of Xcode's external editor support

Expand Messages
  • Eckehard Berns
    Hi! Since FEAT_CW_EDITOR is on by default even for Mac OS X I have changed it a bit to be usable for Xcode when building Vim with gcc. The only things that
    Message 1 of 1 , Feb 1, 2004
    • 0 Attachment
      Hi!

      Since FEAT_CW_EDITOR is on by default even for Mac OS X I have changed
      it a bit to be usable for Xcode when building Vim with gcc. The only
      things that work for me when I use Vim as an external editor are:
      opening files (and in case of the "Errors and Warnings" list in the
      project window jumping to the correct line) and showing the list of
      unsaved files in Vim. Hitting "Save all" doesn't do anything at the
      moment; e.g. you need to save these files yourself in Vim. I appended
      a diff against Vim 6.2.216 below.

      There's also a compiler definition that works with Xcode. It uses the
      command line utility xcodebuild to compile your active target and
      buildstyle (similar to the pbx compiler definitions):

      -----------8<----------------8<---------------
      if exists("current_compiler")
      finish
      endif
      let current_compiler = "xcode"

      set makeprg=xcodebuild\ -activetarget\ -activebuildstyle
      -----------8<----------------8<---------------

      Here's the patch for the tiny subset of Xcode's external editor support:

      diff -cr ../vim62.216/src/gui_mac.c ./src/gui_mac.c
      *** ../vim62.216/src/gui_mac.c Mon Jan 26 18:16:14 2004
      --- ./src/gui_mac.c Sun Feb 1 20:49:17 2004
      ***************
      *** 546,551 ****
      --- 546,554 ----
      * ------------------------------------------------------------
      */
      #ifdef FEAT_CW_EDITOR
      + #ifdef __GNUC__
      + #undef DEBUG_CW_EDITOR
      + #endif

      /*
      * Handle the Window Search event from CodeWarrior
      ***************
      *** 571,577 ****
      *
      */

      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct WindowSearch WindowSearch;
      --- 574,580 ----
      *
      */

      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct WindowSearch WindowSearch;
      ***************
      *** 580,586 ****
      FSSpec theFile; // identifies the file
      long *theDate; // where to put the modification date/time
      };
      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      --- 583,589 ----
      FSSpec theFile; // identifies the file
      long *theDate; // where to put the modification date/time
      };
      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      ***************
      *** 631,636 ****
      --- 634,646 ----
      if (foundFile == false)
      printf (" NOT");
      printf (" found. [date %lx, %lx]\n", *SearchData.theDate, buf->b_mtime_read);
      + #elif defined(DEBUG_CW_EDITOR)
      + printf ("KAHL_SRCH: file \"%s\" {%ld}", SearchData.theFile.name + 1,
      + SearchData.theFile.parID);
      + if (foundFile == false)
      + printf (" NOT");
      + printf (" found. [date %lx, %lx]\n", *SearchData.theDate,
      + buf->b_mtime_read);
      #endif

      return error;
      ***************
      *** 663,669 ****
      *
      */

      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct ModificationInfo ModificationInfo;
      --- 673,679 ----
      *
      */

      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct ModificationInfo ModificationInfo;
      ***************
      *** 673,679 ****
      long theDate; // the date/time the file was last modified
      short saved; // set this to zero when replying, unused
      };
      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      --- 683,689 ----
      long theDate; // the date/time the file was last modified
      short saved; // set this to zero when replying, unused
      };
      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      ***************
      *** 727,733 ****
      --- 737,747 ----

      numFiles = 0;
      for (buf = firstbuf; buf != NULL; buf = buf->b_next)
      + #if defined(__GNUC__)
      + if (buf->b_changed)
      + #else
      if (buf->b_ml.ml_mfp != NULL)
      + #endif
      {
      /* Add this file to the list */
      theFile.theFile = buf->b_FSSpec;
      ***************
      *** 743,753 ****
      --- 757,778 ----
      if (error)
      printf (" (%d)", error);
      numFiles++;
      + #elif defined(DEBUG_CW_EDITOR)
      + if (numFiles == 0)
      + printf ("KAHL_MOD: ");
      + else
      + printf (", ");
      + printf ("\"%s\" {%ld} [date %lx, %lx]", theFile.theFile.name + 1, theFile.theFile.parID, theFile.theDate, buf->b_mtime_read);
      + if (error)
      + printf (" (%d)", error);
      + numFiles++;
      #endif
      };

      #ifdef USE_SIOUX
      printf ("\n");
      + #elif defined(DEBUG_CW_EDITOR)
      + printf ("\n");
      #endif

      #if 0
      ***************
      *** 797,803 ****
      *
      */

      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct CW_GetText CW_GetText;
      --- 822,828 ----
      *
      */

      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct CW_GetText CW_GetText;
      ***************
      *** 808,814 ****
      long *unused; /* 0 (not used) */
      long *theDate; /* where to put the modification date/time */
      };
      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      --- 833,839 ----
      long *unused; /* 0 (not used) */
      long *theDate; /* where to put the modification date/time */
      };
      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      ***************
      *** 845,850 ****
      --- 870,879 ----
      break;
      }

      + #ifdef __GNUC__
      + BufferSize = 0; /* make the compiler happy */
      + #endif
      +
      if (foundFile)
      {
      BufferSize = 0; /* GetHandleSize (GetTextData.theText); */
      ***************
      *** 891,896 ****
      --- 920,930 ----
      if (foundFile == false)
      printf (" NOT");
      printf (" found. (BufferSize = %d)\n", BufferSize);
      + #elif defined(DEBUG_CW_EDITOR)
      + printf ("KAHL_GTTX: file \"%s\" {%ld} [date %lx, %lx]", GetTextData.theFile.name, GetTextData.theFile.parID, *GetTextData.theDate, buf->b_mtime_read);
      + if (foundFile == false)
      + printf (" NOT");
      + printf (" found. (BufferSize = %ld)\n", BufferSize);
      #endif

      error = HandleUnusedParms (theAEvent);
      ***************
      *** 961,967 ****


      anErr = FindProcessBySignature( 'APPL', 'CWIE', &psn );
      ! #ifdef USE_SIOUX
      printf ("CodeWarrior is");
      if (anErr != noErr)
      printf (" NOT");
      --- 995,1001 ----


      anErr = FindProcessBySignature( 'APPL', 'CWIE', &psn );
      ! #if defined(USE_SIOUX) || defined(DEBUG_CW_EDITOR)
      printf ("CodeWarrior is");
      if (anErr != noErr)
      printf (" NOT");
      ***************
      *** 1054,1060 ****
      *
      */

      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct SelectionRange SelectionRange;
      --- 1088,1094 ----
      *
      */

      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=mac68k
      #endif
      typedef struct SelectionRange SelectionRange;
      ***************
      *** 1067,1073 ****
      long unused2; // 0 (not used)
      long theDate; // modification date/time
      };
      ! #if defined(__MWERKS__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      --- 1101,1107 ----
      long unused2; // 0 (not used)
      long theDate; // modification date/time
      };
      ! #if defined(__MWERKS__) || defined(__GNUC__) /* only in Codewarrior */
      # pragma options align=reset
      #endif

      ***************
      *** 1099,1105 ****
      short gotPosition = false;
      long lnum;

      ! #ifdef USE_SIOUX
      printf ("aevt_odoc:\n");
      #endif

      --- 1133,1139 ----
      short gotPosition = false;
      long lnum;

      ! #if defined(USE_SIOUX) || defined(DEBUG_CW_EDITOR)
      printf ("aevt_odoc:\n");
      #endif

      ***************
      *** 1131,1136 ****
      --- 1165,1175 ----
      printf ("aevt_odoc: lineNum: %d, startRange %d, endRange %d, [date %lx]\n",
      thePosition.lineNum, thePosition.startRange, thePosition.endRange,
      thePosition.theDate);
      + #elif defined(DEBUG_CW_EDITOR)
      + printf ("aevt_odoc: lineNum: %d, startRange %ld, endRange %ld,"
      + " [date %lx]\n",
      + thePosition.lineNum, thePosition.startRange, thePosition.endRange,
      + thePosition.theDate);
      #endif
      /*
      error = AEGetParamDesc(theAEvent, keyAEPosition, typeChar, &thePosition);
      ***************
      *** 1279,1284 ****
      --- 1318,1325 ----

      #ifdef USE_SIOUX
      printf ("Unknown Event: %x\n", theAEvent->descriptorType);
      + #elif defined(DEBUG_CW_EDITOR)
      + printf ("Unknown Event: %x\n", (unsigned int)theAEvent->descriptorType);
      #endif

      error = HandleUnusedParms (theAEvent);
      ***************
      *** 5282,5291 ****
      --- 5323,5342 ----
      return 0;

      len = STRLEN(CString);
      + #if defined(DEBUG_CW_EDITOR)
      + /* make sure we can include pascal strings in printf()s */
      + if (len > 254)
      + len = 254;
      + #else
      if (len > 255)
      len = 255;
      + #endif

      + #if defined(DEBUG_CW_EDITOR)
      + for (i = 0; i <= len; i++)
      + #else
      for (i = 0; i < len; i++)
      + #endif
      PascalPtr[i+1] = CString[i];

      PascalPtr[0] = len;
      ***************
      *** 5298,5303 ****
      --- 5349,5361 ----
      char_u *file;
      FSSpec *fileFSSpec;
      {
      + #if defined(__GNUC__)
      + FSRef fsref;
      +
      + FSPathMakeRef(file, &fsref, FALSE);
      + return FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL,
      + fileFSSpec, NULL);
      + #else
      /* From FAQ 8-12 */
      Str255 filePascal;
      CInfoPBRec myCPB;
      ***************
      *** 5317,5322 ****
      --- 5375,5381 ----

      /* TODO: Use an error code mechanism */
      return 0;
      + #endif
      }

      /*

      --
      Eckehard Berns
    Your message has been successfully submitted and would be delivered to recipients shortly.