summaryrefslogtreecommitdiff
path: root/src/message.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-04 15:54:55 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-04 15:54:55 +0200
commitb005cd80cfda591be95146024d9b97eef383500f (patch)
treece7d5ac25d5c8e3442828130c180e04820565d29 /src/message.c
parent1e1d30048e722906a13665bd6c3c24c87eb2fe25 (diff)
downloadvim-git-b005cd80cfda591be95146024d9b97eef383500f.tar.gz
patch 8.1.1979: code for handling file names is spread outv8.1.1979
Problem: Code for handling file names is spread out. Solution: Move code to new filepath.c file. Graduate FEAT_MODIFY_FNAME.
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c162
1 files changed, 0 insertions, 162 deletions
diff --git a/src/message.c b/src/message.c
index 387a142a2..b5aff8476 100644
--- a/src/message.c
+++ b/src/message.c
@@ -3957,168 +3957,6 @@ vim_dialog_yesnoallcancel(
#endif /* FEAT_GUI_DIALOG || FEAT_CON_DIALOG */
-#if defined(FEAT_BROWSE) || defined(PROTO)
-/*
- * Generic browse function. Calls gui_mch_browse() when possible.
- * Later this may pop-up a non-GUI file selector (external command?).
- */
- char_u *
-do_browse(
- int flags, /* BROWSE_SAVE and BROWSE_DIR */
- 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 */
-{
- char_u *fname;
- static char_u *last_dir = NULL; /* last used directory */
- char_u *tofree = NULL;
- int save_browse = cmdmod.browse;
-
- /* Must turn off browse to avoid that autocommands will get the
- * flag too! */
- cmdmod.browse = FALSE;
-
- if (title == NULL || *title == NUL)
- {
- if (flags & BROWSE_DIR)
- title = (char_u *)_("Select Directory dialog");
- else if (flags & BROWSE_SAVE)
- title = (char_u *)_("Save File dialog");
- else
- 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 */
- if (STRCMP(p_bsdir, "last") != 0
- && STRCMP(p_bsdir, "buffer") != 0
- && STRCMP(p_bsdir, "current") != 0
- && mch_isdir(p_bsdir))
- initdir = p_bsdir;
- /* When saving or 'browsedir' is "buffer", use buffer fname */
- else if (((flags & BROWSE_SAVE) || *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)
- {
- initdir = tofree;
- *gettail(initdir) = NUL;
- }
- }
- /* When 'browsedir' is "last", use dir from last browse */
- else if (*p_bsdir == 'l')
- initdir = last_dir;
- /* When 'browsedir is "current", use current directory. This is the
- * default already, leave initdir empty. */
- }
-
-# ifdef FEAT_GUI
- if (gui.in_use) /* when this changes, also adjust f_has()! */
- {
- if (filter == NULL
-# ifdef FEAT_EVAL
- && (filter = get_var_value((char_u *)"b:browsefilter")) == NULL
- && (filter = get_var_value((char_u *)"g:browsefilter")) == NULL
-# endif
- )
- filter = BROWSE_FILTER_DEFAULT;
- if (flags & BROWSE_DIR)
- {
-# if defined(FEAT_GUI_GTK) || defined(MSWIN)
- /* For systems that have a directory dialog. */
- fname = gui_mch_browsedir(title, initdir);
-# else
- /* Generic solution for selecting a directory: select a file and
- * remove the file name. */
- fname = gui_mch_browse(0, title, dflt, ext, initdir, (char_u *)"");
-# endif
-# if !defined(FEAT_GUI_GTK)
- /* Win32 adds a dummy file name, others return an arbitrary file
- * name. GTK+ 2 returns only the directory, */
- if (fname != NULL && *fname != NUL && !mch_isdir(fname))
- {
- /* Remove the file name. */
- char_u *tail = gettail_sep(fname);
-
- if (tail == fname)
- *tail++ = '.'; /* use current dir */
- *tail = NUL;
- }
-# endif
- }
- else
- fname = gui_mch_browse(flags & BROWSE_SAVE,
- title, dflt, ext, initdir, (char_u *)_(filter));
-
- /* We hang around in the dialog for a while, the user might do some
- * things to our files. The Win32 dialog allows deleting or renaming
- * a file, check timestamps. */
- need_check_timestamps = TRUE;
- did_check_timestamps = FALSE;
- }
- else
-# endif
- {
- /* TODO: non-GUI file selector here */
- emsg(_("E338: Sorry, no file browser in console mode"));
- fname = NULL;
- }
-
- /* keep the directory for next time */
- if (fname != NULL)
- {
- vim_free(last_dir);
- last_dir = vim_strsave(fname);
- if (last_dir != NULL && !(flags & BROWSE_DIR))
- {
- *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)
- mch_dirname(last_dir, MAXPATHL);
- }
- }
- }
-
- vim_free(tofree);
- cmdmod.browse = save_browse;
-
- return fname;
-}
-#endif
-
#if defined(FEAT_EVAL)
static char *e_printf = N_("E766: Insufficient arguments for printf()");