}
static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
- size_t titlelen, int buffy)
+ size_t titlelen, int buffy, const char *defaultsel)
{
BUFFER *path = NULL;
+ int i;
path = mutt_buffer_pool_get ();
}
menu->redraw = REDRAW_FULL;
+ if (option (OPTBROWSERSTICKYCURSOR) && defaultsel && *defaultsel)
+ {
+ for (i = 0; i < menu->max; i++)
+ {
+ if (!mutt_strcmp (defaultsel, state->entry[i].full_path))
+ {
+ menu->current = i;
+ break;
+ }
+ }
+ }
+
mutt_buffer_pool_release (&path);
}
BUFFER *prefix = NULL;
BUFFER *tmp = NULL;
BUFFER *OldLastDir = NULL;
+ BUFFER *defaultsel = NULL;
char helpstr[LONG_STRING];
char title[STRING];
struct browser_state state;
prefix = mutt_buffer_pool_get ();
tmp = mutt_buffer_pool_get ();
OldLastDir = mutt_buffer_pool_get ();
+ defaultsel = mutt_buffer_pool_get ();
memset (&state, 0, sizeof (struct browser_state));
else if (!*(mutt_b2s (LastDir)))
mutt_buffer_strcpy (LastDir, NONULL(Maildir));
+ if (Context)
+ mutt_buffer_strcpy (defaultsel, NONULL (Context->path));
+
#ifdef USE_IMAP
if (!buffy && mx_is_imap (mutt_b2s (LastDir)))
{
FolderHelp);
mutt_push_current_menu (menu);
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
FOREVER
{
- switch (op = mutt_menuLoop (menu))
+ op = mutt_menuLoop (menu);
+
+ if (state.entrylen)
+ mutt_buffer_strcpy (defaultsel, state.entry[menu->current].full_path);
+
+ switch (op)
{
case OP_DESCEND_DIRECTORY:
case OP_GENERIC_SELECT_ENTRY:
/* save the old directory */
mutt_buffer_strcpy (OldLastDir, mutt_b2s (LastDir));
+ mutt_buffer_strcpy (defaultsel, mutt_b2s (OldLastDir));
+ if (mutt_buffer_len (defaultsel) && (*(defaultsel->dptr - 1) == '/'))
+ {
+ defaultsel->dptr--;
+ *(defaultsel->dptr) = '\0';
+ }
+
if (mutt_strcmp (state.entry[menu->current].display_name, "..") == 0)
{
size_t lastdirlen = mutt_buffer_len (LastDir);
}
menu->current = 0;
menu->top = 0;
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
break;
}
}
break;
}
- if (!imap_mailbox_create (mutt_b2s (LastDir)))
+ if (!imap_mailbox_create (mutt_b2s (LastDir), defaultsel))
{
/* TODO: find a way to detect if the new folder would appear in
* this window, and insert it without starting over. */
menu->data = state.entry;
menu->current = 0;
menu->top = 0;
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
}
/* else leave error on screen */
break;
{
int nentry = menu->current;
- if (imap_mailbox_rename (state.entry[nentry].full_path) >= 0)
+ if (imap_mailbox_rename (state.entry[nentry].full_path, defaultsel) >= 0)
{
destroy_state (&state);
init_state (&state, NULL);
menu->data = state.entry;
menu->current = 0;
menu->top = 0;
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
}
}
break;
sizeof (struct folder_file));
state.entrylen--;
mutt_message _("Mailbox deleted.");
- init_menu (&state, menu, title, sizeof (title), buffy);
+ mutt_buffer_clear (defaultsel);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
}
else
mutt_error _("Mailbox deletion failed.");
case OP_CHANGE_DIRECTORY:
mutt_buffer_strcpy (buf, mutt_b2s (LastDir));
+ mutt_buffer_clear (defaultsel);
#ifdef USE_IMAP
if (!state.imap_browse)
#endif
menu->data = state.entry;
menu->current = 0;
menu->top = 0;
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
}
else
#endif
}
menu->current = 0;
menu->top = 0;
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
}
else
mutt_error (_("%s is not a directory."), mutt_b2s (buf));
imap_browse (mutt_b2s (LastDir), &state);
browser_sort (&state);
menu->data = state.entry;
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
}
else
#endif
if (examine_directory (menu, &state, mutt_b2s (LastDir), NULL) == 0)
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
else
{
mutt_error _("Error scanning directory.");
case OP_TOGGLE_MAILBOXES:
buffy = 1 - buffy;
+ menu->current = 0;
+ /* fall through */
case OP_CHECK_NEW:
destroy_state (&state);
#endif
else if (examine_directory (menu, &state, mutt_b2s (LastDir), mutt_b2s (prefix)) == -1)
goto bail;
- init_menu (&state, menu, title, sizeof (title), buffy);
+ init_menu (&state, menu, title, sizeof (title), buffy, mutt_b2s (defaultsel));
break;
case OP_BUFFY_LIST:
mutt_buffer_pool_release (&prefix);
mutt_buffer_pool_release (&tmp);
mutt_buffer_pool_release (&OldLastDir);
+ mutt_buffer_pool_release (&defaultsel);
if (menu)
{