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

1434Re: Mac-VIM doesn't cooperate with Finder

Expand Messages
  • Eckehard Berns
    Feb 6, 2004
      > In this situation I suppose Vim would be started without file names.
      > Thus you can use the global argument list to keep the dropped files.
      > Then you only need to do something to open the first one once Vim has
      > finished initializing.
      > I suppose the delay is not needed for the Mac, thus we can skip that
      > anyway. Or do you see some flicker when the gvimrc contains settings
      > that change the size or colors of the window?

      The window does resize for me, the font changes and the initial window
      is all white. I don't actually know why. Creating the window is done in
      gui_mch_init() and gui_mch_open() will show it. I'd think that this is
      the supposed way to do it. The window will be created with default
      values first. I don't know when code snaps in to use the values from

      However, this behavior doesn't change with or without the GUI delay.
      And on the Mac this doesn't get into your way since mapping a correctly
      sized window isn't as important as with modern window managers in X11
      which might try to find the best place to move the window to. Because
      of that, and because reading the initial filelist in the delay works
      nice I'd rather keep the GUI delay.

      > You could actually handle the drop events in the delay, but instead of
      > opening the files they should be put in the argument list that main()
      > uses somehow. Don't know if this works without side effects...

      I tried that. And it was easier than I thought. I was prepared to
      shuffle argv a bit, but when I saw the global_alist, it was quite easy.
      I then checked main() for usage of the global_alist between the
      argument parsing and the GUI delay. I could only make out the expanding
      of the filenames, which isn't needed (nor wanted) for the files from
      the AppleEvent. But maybe there is code hidden behind function calls
      somewhere. There's also the sourcing of the vimrcs. The argument list
      has never been available at that point for the Mac, so we don't change
      things to the worse.

      With the new code, Benji's vimrc addition to change to the directory of
      the first file in the argument list works again. My previous proposal
      broke that nice feature. One could argue that this would be the time to
      add this feature to the Vim binary, but I'm not sure about that.

      Here's the patch (I don't know if one could omit the #ifdef's since I'm
      doing nothing OS X specific--I'm just afraid of breaking Mac OS Classic
      versions and added them as a precaution):

      diff -cr ../vim62.238/src/gui_mac.c ./src/gui_mac.c
      *** ../vim62.238/src/gui_mac.c Mon Jan 26 18:16:14 2004
      --- ./src/gui_mac.c Fri Feb 6 20:13:03 2004
      *** 1162,1167 ****
      --- 1162,1184 ----
      return (error);

      + #ifdef MACOS_X_UNIX
      + if (starting == 1) {
      + int i;
      + char_u *p;
      + /* these are the initial files dropped on the Vim icon */
      + for (i = 0 ; i < numFiles; i++) {
      + if (ga_grow(&global_alist.al_ga, 1) == FAIL
      + || (p = vim_strsave(fnames[i])) == NULL)
      + mch_exit(2);
      + else
      + alist_add(&global_alist, p, 2);
      + }
      + goto finished;
      + }
      + #endif
      /* Handle the drop, :edit to get to the file */
      handle_drop(numFiles, fnames, FALSE);

      *** 1189,1194 ****
      --- 1206,1214 ----

      + #ifdef MACOS_X_UNIX
      + finished:
      + #endif
      AEDisposeDesc(&theList); /* dispose what we allocated */

      error = HandleUnusedParms (theAEvent);

      Eckehard Berns
    • Show all 22 messages in this topic