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

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

Expand Messages
  • Bram Moolenaar
    Feb 7, 2004
    • 0 Attachment
      Eckehard Berns wrote:

      > > > This feature has already been implemented for the Mac GUI, it just broke
      > > > for Mac OS X when borrowing more code from the Unix ports, I think. I
      > > > have a patch here which should detect the GUI version a bit better
      > > > (isatty(2) returned true even if Vim was started from Finder).
      > >
      > > That is strange. Smells like a bug in isatty().
      >
      > Hmm, not necessarily. ttyname(2) returns "/dev/console", which should be
      > considered a tty. So a better test might be to check ttyname also for
      > Mac OS X. "open -a Vim" will report "/dev/console" also, so that should
      > be a good test to distinguish whether output can be reported to the
      > Terminal or not.

      Aha. I suppose you could see the messages on /dev/console by opening
      it. (never had the idea to look there though).

      > > I wonder, after this change and starting gvim from a terminal window, do
      > > you also get the messages in a popup window? I would rather see them in
      > > the terminal in this situation. But this would require reliably
      > > detecting being started from a terminal, that might be difficult if
      > > isatty() doesn't work.
      >
      > It did popup a message window. When checking against ttyname the
      > behavior is corrected. The altered patch looks like this:

      That looks like a good solution. To stay on the safe side I think we
      should also use isatty(). And add a comment about why it's done this
      way (in two years we will have forgotten all about it).

      Here is the patch with my additions, please check it out:

      *** ../vim-6.2.242/src/main.c Fri Feb 6 19:35:39 2004
      --- src/main.c Sat Feb 7 15:34:40 2004
      ***************
      *** 1160,1165 ****
      --- 1160,1173 ----
      want_full_screen = FALSE;
      #endif

      + #if defined(FEAT_GUI_MAC) && defined(MACOS_X_UNIX)
      + /* When the GUI is started from Finder, need to display messages in a
      + * message box. isatty(2) returns TRUE anyway, thus we need to check the
      + * name to know we're not started from a terminal. */
      + if (gui.starting && strcmp("/dev/console", ttyname(2)) == 0)
      + want_full_screen = FALSE;
      + #endif
      +
      /*
      * mch_init() sets up the terminal (window) for use. This must be
      * done after resetting full_screen, otherwise it may move the cursor
      *** ../vim-6.2.242/src/message.c Mon Feb 2 12:53:51 2004
      --- src/message.c Sat Feb 7 15:39:47 2004
      ***************
      *** 2150,2159 ****

      #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stderr if it's a tty.
      ! * When not going to start the GUI also use stderr. */
      if (
      # ifdef UNIX
      isatty(2)
      # ifdef FEAT_GUI
      ||
      # endif
      --- 2150,2164 ----

      #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stderr if it's a tty.
      ! * When not going to start the GUI also use stderr.
      ! * On Mac, when started from Finder, stderr is the console. */
      if (
      # ifdef UNIX
      + # ifdef MACOS_X_UNIX
      + (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
      + # else
      isatty(2)
      + # endif
      # ifdef FEAT_GUI
      ||
      # endif
      ***************
      *** 2214,2223 ****
      #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stdout if we have a tty. This allows "vim -h | more" and
      * uses mch_errmsg() when started from the desktop.
      ! * When not going to start the GUI also use stdout. */
      if (
      # ifdef UNIX
      isatty(2)
      # ifdef FEAT_GUI
      ||
      # endif
      --- 2219,2233 ----
      #if (defined(UNIX) || defined(FEAT_GUI)) && !defined(ALWAYS_USE_GUI)
      /* On Unix use stdout if we have a tty. This allows "vim -h | more" and
      * uses mch_errmsg() when started from the desktop.
      ! * When not going to start the GUI also use stdout.
      ! * On Mac, when started from Finder, stderr is the console. */
      if (
      # ifdef UNIX
      + # ifdef MACOS_X_UNIX
      + (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0)
      + # else
      isatty(2)
      + # endif
      # ifdef FEAT_GUI
      ||
      # endif


      --
      Q: How many legs does a giraffe have?
      A: Eight: two in front, two behind, two on the left and two on the right

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
    • Show all 22 messages in this topic