NeoMutt  2025-12-11-769-g906513
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
lib.h File Reference

GUI manage the main index (list of emails) More...

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "expando/lib.h"
#include "expando_index.h"
#include "functions.h"
#include "shared_data.h"
#include "status.h"
#include "subjectrx.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NT_INDEX_NO_FLAGS   0
 No flags are set.
 
#define NT_INDEX_ADD   (1 << 0)
 New Index Shared Data has been created.
 
#define NT_INDEX_DELETE   (1 << 1)
 Index Shared Data is about to be freed.
 
#define NT_INDEX_SUBSET   (1 << 2)
 Config Subset has changed.
 
#define NT_INDEX_ACCOUNT   (1 << 3)
 Account has changed.
 
#define NT_INDEX_MVIEW   (1 << 4)
 MailboxView has changed.
 
#define NT_INDEX_MAILBOX   (1 << 5)
 Mailbox has changed.
 
#define NT_INDEX_EMAIL   (1 << 6)
 Email has changed.
 
#define CHECK_NO_FLAGS   0
 No flags are set.
 
#define CHECK_IN_MAILBOX   (1 << 0)
 Is there a mailbox open?
 
#define CHECK_MSGCOUNT   (1 << 1)
 Are there any messages?
 
#define CHECK_VISIBLE   (1 << 2)
 Is the selected message visible in the index?
 
#define CHECK_READONLY   (1 << 3)
 Is the mailbox readonly?
 
#define CHECK_ATTACH   (1 << 4)
 Is the user in message-attach mode?
 

Typedefs

typedef uint8_t NotifyIndex
 Flags, e.g. NT_INDEX_ACCOUNT.
 
typedef uint8_t CheckFlags
 Flags, e.g. CHECK_IN_MAILBOX.
 

Enumerations

enum  CollapseMode { COLLAPSE_MODE_TOGGLE , COLLAPSE_MODE_CLOSE , COLLAPSE_MODE_OPEN }
 Action to perform on a Thread. More...
 

Functions

void index_init_keys (struct NeoMutt *n, struct SubMenu *sm_generic)
 Initialise the Index Keybindings - Implements ::init_keys_api.
 
void change_folder_mailbox (struct Menu *menu, struct Mailbox *m, int *oldcount, struct IndexSharedData *shared, bool read_only)
 Change to a different Mailbox by pointer.
 
struct Mailboxchange_folder_notmuch (struct Menu *menu, char *buf, int buflen, int *oldcount, struct IndexSharedData *shared, bool read_only)
 Change to a different Notmuch Mailbox by string.
 
void change_folder_string (struct Menu *menu, struct Buffer *buf, int *oldcount, struct IndexSharedData *shared, bool read_only)
 Change to a different Mailbox by string.
 
bool check_acl (struct Mailbox *m, AclFlags acl, const char *msg)
 Check the ACLs for a function.
 
void collapse_all (struct MailboxView *mv, struct Menu *menu, enum CollapseMode mode)
 Collapse/uncollapse all threads.
 
struct Mailboxdlg_index (struct MuttWindow *dlg, struct Mailbox *m)
 Display a list of emails -.
 
int find_first_message (struct MailboxView *mv)
 Get index of first new message.
 
int find_next_undeleted (struct MailboxView *mv, int msgno, bool uncollapse)
 Find the next undeleted email.
 
int find_previous_undeleted (struct MailboxView *mv, int msgno, bool uncollapse)
 Find the previous undeleted email.
 
struct Mailboxget_current_mailbox (void)
 Get the current Mailbox.
 
struct MailboxViewget_current_mailbox_view (void)
 Get the current Mailbox view.
 
void index_change_folder (struct MuttWindow *dlg, struct Mailbox *m)
 Change the current folder, cautiously.
 
const struct AttrColorindex_color (struct Menu *menu, int line)
 Calculate the colour for a line of the index - Implements Menu::color() -.
 
int index_make_entry (struct Menu *menu, int line, int max_cols, struct Buffer *buf)
 Format an Email for the Menu - Implements Menu::make_entry() -.
 
struct MuttWindowindex_pager_init (void)
 Allocate the Windows for the Index/Pager.
 
int mutt_dlgindex_observer (struct NotifyCallback *nc)
 
void mutt_draw_statusline (struct MuttWindow *win, int max_cols, const char *buf, size_t buflen)
 Draw a highlighted status bar.
 
void email_set_color (struct Mailbox *m, struct Email *e)
 Select an Index colour for an Email.
 
void resort_index (struct MailboxView *mv, struct Menu *menu)
 Resort the index.
 
void update_index (struct Menu *menu, struct MailboxView *mv, enum MxStatus check, int oldcount, const struct IndexSharedData *shared)
 Update the index.
 
