111 {
N_(
"Exit"), OP_EXIT },
112 {
N_(
"Chdir"), OP_CHANGE_DIRECTORY },
113 {
N_(
"Goto"), OP_BROWSER_GOTO_FOLDER },
114 {
N_(
"Mask"), OP_ENTER_MASK },
115 {
N_(
"Help"), OP_HELP },
124 {
N_(
"Exit"), OP_EXIT },
125 {
N_(
"List"), OP_TOGGLE_MAILBOXES },
126 {
N_(
"Subscribe"), OP_BROWSER_SUBSCRIBE },
127 {
N_(
"Unsubscribe"), OP_BROWSER_UNSUBSCRIBE },
128 {
N_(
"Catchup"), OP_CATCHUP },
129 {
N_(
"Mask"), OP_ENTER_MASK },
130 {
N_(
"Help"), OP_HELP },
146 static bool done =
false;
173 struct stat st = { 0 };
180 retval = S_ISDIR(st.st_mode);
209 char op,
const char *src,
const char *prec,
210 const char *if_str,
const char *else_str,
213 char fn[128] = { 0 };
214 char fmt[128] = { 0 };
221 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
222 snprintf(buf, buflen, fmt, folder->
num + 1);
227 if (folder->
ff->local)
229 bool do_locales =
true;
231 const char *t_fmt = NULL;
235 t_fmt =
NONULL(c_date_format);
244 static const time_t one_year = 31536000;
249 setlocale(LC_TIME,
"C");
250 char date[128] = { 0 };
253 setlocale(LC_TIME,
"");
264 if (folder->
ff->local)
266 char buf2[128] = { 0 };
267 bool do_locales =
true;
268 struct tm tm = { 0 };
272 const char *cp = src;
279 size_t len = buflen - 1;
280 while ((len > 0) && (*cp !=
']'))
308 setlocale(LC_TIME,
"C");
309 strftime(buf2,
sizeof(buf2), buf, &tm);
311 setlocale(LC_TIME,
"");
313 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
314 snprintf(buf, buflen, fmt, buf2);
330 snprintf(fn,
sizeof(fn),
"%s%s", s,
332 (S_ISLNK(folder->
ff->
mode) ?
334 (S_ISDIR(folder->
ff->
mode) ?
336 (((folder->
ff->
mode & S_IXUSR) != 0) ?
"*" :
""))) :
344 if (folder->
ff->local)
346 char permission[11] = { 0 };
347 snprintf(permission,
sizeof(permission),
"%c%c%c%c%c%c%c%c%c%c",
348 S_ISDIR(folder->
ff->
mode) ?
'd' : (S_ISLNK(folder->
ff->
mode) ?
'l' :
'-'),
349 ((folder->
ff->
mode & S_IRUSR) != 0) ?
'r' :
'-',
350 ((folder->
ff->
mode & S_IWUSR) != 0) ?
'w' :
'-',
351 ((folder->
ff->
mode & S_ISUID) != 0) ?
's' :
352 ((folder->
ff->
mode & S_IXUSR) != 0) ?
'x' :
354 ((folder->
ff->
mode & S_IRGRP) != 0) ?
'r' :
'-',
355 ((folder->
ff->
mode & S_IWGRP) != 0) ?
'w' :
'-',
356 ((folder->
ff->
mode & S_ISGID) != 0) ?
's' :
357 ((folder->
ff->
mode & S_IXGRP) != 0) ?
'x' :
359 ((folder->
ff->
mode & S_IROTH) != 0) ?
'r' :
'-',
360 ((folder->
ff->
mode & S_IWOTH) != 0) ?
'w' :
'-',
361 ((folder->
ff->
mode & S_ISVTX) != 0) ?
't' :
362 ((folder->
ff->
mode & S_IXOTH) != 0) ?
'x' :
367 else if (folder->
ff->
imap)
369 char permission[11] = { 0 };
371 snprintf(permission,
sizeof(permission),
"IMAP %c",
382 if (folder->
ff->local)
384 struct group *gr = getgrgid(folder->
ff->
gid);
391 snprintf(fmt,
sizeof(fmt),
"%%%sld", prec);
392 snprintf(buf, buflen, fmt, folder->
ff->
gid);
409 snprintf(fn,
sizeof(fn),
"%s%s", s,
411 (S_ISLNK(folder->
ff->
mode) ?
413 (S_ISDIR(folder->
ff->
mode) ?
415 (((folder->
ff->
mode & S_IXUSR) != 0) ?
"*" :
""))) :
423 if (folder->
ff->local)
425 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
426 snprintf(buf, buflen, fmt, folder->
ff->
nlink);
439 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
452 snprintf(fmt,
sizeof(fmt),
"%%%sc", prec);
461 snprintf(fmt,
sizeof(fmt),
"%%%sd", prec);
474 if (folder->
ff->local)
477 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
478 snprintf(buf, buflen, fmt, fn);
487 snprintf(fmt,
sizeof(fmt),
"%%%sc", prec);
488 snprintf(buf, buflen, fmt, folder->
ff->
tagged ?
'*' :
' ');
492 if (folder->
ff->local)
494 struct passwd *pw = getpwuid(folder->
ff->
uid);
501 snprintf(fmt,
sizeof(fmt),
"%%%sld", prec);
502 snprintf(buf, buflen, fmt, folder->
ff->
uid);
512 snprintf(fmt,
sizeof(fmt),
"%%%sc", prec);
513 snprintf(buf, buflen, fmt, op);
543 const char *name,
const char *desc,
544 const struct stat *st,
struct Mailbox *m,
void *data)
555 ff.
mode = st->st_mode;
556 ff.
mtime = st->st_mtime;
557 ff.
size = st->st_size;
560 ff.
nlink = st->st_nlink;
620 const char *dirname,
const char *prefix)
631 for (
unsigned int i = 0; i <
adata->groups_num; i++)
649 struct stat st = { 0 };
651 struct dirent *de = NULL;
653 while (stat(dirname, &st) == -1)
658 char *c = strrchr(dirname,
'/');
660 if (c && (c > dirname))
670 if (!S_ISDIR(st.st_mode))
690 while ((de = readdir(dir)))
710 if (S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))
712 else if (!S_ISREG(st.st_mode))
749 struct stat st = { 0 };
751 struct Buffer *mailbox = NULL;
760 for (
unsigned int i = 0; i <
adata->groups_num; i++)
765 (
mdata->subscribed && (
mdata->unread || !c_show_only_unread))))
799 if (c_browser_abbreviate_mailboxes)
821 if ((!S_ISREG(st.st_mode)) && (!S_ISDIR(st.st_mode)) && (!S_ISLNK(st.st_mode)))
826 struct stat st2 = { 0 };
834 if (st2.st_mtime > st.st_mtime)
835 st.st_mtime = st2.st_mtime;
855 struct BrowserStateEntry *entry = menu->
mdata;
858 return regexec(rx,
ARRAY_GET(entry, line)->desc, 0, NULL, 0);
863 return regexec(rx, search_on, 0, NULL, 0);
872 struct BrowserStateEntry *entry = &bstate->
entry;
940 char title[256] = { 0 };
944 if (index >= menu->
max)
948 if (menu->
top > index)
958 snprintf(title,
sizeof(title),
_(
"Subscribed newsgroups"));
962 snprintf(title,
sizeof(title),
_(
"Newsgroups on server [%s]"),
971 snprintf(title,
sizeof(title),
_(
"Mailboxes [%d]"),
984 snprintf(title,
sizeof(title),
_(
"Subscribed [%s], File mask: %s"),
990 snprintf(title,
sizeof(title),
_(
"Directory [%s], File mask: %s"),
1016 sizeof(target_dir));
1021 bool matched =
false;
1048 struct BrowserStateEntry *entry = menu->
mdata;
1050 if (S_ISDIR(ff->
mode) ||
1110 if (ev_w->
win != win_menu)
1153 struct Mailbox *m,
char ***files,
int *numfiles)
1178 for (
size_t i = 0; i <
adata->groups_num; i++)
1260 bool browser_track =
false;
1268 browser_track =
true;
1304 else if (c_spool_file)
1347 const struct Mapping *help_data = NULL;
1419 }
while (!priv->
done);
1437 struct Mailbox *m,
char ***files,
int *numfiles)
#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_browser, 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.
void mutt_select_file(char *file, size_t filelen, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file.
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.
void mutt_browser_select_dir(const char *f)
Remember the last directory selected.
struct Buffer LastDirBackup
void mutt_buffer_select_file(struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file.
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?
void mutt_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
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.
size_t mutt_buffer_len(const struct Buffer *buf)
Calculate the length of a Buffer.
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
void mutt_buffer_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
size_t mutt_buffer_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
size_t mutt_buffer_strcpy_n(struct Buffer *buf, const char *s, size_t len)
Copy a string into a Buffer.
size_t mutt_buffer_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
static const char * mutt_buffer_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.
void mutt_format_s(char *buf, size_t buflen, const char *prec, const char *s)
Format a simple string.
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.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
@ FR_UNKNOWN
Unknown function.
DIR * mutt_file_opendir(const char *path, enum MuttOpenDirMode mode)
Open a directory.
@ MUTT_OPENDIR_NONE
Plain opendir()
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 -.
#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_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.
int km_dokey(enum MenuType mtype)
Determine what a keypress should do.
void km_error_key(enum MenuType mtype)
Handle an unbound key sequence.
@ LL_DEBUG5
Log at debug level 5.
@ LL_DEBUG1
Log at debug level 1.
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
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)
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_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
@ WT_DLG_BROWSER
Browser Dialog, mutt_buffer_select_file()
@ 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 mutt_buffer_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
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.
const char * opcodes_get_name(int op)
Get the name of an opcode.
All user-callable functions.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from 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.
@ 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 BrowserStateEntry entry
Array of files / dirs / mailboxes.
bool imap_browse
IMAP folder.
String manipulation buffer.
char * data
Pointer to data.
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 Window.
struct MuttWindow * win
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"
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.
void * mdata
Driver specific data.
char * name
A short name for the Mailbox.
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.
NNTP-specific Account data -.
struct Connection * conn
Connection to NNTP Server.
NNTP-specific Mailbox data -.
char * group
Name of newsgroup.
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.