NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
browser.c File Reference
#include "config.h"
#include <dirent.h>
#include <errno.h>
#include <grp.h>
#include <limits.h>
#include <locale.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "conn/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "browser.h"
#include "send/lib.h"
#include "context.h"
#include "format_flags.h"
#include "keymap.h"
#include "mutt_attach.h"
#include "mutt_globals.h"
#include "mutt_mailbox.h"
#include "mutt_menu.h"
#include "muttlib.h"
#include "mx.h"
#include "opcodes.h"
#include "options.h"
#include "imap/lib.h"
#include "nntp/lib.h"
#include "nntp/adata.h"
#include "nntp/mdata.h"
+ Include dependency graph for browser.c:

Go to the source code of this file.

Functions

static void init_lastdir (void)
 Initialise the browser directories. More...
 
void mutt_browser_cleanup (void)
 Clean up working Buffers. More...
 
static void destroy_state (struct BrowserState *state)
 Free the BrowserState. More...
 
static int browser_compare_subject (const void *a, const void *b)
 Compare the subject of two browser entries - Implements sort_t. More...
 
static int browser_compare_order (const void *a, const void *b)
 Compare the order of creation of two browser entries - Implements sort_t. More...
 
static int browser_compare_desc (const void *a, const void *b)
 Compare the descriptions of two browser entries - Implements sort_t. More...
 
static int browser_compare_date (const void *a, const void *b)
 Compare the date of two browser entries - Implements sort_t. More...
 
static int browser_compare_size (const void *a, const void *b)
 Compare the size of two browser entries - Implements sort_t. More...
 
static int browser_compare_count (const void *a, const void *b)
 Compare the message count of two browser entries - Implements sort_t. More...
 
static int browser_compare_count_new (const void *a, const void *b)
 Compare the new count of two browser entries - Implements sort_t. More...
 
static int browser_compare (const void *a, const void *b)
 Sort the items in the browser - Implements sort_t. More...
 
static void browser_sort (struct BrowserState *state)
 Sort the entries in the browser. More...
 
static bool link_is_dir (const char *folder, const char *path)
 Does this symlink point to a directory? More...
 