int mutt_make_string (struct Buffer *buf, size_t max_cols, const struct Expando *exp, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
 Create formatted strings using mailbox expandos.
 

Variables

const struct Mapping IndexNewsHelp []
 Help Bar for the News Index dialog.
 
const struct ExpandoDefinition StatusFormatDef []
 Expando definitions.
 

Detailed Description

GUI manage the main index (list of emails)

Authors
  • Richard Russon

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 lib.h.

Macro Definition Documentation

◆ NT_INDEX_NO_FLAGS

#define NT_INDEX_NO_FLAGS   0

No flags are set.

Definition at line 69 of file lib.h.

◆ NT_INDEX_ADD

#define NT_INDEX_ADD   (1 << 0)

New Index Shared Data has been created.

Definition at line 70 of file lib.h.

◆ NT_INDEX_DELETE

#define NT_INDEX_DELETE   (1 << 1)

Index Shared Data is about to be freed.

Definition at line 71 of file lib.h.

◆ NT_INDEX_SUBSET

#define NT_INDEX_SUBSET   (1 << 2)

Config Subset has changed.

Definition at line 72 of file lib.h.

◆ NT_INDEX_ACCOUNT

#define NT_INDEX_ACCOUNT   (1 << 3)

Account has changed.

Definition at line 73 of file lib.h.

◆ NT_INDEX_MVIEW

#define NT_INDEX_MVIEW   (1 << 4)

MailboxView has changed.

Definition at line 74 of file lib.h.

◆ NT_INDEX_MAILBOX

#define NT_INDEX_MAILBOX   (1 << 5)

Mailbox has changed.

Definition at line 75 of file lib.h.

◆ NT_INDEX_EMAIL

#define NT_INDEX_EMAIL   (1 << 6)

Email has changed.

Definition at line 76 of file lib.h.

◆ CHECK_NO_FLAGS

#define CHECK_NO_FLAGS   0

No flags are set.

Definition at line 79 of file lib.h.

◆ CHECK_IN_MAILBOX

#define CHECK_IN_MAILBOX   (1 << 0)

Is there a mailbox open?

Definition at line 80 of file lib.h.

◆ CHECK_MSGCOUNT

#define CHECK_MSGCOUNT   (1 << 1)

Are there any messages?

Definition at line 81 of file lib.h.

◆ CHECK_VISIBLE

#define CHECK_VISIBLE   (1 << 2)

Is the selected message visible in the index?

Definition at line 82 of file lib.h.

◆ CHECK_READONLY

#define CHECK_READONLY   (1 << 3)

Is the mailbox readonly?

Definition at line 83 of file lib.h.

◆ CHECK_ATTACH

#define CHECK_ATTACH   (1 << 4)

Is the user in message-attach mode?

Definition at line 84 of file lib.h.

Typedef Documentation

◆ NotifyIndex

typedef uint8_t NotifyIndex

Flags, e.g. NT_INDEX_ACCOUNT.

Definition at line 68 of file lib.h.

◆ CheckFlags

typedef uint8_t CheckFlags

Flags, e.g. CHECK_IN_MAILBOX.

Definition at line 78 of file lib.h.

Enumeration Type Documentation

◆ CollapseMode

Action to perform on a Thread.

Enumerator
COLLAPSE_MODE_TOGGLE 

Toggle collapsed state.

COLLAPSE_MODE_CLOSE 

Collapse all threads.

COLLAPSE_MODE_OPEN 

Open all threads.

Definition at line 89 of file lib.h.

90{
94};
@ COLLAPSE_MODE_TOGGLE
Toggle collapsed state.
Definition lib.h:91
@ COLLAPSE_MODE_CLOSE
Collapse all threads.
Definition lib.h:92
@ COLLAPSE_MODE_OPEN
Open all threads.
Definition lib.h:93

Function Documentation

◆ index_init_keys()

void index_init_keys ( struct NeoMutt * n,
struct SubMenu * sm_generic )

Initialise the Index Keybindings - Implements ::init_keys_api.

Definition at line 325 of file functions.c.

326{
327 struct MenuDefinition *md = NULL;
328 struct SubMenu *sm_index = NULL;
329 struct SubMenu *sm_sidebar = sidebar_get_submenu();
330
331 sm_index = km_register_submenu(OpIndex);
332 md = km_register_menu(MENU_INDEX, "index");
333 km_menu_add_submenu(md, sm_index);
334 km_menu_add_submenu(md, sm_sidebar);
335 km_menu_add_submenu(md, sm_generic);
337
339 ASSERT(mod_data);
340 mod_data->menu_index = md;
341}
static const struct MenuFuncOp OpIndex[]
Functions for the Index Menu.
Definition functions.c:85
static const struct MenuOpSeq IndexDefaultBindings[]
Key bindings for the Index Menu.
Definition functions.c:223
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:121
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:87
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:104
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:134
@ MODULE_ID_INDEX
ModuleIndex, Index
Definition module_api.h:72
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:665
struct SubMenu * sidebar_get_submenu(void)
Get the Sidebar SubMenu.
Definition functions.c:106
#define ASSERT(COND)
Definition signal2.h:59
Index private Module data.
Definition module_data.h:32
struct MenuDefinition * menu_index
Index menu definition.
Definition module_data.h:34
Functions for a Dialog or Window.
Definition menu.h:80
Collection of related functions.
Definition menu.h:68
@ MENU_INDEX
Index panel (list of emails)
Definition type.h:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ change_folder_mailbox()

void change_folder_mailbox ( struct Menu * menu,
struct Mailbox * m,
int * oldcount,
struct IndexSharedData * shared,
bool read_only )

Change to a different Mailbox by pointer.

Parameters
menuCurrent Menu
mMailbox
oldcountHow many items are currently in the index
sharedShared Index data
read_onlyOpen Mailbox in read-only mode

Definition at line 631 of file dlg_index.c.

633{
634 if (!m)
635 return;
636
637 /* keepalive failure in mutt_enter_fname may kill connection. */
638 if (shared->mailbox && (buf_is_empty(&shared->mailbox->pathbuf)))
639 {
640 mview_free(&shared->mailbox_view);
641 mailbox_free(&shared->mailbox);
642 }
643
644 if (shared->mailbox)
645 {
646 char *new_last_folder = NULL;
647#ifdef USE_INOTIFY
648 int monitor_remove_rc = mutt_monitor_remove(NULL);
649#endif
650 if (shared->mailbox->compress_info && (shared->mailbox->realpath[0] != '\0'))
651 new_last_folder = mutt_str_dup(shared->mailbox->realpath);
652 else
653 new_last_folder = mutt_str_dup(mailbox_path(shared->mailbox));
654 *oldcount = shared->mailbox->msg_count;
655
656 const enum MxStatus check = mx_mbox_close(shared->mailbox);
657 if (check == MX_STATUS_OK)
658 {
659 mview_free(&shared->mailbox_view);
660 if (shared->mailbox != m)
661 {
662 mailbox_free(&shared->mailbox);
663 }
664 }
665 else
666 {
667#ifdef USE_INOTIFY
668 if (monitor_remove_rc == 0)
669 mutt_monitor_add(NULL);
670#endif
671 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
672 update_index(menu, shared->mailbox_view, check, *oldcount, shared);
673
674 FREE(&new_last_folder);
677 return;
678 }
680 LastFolder = new_last_folder;
681 }
683
684 /* If the `folder-hook` were to call `unmailboxes`, then the Mailbox (`m`)
685 * could be deleted, leaving `m` dangling. */
686 // TODO: Refactor this function to avoid the need for an observer
688 char *dup_path = mutt_str_dup(mailbox_path(m));
689 char *dup_name = mutt_str_dup(m->name);
690
691 exec_folder_hook(dup_path, dup_name);
692 if (m)
693 {
694 /* `m` is still valid, but we won't need the observer again before the end
695 * of the function. */
697 }
698 else
699 {
700 // Recreate the Mailbox as the folder-hook might have invoked `mailboxes`
701 // and/or `unmailboxes`.
702 m = mx_path_resolve(dup_path);
703 }
704
705 FREE(&dup_path);
706 FREE(&dup_name);
707
708 if (!m)
709 return;
710
711 const OpenMailboxFlags flags = read_only ? MUTT_READONLY : MUTT_OPEN_NO_FLAGS;
712 if (mx_mbox_open(m, flags))
713 {
714 struct MailboxView *mv = mview_new(m, NeoMutt->notify);
715 index_shared_data_set_mview(shared, mv);
716
717 menu->max = m->msg_count;
719#ifdef USE_INOTIFY
720 mutt_monitor_add(NULL);
721#endif
722 }
723 else
724 {
725 index_shared_data_set_mview(shared, NULL);
727 }
728
729 const bool c_collapse_all = cs_subset_bool(shared->sub, "collapse_all");
730 if (mutt_using_threads() && c_collapse_all)
732
734 /* force the mailbox check after we have changed the folder */
735 struct EventMailbox ev_m = { shared->mailbox };
739}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition compile.c:830
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition mailbox.c:90
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:213
void update_index(struct Menu *menu, struct MailboxView *mv, enum MxStatus check, int oldcount, const struct IndexSharedData *shared)
Update the index.
Definition dlg_index.c:562
int find_first_message(struct MailboxView *mv)
Get index of first new message.
Definition dlg_index.c:327
void collapse_all(struct MailboxView *mv, struct Menu *menu, enum CollapseMode mode)
Collapse/uncollapse all threads.
Definition dlg_index.c:161
char * LastFolder
Previously selected mailbox.
Definition globals.c:39
char * CurrentFolder
Currently selected mailbox.
Definition globals.c:38
static int index_mailbox_observer(struct NotifyCallback *nc)
Notification that a Mailbox has changed - Implements observer_t -.
Definition dlg_index.c:605
#define mutt_using_threads()
Definition thread.h:113
void exec_folder_hook(const char *path, const char *desc)
Perform a folder hook.
Definition exec.c:64
void index_shared_data_set_mview(struct IndexSharedData *shared, struct MailboxView *mv)
Set the MailboxView for the Index and friends.
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:60
#define MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:57
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:189
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:179
int mutt_monitor_add(struct Mailbox *m)
Add a watch for a mailbox.
Definition monitor.c:484
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition monitor.c:528
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition notify.c:230
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition notify.c:191
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
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.
void mview_free(struct MailboxView **ptr)
Free a MailboxView.
Definition mview.c:47
struct MailboxView * mview_new(struct Mailbox *m, struct Notify *parent)
Create a new MailboxView.
Definition mview.c:88
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition mx.c:285
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition mx.c:1647
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
Definition mx.c:595
#define MUTT_READONLY
Open in read-only mode.
Definition mxapi.h:42
uint8_t OpenMailboxFlags
Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT.
Definition mxapi.h:38
#define MUTT_OPEN_NO_FLAGS
No flags are set.
Definition mxapi.h:39
#define MUTT_MAILBOX_CHECK_POSTPONED
Make sure the number of postponed messages is updated.
Definition mxapi.h:50
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close()
Definition mxapi.h:59
@ MX_STATUS_OK
No changes.
Definition mxapi.h:61
@ MX_STATUS_REOPENED
Mailbox was reopened.
Definition mxapi.h:64
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition mxapi.h:62
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:49
An Event that happened to a Mailbox.
Definition mailbox.h:189
struct Mailbox * mailbox
The Mailbox this Event relates to.
Definition mailbox.h:190
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:41
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:38
struct MailboxView * mailbox_view
Current Mailbox view.
Definition shared_data.h:40
struct SearchState * search_state
State of the current search.
Definition shared_data.h:45
View of a Mailbox.
Definition mview.h:40
struct Menu * menu
Needed for pattern compilation.
Definition mview.h:47
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition mailbox.h:80
int msg_count
Total number of messages.
Definition mailbox.h:87
char * name
A short name for the Mailbox.
Definition mailbox.h:81
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition mailbox.h:144
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:79
void * compress_info
Compressed mbox module private data.
Definition mailbox.h:120
int max
Number of entries in the menu.
Definition lib.h:82
Container for Accounts, Notifications.
Definition neomutt.h:41
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
struct PatternList * pattern
compiled search pattern
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ change_folder_notmuch()

struct Mailbox * change_folder_notmuch ( struct Menu * menu,
char * buf,
int buflen,
int * oldcount,
struct IndexSharedData * shared,
bool read_only )

Change to a different Notmuch Mailbox by string.

Parameters
menuCurrent Menu
bufFolder to change to
buflenLength of buffer
oldcountHow many items are currently in the index
sharedShared Index data
read_onlyOpen Mailbox in read-only mode
Return values
ptrMailbox

Definition at line 752 of file dlg_index.c.

754{
755 if (!nm_url_from_query(NULL, buf, buflen))
756 {
757 mutt_message(_("Failed to create query, aborting"));
758 return NULL;
759 }
760
761 struct Mailbox *m_query = mx_path_resolve(buf);
762 change_folder_mailbox(menu, m_query, oldcount, shared, read_only);
763 if (!shared->mailbox_view)
764 mailbox_free(&m_query);
765 return m_query;
766}
void change_folder_mailbox(struct Menu *menu, struct Mailbox *m, int *oldcount, struct IndexSharedData *shared, bool read_only)
Change to a different Mailbox by pointer.
Definition dlg_index.c:631
#define mutt_message(...)
Definition logging2.h:93
#define _(a)
Definition message.h:28
char * nm_url_from_query(struct Mailbox *m, char *buf, size_t buflen)
Turn a query into a URL.
Definition notmuch.c:1615
A mailbox.
Definition mailbox.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ change_folder_string()

void change_folder_string ( struct Menu * menu,
struct Buffer * buf,
int * oldcount,
struct IndexSharedData * shared,
bool read_only )

Change to a different Mailbox by string.

Parameters
menuCurrent Menu
bufFolder to change to
oldcountHow many items are currently in the index
sharedShared Index data
read_onlyOpen Mailbox in read-only mode

Definition at line 777 of file dlg_index.c.

779{
781 if (OptNews)
782 {
783 OptNews = false;
784 nntp_expand_path(buf->data, buf->dsize, &mod_data->current_news_srv->conn->account);
785 }
786 else
787 {
788 const char *const c_folder = cs_subset_string(shared->sub, "folder");
789 mx_path_canon(buf, c_folder, NULL);
790 }
791
792 enum MailboxType type = mx_path_probe(buf_string(buf));
793 if ((type == MUTT_MAILBOX_ERROR) || (type == MUTT_UNKNOWN))
794 {
795 // Look for a Mailbox by its description, before failing
796 struct Mailbox *m = mailbox_find_name(buf_string(buf));
797 if (m)
798 {
799 change_folder_mailbox(menu, m, oldcount, shared, read_only);
800 }
801 else
802 {
803 mutt_error(_("%s is not a mailbox"), buf_string(buf));
804 }
805 return;
806 }
807
808 struct Mailbox *m = mx_path_resolve(buf_string(buf));
809 change_folder_mailbox(menu, m, oldcount, shared, read_only);
810}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
struct Mailbox * mailbox_find_name(const char *name)
Find the mailbox with a given name.
Definition mailbox.c:187
MailboxType
Supported mailbox formats.
Definition mailbox.h:40
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition mailbox.h:42
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:43
bool OptNews
(pseudo) used to change reader mode
Definition globals.c:53
#define mutt_error(...)
Definition logging2.h:94
@ MODULE_ID_NNTP
ModuleNntp, Nntp
Definition module_api.h:81
int mx_path_canon(struct Buffer *path, const char *folder, enum MailboxType *type)
Canonicalise a mailbox path - Wrapper for MxOps::path_canon()
Definition mx.c:1369
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition mx.c:1323
void nntp_expand_path(char *buf, size_t buflen, struct ConnAccount *acct)
Make fully qualified url from newsgroup name.
Definition newsrc.c:557
size_t dsize
Length of data.
Definition buffer.h:39
char * data
Pointer to data.
Definition buffer.h:37
struct ConnAccount account
Account details: username, password, etc.
Definition connection.h:49
struct Connection * conn
Connection to NNTP Server.
Definition adata.h:63
Nntp private Module data.
Definition module_data.h:30
struct NntpAccountData * current_news_srv
Current NNTP news server.
Definition module_data.h:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_acl()

bool check_acl ( struct Mailbox * m,
AclFlags acl,
const char * msg )

Check the ACLs for a function.

Parameters
mMailbox
aclACL, see AclFlags
msgError message for failure
Return values
trueThe function is permitted

Definition at line 137 of file dlg_index.c.

138{
139 if (!m)
140 return false;
141
142 if (!(m->rights & acl))
143 {
144 /* L10N: %s is one of the CHECK_ACL entries below. */
145 mutt_error(_("%s: Operation not permitted by ACL"), msg);
146 return false;
147 }
148
149 return true;
150}
AclFlags rights
ACL bits, see AclFlags.
Definition mailbox.h:118
+ Here is the caller graph for this function:

◆ collapse_all()

void collapse_all ( struct MailboxView * mv,
struct Menu * menu,
enum CollapseMode mode )

Collapse/uncollapse all threads.

Parameters
mvMailbox View
menuCurrent menu
modeCollapse mode

This function is called by OP_MAIN_COLLAPSE_ALL, by the one-way open/close commands, and on folder enter if the $collapse_all option is set.

Definition at line 161 of file dlg_index.c.

162{
163 if (!mv || !mv->mailbox || (mv->mailbox->msg_count == 0) || !menu)
164 return;
165
166 struct Email *e_cur = mutt_get_virt_email(mv->mailbox, menu_get_index(menu));
167 if (!e_cur)
168 return;
169
170 int final = -1;
171
172 /* Figure out what the current message would be after folding / unfolding,
173 * so that we can restore the cursor in a sane way afterwards. */
174 switch (mode)
175 {
177 if (e_cur->collapsed)
178 final = mutt_uncollapse_thread(e_cur);
179 else if (mutt_thread_can_collapse(e_cur))
180 final = mutt_collapse_thread(e_cur);
181 else
182 final = e_cur->vnum;
183 break;
184
186 if (mutt_thread_can_collapse(e_cur))
187 final = mutt_collapse_thread(e_cur);
188 else
189 final = e_cur->vnum;
190 break;
191
193 if (e_cur->collapsed)
194 final = mutt_uncollapse_thread(e_cur);
195 else
196 final = e_cur->vnum;
197 break;
198 }
199
200 if (final == -1)
201 return;
202
203 struct Email *base = mutt_get_virt_email(mv->mailbox, final);
204 if (!base)
205 return;
206
207 /* Iterate all threads, perform collapse/uncollapse as needed */
208 if (mode == COLLAPSE_MODE_TOGGLE)
209 mv->collapsed = !mv->collapsed;
210 else
211 mv->collapsed = (mode == COLLAPSE_MODE_CLOSE);
213
214 /* Restore the cursor */
216 menu->max = mv->mailbox->vcount;
217 for (int i = 0; i < mv->mailbox->vcount; i++)
218 {
219 struct Email *e = mutt_get_virt_email(mv->mailbox, i);
220 if (!e)
221 break;
222 if (e->index == base->index)
223 {
224 menu_set_index(menu, i);
225 break;
226 }
227 }
228
230}
void mutt_thread_collapse(struct ThreadsContext *tctx, bool collapse)
Toggle collapse.
Definition thread.c:1868
off_t mutt_set_vnum(struct Mailbox *m)
Set the virtual index number of all the messages in a mailbox.
Definition thread.c:1483
bool mutt_thread_can_collapse(struct Email *e)
Check whether a thread can be collapsed.
Definition thread.c:1896
#define mutt_uncollapse_thread(e)
Definition thread.h:107
#define mutt_collapse_thread(e)
Definition thread.h:106
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:165
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition mview.c:415
The envelope/body of an email.
Definition email.h:39
bool collapsed
Is this message part of a collapsed thread?
Definition email.h:120
int vnum
Virtual message number.
Definition email.h:114
int index
The absolute (unsorted) message number.
Definition email.h:110
bool collapsed
Are all threads collapsed?
Definition mview.h:49
struct ThreadsContext * threads
Threads context.
Definition mview.h:44
struct Mailbox * mailbox
Current Mailbox.
Definition mview.h:51
int vcount
The number of virtual messages.
Definition mailbox.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_first_message()

int find_first_message ( struct MailboxView * mv)

Get index of first new message.

Parameters
mvMailbox view
Return values
numIndex of first new message

Return the index of the first new message, or failing that, the first unread message.

Definition at line 327 of file dlg_index.c.

328{
329 if (!mv)
330 return 0;
331
332 struct Mailbox *m = mv->mailbox;
333 if (!m || (m->msg_count == 0))
334 return 0;
335
336 int old = -1;
337 for (int i = 0; i < m->vcount; i++)
338 {
339 struct Email *e = mutt_get_virt_email(m, i);
340 if (!e)
341 continue;
342 if (!e->read && !e->deleted)
343 {
344 if (!e->old)
345 return i;
346 if (old == -1)
347 old = i;
348 }
349 }
350 if (old != -1)
351 return old;
352
353 /* If `$use_threads` is not threaded and `$sort` is reverse, the latest
354 * message is first. Otherwise, the latest message is first if exactly
355 * one of `$use_threads` and `$sort` are reverse.
356 */
357 enum EmailSortType c_sort = cs_subset_sort(m->sub, "sort");
358 if ((c_sort & SORT_MASK) == EMAIL_SORT_THREADS)
359 c_sort = cs_subset_sort(m->sub, "sort_aux");
360 bool reverse = false;
361 switch (mutt_thread_style())
362 {
363 case UT_FLAT:
364 reverse = c_sort & SORT_REVERSE;
365 break;
366 case UT_THREADS:
367 reverse = c_sort & SORT_REVERSE;
368 break;
369 case UT_REVERSE:
370 reverse = !(c_sort & SORT_REVERSE);
371 break;
372 default:
373 ASSERT(false);
374 }
375
376 if (reverse || (m->vcount == 0))
377 return 0;
378
379 return m->vcount - 1;
380}
short cs_subset_sort(const struct ConfigSubset *sub, const char *name)
Get a sort config item by name.
Definition helpers.c:266
#define SORT_MASK
Mask for the sort id.
Definition sort.h:39
#define SORT_REVERSE
Reverse the order of the sort.
Definition sort.h:40
EmailSortType
Methods for sorting Emails.
Definition sort.h:53
@ EMAIL_SORT_THREADS
Sort by email threads.
Definition sort.h:62
enum UseThreads mutt_thread_style(void)
Which threading style is active?
Definition thread.c:79
@ UT_FLAT
Unthreaded.
Definition thread.h:98
@ UT_THREADS
Normal threading (root above subthreads)
Definition thread.h:99
@ UT_REVERSE
Reverse threading (subthreads above root)
Definition thread.h:100
bool read
Email is read.
Definition email.h:50
bool old
Email is seen, but unread.
Definition email.h:49
bool deleted
Email is deleted.
Definition email.h:78
struct ConfigSubset * sub
Inherited config items.
Definition mailbox.h:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_next_undeleted()

int find_next_undeleted ( struct MailboxView * mv,
int msgno,
bool uncollapse )

Find the next undeleted email.

Parameters
mvMailbox view
msgnoMessage number to start at
uncollapseOpen collapsed threads
Return values
>=0Message number of next undeleted email
-1No more undeleted messages

Definition at line 259 of file dlg_index.c.

260{
261 if (!mv || !mv->mailbox)
262 return -1;
263
264 struct Mailbox *m = mv->mailbox;
265
266 int index = -1;
267 for (int i = msgno + 1; i < m->vcount; i++)
268 {
269 struct Email *e = mutt_get_virt_email(m, i);
270 if (!e)
271 continue;
272 if (!e->deleted)
273 {
274 index = i;
275 break;
276 }
277 }
278
279 if (uncollapse)
281
282 return index;
283}
static void uncollapse_thread(struct MailboxView *mv, int index)
Open a collapsed thread.
Definition dlg_index.c:237
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ find_previous_undeleted()

int find_previous_undeleted ( struct MailboxView * mv,
int msgno,
bool uncollapse )

Find the previous undeleted email.

Parameters
mvMailbox View
msgnoMessage number to start at
uncollapseOpen collapsed threads
Return values
>=0Message number of next undeleted email
-1No more undeleted messages

Definition at line 293 of file dlg_index.c.

294{
295 if (!mv || !mv->mailbox)
296 return -1;
297
298 struct Mailbox *m = mv->mailbox;
299
300 int index = -1;
301 for (int i = msgno - 1; i >= 0; i--)
302 {
303 struct Email *e = mutt_get_virt_email(m, i);
304 if (!e)
305 continue;
306 if (!e->deleted)
307 {
308 index = i;
309 break;
310 }
311 }
312
313 if (uncollapse)
315
316 return index;
317}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_current_mailbox()

struct Mailbox * get_current_mailbox ( void )

Get the current Mailbox.

Return values
ptrCurrent Mailbox

Search for the last (most recent) dialog that has an Index. Then return the Mailbox from its shared data.

Definition at line 726 of file index.c.

727{
729 if (mv)
730 return mv->mailbox;
731
732 return NULL;
733}
struct MailboxView * get_current_mailbox_view(void)
Get the current Mailbox view.
Definition index.c:693
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_current_mailbox_view()

struct MailboxView * get_current_mailbox_view ( void )

Get the current Mailbox view.

Return values
ptrCurrent Mailbox view

Search for the last (most recent) dialog that has an Index. Then return the Mailbox from its shared data.

Definition at line 693 of file index.c.

694{
696 if (!gui_data || !gui_data->all_dialogs_window)
697 return NULL;
698
699 struct MuttWindow **wp = NULL;
701 {
702 struct MuttWindow *win = window_find_child(*wp, WT_DLG_INDEX);
703 if (win)
704 {
705 struct IndexSharedData *shared = win->wdata;
706 return shared->mailbox_view;
707 }
708
710 if (win)
711 {
712 return postponed_get_mailbox_view(win);
713 }
714 }
715
716 return NULL;
717}
#define ARRAY_FOREACH_REVERSE(elem, head)
Iterate backwards over all elements of the array.
Definition array.h:274
@ MODULE_ID_GUI
ModuleGui, Graphical code
Definition module_api.h:45
struct MuttWindow * window_find_child(struct MuttWindow *win, enum WindowType type)
Recursively find a child Window of a given type.
@ WT_DLG_INDEX
Index Dialog, dlg_index()
Definition mutt_window.h:86
@ WT_DLG_POSTPONE
Postpone Dialog, dlg_postpone()
Definition mutt_window.h:89
struct MailboxView * postponed_get_mailbox_view(struct MuttWindow *dlg)
Extract the Mailbox from the Postponed Dialog.
Definition functions.c:230
Gui private Module data.
Definition module_data.h:32
struct MuttWindow * all_dialogs_window
Parent of all Dialogs.
Definition module_data.h:38
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
struct MuttWindowArray children
Children Windows.
void * wdata
Private data.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index_change_folder()

void index_change_folder ( struct MuttWindow * dlg,
struct Mailbox * m )

Change the current folder, cautiously.

Parameters
dlgDialog holding the Index
mMailbox to change to

Definition at line 1490 of file dlg_index.c.

1491{
1492 if (!dlg || !m)
1493 return;
1494
1495 struct IndexSharedData *shared = dlg->wdata;
1496 if (!shared)
1497 return;
1498
1499 struct MuttWindow *panel_index = window_find_child(dlg, WT_INDEX);
1500 if (!panel_index)
1501 return;
1502
1503 struct IndexPrivateData *priv = panel_index->wdata;
1504 if (!priv)
1505 return;
1506
1507 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, false);
1508}
@ WT_INDEX
A panel containing the Index Window.
Definition mutt_window.h:96
Private state data for the Index.
struct IndexSharedData * shared
Shared Index data.
struct Menu * menu
Menu controlling the index.
int oldcount
Old count of mails in the mailbox.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index_pager_init()

