106 {
N_(
"Exit"), OP_EXIT },
107 {
N_(
"Chdir"), OP_CHANGE_DIRECTORY },
108 {
N_(
"Goto"), OP_BROWSER_GOTO_FOLDER },
109 {
N_(
"Mask"), OP_ENTER_MASK },
110 {
N_(
"Help"), OP_HELP },
118 {
N_(
"Exit"), OP_EXIT },
119 {
N_(
"List"), OP_TOGGLE_MAILBOXES },
120 {
N_(
"Subscribe"), OP_BROWSER_SUBSCRIBE },
121 {
N_(
"Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
122 {
N_(
"Catchup"), OP_CATCHUP },
123 {
N_(
"Mask"), OP_ENTER_MASK },
124 {
N_(
"Help"), OP_HELP },
141 static bool done =
false;
168 struct stat st = { 0 };
175 rc = S_ISDIR(st.st_mode);
206 char op,
const char *src,
const char *prec,
207 const char *if_str,
const char *else_str,
210 char fn[128] = { 0 };
211 char fmt[128] = { 0 };
220 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
231 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
232 snprintf(buf, buflen, fmt, folder->
num + 1);
237 if (folder->
ff->local)
239 bool use_c_locale =
false;
241 const char *t_fmt = NULL;
245 t_fmt =
NONULL(c_date_format);
254 static const time_t one_year = 31536000;
258 char date[128] = { 0 };
278 if (folder->
ff->local)
280 char buf2[128] = { 0 };
281 bool use_c_locale =
false;
282 struct tm tm = { 0 };
286 const char *cp = src;
293 size_t len = buflen - 1;
294 while ((len > 0) && (*cp !=
']'))
324 strftime(buf2,
sizeof(buf2), buf, &tm);
326 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
327 snprintf(buf, buflen, fmt, buf2);
343 snprintf(fn,
sizeof(fn),
"%s%s", s,
345 (S_ISLNK(folder->
ff->
mode) ?
347 (S_ISDIR(folder->
ff->
mode) ?
349 (((folder->
ff->
mode & S_IXUSR) != 0) ?
"*" :
""))) :
357 if (folder->
ff->local)
359 char permission[11] = { 0 };
360 snprintf(permission,
sizeof(permission),
"%c%c%c%c%c%c%c%c%c%c",
361 S_ISDIR(folder->
ff->
mode) ?
'd' : (S_ISLNK(folder->
ff->
mode) ?
'l' :
'-'),
362 ((folder->
ff->
mode & S_IRUSR) != 0) ?
'r' :
'-',
363 ((folder->
ff->
mode & S_IWUSR) != 0) ?
'w' :
'-',
364 ((folder->
ff->
mode & S_ISUID) != 0) ?
's' :
365 ((folder->
ff->
mode & S_IXUSR) != 0) ?
'x' :
367 ((folder->
ff->
mode & S_IRGRP) != 0) ?
'r' :
'-',
368 ((folder->
ff->
mode & S_IWGRP) != 0) ?
'w' :
'-',
369 ((folder->
ff->
mode & S_ISGID) != 0) ?
's' :
370 ((folder->
ff->
mode & S_IXGRP) != 0) ?
'x' :
372 ((folder->
ff->
mode & S_IROTH) != 0) ?
'r' :
'-',
373 ((folder->
ff->
mode & S_IWOTH) != 0) ?
'w' :
'-',
374 ((folder->
ff->
mode & S_ISVTX) != 0) ?
't' :
375 ((folder->
ff->
mode & S_IXOTH) != 0) ?
'x' :
379 else if (folder->
ff->
imap)
381 char permission[11] = { 0 };
383 snprintf(permission,
sizeof(permission),
"IMAP %c",
395 if (folder->
ff->local)
397 struct group *gr = getgrgid(folder->
ff->
gid);
404 snprintf(fmt,
sizeof(fmt),
"%%%sld", prec);
405 snprintf(buf, buflen, fmt, folder->
ff->
gid);
422 snprintf(fn,
sizeof(fn),
"%s%s", s,
424 (S_ISLNK(folder->
ff->
mode) ?
426 (S_ISDIR(folder->
ff->
mode) ?
428 (((folder->
ff->
mode & S_IXUSR) != 0) ?
"*" :
""))) :
436 if (folder->
ff->local)
438 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
439 snprintf(buf, buflen, fmt, folder->
ff->
nlink);
452 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
467 snprintf(fmt,
sizeof(fmt),
"%%%sc", prec);
476 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
493 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
504 if (folder->
ff->local)
507 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
508 snprintf(buf, buflen, fmt, fn);
517 snprintf(fmt,
sizeof(fmt),
"%%%sc", prec);
518 snprintf(buf, buflen, fmt, folder->
ff->
tagged ?
'*' :
' ');
522 if (folder->
ff->local)
524 struct passwd *pw = getpwuid(folder->
ff->
uid);
531 snprintf(fmt,
sizeof(fmt),
"%%%sld", prec);
532 snprintf(buf, buflen, fmt, folder->
ff->
uid);
542 snprintf(fmt,
sizeof(fmt),
"%%%sc", prec);
543 snprintf(buf, buflen, fmt, op);
573 const char *name,
const char *desc,
574 const struct stat *st,
struct Mailbox *m,
void *data)
585 ff.
mode = st->st_mode;
586 ff.
mtime = st->st_mtime;
587 ff.
size = st->st_size;
590 ff.
nlink = st->st_nlink;
647 const char *dirname,
const char *prefix)
658 for (
unsigned int i = 0; i < adata->
groups_num; i++)
674 struct stat st = { 0 };
676 struct dirent *de = NULL;
678 while (stat(dirname, &st) == -1)
683 char *c = strrchr(dirname,
'/');
685 if (c && (c > dirname))
695 if (!S_ISDIR(st.st_mode))
717 while ((de = readdir(dir)))
736 if (S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))
738 else if (!S_ISREG(st.st_mode))
775 struct stat st = { 0 };
777 struct Buffer *mailbox = NULL;
786 for (
unsigned int i = 0; i <
adata->groups_num; i++)
790 (
mdata->subscribed && (
mdata->unread || !c_show_only_unread))))
824 if (c_browser_abbreviate_mailboxes)
846 if ((!S_ISREG(st.st_mode)) && (!S_ISDIR(st.st_mode)) && (!S_ISLNK(st.st_mode)))
851 struct stat st2 = { 0 };
859 if (st2.st_mtime > st.st_mtime)
860 st.st_mtime = st2.st_mtime;
880 struct BrowserEntryArray *entry = menu->
mdata;
882 return regexec(rx,
ARRAY_GET(entry, line)->desc, 0, NULL, 0);
886 return regexec(rx, search_on, 0, NULL, 0);
897 struct BrowserEntryArray *entry = &bstate->
entry;
962 char title[256] = { 0 };
966 if (index >= menu->
max)
970 if (menu->
top > index)
979 snprintf(title,
sizeof(title),
_(
"Subscribed newsgroups"));
983 snprintf(title,
sizeof(title),
_(
"Newsgroups on server [%s]"),
991 snprintf(title,
sizeof(title),
_(
"Mailboxes [%d]"),
1003 snprintf(title,
sizeof(title),
_(
"Subscribed [%s], File mask: %s"),
1008 snprintf(title,
sizeof(title),
_(
"Directory [%s], File mask: %s"),
1033 sizeof(target_dir));
1039 bool matched =
false;
1066 struct BrowserEntryArray *entry = menu->
mdata;
1068 if (S_ISDIR(ff->
mode) ||
1182 if (ev_w->
win != win_menu)
1227 char ***files,
int *numfiles)
1251 for (
size_t i = 0; i <
adata->groups_num; i++)
1308 if ((i <= 0) && (
buf_string(file)[0] !=
'/'))
1322 bool browser_track =
false;
1330 browser_track =
true;
1366 else if (c_spool_file)
1411 const struct Mapping *help_data = NULL;
1482 }
while (!priv->
done);
#define ARRAY_RESERVE(head, num)
Reserve memory for the array.
#define ARRAY_FIRST(head)
Convenience method to get the first element.
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_EMPTY(head)
Check if an array is empty.
#define ARRAY_SIZE(head)
The number of elements stored.
#define ARRAY_INIT(head)
Initialize an array.
#define ARRAY_GET(head, idx)
Return the element at index.
int browser_function_dispatcher(struct MuttWindow *win, int op)
Perform a Browser function.
#define MUTT_SEL_MAILBOX
Select a mailbox.
void browser_sort(struct BrowserState *state)
Sort the entries in the browser.
#define MUTT_SEL_FOLDER
Select a local directory.
#define MUTT_SEL_MULTI
Multi-selection is enabled.
uint8_t SelectFileFlags
Flags for mutt_select_file(), e.g. MUTT_SEL_MAILBOX.
struct BrowserPrivateData * browser_private_data_new(void)
Create new Browser Data.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
size_t buf_addstr_n(struct Buffer *buf, const char *s, size_t len)
Add a string to a Buffer, expanding it if necessary.
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
size_t buf_strcpy_n(struct Buffer *buf, const char *s, size_t len)
Copy a string into a Buffer.
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const struct Regex * cs_subset_regex(const struct ConfigSubset *sub, const char *name)
Get a regex config item by name.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
@ FR_UNKNOWN
Unknown function.
void init_state(struct BrowserState *state, struct Menu *menu)
Initialise a browser state.
int examine_directory(struct Mailbox *m, struct Menu *menu, struct BrowserState *state, const char *dirname, const char *prefix)
Get list of all files/newsgroups with mask.
void init_menu(struct BrowserState *state, struct Menu *menu, struct Mailbox *m, struct MuttWindow *sbar)
Set up a new menu.
static void init_lastdir(void)
Initialise the browser directories.
static const struct Mapping FolderNewsHelp[]
Help Bar for the NNTP Mailbox browser dialog.
struct Buffer LastDir
Browser: previous selected directory.
void mutt_browser_select_dir(const char *f)
Remember the last directory selected.
struct Buffer LastDirBackup
Browser: backup copy of the current directory.
static const struct Mapping FolderHelp[]
Help Bar for the File/Dir/Mailbox browser dialog.
void browser_add_folder(const struct Menu *menu, struct BrowserState *state, const char *name, const char *desc, const struct stat *st, struct Mailbox *m, void *data)
Add a folder to the browser list.
void mutt_browser_cleanup(void)
Clean up working Buffers.
void browser_highlight_default(struct BrowserState *state, struct Menu *menu)
Decide which browser item should be highlighted.
int examine_mailboxes(struct Mailbox *m, struct Menu *menu, struct BrowserState *state)
Get list of mailboxes/subscribed newsgroups.
bool link_is_dir(const char *folder, const char *path)
Does this symlink point to a directory?
DIR * mutt_file_opendir(const char *path, enum MuttOpenDirMode mode)
Open a directory.
@ MUTT_OPENDIR_NONE
Plain opendir()
int km_dokey(enum MenuType mtype, GetChFlags flags)
Determine what a keypress should do.
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
bool OptNews
(pseudo) used to change reader mode
char * CurrentFolder
Currently selected mailbox.
int menu_tagging_dispatcher(struct MuttWindow *win, int op)
Perform tagging operations on the Menu - Implements function_dispatcher_t -.
int global_function_dispatcher(struct MuttWindow *win, int op)
Perform a Global function - Implements function_dispatcher_t -.
int menu_function_dispatcher(struct MuttWindow *win, int op)
Perform a Menu function - Implements function_dispatcher_t -.
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 -.
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 -.
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 -.
void dlg_browser(struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file -.
#define mutt_debug(LEVEL,...)
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe() -.
static int browser_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
static int browser_mailbox_observer(struct NotifyCallback *nc)
Notification that a Mailbox has changed - Implements observer_t -.
static int browser_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
void browser_private_data_free(struct BrowserPrivateData **ptr)
Free Private Browser Data - Implements MuttWindow::wdata_free() -.
Convenience wrapper for the gui headers.
void simple_dialog_free(struct MuttWindow **ptr)
Destroy a simple index Dialog.
struct MuttWindow * simple_dialog_new(enum MenuType mtype, enum WindowType wtype, const struct Mapping *help_data)
Create a simple index Dialog.
int imap_browse(const char *path, struct BrowserState *state)
IMAP hook into the folder browser.
void imap_clean_path(char *path, size_t plen)
Cleans an IMAP path using imap_fix_path.
#define GETCH_NO_FLAGS
No flags are set.
@ LL_DEBUG5
Log at debug level 5.
@ LL_DEBUG1
Log at debug level 1.
@ NT_MAILBOX_DELETE
Mailbox is about to be deleted.
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
@ MUTT_MMDF
'mmdf' Mailbox type
@ MUTT_POP
'POP3' Mailbox type
@ MUTT_MH
'MH' Mailbox type
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
@ MUTT_IMAP
'IMAP' Mailbox type
@ MUTT_MBOX
'mbox' Mailbox type
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
@ MUTT_MAILDIR
'Maildir' Mailbox type
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
size_t mutt_date_localtime_format_locale(char *buf, size_t buflen, const char *format, time_t t, locale_t loc)
Format localtime using a given locale.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture()
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
int mutt_mailbox_check(struct Mailbox *m_cur, CheckStatsFlags flags)
Check all all Mailboxes for new mail.
Mailbox helper functions.
void window_redraw(struct MuttWindow *win)
Reflow, recalc and repaint a tree of Windows.
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
@ WT_DLG_BROWSER
Browser Dialog, dlg_browser()
@ WT_STATUS_BAR
Status Bar containing extra info about the Index/Pager/etc.
@ WT_MENU
An Window containing a Menu.
@ NT_WINDOW_DELETE
Window is about to be deleted.
void mutt_get_parent_path(const char *path, char *buf, size_t buflen)
Find the parent of a path (or mailbox)
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Some miscellaneous functions.
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
#define MUTT_MAILBOX_CHECK_NO_FLAGS
No flags are set.
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Nntp-specific Account data.
Usenet network mailbox type; talk to an NNTP server.
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Nntp-specific Mailbox data.
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
const char * opcodes_get_name(int op)
Get the name of an opcode.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define STAILQ_HEAD_INITIALIZER(head)
#define STAILQ_FOREACH(var, head, field)
#define TAILQ_EMPTY(head)
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
#define SORT_MASK
Mask for the sort id.
SortType
Methods for sorting.
@ SORT_SUBJECT
Sort by the email's subject.
@ SORT_ORDER
Sort by the order the messages appear in the mailbox.
@ SORT_DESC
Sort by the folder's description.
void * adata
Private data (for Mailbox backends)
Private state data for the Browser.
char *** files
Array of selected files.
struct Buffer * prefix
Folder prefix string.
bool kill_prefix
Prefix is in use.
bool done
Should we close the Dialog?
bool folder
Select folders.
int last_selected_mailbox
Index of last selected Mailbox.
int * numfiles
Number of selected files.
struct Mailbox * mailbox
Mailbox.
struct BrowserState state
State containing list of files/dir/mailboxes.
struct Buffer * file
Buffer for the result.
bool multiple
Allow multiple selections.
struct MuttWindow * win_browser
Browser Window.
struct MuttWindow * sbar
Status Bar.
State of the file/mailbox browser.
char * folder
Folder name.
bool is_mailbox_list
Viewing mailboxes.
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
bool imap_browse
IMAP folder.
String manipulation buffer.
char * data
Pointer to data.
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
char host[128]
Server to login to.
struct ConnAccount account
Account details: username, password, etc.
const char * name
Name of config item that changed.
An Event that happened to a Mailbox.
struct Mailbox * mailbox
The Mailbox this Event relates to.
An Event that happened to a Window.
struct MuttWindow * win
Window that changed.
WindowNotifyFlags flags
Attributes of Window that changed.
Browser entry representing a folder/dir.
bool selectable
Folder can be selected.
bool imap
This is an IMAP folder.
bool has_mailbox
This is a mailbox.
char * name
Name of file/dir/mailbox.
bool tagged
Folder is tagged.
gid_t gid
File's Group ID.
bool has_new_mail
true if mailbox has "new mail"
bool poll_new_mail
Check mailbox for new mail.
bool notify_user
User will be notified of new mail.
nlink_t nlink
Number of hard links.
char * desc
Description of mailbox.
struct NntpMboxData * nd
Extra NNTP data.
int gen
Unique id, used for (un)sorting.
time_t mtime
Modification time.
int msg_count
total number of messages
mode_t mode
File permissions.
bool inferiors
Folder has children.
int msg_unread
number of unread messages
A folder/dir in the browser.
int num
Number in the index.
struct FolderFile * ff
File / Dir / Mailbox.
struct Mailbox * mailbox
Mailbox in the list.
bool has_new
Mailbox has new mail.
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
int msg_count
Total number of messages.
enum MailboxType type
Mailbox type.
bool poll_new_mail
Check for new mail.
void * mdata
Driver specific data.
char * name
A short name for the Mailbox.
bool notify_user
Notify the user of new mail.
bool visible
True if a result of "mailboxes".
int msg_unread
Number of unread messages.
int gen
Generation number, for sorting.
Mapping between user-readable string and a constant.
struct WindowState state
Current state of the Window.
void * wdata
Private data.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Container for Accounts, Notifications.
struct AccountList accounts
List of all Accounts.
struct Notify * notify
Notifications handler.
struct ConfigSubset * sub
Inherited config items.
locale_t time_c_locale
Current locale but LC_TIME=C.
NNTP-specific Account data -.
struct Connection * conn
Connection to NNTP Server.
NNTP-specific Mailbox data -.
struct NntpAccountData * adata
Data passed to a notification function.
void * event_data
Data from notify_send()
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
int event_subtype
Send: Event subtype, e.g. NT_ACCOUNT_ADD.
void * global_data
Data from notify_observer_add()
Cached regular expression.
char * pattern
printable version
short cols
Number of columns, can be MUTT_WIN_SIZE_UNLIMITED.
@ MENU_FOLDER
General file/mailbox browser.