summaryrefslogtreecommitdiffstats
path: root/src/message.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2004-10-11 10:06:20 +0000
committerBram Moolenaar <Bram@vim.org>2004-10-11 10:06:20 +0000
commit7171abea1ad8d33cce89a9664873417187139a53 (patch)
tree491426309f8e38304d96b55b7ac5ab6bdaefcc6b /src/message.c
parent349b2f643a5e840facf42942d37d47c5b37c1292 (diff)
updated for version 7.0018
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c56
1 files changed, 44 insertions, 12 deletions
diff --git a/src/message.c b/src/message.c
index 5b8da3f4db..d678bf3b9e 100644
--- a/src/message.c
+++ b/src/message.c
@@ -813,14 +813,12 @@ ex_messages(eap)
msg_hist_off = FALSE;
}
-#if defined(FEAT_CON_DIALOG) || defined(PROTO)
-static void msg_end_prompt __ARGS((void));
-
+#if defined(FEAT_CON_DIALOG) || defined(FIND_REPLACE_DIALOG) || defined(PROTO)
/*
* Call this after prompting the user. This will avoid a hit-return message
* and a delay.
*/
- static void
+ void
msg_end_prompt()
{
need_wait_return = FALSE;
@@ -3046,8 +3044,8 @@ vim_dialog_yesnoallcancel(type, title, message, dflt)
* Later this may pop-up a non-GUI file selector (external command?).
*/
char_u *
-do_browse(saving, title, dflt, ext, initdir, filter, buf)
- int saving; /* write action */
+do_browse(flags, title, dflt, ext, initdir, filter, buf)
+ 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 */
@@ -3065,9 +3063,11 @@ do_browse(saving, title, dflt, ext, initdir, filter, buf)
* flag too! */
cmdmod.browse = FALSE;
- if (title == NULL)
+ if (title == NULL || *title == NUL)
{
- if (saving)
+ 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");
@@ -3097,10 +3097,13 @@ do_browse(saving, title, dflt, ext, initdir, filter, buf)
if (initdir == NULL || *initdir == NUL)
{
/* When 'browsedir' is a directory, use it */
- if (mch_isdir(p_bsdir))
+ 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 ((saving || *p_bsdir == 'b')
+ else if (((flags & BROWSE_SAVE) || *p_bsdir == 'b')
&& buf != NULL && buf->b_ffname != NULL)
{
if (dflt == NULL || *dflt == NUL)
@@ -3129,7 +3132,36 @@ do_browse(saving, title, dflt, ext, initdir, filter, buf)
# endif
)
filter = BROWSE_FILTER_DEFAULT;
- fname = gui_mch_browse(saving, title, dflt, ext, initdir, filter);
+ if (flags & BROWSE_DIR)
+ {
+# if defined(HAVE_GTK2) || defined(WIN3264)
+ /* 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(HAVE_GTK2)
+ /* 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 *s = get_past_head(fname);
+ char_u *tail = gettail(fname);
+
+ while (tail > s && vim_ispathsep(tail[-1]))
+ --tail;
+ if (tail == fname)
+ *tail++ = '.'; /* use current dir */
+ *tail = NUL;
+ }
+# endif
+ }
+ else
+ fname = gui_mch_browse(flags & BROWSE_SAVE,
+ title, dflt, ext, initdir, 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
@@ -3150,7 +3182,7 @@ do_browse(saving, title, dflt, ext, initdir, filter, buf)
{
vim_free(last_dir);
last_dir = vim_strsave(fname);
- if (last_dir != NULL)
+ if (last_dir != NULL && !(flags & BROWSE_DIR))
{
*gettail(last_dir) = NUL;
if (*last_dir == NUL)