struct MuttWindow * index_pager_init ( void )

Allocate the Windows for the Index/Pager.

Return values
ptrDialog containing nested Windows

Definition at line 1462 of file dlg_index.c.

1463{
1467
1468 struct IndexSharedData *shared = index_shared_data_new();
1469 notify_set_parent(shared->notify, dlg->notify);
1470
1471 dlg->wdata = shared;
1473
1474 const bool c_status_on_top = cs_subset_bool(NeoMutt->sub, "status_on_top");
1475
1476 struct MuttWindow *panel_index = ipanel_new(c_status_on_top, shared);
1477 struct MuttWindow *panel_pager = ppanel_new(c_status_on_top, shared);
1478
1479 mutt_window_add_child(dlg, panel_index);
1480 mutt_window_add_child(dlg, panel_pager);
1481
1482 return dlg;
1483}
void index_shared_data_free(struct MuttWindow *win, void **ptr)
Free Shared Index Data - Implements MuttWindow::wdata_free() -.
struct IndexSharedData * index_shared_data_new(void)
Create new Index Data.
struct MuttWindow * ipanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Index panel.
Definition ipanel.c:121
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void mutt_window_add_child(struct MuttWindow *parent, struct MuttWindow *child)
Add a child to Window.
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
@ MUTT_WIN_ORIENT_HORIZONTAL
Window uses all available horizontal space.
Definition mutt_window.h:39
#define MUTT_WIN_SIZE_UNLIMITED
Use as much space as possible.
Definition mutt_window.h:52
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:48
struct MuttWindow * ppanel_new(bool status_on_top, struct IndexSharedData *shared)
Create the Windows for the Pager panel.
Definition ppanel.c:133
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition shared_data.h:44
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
void(* wdata_free)(struct MuttWindow *win, void **ptr)
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_dlgindex_observer()

