} FOLDER;
static char LastDir[_POSIX_PATH_MAX] = "";
+static char LastDirBackup[_POSIX_PATH_MAX] = "";
/* Frees up the memory allocated for the local-global variables. */
static void destroy_state (struct browser_state *state)
return ((ff->tagged = !ff->tagged) ? 1 : -1);
}
-void _mutt_select_file (char *f, size_t flen, int buffy,
- int multiple, char ***files, int *numfiles)
+void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *numfiles)
{
char buf[_POSIX_PATH_MAX];
char prefix[_POSIX_PATH_MAX] = "";
MUTTMENU *menu;
struct stat st;
int i, killPrefix = 0;
+ int multiple = (flags & M_SEL_MULTI) ? 1 : 0;
+ int folder = (flags & M_SEL_FOLDER) ? 1 : 0;
+ int buffy = (flags & M_SEL_BUFFY) ? 1 : 0;
+ buffy = buffy && folder;
+
memset (&state, 0, sizeof (struct browser_state));
+ if (!folder)
+ strfcpy (LastDirBackup, LastDir, sizeof (LastDirBackup));
+
if (*f)
{
mutt_expand_path (f, flen);
}
else
{
- if (!LastDir[0])
+ if (!folder)
+ getcwd (LastDir, sizeof (LastDir));
+ else if (!LastDir[0])
strfcpy (LastDir, NONULL(Maildir), sizeof (LastDir));
+
#ifdef USE_IMAP
if (!buffy && mx_is_imap (LastDir))
{
if (buffy)
{
if (examine_mailboxes (NULL, &state) == -1)
- return;
+ goto bail;
}
else
#ifdef USE_IMAP
if (!state.imap_browse)
#endif
if (examine_directory (NULL, &state, LastDir, prefix) == -1)
- return;
+ goto bail;
menu = mutt_new_menu ();
menu->menu = MENU_FOLDER;
if (examine_directory (menu, &state, LastDir, prefix) == -1)
{
strfcpy (LastDir, NONULL(Homedir), sizeof (LastDir));
- return;
+ goto bail;
}
}
menu->current = 0;
destroy_state (&state);
mutt_menuDestroy (&menu);
- return;
+ goto bail;
case OP_BROWSER_TELL:
if(state.entrylen)
mutt_error _("Error scanning directory.");
destroy_state (&state);
mutt_menuDestroy (&menu);
- return;
+ goto bail;
}
}
else
{
mutt_error _("Error scanning directory.");
mutt_menuDestroy (&menu);
- return;
+ goto bail;
}
killPrefix = 0;
if (!state.entrylen)
if (buffy)
{
if (examine_mailboxes (menu, &state) == -1)
- return;
+ goto bail;
}
#ifdef USE_IMAP
else if (mx_is_imap (LastDir))
}
#endif
else if (examine_directory (menu, &state, LastDir, prefix) == -1)
- return;
+ goto bail;
init_menu (&state, menu, title, sizeof (title), buffy);
break;
strfcpy (f, buf, flen);
destroy_state (&state);
mutt_menuDestroy (&menu);
- return;
+ goto bail;
}
MAYBE_REDRAW (menu->redraw);
break;
strfcpy (f, state.entry[menu->current].name, flen);
destroy_state (&state);
mutt_menuDestroy (&menu);
- return;
+ goto bail;
}
else
#endif
}
}
}
- /* not reached */
+
+ bail:
+
+ if (!folder)
+ strfcpy (LastDir, LastDirBackup, sizeof (LastDir));
+
}
{
mutt_refresh ();
buf[0] = 0;
- _mutt_select_file (buf, blen, 0, multiple, files, numfiles);
+ _mutt_select_file (buf, blen, M_SEL_FOLDER | (buffy ? M_SEL_BUFFY : 0) | (multiple ? M_SEL_MULTI : 0),
+ files, numfiles);
*redraw = REDRAW_FULL;
}
else
+
/*
* Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
* Copyright (C) 2000 Edmund Grimley Evans <edmundo@rano.org>
if (tempbuf && templen == state->lastchar - i &&
!memcmp (tempbuf, state->wbuf + i, (state->lastchar - i) * sizeof (wchar_t)))
{
- mutt_select_file (buf, buflen, 0);
+ mutt_select_file (buf, buflen, (flags & M_EFILE) ? M_SEL_FOLDER : 0);
set_option (OPTNEEDREDRAW);
if (*buf)
replace_part (state, i, buf);
if ((!tempbuf && !state->lastchar) || (tempbuf && templen == state->lastchar &&
!memcmp (tempbuf, state->wbuf, state->lastchar * sizeof (wchar_t))))
{
- _mutt_select_file (buf, buflen, 0, multiple, files, numfiles);
+ _mutt_select_file (buf, buflen,
+ ((flags & M_EFILE) ? M_SEL_FOLDER : 0) | (multiple ? M_SEL_MULTI : 0),
+ files, numfiles);
set_option (OPTNEEDREDRAW);
if (*buf)
{
exit (1);
}
folder[0] = 0;
- mutt_select_file (folder, sizeof (folder), 1);
+ mutt_select_file (folder, sizeof (folder), M_SEL_FOLDER);
if (!folder[0])
{
mutt_endwin (NULL);
#define SENDKEY (1<<7)
#define SENDRESEND (1<<8)
+/* flags to _mutt_select_file() */
+#define M_SEL_BUFFY (1<<0)
+#define M_SEL_MULTI (1<<1)
+#define M_SEL_FOLDER (1<<2)
+
+
/* boolean vars */
enum
{
void mutt_save_path (char *s, size_t l, ADDRESS *a);
void mutt_score_message (CONTEXT *, HEADER *, int);
void mutt_select_fcc (char *, size_t, HEADER *);
-#define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,0,NULL,NULL)
-void _mutt_select_file (char *, size_t, int, int, char ***, int *);
+#define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,NULL,NULL)
+void _mutt_select_file (char *, size_t, int, char ***, int *);
void mutt_message_hook (CONTEXT *, HEADER *, int);
void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
#define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1)