NeoMutt  2025-12-11-596-g7cc1dd
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
functions.c File Reference

Browser functions. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "functions.h"
#include "lib.h"
#include "attach/lib.h"
#include "editor/lib.h"
#include "history/lib.h"
#include "imap/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "nntp/lib.h"
#include "pattern/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "globals.h"
#include "mutt_mailbox.h"
#include "muttlib.h"
#include "mx.h"
#include "nntp/adata.h"
#include "nntp/mdata.h"
#include "private_data.h"
#include "sort.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

static int op_subscribe_pattern (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Subscribe to newsgroups matching a pattern - Implements browser_function_t -.
 
void browser_init_keys (struct SubMenu *sm_generic)
 Initialise the Browser Keybindings - Implements ::init_keys_api.
 
void destroy_state (struct BrowserState *state)
 Free the BrowserState.
 
static int op_browser_new_file (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Select a new file in this directory - Implements browser_function_t -.
 
static int op_browser_subscribe (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Subscribe to current mbox (IMAP/NNTP only) - Implements browser_function_t -.
 
static int op_browser_tell (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Display the currently selected file's name - Implements browser_function_t -.
 
static int op_browser_toggle_lsub (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Toggle view all/subscribed mailboxes (IMAP only) - Implements browser_function_t -.
 
static int op_browser_view_file (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 View file - Implements browser_function_t -.
 
static int op_catchup (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Mark all articles in newsgroup as read - Implements browser_function_t -.
 
static int op_change_directory (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Change directories - Implements browser_function_t -.
 
static int op_create_mailbox (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Create a new mailbox (IMAP only) - Implements browser_function_t -.
 
static int op_delete_mailbox (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Delete the current mailbox (IMAP only) - Implements browser_function_t -.
 
static int op_enter_mask (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Enter a file mask - Implements browser_function_t -.
 
static int op_exit (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Exit this menu - Implements browser_function_t -.
 
static int op_generic_select_entry (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Select the current entry - Implements browser_function_t -.
 
static int op_load_active (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Load list of all newsgroups from NNTP server - Implements browser_function_t -.
 
static int op_mailbox_list (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 List mailboxes with new mail - Implements browser_function_t -.
 
static int op_rename_mailbox (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Rename the current mailbox (IMAP only) - Implements browser_function_t -.
 
static int op_sort (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Sort messages - Implements browser_function_t -.
 
static int op_toggle_mailboxes (struct BrowserPrivateData *priv, const struct KeyEvent *event)
 Toggle whether to browse mailboxes or all files - Implements browser_function_t -.
 
int browser_function_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform a Browser function.
 

Variables

struct MenuDefinitionMdBrowser = NULL
 Browser Menu Definition.
 
static const struct MenuFuncOp OpBrowser []
 Functions for the file Browser Menu.
 
static const struct MenuOpSeq BrowserDefaultBindings []
 Key bindings for the file Browser Menu.
 
static const struct BrowserFunction BrowserFunctions []
 All the NeoMutt functions that the Browser supports.
 

Detailed Description

Browser functions.

Authors
  • Richard Russon
  • Dennis Schön

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 functions.c.

Function Documentation

◆ browser_init_keys()

void browser_init_keys ( struct SubMenu * sm_generic)

Initialise the Browser Keybindings - Implements ::init_keys_api.

Definition at line 130 of file functions.c.

131{
132 struct MenuDefinition *md = NULL;
133 struct SubMenu *sm = NULL;
134
136 md = km_register_menu(MENU_BROWSER, "browser");
137 km_menu_add_submenu(md, sm);
138 km_menu_add_submenu(md, sm_generic);
140
141 MdBrowser = md;
142}
struct MenuDefinition * MdBrowser
Browser Menu Definition.
Definition functions.c:64
static const struct MenuOpSeq BrowserDefaultBindings[]
Key bindings for the file Browser Menu.
Definition functions.c:104
static const struct MenuFuncOp OpBrowser[]
Functions for the file Browser Menu.
Definition functions.c:70
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:91
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:107
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
Functions for a Dialog or Window.
Definition menu.h:80
Collection of related functions.
Definition menu.h:68
@ MENU_BROWSER
General file/mailbox browser.
Definition type.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy_state()

void destroy_state ( struct BrowserState * state)

Free the BrowserState.

Parameters
stateState to free

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

Definition at line 150 of file functions.c.

151{
152 struct FolderFile *ff = NULL;
153 ARRAY_FOREACH(ff, &state->entry)
154 {
155 FREE(&ff->name);
156 FREE(&ff->desc);
157 }
158 ARRAY_FREE(&state->entry);
159 FREE(&state->folder);
160}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
char * folder
Folder name.
Definition lib.h:148
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition lib.h:146
Browser entry representing a folder/dir.
Definition lib.h:79
char * name
Name of file/dir/mailbox.
Definition lib.h:87
char * desc
Description of mailbox.
Definition lib.h:88
+ Here is the caller graph for this function:

◆ browser_function_dispatcher()

int browser_function_dispatcher ( struct MuttWindow * win,
const struct KeyEvent * event )

Perform a Browser function.

Parameters
winWindow for the Browser
eventEvent to process
Return values
numFunctionRetval, e.g. FR_SUCCESS

Definition at line 1161 of file functions.c.

1162{
1163 // The Dispatcher may be called on any Window in the Dialog
1164 struct MuttWindow *dlg = dialog_find(win);
1165 if (!dlg || !dlg->wdata)
1166 return FR_ERROR;
1167
1168 struct Menu *menu = dlg->wdata;
1169 struct BrowserPrivateData *priv = menu->mdata;
1170 if (!priv)
1171 return FR_ERROR;
1172
1173 int rc = FR_UNKNOWN;
1174 for (size_t i = 0; BrowserFunctions[i].op != OP_NULL; i++)
1175 {
1176 const struct BrowserFunction *fn = &BrowserFunctions[i];
1177 if (fn->op == event->op)
1178 {
1179 rc = fn->function(priv, event);
1180 break;
1181 }
1182 }
1183
1184 return rc;
1185}
static const struct BrowserFunction BrowserFunctions[]
All the NeoMutt functions that the Browser supports.
Definition functions.c:1123
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition dialog.c:89
@ FR_UNKNOWN
Unknown function.
Definition dispatcher.h:34
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
A NeoMutt function.
Definition functions.h:51
int op
Op code, e.g. OP_MAIN_LIMIT.
Definition functions.h:52
browser_function_t function
Function to call.
Definition functions.h:53
Private state data for the Browser.
struct Menu * menu
Menu.
int op
Function opcode, e.g. OP_HELP.
Definition get.h:52
Definition lib.h:80
void * mdata
Private data.
Definition lib.h:149
void * wdata
Private data.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MdBrowser

struct MenuDefinition* MdBrowser = NULL

Browser Menu Definition.

Definition at line 64 of file functions.c.

◆ OpBrowser

const struct MenuFuncOp OpBrowser[]
static
Initial value:
= {
{ "catchup", OP_CATCHUP },
{ "change-dir", OP_CHANGE_DIRECTORY },
{ "check-new", OP_CHECK_NEW },
{ "create-mailbox", OP_CREATE_MAILBOX },
{ "delete-mailbox", OP_DELETE_MAILBOX },
{ "descend-directory", OP_DESCEND_DIRECTORY },
{ "display-filename", OP_BROWSER_TELL },
{ "enter-mask", OP_ENTER_MASK },
{ "exit", OP_EXIT },
{ "goto-folder", OP_BROWSER_GOTO_FOLDER },
{ "goto-parent", OP_GOTO_PARENT },
{ "mailbox-list", OP_MAILBOX_LIST },
{ "reload-active", OP_LOAD_ACTIVE },
{ "rename-mailbox", OP_RENAME_MAILBOX },
{ "select-new", OP_BROWSER_NEW_FILE },
{ "sort", OP_SORT },
{ "sort-reverse", OP_SORT_REVERSE },
{ "subscribe", OP_BROWSER_SUBSCRIBE },
{ "subscribe-pattern", OP_SUBSCRIBE_PATTERN },
{ "toggle-mailboxes", OP_TOGGLE_MAILBOXES },
{ "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB },
{ "uncatchup", OP_UNCATCHUP },
{ "unsubscribe", OP_BROWSER_UNSUBSCRIBE },
{ "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN },
{ "view-file", OP_BROWSER_VIEW_FILE },
{ "buffy-list", OP_MAILBOX_LIST, MFF_DEPRECATED },
{ NULL, 0 },
}
#define MFF_DEPRECATED
Redraw the pager.
Definition get.h:44

Functions for the file Browser Menu.

Definition at line 70 of file functions.c.

70 { /* map: browser */
71 { "catchup", OP_CATCHUP },
72 { "change-dir", OP_CHANGE_DIRECTORY },
73 { "check-new", OP_CHECK_NEW },
74 { "create-mailbox", OP_CREATE_MAILBOX },
75 { "delete-mailbox", OP_DELETE_MAILBOX },
76 { "descend-directory", OP_DESCEND_DIRECTORY },
77 { "display-filename", OP_BROWSER_TELL },
78 { "enter-mask", OP_ENTER_MASK },
79 { "exit", OP_EXIT },
80 { "goto-folder", OP_BROWSER_GOTO_FOLDER },
81 { "goto-parent", OP_GOTO_PARENT },
82 { "mailbox-list", OP_MAILBOX_LIST },
83 { "reload-active", OP_LOAD_ACTIVE },
84 { "rename-mailbox", OP_RENAME_MAILBOX },
85 { "select-new", OP_BROWSER_NEW_FILE },
86 { "sort", OP_SORT },
87 { "sort-reverse", OP_SORT_REVERSE },
88 { "subscribe", OP_BROWSER_SUBSCRIBE },
89 { "subscribe-pattern", OP_SUBSCRIBE_PATTERN },
90 { "toggle-mailboxes", OP_TOGGLE_MAILBOXES },
91 { "toggle-subscribed", OP_BROWSER_TOGGLE_LSUB },
92 { "uncatchup", OP_UNCATCHUP },
93 { "unsubscribe", OP_BROWSER_UNSUBSCRIBE },
94 { "unsubscribe-pattern", OP_UNSUBSCRIBE_PATTERN },
95 { "view-file", OP_BROWSER_VIEW_FILE },
96 // Deprecated
97 { "buffy-list", OP_MAILBOX_LIST, MFF_DEPRECATED },
98 { NULL, 0 },
99};

◆ BrowserDefaultBindings

const struct MenuOpSeq BrowserDefaultBindings[]
static
Initial value:
= {
{ OP_BROWSER_GOTO_FOLDER, "=" },
{ OP_BROWSER_NEW_FILE, "N" },
{ OP_BROWSER_SUBSCRIBE, "s" },
{ OP_BROWSER_TELL, "@" },
{ OP_BROWSER_TOGGLE_LSUB, "T" },
{ OP_BROWSER_UNSUBSCRIBE, "u" },
{ OP_BROWSER_VIEW_FILE, " " },
{ OP_CHANGE_DIRECTORY, "c" },
{ OP_CREATE_MAILBOX, "C" },
{ OP_DELETE_MAILBOX, "d" },
{ OP_ENTER_MASK, "m" },
{ OP_EXIT, "q" },
{ OP_GOTO_PARENT, "p" },
{ OP_MAILBOX_LIST, "." },
{ OP_RENAME_MAILBOX, "r" },
{ OP_SORT, "o" },
{ OP_SORT_REVERSE, "O" },
{ OP_TOGGLE_MAILBOXES, "\t" },
{ 0, NULL },
}

Key bindings for the file Browser Menu.

Definition at line 104 of file functions.c.

104 { /* map: browser */
105 { OP_BROWSER_GOTO_FOLDER, "=" },
106 { OP_BROWSER_NEW_FILE, "N" },
107 { OP_BROWSER_SUBSCRIBE, "s" },
108 { OP_BROWSER_TELL, "@" },
109 { OP_BROWSER_TOGGLE_LSUB, "T" },
110 { OP_BROWSER_UNSUBSCRIBE, "u" },
111 { OP_BROWSER_VIEW_FILE, " " }, // <Space>
112 { OP_CHANGE_DIRECTORY, "c" },
113 { OP_CREATE_MAILBOX, "C" },
114 { OP_DELETE_MAILBOX, "d" },
115 { OP_ENTER_MASK, "m" },
116 { OP_EXIT, "q" },
117 { OP_GOTO_PARENT, "p" },
118 { OP_MAILBOX_LIST, "." },
119 { OP_RENAME_MAILBOX, "r" },
120 { OP_SORT, "o" },
121 { OP_SORT_REVERSE, "O" },
122 { OP_TOGGLE_MAILBOXES, "\t" }, // <Tab>
123 { 0, NULL },
124};

◆ BrowserFunctions

const struct BrowserFunction BrowserFunctions[]
static

All the NeoMutt functions that the Browser supports.

Definition at line 1123 of file functions.c.

1123 {
1124 // clang-format off
1125 { OP_BROWSER_GOTO_FOLDER, op_toggle_mailboxes },
1126 { OP_BROWSER_NEW_FILE, op_browser_new_file },
1127 { OP_BROWSER_SUBSCRIBE, op_browser_subscribe },
1128 { OP_BROWSER_TELL, op_browser_tell },
1129 { OP_BROWSER_TOGGLE_LSUB, op_browser_toggle_lsub },
1130 { OP_BROWSER_UNSUBSCRIBE, op_browser_subscribe },
1131 { OP_BROWSER_VIEW_FILE, op_browser_view_file },
1132 { OP_CATCHUP, op_catchup },
1133 { OP_CHANGE_DIRECTORY, op_change_directory },
1134 { OP_CHECK_NEW, op_toggle_mailboxes },
1135 { OP_CREATE_MAILBOX, op_create_mailbox },
1136 { OP_DELETE_MAILBOX, op_delete_mailbox },
1137 { OP_DESCEND_DIRECTORY, op_generic_select_entry },
1138 { OP_ENTER_MASK, op_enter_mask },
1139 { OP_EXIT, op_exit },
1140 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
1141 { OP_GOTO_PARENT, op_change_directory },
1142 { OP_LOAD_ACTIVE, op_load_active },
1143 { OP_MAILBOX_LIST, op_mailbox_list },
1144 { OP_RENAME_MAILBOX, op_rename_mailbox },
1145 { OP_SORT, op_sort },
1146 { OP_SORT_REVERSE, op_sort },
1147 { OP_SUBSCRIBE_PATTERN, op_subscribe_pattern },
1148 { OP_TOGGLE_MAILBOXES, op_toggle_mailboxes },
1149 { OP_UNCATCHUP, op_catchup },
1150 { OP_UNSUBSCRIBE_PATTERN, op_subscribe_pattern },
1151 { 0, NULL },
1152 // clang-format on
1153};
static int op_generic_select_entry(struct AliasMenuData *mdata, const struct KeyEvent *event)
select the current entry - Implements alias_function_t -
Definition functions.c:248
static int op_sort(struct AliasMenuData *mdata, const struct KeyEvent *event)
sort aliases - Implements alias_function_t -
Definition functions.c:423
static int op_exit(struct AliasMenuData *mdata, const struct KeyEvent *event)
exit this menu - Implements alias_function_t -
Definition functions.c:234
static int op_browser_new_file(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Select a new file in this directory - Implements browser_function_t -.
Definition functions.c:167
static int op_rename_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Rename the current mailbox (IMAP only) - Implements browser_function_t -.
Definition functions.c:866
static int op_create_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Create a new mailbox (IMAP only) - Implements browser_function_t -.
Definition functions.c:470
static int op_browser_view_file(struct BrowserPrivateData *priv, const struct KeyEvent *event)
View file - Implements browser_function_t -.
Definition functions.c:273
static int op_mailbox_list(struct BrowserPrivateData *priv, const struct KeyEvent *event)
List mailboxes with new mail - Implements browser_function_t -.
Definition functions.c:857
static int op_catchup(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Mark all articles in newsgroup as read - Implements browser_function_t -.
Definition functions.c:318
static int op_browser_subscribe(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Subscribe to current mbox (IMAP/NNTP only) - Implements browser_function_t -.
Definition functions.c:194
static int op_delete_mailbox(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Delete the current mailbox (IMAP only) - Implements browser_function_t -.
Definition functions.c:497
static int op_load_active(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Load list of all newsgroups from NNTP server - Implements browser_function_t -.
Definition functions.c:820
static int op_enter_mask(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Enter a file mask - Implements browser_function_t -.
Definition functions.c:548
static int op_subscribe_pattern(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Subscribe to newsgroups matching a pattern - Implements browser_function_t -.
Definition functions.c:966
static int op_browser_tell(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Display the currently selected file's name - Implements browser_function_t -.
Definition functions.c:249
static int op_browser_toggle_lsub(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Toggle view all/subscribed mailboxes (IMAP only) - Implements browser_function_t -.
Definition functions.c:262
static int op_toggle_mailboxes(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Toggle whether to browse mailboxes or all files - Implements browser_function_t -.
Definition functions.c:1052
static int op_change_directory(struct BrowserPrivateData *priv, const struct KeyEvent *event)
Change directories - Implements browser_function_t -.
Definition functions.c:361