int mutt_dlgindex_observer ( struct NotifyCallback * nc)

◆ mutt_draw_statusline()

void mutt_draw_statusline ( struct MuttWindow * win,
int max_cols,
const char * buf,
size_t buflen )

Draw a highlighted status bar.

Parameters
winWindow
max_colsMaximum number of screen columns
bufMessage to be displayed
buflenLength of the buffer

Users configure the highlighting of the status bar, e.g. color status red default "[0-9][0-9]:[0-9][0-9]"

Where regexes overlap, the one nearest the start will be used. If two regexes start at the same place, the longer match will be used.

Colours of the status bar

< Colour attribute

< First character of that colour

< Last character of that colour

Definition at line 980 of file dlg_index.c.

981{
982 if (!buf || !stdscr)
983 return;
984
985 size_t i = 0;
986 size_t offset = 0;
987 bool found = false;
988 size_t chunks = 0;
989 size_t len = 0;
990
994 struct StatusSyntax
995 {
996 const struct AttrColor *attr_color;
997 int first;
998 int last;
999 } *syntax = NULL;
1000
1003 do
1004 {
1005 struct RegexColor *cl = NULL;
1006 found = false;
1007
1008 if (!buf[offset])
1009 break;
1010
1011 /* loop through each "color status regex" */
1013 {
1014 regmatch_t pmatch[cl->match + 1];
1015 memset(pmatch, 0, (cl->match + 1) * sizeof(regmatch_t));
1016
1017 if (regexec(&cl->regex, buf + offset, cl->match + 1, pmatch, 0) != 0)
1018 continue; /* regex doesn't match the status bar */
1019
1020 int first = pmatch[cl->match].rm_so + offset;
1021 int last = pmatch[cl->match].rm_eo + offset;
1022
1023 if (first == last)
1024 continue; /* ignore an empty regex */
1025
1026 if (!found)
1027 {
1028 chunks++;
1029 MUTT_MEM_REALLOC(&syntax, chunks, struct StatusSyntax);
1030 }
1031
1032 i = chunks - 1;
1033 if (!found || (first < syntax[i].first) ||
1034 ((first == syntax[i].first) && (last > syntax[i].last)))
1035 {
1036 const struct AttrColor *ac_merge = merged_color_overlay(ac_base, &cl->attr_color);
1037
1038 syntax[i].attr_color = ac_merge;
1039 syntax[i].first = first;
1040 syntax[i].last = last;
1041 }
1042 found = true;
1043 }
1044
1045 if (syntax)
1046 {
1047 offset = syntax[i].last;
1048 }
1049 } while (found);
1050
1051 /* Only 'len' bytes will fit into 'max_cols' screen columns */
1052 len = mutt_wstr_trunc(buf, buflen, max_cols, NULL);
1053
1054 offset = 0;
1055
1056 if ((chunks > 0) && (syntax[0].first > 0))
1057 {
1058 /* Text before the first highlight */
1059 mutt_window_addnstr(win, buf, MIN(len, syntax[0].first));
1060 mutt_curses_set_color(ac_base);
1061 if (len <= syntax[0].first)
1062 goto dsl_finish; /* no more room */
1063
1064 offset = syntax[0].first;
1065 }
1066
1067 for (i = 0; i < chunks; i++)
1068 {
1069 /* Highlighted text */
1070 mutt_curses_set_color(syntax[i].attr_color);
1071 mutt_window_addnstr(win, buf + offset, MIN(len, syntax[i].last) - offset);
1072 if (len <= syntax[i].last)
1073 goto dsl_finish; /* no more room */
1074
1075 size_t next;
1076 if ((i + 1) == chunks)
1077 {
1078 next = len;
1079 }
1080 else
1081 {
1082 next = MIN(len, syntax[i + 1].first);
1083 }
1084
1085 mutt_curses_set_color(ac_base);
1086 offset = syntax[i].last;
1087 mutt_window_addnstr(win, buf + offset, next - offset);
1088
1089 offset = next;
1090 if (offset >= len)
1091 goto dsl_finish; /* no more room */
1092 }
1093
1094 mutt_curses_set_color(ac_base);
1095 if (offset < len)
1096 {
1097 /* Text after the last highlight */
1098 mutt_window_addnstr(win, buf + offset, len - offset);
1099 }
1100
1101 int width = mutt_strwidth(buf);
1102 if (width < max_cols)
1103 {
1104 /* Pad the rest of the line with whitespace */
1105 mutt_paddstr(win, max_cols - width, "");
1106 }
1107dsl_finish:
1108 FREE(&syntax);
1109}
struct RegexColorList * regex_colors_get_list(enum ColorId cid)
Return the RegexColorList for a Colour ID.
Definition regex.c:190
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition simple.c:97
@ MT_COLOR_STATUS
Status bar (takes a pattern)
Definition color.h:78
@ MT_COLOR_NORMAL
Plain text.
Definition color.h:53
size_t mutt_wstr_trunc(const char *src, size_t maxlen, size_t maxwid, size_t *width)
Work out how to truncate a widechar string.
Definition curs_lib.c:386
void mutt_paddstr(struct MuttWindow *win, int n, const char *s)
Display a string on screen, padded if necessary.
Definition curs_lib.c:344
size_t mutt_strwidth(const char *s)
Measure a string's width in screen cells.
Definition curs_lib.c:446
#define MIN(a, b)
Return the minimum of two values.
Definition memory.h:40
#define MUTT_MEM_REALLOC(pptr, n, type)
Definition memory.h:55
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
Definition merged.c:110
void mutt_curses_set_color(const struct AttrColor *ac)
Set the colour and attributes for text.
Definition mutt_curses.c:38
int mutt_window_addnstr(struct MuttWindow *win, const char *str, int num)
Write a partial string to a Window.
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
A curses colour and its attributes.
Definition attr.h:65
A regular expression and a color to highlight a line.
Definition regex4.h:35
regex_t regex
Compiled regex.
Definition regex4.h:38
struct AttrColor attr_color
Colour and attributes to apply.
Definition regex4.h:36
int match
Substring to match, 0 for old behaviour.
Definition regex4.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ email_set_color()