static const char * folder_format_str (char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
 Format a string for the folder browser - Implements format_t. More...
 
static void add_folder (struct Menu *menu, struct BrowserState *state, const char *name, const char *desc, const struct stat *s, struct Mailbox *m, void *data)
 Add a folder to the browser list. More...
 
static void init_state (struct BrowserState *state, struct Menu *menu)
 Initialise a browser state. More...
 
static int examine_directory (struct Mailbox *m, struct Menu *menu, struct BrowserState *state, const char *d, const char *prefix)
 Get list of all files/newsgroups with mask. More...
 
static int examine_mailboxes (struct Mailbox *m, struct Menu *menu, struct BrowserState *state)
 Get list of mailboxes/subscribed newsgroups. More...
 
static int select_file_search (struct Menu *menu, regex_t *rx, int line)
 Menu search callback for matching files - Implements Menu::search() More...
 
static void folder_make_entry (struct Menu *menu, char *buf, size_t buflen, int line)
 Format a menu item for the folder browser - Implements Menu::make_entry() More...
 
static void browser_highlight_default (struct BrowserState *state, struct Menu *menu)
 Decide which browser item should be highlighted. More...
 
static void init_menu (struct BrowserState *state, struct Menu *menu, char *title, size_t titlelen, bool mailbox, struct Mailbox *m)
 Set up a new menu. More...
 
static int file_tag (struct Menu *menu, int sel, int act)
 Tag an entry in the menu - Implements Menu::tag() More...
 
void mutt_browser_select_dir (const char *f)
 Remember the last directory selected. More...
 
void mutt_buffer_select_file (struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
 Let the user select a file. More...
 
void mutt_select_file (char *file, size_t filelen, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
 Let the user select a file. More...
 

Variables

bool C_BrowserAbbreviateMailboxes
 Config: Abbreviate mailboxes using '~' and '=' in the browser. More...
 
char * C_FolderFormat
 Config: printf-like format string for the browser's display of folders. More...
 
short C_SortBrowser
 Config: Sort method for the browser. More...
 
static const struct Mapping FolderHelp []
 Help Bar for the File/Dir/Mailbox browser dialog. More...
 
static const struct Mapping FolderNewsHelp []
 Help Bar for the NNTP Mailbox browser dialog. More...
 
static struct Buffer LastDir = { 0 }
 
static struct Buffer LastDirBackup = { 0 }
 

Detailed Description

GUI component for displaying/selecting items from a list

Authors
  • Michael R. Elkins
  • R Primus

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file browser.c.

Function Documentation

◆ init_lastdir()

static void init_lastdir ( void  )
static

Initialise the browser directories.

These keep track of where the browser used to be looking.

Definition at line 112 of file browser.c.

113 {
114  static bool done = false;
115  if (!done)
116  {
119  done = true;
120  }
121 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_browser_cleanup()

void mutt_browser_cleanup ( void  )

Clean up working Buffers.

Definition at line 126 of file browser.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy_state()

static void destroy_state ( struct BrowserState state)
static

Free the BrowserState.

Parameters
stateState to free

Frees up the memory allocated for the local-global variables.

Definition at line 138 of file browser.c.

139 {
140  struct FolderFile *ff = NULL;
141  ARRAY_FOREACH(ff, &state->entry)
142  {
143  FREE(&ff->name);
144  FREE(&ff->desc);
145  }
146  ARRAY_FREE(&state->entry);
147 
148 #ifdef USE_IMAP
149  FREE(&state->folder);
150 #endif
151 }
+ Here is the caller graph for this function:

◆ browser_compare_subject()

static int browser_compare_subject ( const void *  a,
const void *  b 
)
static

Compare the subject of two browser entries - Implements sort_t.

Definition at line 156 of file browser.c.

157 {
158  const struct FolderFile *pa = (const struct FolderFile *) a;
159  const struct FolderFile *pb = (const struct FolderFile *) b;
160 
161  /* inbox should be sorted ahead of its siblings */
162  int r = mutt_inbox_cmp(pa->name, pb->name);
163  if (r == 0)
164  r = mutt_str_coll(pa->name, pb->name);
165  return (C_SortBrowser & SORT_REVERSE) ? -r : r;
166 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ browser_compare_order()

static int browser_compare_order ( const void *  a,
const void *  b 
)
static

Compare the order of creation of two browser entries - Implements sort_t.

Note
This only affects browsing mailboxes and is a no-op for folders.

Definition at line 173 of file browser.c.

174 {
175  const struct FolderFile *pa = (const struct FolderFile *) a;
176  const struct FolderFile *pb = (const struct FolderFile *) b;
177 
178  return ((C_SortBrowser & SORT_REVERSE) ? -1 : 1) * (pa->gen - pb->gen);
179 }
+ Here is the caller graph for this function:

◆ browser_compare_desc()

static int browser_compare_desc ( const void *  a,
const void *  b 
)
static

Compare the descriptions of two browser entries - Implements sort_t.

Definition at line 184 of file browser.c.

185 {
186  const struct FolderFile *pa = (const struct FolderFile *) a;
187  const struct FolderFile *pb = (const struct FolderFile *) b;
188 
189  int r = mutt_str_coll(pa->desc, pb->desc);
190 
191  return (C_SortBrowser & SORT_REVERSE) ? -r : r;
192 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ browser_compare_date()

static int browser_compare_date ( const void *  a,
const void *  b 
)
static

Compare the date of two browser entries - Implements sort_t.

Definition at line 197 of file browser.c.

198 {
199  const struct FolderFile *pa = (const struct FolderFile *) a;
200  const struct FolderFile *pb = (const struct FolderFile *) b;
201 
202  int r = pa->mtime - pb->mtime;
203 
204  return (C_SortBrowser & SORT_REVERSE) ? -r : r;
205 }
+ Here is the caller graph for this function:

◆ browser_compare_size()

static int browser_compare_size ( const void *  a,
const void *  b 
)
static

Compare the size of two browser entries - Implements sort_t.

Definition at line 210 of file browser.c.

211 {
212  const struct FolderFile *pa = (const struct FolderFile *) a;
213  const struct FolderFile *pb = (const struct FolderFile *) b;
214 
215  int r = pa->size - pb->size;
216 
217  return (C_SortBrowser & SORT_REVERSE) ? -r : r;
218 }
+ Here is the caller graph for this function:

◆ browser_compare_count()

static int browser_compare_count ( const void *  a,
const void *  b 
)
static

Compare the message count of two browser entries - Implements sort_t.

Definition at line 223 of file browser.c.

224 {
225  const struct FolderFile *pa = (const struct FolderFile *) a;
226  const struct FolderFile *pb = (const struct FolderFile *) b;
227 
228  int r = 0;
229  if (pa->has_mailbox && pb->has_mailbox)
230  r = pa->msg_count - pb->msg_count;
231  else if (pa->has_mailbox)
232  r = -1;
233  else
234  r = 1;
235 
236  return (C_SortBrowser & SORT_REVERSE) ? -r : r;
237 }
+ Here is the caller graph for this function:

◆ browser_compare_count_new()

static int browser_compare_count_new ( const void *  a,
const void *  b 
)
static

Compare the new count of two browser entries - Implements sort_t.

Definition at line 242 of file browser.c.

243 {
244  const struct FolderFile *pa = (const struct FolderFile *) a;
245  const struct FolderFile *pb = (const struct FolderFile *) b;
246 
247  int r = 0;
248  if (pa->has_mailbox && pb->has_mailbox)
249  r = pa->msg_unread - pb->msg_unread;
250  else if (pa->has_mailbox)
251  r = -1;
252  else
253  r = 1;
254 
255  return (C_SortBrowser & SORT_REVERSE) ? -r : r;
256 }
+ Here is the caller graph for this function:

◆ browser_compare()

static int browser_compare ( const void *  a,
const void *  b 
)
static

Sort the items in the browser - Implements sort_t.

Wild compare function that calls the others. It's useful because it provides a way to tell "../" is always on the top of the list, independently of the sort method.

Definition at line 265 of file browser.c.

266 {
267  const struct FolderFile *pa = (const struct FolderFile *) a;
268  const struct FolderFile *pb = (const struct FolderFile *) b;
269 
270  if ((mutt_str_coll(pa->desc, "../") == 0) || (mutt_str_coll(pa->desc, "..") == 0))
271  return -1;
272  if ((mutt_str_coll(pb->desc, "../") == 0) || (mutt_str_coll(pb->desc, "..") == 0))
273  return 1;
274 
275  switch (C_SortBrowser & SORT_MASK)
276  {
277  case SORT_COUNT:
278  return browser_compare_count(a, b);
279  case SORT_DATE:
280  return browser_compare_date(a, b);
281  case SORT_DESC:
282  return browser_compare_desc(a, b);
283  case SORT_SIZE:
284  return browser_compare_size(a, b);
285  case SORT_UNREAD:
286  return browser_compare_count_new(a, b);
287  case SORT_SUBJECT:
288  return browser_compare_subject(a, b);
289  default:
290  case SORT_ORDER:
291  return browser_compare_order(a, b);
292  }
293 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ browser_sort()

static void browser_sort ( struct BrowserState state)
static

Sort the entries in the browser.

Parameters
stateBrowser state

Call to qsort using browser_compare function. Some specific sort methods are not used via NNTP.

Definition at line 302 of file browser.c.

303 {
304  switch (C_SortBrowser & SORT_MASK)
305  {
306 #ifdef USE_NNTP
307  case SORT_SIZE:
308  case SORT_DATE:
309  if (OptNews)
310  return;
311 #endif
312  default:
313  break;
314  }
315 
316  ARRAY_SORT(&state->entry, browser_compare);
317 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ link_is_dir()

static bool link_is_dir ( const char *  folder,
const char *  path 
)
static

Does this symlink point to a directory?

Parameters
folderFolder
pathLink name
Return values
trueLinks to a directory
falseOtherwise

Definition at line 326 of file browser.c.

327 {
328  struct stat st;
329  bool retval = false;
330 
331  struct Buffer *fullpath = mutt_buffer_pool_get();
332  mutt_buffer_concat_path(fullpath, folder, path);
333 
334  if (stat(mutt_buffer_string(fullpath), &st) == 0)
335  retval = S_ISDIR(st.st_mode);
336 
337  mutt_buffer_pool_release(&fullpath);
338 
339  return retval;
340 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ folder_format_str()

static const char* folder_format_str ( char *  buf,
size_t  buflen,
size_t  col,
int  cols,
char  op,
const char *  src,
const char *  prec,
const char *  if_str,
const char *  else_str,
intptr_t  data,
MuttFormatFlags  flags 
)
static

Format a string for the folder browser - Implements format_t.

Expando Description
%C Current file number
%d Date/time folder was last modified
%D Date/time folder was last modified using $date_format.
%F File permissions
%f Filename (with suffix /, @ or *)
%g Group name (or numeric gid, if missing)
%i Description of the folder
%l Number of hard links
%m Number of messages in the mailbox
%N N if mailbox has new mail, blank otherwise
%n Number of unread messages in the mailbox
%s Size in bytes
%t * if the file is tagged, blank otherwise
%u Owner name (or numeric uid, if missing)

Definition at line 362 of file browser.c.

366 {
367  char fn[128], fmt[128];
368  struct Folder *folder = (struct Folder *) data;
369  bool optional = (flags & MUTT_FORMAT_OPTIONAL);
370 
371  switch (op)
372  {
373  case 'C':
374  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
375  snprintf(buf, buflen, fmt, folder->num + 1);
376  break;
377 
378  case 'd':
379  case 'D':
380  if (folder->ff->local)
381  {
382  bool do_locales = true;
383 
384  char *t_fmt = NULL;
385  if (op == 'D')
386  {
387  t_fmt = NONULL(C_DateFormat);
388  if (*t_fmt == '!')
389  {
390  t_fmt++;
391  do_locales = false;
392  }
393  }
394  else
395  {
396  static const time_t one_year = 31536000;
397  t_fmt = ((mutt_date_epoch() - folder->ff->mtime) < one_year) ?
398  "%b %d %H:%M" :
399  "%b %d %Y";
400  }
401 
402  if (!do_locales)
403  setlocale(LC_TIME, "C");
404  char date[128];
405  mutt_date_localtime_format(date, sizeof(date), t_fmt, folder->ff->mtime);
406  if (!do_locales)
407  setlocale(LC_TIME, "");
408 
409  mutt_format_s(buf, buflen, prec, date);
410  }
411  else
412  mutt_format_s(buf, buflen, prec, "");
413  break;
414 
415  case 'f':
416  {
417  char *s = NULL;
418 
419  s = NONULL(folder->ff->name);
420 
421  snprintf(fn, sizeof(fn), "%s%s", s,
422  folder->ff->local ?
423  (S_ISLNK(folder->ff->mode) ?
424  "@" :
425  (S_ISDIR(folder->ff->mode) ?
426  "/" :
427  (((folder->ff->mode & S_IXUSR) != 0) ? "*" : ""))) :
428  "");
429 
430  mutt_format_s(buf, buflen, prec, fn);
431  break;
432  }
433  case 'F':
434  {
435  if (folder->ff->local)
436  {
437  char permission[11];
438  snprintf(permission, sizeof(permission), "%c%c%c%c%c%c%c%c%c%c",
439  S_ISDIR(folder->ff->mode) ? 'd' : (S_ISLNK(folder->ff->mode) ? 'l' : '-'),
440  ((folder->ff->mode & S_IRUSR) != 0) ? 'r' : '-',
441  ((folder->ff->mode & S_IWUSR) != 0) ? 'w' : '-',
442  ((folder->ff->mode & S_ISUID) != 0) ? 's' :
443  ((folder->ff->mode & S_IXUSR) != 0) ? 'x' :
444  '-',
445  ((folder->ff->mode & S_IRGRP) != 0) ? 'r' : '-',
446  ((folder->ff->mode & S_IWGRP) != 0) ? 'w' : '-',
447  ((folder->ff->mode & S_ISGID) != 0) ? 's' :
448  ((folder->ff->mode & S_IXGRP) != 0) ? 'x' :
449  '-',
450  ((folder->ff->mode & S_IROTH) != 0) ? 'r' : '-',
451  ((folder->ff->mode & S_IWOTH) != 0) ? 'w' : '-',
452  ((folder->ff->mode & S_ISVTX) != 0) ? 't' :
453  ((folder->ff->mode & S_IXOTH) != 0) ? 'x' :
454  '-');
455  mutt_format_s(buf, buflen, prec, permission);
456  }
457 #ifdef USE_IMAP
458  else if (folder->ff->imap)
459  {
460  char permission[11];
461  /* mark folders with subfolders AND mail */
462  snprintf(permission, sizeof(permission), "IMAP %c",
463  (folder->ff->inferiors && folder->ff->selectable) ? '+' : ' ');
464  mutt_format_s(buf, buflen, prec, permission);
465  }
466 #endif
467  else
468  mutt_format_s(buf, buflen, prec, "");
469  break;
470  }
471 
472  case 'g':
473  if (folder->ff->local)
474  {
475  struct group *gr = getgrgid(folder->ff->gid);
476  if (gr)
477  mutt_format_s(buf, buflen, prec, gr->gr_name);
478  else
479  {
480  snprintf(fmt, sizeof(fmt), "%%%sld", prec);
481  snprintf(buf, buflen, fmt, folder->ff->gid);
482  }
483  }
484  else
485  mutt_format_s(buf, buflen, prec, "");
486  break;
487 
488  case 'i':
489  {
490  char *s = NULL;
491  if (folder->ff->desc)
492  s = folder->ff->desc;
493  else
494  s = folder->ff->name;
495 
496  snprintf(fn, sizeof(fn), "%s%s", s,
497  folder->ff->local ?
498  (S_ISLNK(folder->ff->mode) ?
499  "@" :
500  (S_ISDIR(folder->ff->mode) ?
501  "/" :
502  (((folder->ff->mode & S_IXUSR) != 0) ? "*" : ""))) :
503  "");
504 
505  mutt_format_s(buf, buflen, prec, fn);
506  break;
507  }
508 
509  case 'l':
510  if (folder->ff->local)
511  {
512  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
513  snprintf(buf, buflen, fmt, folder->ff->nlink);
514  }
515  else
516  mutt_format_s(buf, buflen, prec, "");
517  break;
518 
519  case 'm':
520  if (!optional)
521  {
522  if (folder->ff->has_mailbox)
523  {
524  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
525  snprintf(buf, buflen, fmt, folder->ff->msg_count);
526  }
527  else
528  mutt_format_s(buf, buflen, prec, "");
529  }
530  else if (folder->ff->msg_count == 0)
531  optional = false;
532  break;
533 
534  case 'N':
535  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
536  snprintf(buf, buflen, fmt, folder->ff->has_new_mail ? 'N' : ' ');
537  break;
538 
539  case 'n':
540  if (!optional)
541  {
542  if (folder->ff->has_mailbox)
543  {
544  snprintf(fmt, sizeof(fmt), "%%%sd", prec);
545  snprintf(buf, buflen, fmt, folder->ff->msg_unread);
546  }
547  else
548  mutt_format_s(buf, buflen, prec, "");
549  }
550  else if (folder->ff->msg_unread == 0)
551  optional = false;
552  break;
553 
554  case 's':
555  if (folder->ff->local)
556  {
557  mutt_str_pretty_size(fn, sizeof(fn), folder->ff->size);
558  snprintf(fmt, sizeof(fmt), "%%%ss", prec);
559  snprintf(buf, buflen, fmt, fn);
560  }
561  else
562  mutt_format_s(buf, buflen, prec, "");
563  break;
564 
565  case 't':
566  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
567  snprintf(buf, buflen, fmt, folder->ff->tagged ? '*' : ' ');
568  break;
569 
570  case 'u':
571  if (folder->ff->local)
572  {
573  struct passwd *pw = getpwuid(folder->ff->uid);
574  if (pw)
575  mutt_format_s(buf, buflen, prec, pw->pw_name);
576  else
577  {
578  snprintf(fmt, sizeof(fmt), "%%%sld", prec);
579  snprintf(buf, buflen, fmt, folder->ff->uid);
580  }
581  }
582  else
583  mutt_format_s(buf, buflen, prec, "");
584  break;
585 
586  default:
587  snprintf(fmt, sizeof(fmt), "%%%sc", prec);
588  snprintf(buf, buflen, fmt, op);
589  break;
590  }
591 
592  if (optional)
593  {
594  mutt_expando_format(buf, buflen, col, cols, if_str, folder_format_str, data,
596  }
597  else if (flags & MUTT_FORMAT_OPTIONAL)
598  {
599  mutt_expando_format(buf, buflen, col, cols, else_str, folder_format_str,
600  data, MUTT_FORMAT_NO_FLAGS);
601  }
602 
603  return src;
604 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_folder()

static void add_folder ( struct Menu menu,
struct BrowserState state,
const char *  name,
const char *  desc,
const struct stat *  s,
struct Mailbox m,
void *  data 
)
static

Add a folder to the browser list.

Parameters
menuMenu to use
stateBrowser state
nameName of folder
descDescription of folder
sstat info for the folder
mMailbox
dataData to associate with the folder

Definition at line 616 of file browser.c.

619 {
620  if ((!menu || menu->is_mailbox_list) && m && (m->flags & MB_HIDDEN))
621  {
622  return;
623  }
624 
625  struct FolderFile ff = { 0 };
626 
627  if (s)
628  {
629  ff.mode = s->st_mode;
630  ff.mtime = s->st_mtime;
631  ff.size = s->st_size;
632  ff.gid = s->st_gid;
633  ff.uid = s->st_uid;
634  ff.nlink = s->st_nlink;
635  ff.local = true;
636  }
637  else
638  ff.local = false;
639 
640  if (m)
641  {
642  ff.has_mailbox = true;
643  ff.gen = m->gen;
644  ff.has_new_mail = m->has_new;
645  ff.msg_count = m->msg_count;
646  ff.msg_unread = m->msg_unread;
647  }
648 
649  ff.name = mutt_str_dup(name);
650  ff.desc = mutt_str_dup(desc ? desc : name);
651 #ifdef USE_IMAP
652  ff.imap = false;
653 #endif
654 #ifdef USE_NNTP
655  if (OptNews)
656  ff.nd = data;
657 #endif
658 
659  ARRAY_ADD(&state->entry, ff);
660 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_state()

static void init_state ( struct BrowserState state,
struct Menu menu 
)
static

Initialise a browser state.

Parameters
stateBrowserState to initialise
menuCurrent menu

Definition at line 667 of file browser.c.

668 {
669  ARRAY_INIT(&state->entry);
670  ARRAY_RESERVE(&state->entry, 256);
671 #ifdef USE_IMAP
672  state->imap_browse = false;
673 #endif
674  if (menu)
675  menu->mdata = &state->entry;
676 }
+ Here is the caller graph for this function:

◆ examine_directory()

static int examine_directory ( struct Mailbox m,
struct Menu menu,
struct BrowserState state,
const char *  d,
const char *  prefix 
)
static

Get list of all files/newsgroups with mask.

Parameters
mMailbox
menuCurrent Menu
stateState of browser
dDirectory
prefixFiles/newsgroups must match this prefix
Return values
0Success
-1Error

Definition at line 688 of file browser.c.

690 {
691  int rc = -1;
692  struct Buffer *buf = mutt_buffer_pool_get();
693 #ifdef USE_NNTP
694  if (OptNews)
695  {
697 
698  init_state(state, menu);
699 
700  for (unsigned int i = 0; i < adata->groups_num; i++)
701  {
702  struct NntpMboxData *mdata = adata->groups_list[i];
703  if (!mdata)
704  continue;
705  if (prefix && *prefix && !mutt_str_startswith(mdata->group, prefix))
706  continue;
707  if (!mutt_regex_match(C_Mask, mdata->group))
708  {
709  continue;
710  }
711  add_folder(menu, state, mdata->group, NULL, NULL, NULL, mdata);
712  }
713  }
714  else
715 #endif /* USE_NNTP */
716  {
717  struct stat s;
718  DIR *dp = NULL;
719  struct dirent *de = NULL;
720 
721  while (stat(d, &s) == -1)
722  {
723  if (errno == ENOENT)
724  {
725  /* The last used directory is deleted, try to use the parent dir. */
726  char *c = strrchr(d, '/');
727 
728  if (c && (c > d))
729  {
730  *c = '\0';
731  continue;
732  }
733  }
734  mutt_perror(d);
735  goto ed_out;
736  }
737 
738  if (!S_ISDIR(s.st_mode))
739  {
740  mutt_error(_("%s is not a directory"), d);
741  goto ed_out;
742  }
743 
744  if (m)
745  mutt_mailbox_check(m, 0);
746 
747  dp = opendir(d);
748  if (!dp)
749  {
750  mutt_perror(d);
751  goto ed_out;
752  }
753 
754  init_state(state, menu);
755 
756  struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
758  while ((de = readdir(dp)))
759  {
760  if (mutt_str_equal(de->d_name, "."))
761  continue; /* we don't need . */
762 
763  if (prefix && *prefix && !mutt_str_startswith(de->d_name, prefix))
764  {
765  continue;
766  }
767  if (!mutt_regex_match(C_Mask, de->d_name))
768  {
769  continue;
770  }
771 
772  mutt_buffer_concat_path(buf, d, de->d_name);
773  if (lstat(mutt_buffer_string(buf), &s) == -1)
774  continue;
775 
776  /* No size for directories or symlinks */
777  if (S_ISDIR(s.st_mode) || S_ISLNK(s.st_mode))
778  s.st_size = 0;
779  else if (!S_ISREG(s.st_mode))
780  continue;
781 
782  struct MailboxNode *np = NULL;
783  STAILQ_FOREACH(np, &ml, entries)
784  {
786  break;
787  }
788 
789  if (np && m && mutt_str_equal(np->mailbox->realpath, m->realpath))
790  {
791  np->mailbox->msg_count = m->msg_count;
792  np->mailbox->msg_unread = m->msg_unread;
793  }
794  add_folder(menu, state, de->d_name, NULL, &s, np ? np->mailbox : NULL, NULL);
795  }
797  closedir(dp);
798  }
799  browser_sort(state);
800  rc = 0;
801 ed_out:
803  return rc;
804 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ examine_mailboxes()

static int examine_mailboxes ( struct Mailbox m,
struct Menu menu,
struct BrowserState state 
)
static

Get list of mailboxes/subscribed newsgroups.

Parameters
mMailbox
menuCurrent menu
stateState of browser
Return values
0Success
-1Error

Definition at line 814 of file browser.c.

815 {
816  struct stat s;
817  struct Buffer *md = NULL;
818  struct Buffer *mailbox = NULL;
819 
820 #ifdef USE_NNTP
821  if (OptNews)
822  {
824 
825  init_state(state, menu);
826 
827  for (unsigned int i = 0; i < adata->groups_num; i++)
828  {
829  struct NntpMboxData *mdata = adata->groups_list[i];
830  if (mdata && (mdata->has_new_mail ||
831  (mdata->subscribed && (mdata->unread || !C_ShowOnlyUnread))))
832  {
833  add_folder(menu, state, mdata->group, NULL, NULL, NULL, mdata);
834  }
835  }
836  }
837  else
838 #endif
839  {
840  init_state(state, menu);
841 
843  return -1;
844  mailbox = mutt_buffer_pool_get();
845  md = mutt_buffer_pool_get();
846 
847  mutt_mailbox_check(m, 0);
848 
849  struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
851  struct MailboxNode *np = NULL;
852  STAILQ_FOREACH(np, &ml, entries)
853  {
854  if (!np->mailbox)
855  continue;
856 
857  if (m && mutt_str_equal(np->mailbox->realpath, m->realpath))
858  {
859  np->mailbox->msg_count = m->msg_count;
860  np->mailbox->msg_unread = m->msg_unread;
861  }
862 
866 
867  switch (np->mailbox->type)
868  {
869  case MUTT_IMAP:
870  case MUTT_POP:
871  add_folder(menu, state, mutt_buffer_string(mailbox),
872  np->mailbox->name, NULL, np->mailbox, NULL);
873  continue;
874  case MUTT_NOTMUCH:
875  case MUTT_NNTP:
876  add_folder(menu, state, mailbox_path(np->mailbox), np->mailbox->name,
877  NULL, np->mailbox, NULL);
878  continue;
879  default: /* Continue */
880  break;
881  }
882 
883  if (lstat(mailbox_path(np->mailbox), &s) == -1)
884  continue;
885 
886  if ((!S_ISREG(s.st_mode)) && (!S_ISDIR(s.st_mode)) && (!S_ISLNK(s.st_mode)))
887  continue;
888 
889  if (np->mailbox->type == MUTT_MAILDIR)
890  {
891  struct stat st2;
892 
893  mutt_buffer_printf(md, "%s/new", mailbox_path(np->mailbox));
894  if (stat(mutt_buffer_string(md), &s) < 0)
895  s.st_mtime = 0;
896  mutt_buffer_printf(md, "%s/cur", mailbox_path(np->mailbox));
897  if (stat(mutt_buffer_string(md), &st2) < 0)
898  st2.st_mtime = 0;
899  if (st2.st_mtime > s.st_mtime)
900  s.st_mtime = st2.st_mtime;
901  }
902 
903  add_folder(menu, state, mutt_buffer_string(mailbox), np->mailbox->name,
904  &s, np->mailbox, NULL);
905  }
907  }
908  browser_sort(state);
909 
910  mutt_buffer_pool_release(&mailbox);
912  return 0;
913 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ select_file_search()

static int select_file_search ( struct Menu menu,
regex_t *  rx,
int  line 
)
static

Menu search callback for matching files - Implements Menu::search()

Definition at line 918 of file browser.c.

919 {
920  struct BrowserStateEntry *entry = menu->mdata;
921 #ifdef USE_NNTP
922  if (OptNews)
923  return regexec(rx, ARRAY_GET(entry, line)->desc, 0, NULL, 0);
924 #endif
925  struct FolderFile *ff = ARRAY_GET(entry, line);
926  char *search_on = ff->desc ? ff->desc : ff->name;
927 
928  return regexec(rx, search_on, 0, NULL, 0);
929 }
+ Here is the caller graph for this function:

◆ folder_make_entry()

static void folder_make_entry ( struct Menu menu,
char *  buf,
size_t  buflen,
int  line 
)
static

Format a menu item for the folder browser - Implements Menu::make_entry()

Definition at line 934 of file browser.c.

935 {
936  struct BrowserStateEntry *entry = menu->mdata;
937  struct Folder folder = {
938  .ff = ARRAY_GET(entry, line),
939  .num = line,
940  };
941 
942 #ifdef USE_NNTP
943  if (OptNews)
944  {
945  mutt_expando_format(buf, buflen, 0, menu->win_index->state.cols,
947  (intptr_t) &folder, MUTT_FORMAT_ARROWCURSOR);
948  }
949  else
950 #endif
951  {
952  mutt_expando_format(buf, buflen, 0, menu->win_index->state.cols,
954  (intptr_t) &folder, MUTT_FORMAT_ARROWCURSOR);
955  }
956 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ browser_highlight_default()

static void browser_highlight_default ( struct BrowserState state,
struct Menu menu 
)
static

Decide which browser item should be highlighted.

Parameters
stateBrowser state
menuCurrent Menu

This function takes a menu and a state and defines the current entry that should be highlighted.

Definition at line 966 of file browser.c.

967 {
968  menu->top = 0;
969  /* Reset menu position to 1.
970  * We do not risk overflow as the init_menu function changes
971  * current if it is bigger than state->entrylen. */
972  if (!ARRAY_EMPTY(&state->entry) &&
973  (mutt_str_equal(ARRAY_FIRST(&state->entry)->desc, "..") ||
974  mutt_str_equal(ARRAY_FIRST(&state->entry)->desc, "../")))
975  {
976  /* Skip the first entry, unless there's only one entry. */
977  menu->current = (menu->max > 1);
978  }
979  else
980  {
981  menu->current = 0;
982  }
983 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_menu()

static void init_menu ( struct BrowserState state,
struct Menu menu,
char *  title,
size_t  titlelen,
bool  mailbox,
struct Mailbox m 
)
static

Set up a new menu.

Parameters
stateBrowser state
menuCurrent menu
titleBuffer for the title
titlelenLength of buffer
mailboxIf true, select mailboxes
mMailbox

Definition at line 994 of file browser.c.

996 {
997  menu->max = ARRAY_SIZE(&state->entry);
998 
999  if (menu->current >= menu->max)
1000  menu->current = menu->max - 1;
1001  if (menu->current < 0)
1002  menu->current = 0;
1003  if (menu->top > menu->current)
1004  menu->top = 0;
1005 
1006  menu->tagged = 0;
1007 
1008 #ifdef USE_NNTP
1009  if (OptNews)
1010  {
1011  if (mailbox)
1012  snprintf(title, titlelen, _("Subscribed newsgroups"));
1013  else
1014  {
1015  snprintf(title, titlelen, _("Newsgroups on server [%s]"),
1017  }
1018  }
1019  else
1020 #endif
1021  {
1022  if (mailbox)
1023  {
1024  menu->is_mailbox_list = true;
1025  snprintf(title, titlelen, _("Mailboxes [%d]"), mutt_mailbox_check(m, 0));
1026  }
1027  else
1028  {
1029  struct Buffer *path = mutt_buffer_pool_get();
1030  menu->is_mailbox_list = false;
1031  mutt_buffer_copy(path, &LastDir);
1033 #ifdef USE_IMAP
1034  if (state->imap_browse && C_ImapListSubscribed)
1035  {
1036  snprintf(title, titlelen, _("Subscribed [%s], File mask: %s"),
1037  mutt_buffer_string(path), NONULL(C_Mask ? C_Mask->pattern : NULL));
1038  }
1039  else
1040 #endif
1041  {
1042  snprintf(title, titlelen, _("Directory [%s], File mask: %s"),
1043  mutt_buffer_string(path), NONULL(C_Mask ? C_Mask->pattern : NULL));
1044  }
1045  mutt_buffer_pool_release(&path);
1046  }
1047  }
1048 
1049  /* Browser tracking feature.
1050  * The goal is to highlight the good directory if LastDir is the parent dir
1051  * of LastDirBackup (this occurs mostly when one hit "../"). It should also work
1052  * properly when the user is in examine_mailboxes-mode. */
1054  {
1055  char target_dir[PATH_MAX] = { 0 };
1056 
1057 #ifdef USE_IMAP
1058  /* Check what kind of dir LastDirBackup is. */
1060  {
1061  mutt_str_copy(target_dir, mutt_buffer_string(&LastDirBackup), sizeof(target_dir));
1062  imap_clean_path(target_dir, sizeof(target_dir));
1063  }
1064  else
1065 #endif
1066  mutt_str_copy(target_dir, strrchr(mutt_buffer_string(&LastDirBackup), '/') + 1,
1067  sizeof(target_dir));
1068 
1069  /* If we get here, it means that LastDir is the parent directory of
1070  * LastDirBackup. I.e., we're returning from a subdirectory, and we want
1071  * to position the cursor on the directory we're returning from. */
1072  bool matched = false;
1073  struct FolderFile *ff = NULL;
1074  ARRAY_FOREACH(ff, &state->entry)
1075  {
1076  if (mutt_str_equal(ff->name, target_dir))
1077  {
1078  menu->current = ARRAY_FOREACH_IDX;
1079  matched = true;
1080  break;
1081  }
1082  }
1083  if (!matched)
1084  browser_highlight_default(state, menu);
1085  }
1086  else
1087  browser_highlight_default(state, menu);
1088 
1089  menu->redraw = REDRAW_FULL;
1090 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ file_tag()

static int file_tag ( struct Menu menu,
int  sel,
int  act 
)
static

Tag an entry in the menu - Implements Menu::tag()

Definition at line 1095 of file browser.c.

1096 {
1097  struct BrowserStateEntry *entry = menu->mdata;
1098  struct FolderFile *ff = ARRAY_GET(entry, sel);
1099  if (S_ISDIR(ff->mode) ||
1100  (S_ISLNK(ff->mode) && link_is_dir(mutt_buffer_string(&LastDir), ff->name)))
1101  {
1102  mutt_error(_("Can't attach a directory"));
1103  return 0;
1104  }
1105 
1106  bool ot = ff->tagged;
1107  ff->tagged = ((act >= 0) ? act : !ff->tagged);
1108 
1109  return ff->tagged - ot;
1110 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_browser_select_dir()

void mutt_browser_select_dir ( const char *  f)

Remember the last directory selected.

Parameters
fDirectory name to save

This function helps the browser to know which directory has been selected. It should be called anywhere a confirm hit is done to open a new directory/file which is a maildir/mbox.

We could check if the sort method is appropriate with this feature.

Definition at line 1122 of file browser.c.

1123 {
1124  init_lastdir();
1125 
1127 
1128  /* Method that will fetch the parent path depending on the type of the path. */
1129  char buf[PATH_MAX];
1131  mutt_buffer_strcpy(&LastDir, buf);
1132 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_buffer_select_file()

void mutt_buffer_select_file ( struct Buffer file,
SelectFileFlags  flags,
struct Mailbox m,
char ***  files,
int *  numfiles 
)

Let the user select a file.

Parameters
[in]fileBuffer for the result
[in]flagsFlags, see SelectFileFlags
[in]mMailbox
[out]filesArray of selected files
[out]numfilesNumber of selected files

Definition at line 1142 of file browser.c.

1144 {
1145  char title[256];
1146  struct BrowserState state = { { 0 } };
1147  struct Menu *menu = NULL;
1148  bool kill_prefix = false;
1149  bool multiple = (flags & MUTT_SEL_MULTI);
1150  bool folder = (flags & MUTT_SEL_FOLDER);
1151  bool mailbox = (flags & MUTT_SEL_MAILBOX);
1152 
1153  /* Keeps in memory the directory we were in when hitting '='
1154  * to go directly to $folder (`$folder`) */
1155  char goto_swapper[PATH_MAX] = { 0 };
1156 
1157  mailbox = mailbox && folder;
1158 
1159  struct Buffer *OldLastDir = mutt_buffer_pool_get();
1160  struct Buffer *tmp = mutt_buffer_pool_get();
1161  struct Buffer *buf = mutt_buffer_pool_get();
1162  struct Buffer *prefix = mutt_buffer_pool_get();
1163 
1164  init_lastdir();
1165 
1166 #ifdef USE_NNTP
1167  if (OptNews)
1168  {
1169  if (mutt_buffer_is_empty(file))
1170  {
1172 
1173  /* default state for news reader mode is browse subscribed newsgroups */
1174  mailbox = false;
1175  for (size_t i = 0; i < adata->groups_num; i++)
1176  {
1177  struct NntpMboxData *mdata = adata->groups_list[i];
1178  if (mdata && mdata->subscribed)
1179  {
1180  mailbox = true;
1181  break;
1182  }
1183  }
1184  }
1185  else
1186  {
1187  mutt_buffer_copy(prefix, file);
1188  }
1189  }
1190  else
1191 #endif
1192  if (!mutt_buffer_is_empty(file))
1193  {
1195 #ifdef USE_IMAP
1196  if (imap_path_probe(mutt_buffer_string(file), NULL) == MUTT_IMAP)
1197  {
1198  init_state(&state, NULL);
1199  state.imap_browse = true;
1200  if (imap_browse(mutt_buffer_string(file), &state) == 0)
1201  {
1203  browser_sort(&state);
1204  }
1205  }
1206  else
1207  {
1208 #endif
1209  int i;
1210  for (i = mutt_buffer_len(file) - 1;
1211  (i > 0) && ((mutt_buffer_string(file))[i] != '/'); i--)
1212  {
1213  ; // do nothing
1214  }
1215 
1216  if (i > 0)
1217  {
1218  if ((mutt_buffer_string(file))[0] == '/')
1220  else
1221  {
1223  mutt_buffer_addch(&LastDir, '/');
1225  }
1226  }
1227  else
1228  {
1229  if ((mutt_buffer_string(file))[0] == '/')
1230  mutt_buffer_strcpy(&LastDir, "/");
1231  else
1233  }
1234 
1235  if ((i <= 0) && (mutt_buffer_string(file)[0] != '/'))
1236  mutt_buffer_copy(prefix, file);
1237  else
1238  mutt_buffer_strcpy(prefix, mutt_buffer_string(file) + i + 1);
1239  kill_prefix = true;
1240 #ifdef USE_IMAP
1241  }
1242 #endif
1243  }
1244  else
1245  {
1246  if (!folder)
1248  else
1249  {
1250  /* Whether we use the tracking feature of the browser depends
1251  * on which sort method we chose to use. This variable is defined
1252  * only to help readability of the code. */
1253  bool browser_track = false;
1254 
1255  switch (C_SortBrowser & SORT_MASK)
1256  {
1257  case SORT_DESC:
1258  case SORT_SUBJECT:
1259  case SORT_ORDER:
1260  browser_track = true;
1261  break;
1262  }
1263 
1264  /* We use mutt_browser_select_dir to initialize the two
1265  * variables (LastDir, LastDirBackup) at the appropriate
1266  * values.
1267  *
1268  * We do it only when LastDir is not set (first pass there)
1269  * or when CurrentFolder and LastDirBackup are not the same.
1270  * This code is executed only when we list files, not when
1271  * we press up/down keys to navigate in a displayed list.
1272  *
1273  * We only do this when CurrentFolder has been set (ie, not
1274  * when listing folders on startup with "neomutt -y").
1275  *
1276  * This tracker is only used when browser_track is true,
1277  * meaning only with sort methods SUBJECT/DESC for now. */
1278  if (CurrentFolder)
1279  {
1281  {
1282  /* If browsing in "local"-mode, than we chose to define LastDir to
1283  * MailDir */
1284  switch (mx_path_probe(CurrentFolder))
1285  {
1286  case MUTT_IMAP:
1287  case MUTT_MAILDIR:
1288  case MUTT_MBOX:
1289  case MUTT_MH:
1290  case MUTT_MMDF:
1291  if (C_Folder)
1293  else if (C_SpoolFile)
1295  break;
1296  default:
1298  break;
1299  }
1300  }
1302  {
1304  }
1305  }
1306 
1307  /* When browser tracking feature is disabled, clear LastDirBackup */
1308  if (!browser_track)
1310  }
1311 
1312 #ifdef USE_IMAP
1313  if (!mailbox && (imap_path_probe(mutt_buffer_string(&LastDir), NULL) == MUTT_IMAP))
1314  {
1315  init_state(&state, NULL);
1316  state.imap_browse = true;
1318  browser_sort(&state);
1319  }
1320  else
1321 #endif
1322  {
1323  size_t i = mutt_buffer_len(&LastDir);
1324  while ((i > 0) && (mutt_buffer_string(&LastDir)[--i] == '/'))
1325  LastDir.data[i] = '\0';
1329  }
1330  }
1331 
1332  mutt_buffer_reset(file);
1333 
1334  menu = mutt_menu_new(MENU_FOLDER);
1336 
1337 #ifdef USE_NNTP
1338  if (OptNews)
1339  dlg->help_data = FolderNewsHelp;
1340  else
1341 #endif
1342  dlg->help_data = FolderHelp;
1343  dlg->help_menu = MENU_FOLDER;
1344 
1345  menu->make_entry = folder_make_entry;
1346  menu->search = select_file_search;
1347  menu->title = title;
1348  if (multiple)
1349  menu->tag = file_tag;
1350 
1351  mutt_menu_push_current(menu);
1352 
1353  if (mailbox)
1354  {
1355  examine_mailboxes(m, NULL, &state);
1356  }
1357  else
1358 #ifdef USE_IMAP
1359  if (!state.imap_browse)
1360 #endif
1361  {
1362  // examine_directory() calls add_folder() which needs the menu
1364  mutt_buffer_string(prefix)) == -1)
1365  {
1366  goto bail;
1367  }
1368  }
1369 
1370  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1371  // only now do we have a valid state to attach
1372  menu->mdata = &state.entry;
1373 
1374  while (true)
1375  {
1376  int op = mutt_menu_loop(menu);
1377  if (op >= 0)
1378  mutt_debug(LL_DEBUG1, "Got op %s (%d)\n", OpStrings[op][0], op);
1379  struct FolderFile *ff = ARRAY_GET(&state.entry, menu->current);
1380  switch (op)
1381  {
1382  case OP_DESCEND_DIRECTORY:
1383  case OP_GENERIC_SELECT_ENTRY:
1384  {
1385  if (ARRAY_EMPTY(&state.entry))
1386  {
1387  mutt_error(_("No files match the file mask"));
1388  break;
1389  }
1390 
1391  if (S_ISDIR(ff->mode) ||
1392  (S_ISLNK(ff->mode) && link_is_dir(mutt_buffer_string(&LastDir), ff->name))
1393 #ifdef USE_IMAP
1394  || ff->inferiors
1395 #endif
1396  )
1397  {
1398  /* make sure this isn't a MH or maildir mailbox */
1399  if (mailbox)
1400  {
1401  mutt_buffer_strcpy(buf, ff->name);
1403  }
1404 #ifdef USE_IMAP
1405  else if (state.imap_browse)
1406  {
1407  mutt_buffer_strcpy(buf, ff->name);
1408  }
1409 #endif
1410  else
1411  {
1413  }
1414 
1415  enum MailboxType type = mx_path_probe(mutt_buffer_string(buf));
1416  if ((op == OP_DESCEND_DIRECTORY) || (type == MUTT_MAILBOX_ERROR) ||
1417  (type == MUTT_UNKNOWN)
1418 #ifdef USE_IMAP
1419  || ff->inferiors
1420 #endif
1421  )
1422  {
1423  /* save the old directory */
1424  mutt_buffer_copy(OldLastDir, &LastDir);
1425 
1426  if (mutt_str_equal(ff->name, ".."))
1427  {
1428  size_t lastdirlen = mutt_buffer_len(&LastDir);
1429  if ((lastdirlen > 1) &&
1430  mutt_str_equal("..", mutt_buffer_string(&LastDir) + lastdirlen - 2))
1431  {
1432  mutt_buffer_addstr(&LastDir, "/..");
1433  }
1434  else
1435  {
1436  char *p = NULL;
1437  if (lastdirlen > 1)
1438  p = strrchr(mutt_buffer_string(&LastDir) + 1, '/');
1439 
1440  if (p)
1441  {
1442  *p = '\0';
1444  }
1445  else
1446  {
1447  if (mutt_buffer_string(&LastDir)[0] == '/')
1448  mutt_buffer_strcpy(&LastDir, "/");
1449  else
1450  mutt_buffer_addstr(&LastDir, "/..");
1451  }
1452  }
1453  }
1454  else if (mailbox)
1455  {
1458  }
1459 #ifdef USE_IMAP
1460  else if (state.imap_browse)
1461  {
1463  /* tack on delimiter here */
1464 
1465  /* special case "" needs no delimiter */
1466  struct Url *url = url_parse(ff->name);
1467  if (url && url->path && (ff->delim != '\0'))
1468  {
1470  }
1471  url_free(&url);
1472  }
1473 #endif
1474  else
1475  {
1477  mutt_buffer_copy(&LastDir, tmp);
1478  }
1479 
1480  destroy_state(&state);
1481  if (kill_prefix)
1482  {
1483  mutt_buffer_reset(prefix);
1484  kill_prefix = false;
1485  }
1486  mailbox = false;
1487 #ifdef USE_IMAP
1488  if (state.imap_browse)
1489  {
1490  init_state(&state, NULL);
1491  state.imap_browse = true;
1493  browser_sort(&state);
1494  menu->mdata = &state.entry;
1495  }
1496  else
1497 #endif
1498  {
1499  if (examine_directory(m, menu, &state, mutt_buffer_string(&LastDir),
1500  mutt_buffer_string(prefix)) == -1)
1501  {
1502  /* try to restore the old values */
1503  mutt_buffer_copy(&LastDir, OldLastDir);
1504  if (examine_directory(m, menu, &state, mutt_buffer_string(&LastDir),
1505  mutt_buffer_string(prefix)) == -1)
1506  {
1508  goto bail;
1509  }
1510  }
1511  /* resolve paths navigated from GUI */
1512  if (mutt_path_realpath(LastDir.data) == 0)
1513  break;
1514  }
1515 
1516  browser_highlight_default(&state, menu);
1517  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1518  goto_swapper[0] = '\0';
1519  break;
1520  }
1521  }
1522  else if (op == OP_DESCEND_DIRECTORY)
1523  {
1524  mutt_error(_("%s is not a directory"),
1525  ARRAY_GET(&state.entry, menu->current)->name);
1526  break;
1527  }
1528 
1529  if (mailbox || OptNews) /* USE_NNTP */
1530  {
1531  mutt_buffer_strcpy(file, ff->name);
1533  }
1534 #ifdef USE_IMAP
1535  else if (state.imap_browse)
1536  mutt_buffer_strcpy(file, ff->name);
1537 #endif
1538  else
1539  {
1541  }
1542  }
1543  /* fallthrough */
1544 
1545  case OP_EXIT:
1546 
1547  if (multiple)
1548  {
1549  char **tfiles = NULL;
1550 
1551  if (menu->tagged)
1552  {
1553  *numfiles = menu->tagged;
1554  tfiles = mutt_mem_calloc(*numfiles, sizeof(char *));
1555  size_t j = 0;
1556  ARRAY_FOREACH(ff, &state.entry)
1557  {
1558  if (ff->tagged)
1559  {
1562  tfiles[j++] = mutt_buffer_strdup(tmp);
1563  }
1564  }
1565  *files = tfiles;
1566  }
1567  else if (!mutt_buffer_is_empty(file)) /* no tagged entries. return selected entry */
1568  {
1569  *numfiles = 1;
1570  tfiles = mutt_mem_calloc(*numfiles, sizeof(char *));
1572  tfiles[0] = mutt_buffer_strdup(file);
1573  *files = tfiles;
1574  }
1575  }
1576 
1577  destroy_state(&state);
1578  goto bail;
1579 
1580  case OP_BROWSER_TELL:
1581  if (!ARRAY_EMPTY(&state.entry))
1582  mutt_message("%s", ARRAY_GET(&state.entry, menu->current)->name);
1583  break;
1584 
1585 #ifdef USE_IMAP
1586  case OP_BROWSER_TOGGLE_LSUB:
1587  bool_str_toggle(NeoMutt->sub, "imap_list_subscribed", NULL);
1588 
1589  mutt_unget_event(0, OP_CHECK_NEW);
1590  break;
1591 
1592  case OP_CREATE_MAILBOX:
1593  if (!state.imap_browse)
1594  {
1595  mutt_error(_("Create is only supported for IMAP mailboxes"));
1596  break;
1597  }
1598 
1600  {
1601  /* TODO: find a way to detect if the new folder would appear in
1602  * this window, and insert it without starting over. */
1603  destroy_state(&state);
1604  init_state(&state, NULL);
1605  state.imap_browse = true;
1607  browser_sort(&state);
1608  menu->mdata = &state.entry;
1609  browser_highlight_default(&state, menu);
1610  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1611  }
1612  /* else leave error on screen */
1613  break;
1614 
1615  case OP_RENAME_MAILBOX:
1616  if (!ff->imap)
1617  mutt_error(_("Rename is only supported for IMAP mailboxes"));
1618  else
1619  {
1620  if (imap_mailbox_rename(ff->name) >= 0)
1621  {
1622  destroy_state(&state);
1623  init_state(&state, NULL);
1624  state.imap_browse = true;
1626  browser_sort(&state);
1627  menu->mdata = &state.entry;
1628  browser_highlight_default(&state, menu);
1629  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1630  }
1631  }
1632  break;
1633 
1634  case OP_DELETE_MAILBOX:
1635  if (!ff->imap)
1636  mutt_error(_("Delete is only supported for IMAP mailboxes"));
1637  else
1638  {
1639  char msg[128];
1640 
1641  // TODO(sileht): It could be better to select INBOX instead. But I
1642  // don't want to manipulate Context/Mailboxes/mailbox->account here for now.
1643  // Let's just protect neomutt against crash for now. #1417
1644  if (mutt_str_equal(mailbox_path(m), ff->name))
1645  {
1646  mutt_error(_("Can't delete currently selected mailbox"));
1647  break;
1648  }
1649 
1650  snprintf(msg, sizeof(msg), _("Really delete mailbox \"%s\"?"), ff->name);
1651  if (mutt_yesorno(msg, MUTT_NO) == MUTT_YES)
1652  {
1653  if (imap_delete_mailbox(m, ff->name) == 0)
1654  {
1655  /* free the mailbox from the browser */
1656  FREE(&ff->name);
1657  FREE(&ff->desc);
1658  /* and move all other entries up */
1659  ARRAY_REMOVE(&state.entry, ff);
1660  mutt_message(_("Mailbox deleted"));
1661  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1662  }
1663  else
1664  mutt_error(_("Mailbox deletion failed"));
1665  }
1666  else
1667  mutt_message(_("Mailbox not deleted"));
1668  }
1669  break;
1670 #endif
1671 
1672  case OP_GOTO_PARENT:
1673  case OP_CHANGE_DIRECTORY:
1674 
1675 #ifdef USE_NNTP
1676  if (OptNews)
1677  break;
1678 #endif
1679 
1680  mutt_buffer_copy(buf, &LastDir);
1681 #ifdef USE_IMAP
1682  if (!state.imap_browse)
1683 #endif
1684  {
1685  /* add '/' at the end of the directory name if not already there */
1686  size_t len = mutt_buffer_len(buf);
1687  if ((len > 0) && (mutt_buffer_string(&LastDir)[len - 1] != '/'))
1688  mutt_buffer_addch(buf, '/');
1689  }
1690 
1691  if (op == OP_CHANGE_DIRECTORY)
1692  {
1693  /* buf comes from the buffer pool, so defaults to size 1024 */
1694  int ret = mutt_buffer_get_field(_("Chdir to: "), buf, MUTT_FILE,
1695  false, NULL, NULL, NULL);
1696  if ((ret != 0) && mutt_buffer_is_empty(buf))
1697  break;
1698  }
1699  else if (op == OP_GOTO_PARENT)
1701 
1702  if (!mutt_buffer_is_empty(buf))
1703  {
1704  mailbox = false;
1706 #ifdef USE_IMAP
1707  if (imap_path_probe(mutt_buffer_string(buf), NULL) == MUTT_IMAP)
1708  {
1709  mutt_buffer_copy(&LastDir, buf);
1710  destroy_state(&state);
1711  init_state(&state, NULL);
1712  state.imap_browse = true;
1714  browser_sort(&state);
1715  menu->mdata = &state.entry;
1716  browser_highlight_default(&state, menu);
1717  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1718  }
1719  else
1720 #endif
1721  {
1722  if (mutt_buffer_string(buf)[0] != '/')
1723  {
1724  /* in case dir is relative, make it relative to LastDir,
1725  * not current working dir */
1727  mutt_buffer_string(buf));
1728  mutt_buffer_copy(buf, tmp);
1729  }
1730  /* Resolve path from <chdir>
1731  * Avoids buildup such as /a/b/../../c
1732  * Symlinks are always unraveled to keep code simple */
1733  if (mutt_path_realpath(buf->data) == 0)
1734  break;
1735 
1736  struct stat st;
1737  if (stat(mutt_buffer_string(buf), &st) == 0)
1738  {
1739  if (S_ISDIR(st.st_mode))
1740  {
1741  destroy_state(&state);
1742  if (examine_directory(m, menu, &state, mutt_buffer_string(buf),
1743  mutt_buffer_string(prefix)) == 0)
1744  {
1745  mutt_buffer_copy(&LastDir, buf);
1746  }
1747  else
1748  {
1749  mutt_error(_("Error scanning directory"));
1750  if (examine_directory(m, menu, &state, mutt_buffer_string(&LastDir),
1751  mutt_buffer_string(prefix)) == -1)
1752  {
1753  goto bail;
1754  }
1755  }
1756  browser_highlight_default(&state, menu);
1757  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1758  }
1759  else
1760  mutt_error(_("%s is not a directory"), mutt_buffer_string(buf));
1761  }
1762  else
1764  }
1765  }
1766  break;
1767 
1768  case OP_ENTER_MASK:
1769  {
1770  mutt_buffer_strcpy(buf, C_Mask ? C_Mask->pattern : NULL);
1771  if (mutt_get_field(_("File Mask: "), buf->data, buf->dsize,
1772  MUTT_COMP_NO_FLAGS, false, NULL, NULL) != 0)
1773  {
1774  break;
1775  }
1776 
1777  mutt_buffer_fix_dptr(buf);
1778 
1779  mailbox = false;
1780  /* assume that the user wants to see everything */
1781  if (mutt_buffer_is_empty(buf))
1782  mutt_buffer_strcpy(buf, ".");
1783 
1784  struct Buffer errmsg = mutt_buffer_make(256);
1785  int rc = cs_subset_str_string_set(NeoMutt->sub, "mask",
1786  mutt_buffer_string(buf), &errmsg);
1787  if (CSR_RESULT(rc) != CSR_SUCCESS)
1788  {
1789  if (!mutt_buffer_is_empty(&errmsg))
1790  {
1791  mutt_error("%s", mutt_buffer_string(&errmsg));
1792  mutt_buffer_dealloc(&errmsg);
1793  }
1794  break;
1795  }
1796  mutt_buffer_dealloc(&errmsg);
1797 
1798  destroy_state(&state);
1799 #ifdef USE_IMAP
1800  if (state.imap_browse)
1801  {
1802  init_state(&state, NULL);
1803  state.imap_browse = true;
1805  browser_sort(&state);
1806  menu->mdata = &state.entry;
1807  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1808  }
1809  else
1810 #endif
1811  if (examine_directory(m, menu, &state, mutt_buffer_string(&LastDir), NULL) == 0)
1812  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1813  else
1814  {
1815  mutt_error(_("Error scanning directory"));
1816  goto bail;
1817  }
1818  kill_prefix = false;
1819  if (ARRAY_EMPTY(&state.entry))
1820  {
1821  mutt_error(_("No files match the file mask"));
1822  break;
1823  }
1824  break;
1825  }
1826 
1827  case OP_SORT:
1828  case OP_SORT_REVERSE:
1829 
1830  {
1831  bool resort = true;
1832  int sort = -1;
1833  int reverse = (op == OP_SORT_REVERSE);
1834 
1835  switch (mutt_multi_choice(
1836  (reverse) ?
1837  /* L10N: The highlighted letters must match the "Sort" options */
1838  _("Reverse sort by (d)ate, (a)lpha, si(z)e, d(e)scription, "
1839  "(c)ount, ne(w) count, or do(n)'t sort?") :
1840  /* L10N: The highlighted letters must match the "Reverse Sort" options */
1841  _("Sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount, "
1842  "ne(w) count, or do(n)'t sort?"),
1843  /* L10N: These must match the highlighted letters from "Sort" and "Reverse Sort" */
1844  _("dazecwn")))
1845  {
1846  case -1: /* abort */
1847  resort = false;
1848  break;
1849 
1850  case 1: /* (d)ate */
1851  sort = SORT_DATE;
1852  break;
1853 
1854  case 2: /* (a)lpha */
1855  sort = SORT_SUBJECT;
1856  break;
1857 
1858  case 3: /* si(z)e */
1859  sort = SORT_SIZE;
1860  break;
1861 
1862  case 4: /* d(e)scription */
1863  sort = SORT_DESC;
1864  break;
1865 
1866  case 5: /* (c)ount */
1867  sort = SORT_COUNT;
1868  break;
1869 
1870  case 6: /* ne(w) count */
1871  sort = SORT_UNREAD;
1872  break;
1873 
1874  case 7: /* do(n)'t sort */
1875  sort = SORT_ORDER;
1876  break;
1877  }
1878  if (resort)
1879  {
1880  sort |= reverse ? SORT_REVERSE : 0;
1881  cs_subset_str_native_set(NeoMutt->sub, "sort_browser", sort, NULL);
1882  browser_sort(&state);
1883  browser_highlight_default(&state, menu);
1884  menu->redraw = REDRAW_FULL;
1885  }
1886  else
1887  {
1888  cs_subset_str_native_set(NeoMutt->sub, "sort_browser", sort, NULL);
1889  }
1890  break;
1891  }
1892 
1893  case OP_TOGGLE_MAILBOXES:
1894  case OP_BROWSER_GOTO_FOLDER:
1895  case OP_CHECK_NEW:
1896  if (op == OP_TOGGLE_MAILBOXES)
1897  {
1898  mailbox = !mailbox;
1899  menu->is_mailbox_list = mailbox;
1900  }
1901 
1902  if (op == OP_BROWSER_GOTO_FOLDER)
1903  {
1904  /* When in mailboxes mode, disables this feature */
1905  if (C_Folder)
1906  {
1907  mutt_debug(LL_DEBUG3, "= hit! Folder: %s, LastDir: %s\n", C_Folder,
1909  if (goto_swapper[0] == '\0')
1910  {
1912  {
1913  /* Stores into goto_swapper LastDir, and swaps to `$folder` */
1914  mutt_str_copy(goto_swapper, mutt_buffer_string(&LastDir),
1915  sizeof(goto_swapper));
1918  }
1919  }
1920  else
1921  {
1923  mutt_buffer_strcpy(&LastDir, goto_swapper);
1924  goto_swapper[0] = '\0';
1925  }
1926  }
1927  }
1928  destroy_state(&state);
1929  mutt_buffer_reset(prefix);
1930  kill_prefix = false;
1931 
1932  if (mailbox)
1933  {
1934  examine_mailboxes(m, menu, &state);
1935  }
1936 #ifdef USE_IMAP
1937  else if (imap_path_probe(mutt_buffer_string(&LastDir), NULL) == MUTT_IMAP)
1938  {
1939  init_state(&state, NULL);
1940  state.imap_browse = true;
1942  browser_sort(&state);
1943  menu->mdata = &state.entry;
1944  }
1945 #endif
1946  else if (examine_directory(m, menu, &state, mutt_buffer_string(&LastDir),
1947  mutt_buffer_string(prefix)) == -1)
1948  {
1949  goto bail;
1950  }
1951  init_menu(&state, menu, title, sizeof(title), mailbox, m);
1952  break;
1953 
1954  case OP_MAILBOX_LIST:
1956  break;
1957 
1958  case OP_BROWSER_NEW_FILE:
1960  /* buf comes from the buffer pool, so defaults to size 1024 */
1961  if (mutt_buffer_get_field(_("New file name: "), buf, MUTT_FILE, false,
1962  NULL, NULL, NULL) == 0)
1963  {
1964  mutt_buffer_copy(file, buf);
1965  destroy_state(&state);
1966  goto bail;
1967  }
1968  break;
1969 
1970  case OP_BROWSER_VIEW_FILE:
1971  if (ARRAY_EMPTY(&state.entry))
1972  {
1973  mutt_error(_("No files match the file mask"));
1974  break;
1975  }
1976 
1977 #ifdef USE_IMAP
1978  if (ff->selectable)
1979  {
1980  mutt_buffer_strcpy(file, ff->name);
1981  destroy_state(&state);
1982  goto bail;
1983  }
1984  else
1985 #endif
1986  if (S_ISDIR(ff->mode) ||
1987  (S_ISLNK(ff->mode) && link_is_dir(mutt_buffer_string(&LastDir), ff->name)))
1988  {
1989  mutt_error(_("Can't view a directory"));
1990  break;
1991  }
1992  else
1993  {
1994  char buf2[PATH_MAX];
1995 
1996  mutt_path_concat(buf2, mutt_buffer_string(&LastDir), ff->name, sizeof(buf2));
1997  struct Body *b = mutt_make_file_attach(buf2, NeoMutt->sub);
1998  if (b)
1999  {
2000  mutt_view_attachment(NULL, b, MUTT_VA_REGULAR, NULL, NULL, menu->win_index);
2001  mutt_body_free(&b);
2002  menu->redraw = REDRAW_FULL;
2003  }
2004  else
2005  mutt_error(_("Error trying to view file"));
2006  }
2007  break;
2008 
2009 #ifdef USE_NNTP
2010  case OP_CATCHUP:
2011  case OP_UNCATCHUP:
2012  {
2013  if (!OptNews)
2014  break;
2015 
2016  struct NntpMboxData *mdata = NULL;
2017 
2019  if (rc < 0)
2020  break;
2021 
2022  if (op == OP_CATCHUP)
2024  else
2026 
2027  if (mdata)
2028  {
2030  if ((menu->current + 1) < menu->max)
2031  menu->current++;
2032  menu->redraw = REDRAW_MOTION_RESYNC;
2033  }
2034  if (rc)
2035  menu->redraw = REDRAW_INDEX;
2037  break;
2038  }
2039 
2040  case OP_LOAD_ACTIVE:
2041  {
2042  if (!OptNews)
2043  break;
2044 
2046 
2047  if (nntp_newsrc_parse(adata) < 0)
2048  break;
2049 
2050  for (size_t i = 0; i < adata->groups_num; i++)
2051  {
2052  struct NntpMboxData *mdata = adata->groups_list[i];
2053  if (mdata)
2054  mdata->deleted = true;
2055  }
2056  nntp_active_fetch(adata, true);
2059 
2060  destroy_state(&state);
2061  if (mailbox)
2062  examine_mailboxes(m, menu, &state);
2063  else
2064  {
2065  if (examine_directory(m, menu, &state, NULL, NULL) == -1)
2066  break;
2067  }
2068  init_menu(&state, menu, title, sizeof(title), mailbox, m);
2069  break;
2070  }
2071 #endif /* USE_NNTP */
2072 
2073 #if defined(USE_IMAP) || defined(USE_NNTP)
2074  case OP_BROWSER_SUBSCRIBE:
2075  case OP_BROWSER_UNSUBSCRIBE:
2076 #endif
2077 #ifdef USE_NNTP
2078  case OP_SUBSCRIBE_PATTERN:
2079  case OP_UNSUBSCRIBE_PATTERN:
2080  if (OptNews)
2081  {
2083  regex_t rx;
2084  memset(&rx, 0, sizeof(rx));
2085  char *s = buf->data;
2086  int i = menu->current;
2087 
2088  if ((op == OP_SUBSCRIBE_PATTERN) || (op == OP_UNSUBSCRIBE_PATTERN))
2089  {
2090  char tmp2[256];
2091 
2092  mutt_buffer_reset(buf);
2093  if (op == OP_SUBSCRIBE_PATTERN)
2094  snprintf(tmp2, sizeof(tmp2), _("Subscribe pattern: "));
2095  else
2096  snprintf(tmp2, sizeof(tmp2), _("Unsubscribe pattern: "));
2097  /* buf comes from the buffer pool, so defaults to size 1024 */
2098  if ((mutt_buffer_get_field(tmp2, buf, MUTT_PATTERN, false, NULL, NULL, NULL) != 0) ||
2099  mutt_buffer_is_empty(buf))
2100  {
2101  break;
2102  }
2103 
2104  int err = REG_COMP(&rx, s, REG_NOSUB);
2105  if (err != 0)
2106  {
2107  regerror(err, &rx, buf->data, buf->dsize);
2108  regfree(&rx);
2109  mutt_error("%s", mutt_buffer_string(buf));
2110  break;
2111  }
2112  menu->redraw = REDRAW_FULL;
2113  i = 0;
2114  }
2115  else if (ARRAY_EMPTY(&state.entry))
2116  {
2117  mutt_error(_("No newsgroups match the mask"));
2118  break;
2119  }
2120 
2121  int rc = nntp_newsrc_parse(adata);
2122  if (rc < 0)
2123  break;
2124 
2125  ARRAY_FOREACH_FROM(ff, &state.entry, i)
2126  {
2127  if ((op == OP_BROWSER_SUBSCRIBE) || (op == OP_BROWSER_UNSUBSCRIBE) ||
2128  (regexec(&rx, ff->name, 0, NULL, 0) == 0))
2129  {
2130  if ((op == OP_BROWSER_SUBSCRIBE) || (op == OP_SUBSCRIBE_PATTERN))
2132  else
2134  }
2135  if ((op == OP_BROWSER_SUBSCRIBE) || (op == OP_BROWSER_UNSUBSCRIBE))
2136  {
2137  if ((menu->current + 1) < menu->max)
2138  menu->current++;
2139  menu->redraw = REDRAW_MOTION_RESYNC;
2140  break;
2141  }
2142  }
2143 
2144  if (op == OP_SUBSCRIBE_PATTERN)
2145  {
2146  for (size_t j = 0; adata && (j < adata->groups_num); j++)
2147  {
2148  struct NntpMboxData *mdata = adata->groups_list[j];
2149  if (mdata && mdata->group && !mdata->subscribed)
2150  {
2151  if (regexec(&rx, mdata->group, 0, NULL, 0) == 0)
2152  {
2154  add_folder(menu, &state, mdata->group, NULL, NULL, NULL, mdata);
2155  }
2156  }
2157  }
2158  init_menu(&state, menu, title, sizeof(title), mailbox, m);
2159  }
2160  if (rc > 0)
2161  menu->redraw = REDRAW_FULL;
2165  if ((op != OP_BROWSER_SUBSCRIBE) && (op != OP_BROWSER_UNSUBSCRIBE))
2166  regfree(&rx);
2167  }
2168 #ifdef USE_IMAP
2169  else
2170 #endif /* USE_IMAP && USE_NNTP */
2171 #endif /* USE_NNTP */
2172 #ifdef USE_IMAP
2173  {
2174  char tmp2[256];
2175  mutt_str_copy(tmp2, ff->name, sizeof(tmp2));
2176  mutt_expand_path(tmp2, sizeof(tmp2));
2177  imap_subscribe(tmp2, (op == OP_BROWSER_SUBSCRIBE));
2178  }
2179 #endif /* USE_IMAP */
2180  }
2181  }
2182 
2183 bail:
2184  mutt_buffer_pool_release(&OldLastDir);
2187  mutt_buffer_pool_release(&prefix);
2188 
2189  if (menu)
2190  {
2191  mutt_menu_pop_current(menu);
2192  mutt_menu_free(&menu);
2194  }
2195 
2196  goto_swapper[0] = '\0';
2197 }
+ Here is the caller graph for this function:

◆ mutt_select_file()

void mutt_select_file ( char *  file,
size_t  filelen,
SelectFileFlags  flags,
struct Mailbox m,
char ***  files,
int *  numfiles 
)

Let the user select a file.

Parameters
[in]fileBuffer for the result
[in]filelenLength of buffer
[in]flagsFlags, see SelectFileFlags
[in]mMailbox
[out]filesArray of selected files
[out]numfilesNumber of selected files

Definition at line 2208 of file browser.c.

2210 {
2211  struct Buffer *f_buf = mutt_buffer_pool_get();
2212 
2213  mutt_buffer_strcpy(f_buf, NONULL(file));
2214  mutt_buffer_select_file(f_buf, flags, m, files, numfiles);
2215  mutt_str_copy(file, mutt_buffer_string(f_buf), filelen);
2216 
2217  mutt_buffer_pool_release(&f_buf);
2218 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_BrowserAbbreviateMailboxes

bool C_BrowserAbbreviateMailboxes

Config: Abbreviate mailboxes using '~' and '=' in the browser.

Definition at line 72 of file browser.c.

◆ C_FolderFormat

char* C_FolderFormat

Config: printf-like format string for the browser's display of folders.

Definition at line 73 of file browser.c.

◆ C_SortBrowser

short C_SortBrowser

Config: Sort method for the browser.

Definition at line 74 of file browser.c.

◆ FolderHelp

const struct Mapping FolderHelp[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("Chdir"), OP_CHANGE_DIRECTORY },
{ N_("Goto"), OP_BROWSER_GOTO_FOLDER },
{ N_("Mask"), OP_ENTER_MASK },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}

Help Bar for the File/Dir/Mailbox browser dialog.

Definition at line 77 of file browser.c.

◆ FolderNewsHelp

const struct Mapping FolderNewsHelp[]
static
Initial value:
= {
{ N_("Exit"), OP_EXIT },
{ N_("List"), OP_TOGGLE_MAILBOXES },
{ N_("Subscribe"), OP_BROWSER_SUBSCRIBE },
{ N_("Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
{ N_("Catchup"), OP_CATCHUP },
{ N_("Mask"), OP_ENTER_MASK },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}

Help Bar for the NNTP Mailbox browser dialog.

Definition at line 90 of file browser.c.

◆ LastDir

struct Buffer LastDir = { 0 }
static

Definition at line 104 of file browser.c.

◆ LastDirBackup

struct Buffer LastDirBackup = { 0 }
static

Definition at line 105 of file browser.c.

examine_directory
static int examine_directory(struct Mailbox *m, struct Menu *menu, struct BrowserState *state, const char *d, const char *prefix)
Get list of all files/newsgroups with mask.
Definition: browser.c:688
destroy_state
static void destroy_state(struct BrowserState *state)
Free the BrowserState.
Definition: browser.c:138
dialog_create_simple_index
struct MuttWindow * dialog_create_simple_index(struct Menu *menu, enum WindowType type)
Create a simple index Dialog.
Definition: dialog.c:165
Menu::search
int(* search)(struct Menu *menu, regex_t *rx, int line)
Search a menu for a item matching a regex.
Definition: mutt_menu.h:98
FolderFile::mode
mode_t mode
Definition: browser.h:60
folder_format_str
static const char * folder_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Format a string for the folder browser - Implements format_t.
Definition: browser.c:362
imap_mailbox_rename
int imap_mailbox_rename(const char *path)
Rename a mailbox.
Definition: browse.c:433
MUTT_MMDF
@ MUTT_MMDF
'mmdf' Mailbox type
Definition: mailbox.h:49
BrowserState::entry
struct BrowserStateEntry entry
Definition: browser.h:98
ConnAccount::host
char host[128]
Server to login to.
Definition: connaccount.h:53
MailboxNode
List of Mailboxes.
Definition: mailbox.h:152
mutt_mem_calloc
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
NeoMutt::accounts
struct AccountList accounts
List of all Accounts.
Definition: neomutt.h:40
_
#define _(a)
Definition: message.h:28
NONULL
#define NONULL(x)
Definition: string2.h:37
browser_compare_desc
static int browser_compare_desc(const void *a, const void *b)
Compare the descriptions of two browser entries - Implements sort_t.
Definition: browser.c:184
FolderFile::delim
char delim
Definition: browser.h:75
ARRAY_ADD
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:152
BrowserState
State of the file/mailbox browser.
Definition: browser.h:96
C_SortBrowser
short C_SortBrowser
Config: Sort method for the browser.
Definition: browser.c:74
ARRAY_FOREACH_FROM
#define ARRAY_FOREACH_FROM(elem, head, from)
Iterate from an index to the end.
Definition: array.h:217
mutt_mailbox_list
bool mutt_mailbox_list(void)
List the mailboxes with new mail.
Definition: mutt_mailbox.c:220
folder_make_entry
static void folder_make_entry(struct Menu *menu, char *buf, size_t buflen, int line)
Format a menu item for the folder browser - Implements Menu::make_entry()
Definition: browser.c:934
Buffer
String manipulation buffer.
Definition: buffer.h:33
LL_DEBUG3
@ LL_DEBUG3
Log at debug level 3.
Definition: logging.h:42
ARRAY_INIT
#define ARRAY_INIT(head)
Initialize an array.
Definition: array.h:61
FolderFile::has_new_mail
bool has_new_mail
true if mailbox has "new mail"
Definition: browser.h:70
Connection::account
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:36
browser_compare_order
static int browser_compare_order(const void *a, const void *b)
Compare the order of creation of two browser entries - Implements sort_t.
Definition: browser.c:173
add_folder
static void add_folder(struct Menu *menu, struct BrowserState *state, const char *name, const char *desc, const struct stat *s, struct Mailbox *m, void *data)
Add a folder to the browser list.
Definition: browser.c:616
MUTT_PATTERN
#define MUTT_PATTERN
Pattern mode - only used for history classes.
Definition: mutt.h:64
mutt_buffer_pretty_mailbox
void mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition: muttlib.c:599
mutt_buffer_is_empty
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
mutt_buffer_dealloc
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
Body
The body of an email.
Definition: body.h:34
mutt_path_getcwd
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
Definition: path.c:563
mutt_str_coll
int mutt_str_coll(const char *a, const char *b)
Collate two strings (compare using locale), safely.
Definition: string.c:644
MUTT_FORMAT_ARROWCURSOR
#define MUTT_FORMAT_ARROWCURSOR
Reserve space for arrow_cursor.
Definition: format_flags.h:35
CSR_SUCCESS
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
CSR_RESULT
#define CSR_RESULT(x)
Definition: set.h:52
MUTT_POP
@ MUTT_POP
'POP3' Mailbox type
Definition: mailbox.h:55
MuttWindow
A division of the screen.
Definition: mutt_window.h:115
mutt_multi_choice
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
Definition: curs_lib.c:937
FolderFile::gid
gid_t gid
Definition: browser.h:64
FolderFile::mtime
time_t mtime
Definition: browser.h:62
TAILQ_EMPTY
#define TAILQ_EMPTY(head)
Definition: queue.h:714
Folder::ff
struct FolderFile * ff
Definition: browser.h:51
C_FolderFormat
char * C_FolderFormat
Config: printf-like format string for the browser's display of folders.
Definition: browser.c:73
SORT_COUNT
@ SORT_COUNT
Sort by number of emails in a folder.
Definition: sort2.h:60
nntp_active_fetch
int nntp_active_fetch(struct NntpAccountData *adata, bool mark_new)
Fetch list of all newsgroups from server.
Definition: nntp.c:1948
neomutt_mailboxlist_get_all
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:160
FolderFile::uid
uid_t uid
Definition: browser.h:63
browser_compare_count
static int browser_compare_count(const void *a, const void *b)
Compare the message count of two browser entries - Implements sort_t.
Definition: browser.c:223
MUTT_YES
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:40
select_file_search
static int select_file_search(struct Menu *menu, regex_t *rx, int line)
Menu search callback for matching files - Implements Menu::search()
Definition: browser.c:918
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
FolderFile::nlink
nlink_t nlink
Definition: browser.h:65
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
Mailbox::flags
uint8_t flags
e.g. MB_NORMAL
Definition: mailbox.h:134
ARRAY_SORT
#define ARRAY_SORT(head, fn)
Sort an array.
Definition: array.h:271
NntpAccountData::groups_list
void ** groups_list
Definition: adata.h:58
Mailbox::has_new
bool has_new
Mailbox has new mail.
Definition: mailbox.h:88
FREE
#define FREE(x)
Definition: memory.h:40
mutt_newsgroup_subscribe
struct NntpMboxData * mutt_newsgroup_subscribe(struct NntpAccountData *adata, char *group)
Subscribe newsgroup.
Definition: newsrc.c:1247
SORT_REVERSE
#define SORT_REVERSE
Reverse the order of the sort.
Definition: sort2.h:81
mutt_perror
#define mutt_perror(...)
Definition: logging.h:85
mutt_menu_new
struct Menu * mutt_menu_new(enum MenuType type)
Create a new Menu.
Definition: menu.c:956
MUTT_MAILBOX_ERROR
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition: mailbox.h:46
Buffer::dsize
size_t dsize
Length of data.
Definition: buffer.h:37
SORT_MASK
#define SORT_MASK
Mask for the sort id.
Definition: sort2.h:80
MuttWindow::help_menu
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
mutt_newsgroup_uncatchup
struct NntpMboxData * mutt_newsgroup_uncatchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Uncatchup newsgroup.
Definition: newsrc.c:1336
REDRAW_MOTION_RESYNC
#define REDRAW_MOTION_RESYNC
Redraw any changing the menu selection.
Definition: mutt_menu.h:42
PATH_MAX
#define PATH_MAX
Definition: mutt.h:44
MailboxNode::mailbox
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:154
ARRAY_SIZE
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:83
file_tag
static int file_tag(struct Menu *menu, int sel, int act)
Tag an entry in the menu - Implements Menu::tag()
Definition: browser.c:1095
Menu::make_entry
void(* make_entry)(struct Menu *menu, char *buf, size_t buflen, int line)
Format a item for a menu.
Definition: mutt_menu.h:88
mutt_buffer_reset
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
mutt_buffer_strcpy_n
size_t mutt_buffer_strcpy_n(struct Buffer *buf, const char *s, size_t len)
Copy a string into a Buffer.
Definition: buffer.c:327
FolderFile::size
off_t size
Definition: browser.h:61
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
mutt_buffer_addstr_n
size_t mutt_buffer_addstr_n(struct Buffer *buf, const char *s, size_t len)
Add a string to a Buffer, expanding it if necessary.
Definition: buffer.c:99
MUTT_FORMAT_NO_FLAGS
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
Definition: format_flags.h:30
FolderFile::selectable
bool selectable
Definition: browser.h:78
mx_path_probe
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition: mx.c:1335
mutt_body_free
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
url_parse
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
Folder::num
int num
Definition: browser.h:52
ARRAY_GET
#define ARRAY_GET(head, idx)
Return the element at index.
Definition: array.h:105
STAILQ_FOREACH
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
cs_subset_str_native_set
int cs_subset_str_native_set(const struct ConfigSubset *sub, const char *name, intptr_t value, struct Buffer *err)
Natively set the value of a string config item.
Definition: subset.c:292
mutt_buffer_alloc
void mutt_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:265
NntpAccountData::conn
struct Connection * conn
Definition: adata.h:60
NntpMboxData::adata
struct NntpAccountData * adata
Definition: mdata.h:46
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
MB_HIDDEN
#define MB_HIDDEN
Definition: mailbox.h:38
MUTT_FILE
#define MUTT_FILE
Do file completion.
Definition: mutt.h:58
FolderFile::gen
int gen
Definition: browser.h:88
mutt_str_pretty_size
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Definition: muttlib.c:1663
init_lastdir
static void init_lastdir(void)
Initialise the browser directories.
Definition: browser.c:112
mutt_menu_push_current
void mutt_menu_push_current(struct Menu *menu)
Add a new Menu to the stack.
Definition: menu.c:1015
mutt_buffer_addch
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
mutt_date_localtime_format
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:680
mutt_expand_path
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:128
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
MUTT_NNTP
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition: mailbox.h:52
LastDirBackup
static struct Buffer LastDirBackup
Definition: browser.c:105
ARRAY_REMOVE
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition: array.h:261
examine_mailboxes
static int examine_mailboxes(struct Mailbox *m, struct Menu *menu, struct BrowserState *state)
Get list of mailboxes/subscribed newsgroups.
Definition: browser.c:814
Folder
A folder/dir in the browser.
Definition: browser.h:49
Mailbox::type
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
Mailbox::mdata
void * mdata
Driver specific data.
Definition: mailbox.h:136
imap_mailbox_create
int imap_mailbox_create(const char *path)
Create a new IMAP mailbox.
Definition: browse.c:380
browser_sort
static void browser_sort(struct BrowserState *state)
Sort the entries in the browser.
Definition: browser.c:302
ARRAY_FOREACH
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
mutt_view_attachment
int mutt_view_attachment(FILE *fp, struct Body *a, enum ViewAttachMode mode, struct Email *e, struct AttachCtx *actx, struct MuttWindow *win)
View an attachment.
Definition: mutt_attach.c:414
mutt_buffer_copy
size_t mutt_buffer_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition: buffer.c:445
mutt_path_concat
char * mutt_path_concat(char *d, const char *dir, const char *fname, size_t l)
Join a directory name and a filename.
Definition: path.c:351
mutt_make_file_attach
struct Body * mutt_make_file_attach(const char *path, struct ConfigSubset *sub)
Create a file attachment.
Definition: sendlib.c:1083
init_menu
static void init_menu(struct BrowserState *state, struct Menu *menu, char *title, size_t titlelen, bool mailbox, struct Mailbox *m)
Set up a new menu.
Definition: browser.c:994
C_Folder
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: mutt_globals.h:96
nntp_newsrc_parse
int nntp_newsrc_parse(struct NntpAccountData *adata)
Parse .newsrc file.
Definition: newsrc.c:164
SORT_SUBJECT
@ SORT_SUBJECT
Sort by the email's subject.
Definition: sort2.h:48
FolderFile::imap
bool imap
Definition: browser.h:77
Mailbox::gen
int gen
Generation number, for sorting.
Definition: mailbox.h:146
MUTT_SEL_FOLDER
#define MUTT_SEL_FOLDER
Select a local directory.
Definition: browser.h:44
Mailbox::name
char * name
A short name for the Mailbox.
Definition: mailbox.h:85
Url
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:67
OpStrings
const char * OpStrings[][2]
Definition: opcodes.c:28
REDRAW_FULL
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
cs_subset_str_string_set
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition: subset.c:395
url_free
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
mutt_mailbox_check
int mutt_mailbox_check(struct Mailbox *m_cur, int force)
Check all all Mailboxes for new mail.
Definition: mutt_mailbox.c:141
MUTT_MAILBOX_ANY
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition: mailbox.h:45
MUTT_UNKNOWN
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition: mailbox.h:47
imap_delete_mailbox
int imap_delete_mailbox(struct Mailbox *m, char *path)
Delete a mailbox.
Definition: imap.c:515
MUTT_SEL_MULTI
#define MUTT_SEL_MULTI
Multi-selection is enabled.
Definition: browser.h:43
BrowserState::imap_browse
bool imap_browse
Definition: browser.h:100
MUTT_NOTMUCH
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:54
MUTT_IMAP
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:53
ARRAY_FREE
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:198
FolderNewsHelp
static const struct Mapping FolderNewsHelp[]
Help Bar for the NNTP Mailbox browser dialog.
Definition: browser.c:90
MUTT_MH
@ MUTT_MH
'MH' Mailbox type
Definition: mailbox.h:50
FolderFile::name
char * name
Definition: browser.h:67
mutt_buffer_concat_path
size_t mutt_buffer_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
Definition: buffer.c:374
browser_highlight_default
static void browser_highlight_default(struct BrowserState *state, struct Menu *menu)
Decide which browser item should be highlighted.
Definition: browser.c:966
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
nntp_newsrc_close
void nntp_newsrc_close(struct NntpAccountData *adata)
Unlock and close .newsrc file.
Definition: newsrc.c:120
MUTT_NO
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:39
SORT_UNREAD
@ SORT_UNREAD
Sort by the number of unread emails.
Definition: sort2.h:61
Menu::tag
int(* tag)(struct Menu *menu, int sel, int act)
Tag some menu items.
Definition: mutt_menu.h:107
Menu::title
const char * title
Title of this menu.
Definition: mutt_menu.h:54
Menu::is_mailbox_list
bool is_mailbox_list
Definition: mutt_menu.h:62
imap_subscribe
int imap_subscribe(char *path, bool subscribe)
Subscribe to a mailbox.
Definition: imap.c:1272
REG_COMP
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition: regex3.h:54
mutt_newsgroup_unsubscribe
struct NntpMboxData * mutt_newsgroup_unsubscribe(struct NntpAccountData *adata, char *group)
Unsubscribe newsgroup.
Definition: newsrc.c:1271
bool_str_toggle
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition: bool.c:213
Mailbox::realpath
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
REDRAW_INDEX
#define REDRAW_INDEX
Redraw the index.
Definition: mutt_menu.h:40
mutt_buffer_expand_path
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
mutt_buffer_get_field
int mutt_buffer_get_field(const char *field, struct Buffer *buf, CompletionFlags complete, bool multiple, struct Mailbox *m, char ***files, int *numfiles)
Ask the user for a string.
Definition: curs_lib.c:260
mutt_regex_match
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture()
Definition: regex.c:611
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
CurrentNewsSrv
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition: nntp.c:79
mutt_path_realpath
size_t mutt_path_realpath(char *buf)
resolve path, unraveling symlinks
Definition: path.c:440
mutt_date_epoch
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
WT_DLG_BROWSER
@ WT_DLG_BROWSER
Browser Dialog, mutt_buffer_select_file()
Definition: mutt_window.h:77
SORT_ORDER
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
Definition: sort2.h:50
group_index_format_str
const char * group_index_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Format a string for the newsgroup menu - Implements format_t.
Definition: browse.c:54
imap_browse
int imap_browse(const char *path, struct BrowserState *state)
IMAP hook into the folder browser.
Definition: browse.c:179
MuttWindow::help_data
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
mutt_format_s
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
Definition: curs_lib.c:1248
Menu::top
int top
Entry that is the top of the current page.
Definition: mutt_menu.h:75
MUTT_FORMAT_OPTIONAL
#define MUTT_FORMAT_OPTIONAL
Allow optional field processing.
Definition: format_flags.h:33
mutt_inbox_cmp
int mutt_inbox_cmp(const char *a, const char *b)
do two folders share the same path and one is an inbox
Definition: muttlib.c:1595
nntp_newsrc_update
int nntp_newsrc_update(struct NntpAccountData *adata)
Update .newsrc file.
Definition: newsrc.c:442
mutt_buffer_select_file
void mutt_buffer_select_file(struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file.
Definition: browser.c:1142
mutt_menu_loop
int mutt_menu_loop(struct Menu *menu)
Menu event loop.
Definition: menu.c:1309
MuttWindow::state
struct WindowState state
Current state of the Window.
Definition: mutt_window.h:120
browser_compare_size
static int browser_compare_size(const void *a, const void *b)
Compare the size of two browser entries - Implements sort_t.
Definition: browser.c:210
mutt_menu_pop_current
void mutt_menu_pop_current(struct Menu *menu)
Remove a Menu from the stack.
Definition: menu.c:1027
browser_compare_count_new
static int browser_compare_count_new(const void *a, const void *b)
Compare the new count of two browser entries - Implements sort_t.
Definition: browser.c:242
STAILQ_HEAD_INITIALIZER
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
BrowserState::folder
char * folder
Definition: browser.h:101
C_GroupIndexFormat
char * C_GroupIndexFormat
Config: (nntp) printf-like format string for the browser's display of newsgroups.
Definition: config.c:39
LastDir
static struct Buffer LastDir
Definition: browser.c:104
C_ShowOnlyUnread
bool C_ShowOnlyUnread
Config: (nntp) Only show subscribed newsgroups with unread articles.
Definition: config.c:54
FolderFile::msg_count
int msg_count
total number of messages
Definition: browser.h:71
ARRAY_EMPTY
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition: array.h:70
MUTT_VA_REGULAR
@ MUTT_VA_REGULAR
View using default method.
Definition: mutt_attach.h:42
NntpAccountData
NNTP-specific Account data -.
Definition: adata.h:33
browser_compare
static int browser_compare(const void *a, const void *b)
Sort the items in the browser - Implements sort_t.
Definition: browser.c:265
C_ImapListSubscribed
bool C_ImapListSubscribed
Config: (imap) When browsing a mailbox, only display subscribed folders.
Definition: config.c:50
HomeDir
char * HomeDir
User's home directory.
Definition: mutt_globals.h:49
Menu::mdata
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:55
Menu::tagged
int tagged
Number of tagged entries.
Definition: mutt_menu.h:78
mutt_expando_format
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string.
Definition: muttlib.c:774
imap_clean_path
void imap_clean_path(char *path, size_t plen)
Cleans an IMAP path using imap_fix_path.
Definition: util.c:190
Menu::max
int max
Number of entries in the menu.
Definition: mutt_menu.h:57
C_BrowserAbbreviateMailboxes
bool C_BrowserAbbreviateMailboxes
Config: Abbreviate mailboxes using '~' and '=' in the browser.
Definition: browser.c:72
FolderFile::inferiors
bool inferiors
Definition: browser.h:79
mutt_buffer_fix_dptr
void mutt_buffer_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition: buffer.c:181
ARRAY_RESERVE
#define ARRAY_RESERVE(head, num)
Reserve memory for the array.
Definition: array.h:185
C_SpoolFile
WHERE char * C_SpoolFile
Config: Inbox.
Definition: mutt_globals.h:108
NeoMutt
Container for Accounts, Notifications.
Definition: neomutt.h:36
MENU_FOLDER
@ MENU_FOLDER
General file/mailbox browser.
Definition: keymap.h:78
MUTT_SEL_MAILBOX
#define MUTT_SEL_MAILBOX
Select a mailbox.
Definition: browser.h:42
Menu::redraw
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
imap_path_probe
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2372
mutt_buffer_len
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:356
Account::adata
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
FolderFile::nd
struct NntpMboxData * nd
Definition: browser.h:85
MailboxType
MailboxType
Supported mailbox formats.
Definition: mailbox.h:43
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
CurrentFolder
WHERE char * CurrentFolder
Currently selected mailbox.
Definition: mutt_globals.h:54
browser_compare_subject
static int browser_compare_subject(const void *a, const void *b)
Compare the subject of two browser entries - Implements sort_t.
Definition: browser.c:156
mutt_buffer_addstr
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
init_state
static void init_state(struct BrowserState *state, struct Menu *menu)
Initialise a browser state.
Definition: browser.c:667
FolderFile
Browser entry representing a folder/dir.
Definition: browser.h:58
Mailbox::msg_unread
int msg_unread
Number of unread messages.
Definition: mailbox.h:92
mutt_get_field
int mutt_get_field(const char *field, char *buf, size_t buflen, CompletionFlags complete, bool multiple, char ***files, int *numfiles)
Ask the user for a string.
Definition: curs_lib.c:311
MUTT_MAILDIR
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:51
Url::path
char * path
Path.
Definition: url.h:74
Regex::pattern
char * pattern
printable version
Definition: regex3.h:91
mutt_buffer_strdup
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:432
WindowState::cols
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
Definition: mutt_window.h:57
dialog_destroy_simple_index
void dialog_destroy_simple_index(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: dialog.c:209
mailbox_path
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:206
Menu::current
int current
Current entry.
Definition: mutt_menu.h:56
C_DateFormat
WHERE char * C_DateFormat
Config: strftime format string for the d expando.
Definition: mutt_globals.h:89
mutt_yesorno
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:380
mutt_get_parent_path
void mutt_get_parent_path(const char *path, char *buf, size_t buflen)
Find the parent of a path (or mailbox)
Definition: muttlib.c:1540
Buffer::data
char * data
Pointer to data.
Definition: buffer.h:35
C_Mask
WHERE struct Regex * C_Mask
Config: Only display files/dirs matching this regex in the browser.
Definition: mutt_globals.h:119
SORT_SIZE
@ SORT_SIZE
Sort by the size of the email.
Definition: sort2.h:46
mutt_str_startswith
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:160
mutt_message
#define mutt_message(...)
Definition: logging.h:83
mutt_unget_event
void mutt_unget_event(int ch, int op)
Return a keystroke to the input buffer.
Definition: curs_lib.c:838
mutt_browser_select_dir
void mutt_browser_select_dir(const char *f)
Remember the last directory selected.
Definition: browser.c:1122
mutt_buffer_printf
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
Menu::win_index
struct MuttWindow * win_index
Definition: mutt_menu.h:63
SORT_DATE
@ SORT_DATE
Sort by the date the email was sent.
Definition: sort2.h:45
mutt_buffer_make
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
Menu
GUI selectable list of items.
Definition: mutt_menu.h:52
mutt_newsgroup_catchup
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1297
MUTT_MBOX
@ MUTT_MBOX
'mbox' Mailbox type
Definition: mailbox.h:48
FolderFile::desc
char * desc
Definition: browser.h:68
N_
#define N_(a)
Definition: message.h:32
FolderHelp
static const struct Mapping FolderHelp[]
Help Bar for the File/Dir/Mailbox browser dialog.
Definition: browser.c:77
mutt_buffer_strcpy
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
neomutt_mailboxlist_clear
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:137
NntpMboxData
NNTP-specific Mailbox data -.
Definition: mdata.h:31
FolderFile::msg_unread
int msg_unread
number of unread messages
Definition: browser.h:72
browser_compare_date
static int browser_compare_date(const void *a, const void *b)
Compare the date of two browser entries - Implements sort_t.
Definition: browser.c:197
nntp_clear_cache
void nntp_clear_cache(struct NntpAccountData *adata)
Clear the NNTP cache.
Definition: newsrc.c:843
FolderFile::tagged
bool tagged
Definition: browser.h:83
OptNews
WHERE bool OptNews
(pseudo) used to change reader mode
Definition: options.h:45
mutt_menu_free
void mutt_menu_free(struct Menu **ptr)
Destroy a menu.
Definition: menu.c:972
mutt_error
#define mutt_error(...)
Definition: logging.h:84
link_is_dir
static bool link_is_dir(const char *folder, const char *path)
Does this symlink point to a directory?
Definition: browser.c:326
ARRAY_FIRST
#define ARRAY_FIRST(head)
Convenience method to get the first element.
Definition: array.h:131
SORT_DESC
@ SORT_DESC
Sort by the folder's description.
Definition: sort2.h:65
mutt_str_copy
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716
FolderFile::has_mailbox
bool has_mailbox
Definition: browser.h:81
MUTT_COMP_NO_FLAGS
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56