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

Patch 6.0.163

Expand Messages
  • Bram Moolenaar
    Patch 6.0.163 Problem: When using a GUI dialog, a file name is sometimes used like it was a directory. Solution: Separate path and file name properly. For
    Message 1 of 1 , Feb 3, 2002
    • 0 Attachment
      Patch 6.0.163
      Problem: When using a GUI dialog, a file name is sometimes used like it was
      a directory.
      Solution: Separate path and file name properly.
      For GTK, Motif and Athena concatenate directory and file name for
      the default selection.
      Files: src/diff.c, src/ex_cmds.c, src/ex_cmds2.c, src/ex_docmd.c,
      src/gui_athena.c, src/gui_gtk.c, src/gui_motif.c, src/message.c


      *** ../vim60.162/src/diff.c Wed Sep 19 18:36:35 2001
      --- src/diff.c Sun Feb 3 13:43:37 2002
      ***************
      *** 744,751 ****
      #ifdef FEAT_BROWSE
      if (cmdmod.browse)
      {
      ! browseFile = do_browse(TRUE, (char_u *)_("Patch file"),
      ! NULL, NULL, eap->arg, BROWSE_FILTER_ALL_FILES, curbuf);
      if (browseFile == NULL)
      return; /* operation cancelled */
      eap->arg = browseFile;
      --- 744,751 ----
      #ifdef FEAT_BROWSE
      if (cmdmod.browse)
      {
      ! browseFile = do_browse(FALSE, (char_u *)_("Patch file"),
      ! eap->arg, NULL, NULL, BROWSE_FILTER_ALL_FILES, NULL);
      if (browseFile == NULL)
      return; /* operation cancelled */
      eap->arg = browseFile;
      *** ../vim60.162/src/ex_cmds.c Sun Feb 3 12:33:39 2002
      --- src/ex_cmds.c Sun Feb 3 13:29:29 2002
      ***************
      *** 2050,2057 ****
      #ifdef FEAT_BROWSE
      if (cmdmod.browse)
      {
      ! browse_file = do_browse(TRUE, (char_u *)_("Save As"), NULL,
      ! NULL, ffname, NULL, curbuf);
      if (browse_file == NULL)
      goto theend;
      ffname = browse_file;
      --- 2050,2057 ----
      #ifdef FEAT_BROWSE
      if (cmdmod.browse)
      {
      ! browse_file = do_browse(TRUE, (char_u *)_("Save As"), ffname,
      ! NULL, NULL, NULL, curbuf);
      if (browse_file == NULL)
      goto theend;
      ffname = browse_file;
      ***************
      *** 2308,2314 ****
      /* ":browse wall": ask for file name if there isn't one */
      if (buf->b_ffname == NULL && cmdmod.browse)
      buf->b_ffname = do_browse(TRUE, (char_u *)_("Save As"), NULL,
      ! NULL, (char_u *)"", NULL, buf);
      #endif
      if (buf->b_ffname == NULL)
      {
      --- 2308,2314 ----
      /* ":browse wall": ask for file name if there isn't one */
      if (buf->b_ffname == NULL && cmdmod.browse)
      buf->b_ffname = do_browse(TRUE, (char_u *)_("Save As"), NULL,
      ! NULL, NULL, NULL, buf);
      #endif
      if (buf->b_ffname == NULL)
      {
      ***************
      *** 2535,2542 ****
      #ifdef FEAT_BROWSE
      if (cmdmod.browse)
      {
      ! browse_file = do_browse(FALSE, (char_u *)_("Edit File"), NULL,
      ! NULL, ffname, NULL, curbuf);
      if (browse_file == NULL)
      goto theend;
      ffname = browse_file;
      --- 2535,2542 ----
      #ifdef FEAT_BROWSE
      if (cmdmod.browse)
      {
      ! browse_file = do_browse(FALSE, (char_u *)_("Edit File"), ffname,
      ! NULL, NULL, NULL, curbuf);
      if (browse_file == NULL)
      goto theend;
      ffname = browse_file;
      *** ../vim60.162/src/ex_cmds2.c Wed Oct 31 10:12:03 2001
      --- src/ex_cmds2.c Sun Feb 3 13:44:58 2002
      ***************
      *** 1711,1718 ****
      {
      char_u *fname = NULL;

      ! fname = do_browse(FALSE, (char_u *)_("Run Macro"),
      ! NULL, NULL, eap->arg, BROWSE_FILTER_MACROS, curbuf);
      if (fname != NULL)
      {
      cmd_source(fname, eap);
      --- 1711,1718 ----
      {
      char_u *fname = NULL;

      ! fname = do_browse(FALSE, (char_u *)_("Run Macro"), eap->arg,
      ! NULL, NULL, BROWSE_FILTER_MACROS, NULL);
      if (fname != NULL)
      {
      cmd_source(fname, eap);
      *** ../vim60.162/src/ex_docmd.c Wed Jan 30 16:52:44 2002
      --- src/ex_docmd.c Sun Feb 3 13:47:11 2002
      ***************
      *** 5554,5560 ****
      && eap->cmdidx != CMD_new)
      {
      fname = do_browse(FALSE, (char_u *)_("Edit File in new window"),
      ! NULL, NULL, eap->arg, NULL, curbuf);
      if (fname == NULL)
      goto theend;
      eap->arg = fname;
      --- 5554,5560 ----
      && eap->cmdidx != CMD_new)
      {
      fname = do_browse(FALSE, (char_u *)_("Edit File in new window"),
      ! eap->arg, NULL, NULL, NULL, curbuf);
      if (fname == NULL)
      goto theend;
      eap->arg = fname;
      ***************
      *** 5923,5930 ****
      {
      char_u *browseFile;

      ! browseFile = do_browse(FALSE, (char_u *)_("Append File"), NULL,
      ! NULL, eap->arg, NULL, curbuf);
      if (browseFile != NULL)
      {
      i = readfile(browseFile, NULL,
      --- 5923,5930 ----
      {
      char_u *browseFile;

      ! browseFile = do_browse(FALSE, (char_u *)_("Append File"), eap->arg,
      ! NULL, NULL, NULL, curbuf);
      if (browseFile != NULL)
      {
      i = readfile(browseFile, NULL,
      ***************
      *** 6449,6455 ****
      if (cmdmod.browse)
      {
      browseFile = do_browse(TRUE, (char_u *)_("Save Redirection"),
      ! NULL, NULL, eap->arg, BROWSE_FILTER_ALL_FILES, curbuf);
      if (browseFile == NULL)
      return; /* operation cancelled */
      eap->arg = browseFile;
      --- 6449,6455 ----
      if (cmdmod.browse)
      {
      browseFile = do_browse(TRUE, (char_u *)_("Save Redirection"),
      ! eap->arg, NULL, NULL, BROWSE_FILTER_ALL_FILES, curbuf);
      if (browseFile == NULL)
      return; /* operation cancelled */
      eap->arg = browseFile;
      ***************
      *** 6601,6607 ****
      eap->cmdidx == CMD_mksession ? (char_u *)_("Save Session") :
      # endif
      (char_u *)_("Save Setup"),
      ! NULL, (char_u *)"vim", fname, BROWSE_FILTER_MACROS, curbuf);
      if (browseFile == NULL)
      goto theend;
      fname = browseFile;
      --- 6601,6607 ----
      eap->cmdidx == CMD_mksession ? (char_u *)_("Save Session") :
      # endif
      (char_u *)_("Save Setup"),
      ! fname, (char_u *)"vim", NULL, BROWSE_FILTER_MACROS, NULL);
      if (browseFile == NULL)
      goto theend;
      fname = browseFile;
      *** ../vim60.162/src/gui_athena.c Wed Dec 12 20:36:34 2001
      --- src/gui_athena.c Sun Feb 3 15:24:05 2002
      ***************
      *** 1836,1841 ****
      --- 1836,1856 ----
      char_u *filter; /* not used (file name filter) */
      {
      Position x, y;
      + char_u dirbuf[MAXPATHL];
      +
      + /* Concatenate "initdir" and "dflt". */
      + if (initdir == NULL || *initdir == NUL)
      + mch_dirname(dirbuf, MAXPATHL);
      + else if (STRLEN(initdir) + 2 < MAXPATHL)
      + STRCPY(dirbuf, initdir);
      + else
      + dirbuf[0] = NUL;
      + if (dflt != NULL && *dflt != NUL
      + && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
      + {
      + add_pathsep(dirbuf);
      + STRCAT(dirbuf, dflt);
      + }

      /* Position the file selector just below the menubar */
      XtTranslateCoords(vimShell, (Position)0, (Position)
      ***************
      *** 1845,1851 ****
      0
      #endif
      , &x, &y);
      ! return (char_u *)vim_SelFile(vimShell, (char *)title, (char *)initdir,
      NULL, (int)x, (int)y, gui.menu_fg_pixel, gui.menu_bg_pixel);
      }
      #endif
      --- 1860,1866 ----
      0
      #endif
      , &x, &y);
      ! return (char_u *)vim_SelFile(vimShell, (char *)title, (char *)dirbuf,
      NULL, (int)x, (int)y, gui.menu_fg_pixel, gui.menu_bg_pixel);
      }
      #endif
      *** ../vim60.162/src/gui_gtk.c Fri Dec 14 20:19:45 2001
      --- src/gui_gtk.c Sun Feb 3 15:25:14 2002
      ***************
      *** 875,890 ****
      /* if our pointer is currently hidden, then we should show it. */
      gui_mch_mousehide(FALSE);

      ! if (dflt == NULL)
      ! dflt = (char_u *)"";
      if (initdir == NULL || *initdir == NUL)
      - {
      mch_dirname(dirbuf, MAXPATHL);
      ! strcat((char *)dirbuf, "/"); /* make sure this is a directory */
      ! initdir = dirbuf;
      ! }
      gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg),
      ! (const gchar *)initdir);

      gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin),
      GTK_WIDGET(gui.filedlg), VW_POS_MOUSE);
      --- 875,895 ----
      /* if our pointer is currently hidden, then we should show it. */
      gui_mch_mousehide(FALSE);

      ! /* Concatenate "initdir" and "dflt". */
      if (initdir == NULL || *initdir == NUL)
      mch_dirname(dirbuf, MAXPATHL);
      ! else if (STRLEN(initdir) + 2 < MAXPATHL)
      ! STRCPY(dirbuf, initdir);
      ! else
      ! dirbuf[0] = NUL;
      ! /* Always need a trailing slash for a directory. */
      ! add_pathsep(dirbuf);
      ! if (dflt != NULL && *dflt != NUL
      ! && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
      ! STRCAT(dirbuf, dflt);
      !
      gtk_file_selection_set_filename(GTK_FILE_SELECTION(gui.filedlg),
      ! (const gchar *)dirbuf);

      gui_gtk_position_in_parent(GTK_WIDGET(gui.mainwin),
      GTK_WIDGET(gui.filedlg), VW_POS_MOUSE);
      ***************
      *** 900,906 ****

      #endif /* FEAT_BROWSE */

      ! #ifdef FEAT_GUI_DIALOG

      static char_u *dialog_textfield = NULL;
      static GtkWidget *dialog_textentry;
      --- 905,911 ----

      #endif /* FEAT_BROWSE */

      ! #if defined(FEAT_GUI_DIALOG) || defined(PROTO)

      static char_u *dialog_textfield = NULL;
      static GtkWidget *dialog_textentry;
      *** ../vim60.162/src/gui_motif.c Wed Sep 26 16:47:48 2001
      --- src/gui_motif.c Sun Feb 3 14:23:53 2002
      ***************
      *** 1531,1537 ****

      str = XmStringCreate(new_label, STRING_TAG);

      ! if (str) {
      XtVaSetValues(w, XmNlabelString, str, NULL);
      XmStringFree(str);
      }
      --- 1531,1538 ----

      str = XmStringCreate(new_label, STRING_TAG);

      ! if (str)
      ! {
      XtVaSetValues(w, XmNlabelString, str, NULL);
      XmStringFree(str);
      }
      ***************
      *** 1552,1568 ****
      char_u *filter; /* file name filter */
      {
      char_u dirbuf[MAXPATHL];
      char_u *pattern;
      char_u *tofree = NULL;

      dialog_wgt = XmCreateFileSelectionDialog(vimShell, (char *)title, NULL, 0);

      - if (dflt == NULL)
      - dflt = (char_u *)"";
      if (initdir == NULL || *initdir == NUL)
      {
      mch_dirname(dirbuf, MAXPATHL);
      initdir = dirbuf;
      }

      /* Can only use one pattern for a file name. Get the first pattern out of
      --- 1553,1580 ----
      char_u *filter; /* file name filter */
      {
      char_u dirbuf[MAXPATHL];
      + char_u dfltbuf[MAXPATHL];
      char_u *pattern;
      char_u *tofree = NULL;

      dialog_wgt = XmCreateFileSelectionDialog(vimShell, (char *)title, NULL, 0);

      if (initdir == NULL || *initdir == NUL)
      {
      mch_dirname(dirbuf, MAXPATHL);
      initdir = dirbuf;
      + }
      +
      + if (dflt == NULL)
      + dflt = (char_u *)"";
      + else if (STRLEN(initdir) + STRLEN(dflt) + 2 < MAXPATHL)
      + {
      + /* The default selection should be the full path, "dflt" is only the
      + * file name. */
      + STRCPY(dfltbuf, initdir);
      + add_pathsep(dfltbuf);
      + STRCAT(dfltbuf, dflt);
      + dflt = dfltbuf;
      }

      /* Can only use one pattern for a file name. Get the first pattern out of
      *** ../vim60.162/src/message.c Fri Sep 28 22:19:57 2001
      --- src/message.c Sun Feb 3 13:42:00 2002
      ***************
      *** 2475,2483 ****
      do_browse(saving, title, dflt, ext, initdir, filter, buf)
      int saving; /* write action */
      char_u *title; /* title for the window */
      ! char_u *dflt; /* default file name */
      char_u *ext; /* extension added */
      ! char_u *initdir; /* initial directory, NULL for current dir */
      char_u *filter; /* file name filter */
      buf_T *buf; /* buffer to read/write for */
      {
      --- 2475,2484 ----
      do_browse(saving, title, dflt, ext, initdir, filter, buf)
      int saving; /* write action */
      char_u *title; /* title for the window */
      ! char_u *dflt; /* default file name (may include directory) */
      char_u *ext; /* extension added */
      ! char_u *initdir; /* initial directory, NULL for current dir or
      ! when using path from "dflt" */
      char_u *filter; /* file name filter */
      buf_T *buf; /* buffer to read/write for */
      {
      ***************
      *** 2498,2505 ****
      title = (char_u *)_("Open File dialog");
      }

      ! /* When no directory specified, use default dir, buffer dir, last dir
      ! * or current dir */
      if (initdir == NULL || *initdir == NUL)
      {
      /* When 'browsedir' is a directory, use it */
      --- 2499,2525 ----
      title = (char_u *)_("Open File dialog");
      }

      ! /* When no directory specified, use default file name, default dir, buffer
      ! * dir, last dir or current dir */
      ! if ((initdir == NULL || *initdir == NUL) && dflt != NULL && *dflt != NUL)
      ! {
      ! if (mch_isdir(dflt)) /* default file name is a directory */
      ! {
      ! initdir = dflt;
      ! dflt = NULL;
      ! }
      ! else if (gettail(dflt) != dflt) /* default file name includes a path */
      ! {
      ! tofree = vim_strsave(dflt);
      ! if (tofree != NULL)
      ! {
      ! initdir = tofree;
      ! *gettail(initdir) = NUL;
      ! dflt = gettail(dflt);
      ! }
      ! }
      ! }
      !
      if (initdir == NULL || *initdir == NUL)
      {
      /* When 'browsedir' is a directory, use it */
      ***************
      *** 2509,2515 ****
      else if ((saving || *p_bsdir == 'b')
      && buf != NULL && buf->b_ffname != NULL)
      {
      ! dflt = gettail(curbuf->b_ffname);
      tofree = vim_strsave(curbuf->b_ffname);
      if (tofree != NULL)
      {
      --- 2529,2536 ----
      else if ((saving || *p_bsdir == 'b')
      && buf != NULL && buf->b_ffname != NULL)
      {
      ! if (dflt == NULL || *dflt == NUL)
      ! dflt = gettail(curbuf->b_ffname);
      tofree = vim_strsave(curbuf->b_ffname);
      if (tofree != NULL)
      {
      ***************
      *** 2560,2566 ****
      *gettail(last_dir) = NUL;
      if (*last_dir == NUL)
      {
      ! /* filename only returned, must be in current dir*/
      vim_free(last_dir);
      last_dir = alloc(MAXPATHL);
      if (last_dir != NULL)
      --- 2581,2587 ----
      *gettail(last_dir) = NUL;
      if (*last_dir == NUL)
      {
      ! /* filename only returned, must be in current dir */
      vim_free(last_dir);
      last_dir = alloc(MAXPATHL);
      if (last_dir != NULL)
      *** ../vim60.162/src/version.c Sun Feb 3 12:42:13 2002
      --- src/version.c Sun Feb 3 15:16:22 2002
      ***************
      *** 608,609 ****
      --- 608,611 ----
      { /* Add new patch number below this line */
      + /**/
      + 163,
      /**/

      --
      hundred-and-one symptoms of being an internet addict:
      168. You have your own domain name.

      /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
      ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
      \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
    Your message has been successfully submitted and would be delivered to recipients shortly.