void email_set_color ( struct Mailbox * m,
struct Email * e )

Select an Index colour for an Email.

Parameters
mMailbox
eCurrent Email

Calculate the colour for an Email in the Index. Cache the colour in the Email.

Definition at line 1431 of file dlg_index.c.

1432{
1433 if (!e)
1434 return;
1435
1436 struct RegexColor *color = NULL;
1437 struct PatternCache cache = { 0 };
1438
1439 const struct AttrColor *ac_merge = NULL;
1441 {
1443 MUTT_MATCH_FULL_ADDRESS, m, e, &cache))
1444 {
1445 ac_merge = merged_color_overlay(ac_merge, &color->attr_color);
1446 }
1447 }
1448
1449 struct AttrColor *ac_normal = simple_color_get(MT_COLOR_NORMAL);
1450 if (ac_merge)
1451 ac_merge = merged_color_overlay(ac_normal, ac_merge);
1452 else
1453 ac_merge = ac_normal;
1454
1455 e->attr_color = ac_merge;
1456}
@ MT_COLOR_INDEX
Index: default colour.
Definition color.h:86
bool mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Match a pattern against an email header.
Definition exec.c:1151
#define MUTT_MATCH_FULL_ADDRESS
Match the full address.
Definition lib.h:107
#define SLIST_FIRST(head)
Definition queue.h:227
const struct AttrColor * attr_color
Color-pair to use when displaying in the index.
Definition email.h:112
Cache commonly-used patterns.
Definition lib.h:118
struct PatternList * color_pattern
Compiled pattern to speed up index color calculation.
Definition regex4.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resort_index()

void resort_index ( struct MailboxView * mv,
struct Menu * menu )

Resort the index.

Parameters
mvMailbox View
menuCurrent Menu

Definition at line 387 of file dlg_index.c.

388{
389 if (!mv || !mv->mailbox || !menu)
390 return;
391
392 struct Mailbox *m = mv->mailbox;
393 const int old_index = menu_get_index(menu);
394 struct Email *e_cur = mutt_get_virt_email(m, old_index);
395
396 int new_index = -1;
397 mutt_sort_headers(mv, false);
398
399 /* Restore the current message */
400 for (int i = 0; i < m->vcount; i++)
401 {
402 struct Email *e = mutt_get_virt_email(m, i);
403 if (!e)
404 continue;
405 if (e == e_cur)
406 {
407 new_index = i;
408 break;
409 }
410 }
411
412 if (mutt_using_threads() && (old_index < 0))
413 new_index = mutt_parent_message(e_cur, false);
414
415 if (old_index < 0)
416 new_index = find_first_message(mv);
417
418 menu->max = m->vcount;
419 menu_set_index(menu, new_index);
421}
void mutt_sort_headers(struct MailboxView *mv, bool init)
Sort emails by their headers.
Definition sort.c:354
int mutt_parent_message(struct Email *e, bool find_root)
Find the parent of a message.
Definition thread.c:1433
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_index()

void update_index ( struct Menu * menu,
struct MailboxView * mv,
enum MxStatus check,
int oldcount,
const struct IndexSharedData * shared )

Update the index.

Parameters
menuCurrent Menu
mvMailbox
checkFlags, e.g. MX_STATUS_REOPENED
oldcountHow many items are currently in the index
sharedShared Index data

Definition at line 562 of file dlg_index.c.

564{
565 if (!menu || !mv)
566 return;
567
568 struct Mailbox *m = mv->mailbox;
569 if (mutt_using_threads())
570 update_index_threaded(mv, check, oldcount);
571 else
572 update_index_unthreaded(mv, check);
573
574 menu->max = m->vcount;
575 const int old_index = menu_get_index(menu);
576 int index = -1;
577 if (oldcount)
578 {
579 /* restore the current message to the message it was pointing to */
580 for (int i = 0; i < m->vcount; i++)
581 {
582 struct Email *e = mutt_get_virt_email(m, i);
583 if (!e)
584 continue;
585 if (index_shared_data_is_cur_email(shared, e))
586 {
587 index = i;
588 break;
589 }
590 }
591 }
592
593 if (index < 0)
594 {
595 index = (old_index < m->vcount) ? old_index : find_first_message(mv);
596 }
597 menu_set_index(menu, index);
598}
static void update_index_threaded(struct MailboxView *mv, enum MxStatus check, int oldcount)
Update the index (if threaded)
Definition dlg_index.c:429
static void update_index_unthreaded(struct MailboxView *mv, enum MxStatus check)
Update the index (if unthreaded)
Definition dlg_index.c:513
bool index_shared_data_is_cur_email(const struct IndexSharedData *shared, const struct Email *e)
Check whether an email is the currently selected Email.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_make_string()

int mutt_make_string ( struct Buffer * buf,
size_t max_cols,
const struct Expando * exp,
struct Mailbox * m,
int inpgr,
struct Email * e,
MuttFormatFlags flags,
const char * progress )

Create formatted strings using mailbox expandos.

Parameters
bufBuffer for the result
max_colsNumber of screen columns (-1 means unlimited)
expExpando containing expando tree
mMailbox
inpgrMessage shown in the pager
eEmail
flagsFlags, see MuttFormatFlags
progressPager progress string
Return values
numNumber of screen columns used

Definition at line 824 of file dlg_index.c.

827{
828 if (!exp)
829 return 0;
830
831 struct EmailFormatInfo efi = { 0 };
832
833 efi.email = e;
834 efi.mailbox = m;
835 efi.msg_in_pager = inpgr;
836 efi.pager_progress = progress;
837
838 return expando_filter(exp, IndexRenderCallbacks, &efi, flags, max_cols,
839 NeoMutt->env, buf);
840}
int expando_filter(const struct Expando *exp, const struct ExpandoRenderCallback *erc, void *data, MuttFormatFlags flags, int max_cols, char **env_list, struct Buffer *buf)
Render an Expando and run the result through a filter.
Definition filter.c:139
const struct ExpandoRenderCallback IndexRenderCallbacks[]
Callbacks for Index Expandos.
Data passed to index_format_str()
Definition private.h:37
struct Email * email
Current Email.
Definition private.h:40
struct Mailbox * mailbox
Current Mailbox.
Definition private.h:38
int msg_in_pager
Index of Email displayed in the Pager.
Definition private.h:39
const char * pager_progress
String representing Pager position through Email.
Definition private.h:41
char ** env
Private copy of the environment variables.
Definition neomutt.h:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ IndexNewsHelp

const struct Mapping IndexNewsHelp[]
extern

Help Bar for the News Index dialog.

Definition at line 116 of file dlg_index.c.

116 {
117 // clang-format off
118 { N_("Quit"), OP_QUIT },
119 { N_("Del"), OP_DELETE },
120 { N_("Undel"), OP_UNDELETE },
121 { N_("Save"), OP_SAVE },
122 { N_("Post"), OP_POST },
123 { N_("Followup"), OP_FOLLOWUP },
124 { N_("Catchup"), OP_CATCHUP },
125 { N_("Help"), OP_HELP },
126 { NULL, 0 },
127 // clang-format on
128};
#define N_(a)
Definition message.h:32

◆ StatusFormatDef

const struct ExpandoDefinition StatusFormatDef[]
extern

Expando definitions.

Config:

  • $new_mail_command
  • $status_format
  • $ts_icon_format
  • $ts_status_format

Definition at line 49 of file config.c.

49 {
50 // clang-format off
51 { "*", "padding-soft", ED_GLOBAL, ED_GLO_PADDING_SOFT, node_padding_parse },
52 { ">", "padding-hard", ED_GLOBAL, ED_GLO_PADDING_HARD, node_padding_parse },
53 { "|", "padding-eol", ED_GLOBAL, ED_GLO_PADDING_EOL, node_padding_parse },
54 { "b", "unread-mailboxes", ED_INDEX, ED_IND_UNREAD_MAILBOXES, NULL },
55 { "d", "deleted-count", ED_INDEX, ED_IND_DELETED_COUNT, NULL },
56 { "D", "description", ED_INDEX, ED_IND_DESCRIPTION, NULL },
57 { "f", "mailbox-path", ED_INDEX, ED_IND_MAILBOX_PATH, NULL },
58 { "F", "flagged-count", ED_INDEX, ED_IND_FLAGGED_COUNT, NULL },
59 { "h", "hostname", ED_GLOBAL, ED_GLO_HOSTNAME, NULL },
60 { "l", "mailbox-size", ED_INDEX, ED_IND_MAILBOX_SIZE, NULL },
61 { "L", "limit-size", ED_INDEX, ED_IND_LIMIT_SIZE, NULL },
62 { "m", "message-count", ED_INDEX, ED_IND_MESSAGE_COUNT, NULL },
63 { "M", "limit-count", ED_INDEX, ED_IND_LIMIT_COUNT, NULL },
64 { "n", "new-count", ED_INDEX, ED_IND_NEW_COUNT, NULL },
65 { "o", "old-count", ED_INDEX, ED_IND_OLD_COUNT, NULL },
66 { "p", "postponed-count", ED_INDEX, ED_IND_POSTPONED_COUNT, NULL },
67 { "P", "percentage", ED_MENU, ED_MEN_PERCENTAGE, NULL },
68 { "r", "readonly", ED_INDEX, ED_IND_READONLY, NULL },
69 { "R", "read-count", ED_INDEX, ED_IND_READ_COUNT, NULL },
70 { "s", "sort", ED_GLOBAL, ED_GLO_CONFIG_SORT, NULL },
71 { "S", "sort-aux", ED_GLOBAL, ED_GLO_CONFIG_SORT_AUX, NULL },
72 { "t", "tagged-count", ED_INDEX, ED_IND_TAGGED_COUNT, NULL },
73 { "T", "use-threads", ED_GLOBAL, ED_GLO_CONFIG_USE_THREADS, NULL },
74 { "u", "unread-count", ED_INDEX, ED_IND_UNREAD_COUNT, NULL },
75 { "v", "version", ED_GLOBAL, ED_GLO_VERSION, NULL },
76 { "V", "limit-pattern", ED_INDEX, ED_IND_LIMIT_PATTERN, NULL },
77 { NULL, NULL, 0, -1, NULL }
78 // clang-format on
79};
@ ED_MENU
Menu ED_MEN_ ExpandoDataMenu.
Definition domain.h:48
@ ED_GLOBAL
Global ED_GLO_ ExpandoDataGlobal.
Definition domain.h:44
@ ED_INDEX
Index ED_IND_ ExpandoDataIndex.
Definition domain.h:46
struct ExpandoNode * node_padding_parse(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Padding Expando - Implements ExpandoDefinition::parse() -.
@ ED_IND_LIMIT_COUNT
Mailbox.vcount.
Definition shared_data.h:59
@ ED_IND_MAILBOX_PATH
Mailbox.pathbuf, Mailbox.name.
Definition shared_data.h:62
@ ED_IND_DELETED_COUNT
Mailbox.msg_deleted.
Definition shared_data.h:56
@ ED_IND_NEW_COUNT
Mailbox.msg_new.
Definition shared_data.h:65
@ ED_IND_MAILBOX_SIZE
Mailbox.size.
Definition shared_data.h:63
@ ED_IND_LIMIT_PATTERN
MailboxView.pattern.
Definition shared_data.h:60
@ ED_IND_READ_COUNT
Mailbox.msg_count, Mailbox.msg_unread.
Definition shared_data.h:69
@ ED_IND_POSTPONED_COUNT
mutt_num_postponed()
Definition shared_data.h:67
@ ED_IND_FLAGGED_COUNT
Mailbox.msg_flagged.
Definition shared_data.h:58
@ ED_IND_MESSAGE_COUNT
Mailbox.msg_count.
Definition shared_data.h:64
@ ED_IND_OLD_COUNT
Mailbox.msg_unread, Mailbox.msg_new.
Definition shared_data.h:66
@ ED_IND_READONLY
Mailbox.readonly, Mailbox.dontwrite.
Definition shared_data.h:68
@ ED_IND_UNREAD_COUNT
Mailbox.msg_unread.
Definition shared_data.h:71
@ ED_IND_TAGGED_COUNT
Mailbox.msg_tagged.
Definition shared_data.h:70
@ ED_IND_LIMIT_SIZE
MailboxView.vsize.
Definition shared_data.h:61
@ ED_IND_DESCRIPTION
Mailbox.name.
Definition shared_data.h:57
@ ED_IND_UNREAD_MAILBOXES
Mailbox, mutt_mailbox_check()
Definition shared_data.h:72
@ ED_MEN_PERCENTAGE
Menu.top, ...
Definition lib.h:69
@ ED_GLO_CONFIG_USE_THREADS
Value of $use_threads.
Definition uid.h:36
@ ED_GLO_PADDING_EOL
Padding to end-of-line.
Definition uid.h:38
@ ED_GLO_CONFIG_SORT
Value of $sort.
Definition uid.h:34
@ ED_GLO_VERSION
NeoMutt version.
Definition uid.h:42
@ ED_GLO_PADDING_HARD
Hard Padding.
Definition uid.h:39
@ ED_GLO_PADDING_SOFT
Soft Padding.
Definition uid.h:40
@ ED_GLO_CONFIG_SORT_AUX
Value of $sort_aux.
Definition uid.h:35
@ ED_GLO_HOSTNAME
Local hostname.
Definition uid.h:37