NeoMutt  2024-11-14-138-ge5ca67
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 "mutt.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 "functions.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, int op)
 Subscribe to newsgroups matching a pattern - Implements browser_function_t -.
 
void destroy_state (struct BrowserState *state)
 Free the BrowserState.
 
static int op_browser_new_file (struct BrowserPrivateData *priv, int op)
 Select a new file in this directory - Implements browser_function_t -.
 
static int op_browser_subscribe (struct BrowserPrivateData *priv, int op)
 Subscribe to current mbox (IMAP/NNTP only) - Implements browser_function_t -.
 
static int op_browser_tell (struct BrowserPrivateData *priv, int op)
 Display the currently selected file's name - Implements browser_function_t -.
 
static int op_browser_toggle_lsub (struct BrowserPrivateData *priv, int op)
 Toggle view all/subscribed mailboxes (IMAP only) - Implements browser_function_t -.
 
static int op_browser_view_file (struct BrowserPrivateData *priv, int op)
 View file - Implements browser_function_t -.
 
static int op_catchup (struct BrowserPrivateData *priv, int op)
 Mark all articles in newsgroup as read - Implements browser_function_t -.
 
static int op_change_directory (struct BrowserPrivateData *priv, int op)
 Change directories - Implements browser_function_t -.
 
static int op_create_mailbox (struct BrowserPrivateData *priv, int op)
 Create a new mailbox (IMAP only) - Implements browser_function_t -.
 
static int op_delete_mailbox (struct BrowserPrivateData *priv, int op)
 Delete the current mailbox (IMAP only) - Implements browser_function_t -.
 
static int op_enter_mask (struct BrowserPrivateData *priv, int op)
 Enter a file mask - Implements browser_function_t -.
 
static int op_exit (struct BrowserPrivateData *priv, int op)
 Exit this menu - Implements browser_function_t -.
 
static int op_generic_select_entry (struct BrowserPrivateData *priv, int op)
 Select the current entry - Implements browser_function_t -.
 
static int op_load_active (struct BrowserPrivateData *priv, int op)
 Load list of all newsgroups from NNTP server - Implements browser_function_t -.
 
static int op_mailbox_list (struct BrowserPrivateData *priv, int op)
 List mailboxes with new mail - Implements browser_function_t -.
 
static int op_rename_mailbox (struct BrowserPrivateData *priv, int op)
 Rename the current mailbox (IMAP only) - Implements browser_function_t -.
 
static int op_sort (struct BrowserPrivateData *priv, int op)
 Sort messages - Implements browser_function_t -.
 
static int op_toggle_mailboxes (struct BrowserPrivateData *priv, int op)
 Toggle whether to browse mailboxes or all files - Implements browser_function_t -.
 
int browser_function_dispatcher (struct MuttWindow *win, int op)
 Perform a Browser function.
 

Variables

const struct MenuFuncOp OpBrowser []
 Functions for the file Browser Menu.
 
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

◆ 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 135 of file functions.c.

136{
137 struct FolderFile *ff = NULL;
138 ARRAY_FOREACH(ff, &state->entry)
139 {
140 FREE(&ff->name);
141 FREE(&ff->desc);
142 }
143 ARRAY_FREE(&state->entry);
144 FREE(&state->folder);
145}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
#define FREE(x)
Definition: memory.h:55
char * folder
Folder name.
Definition: lib.h:147
struct BrowserEntryArray entry
Array of files / dirs / mailboxes.
Definition: lib.h:145
Browser entry representing a folder/dir.
Definition: lib.h:78
char * name
Name of file/dir/mailbox.
Definition: lib.h:86
char * desc
Description of mailbox.
Definition: lib.h:87
+ Here is the caller graph for this function:

◆ browser_function_dispatcher()

int browser_function_dispatcher ( struct MuttWindow win,
int  op 
)

Perform a Browser function.

Parameters
winWindow for the Browser
opOperation to perform, e.g. OP_GOTO_PARENT
Return values
numFunctionRetval, e.g. FR_SUCCESS

Definition at line 1126 of file functions.c.

1127{
1128 // The Dispatcher may be called on any Window in the Dialog
1129 struct MuttWindow *dlg = dialog_find(win);
1130 if (!dlg || !dlg->wdata)
1131 return FR_ERROR;
1132
1133 struct Menu *menu = dlg->wdata;
1134 struct BrowserPrivateData *priv = menu->mdata;
1135 if (!priv)
1136 return FR_ERROR;
1137
1138 int rc = FR_UNKNOWN;
1139 for (size_t i = 0; BrowserFunctions[i].op != OP_NULL; i++)
1140 {
1141 const struct BrowserFunction *fn = &BrowserFunctions[i];
1142 if (fn->op == op)
1143 {
1144 rc = fn->function(priv, op);
1145 break;
1146 }
1147 }
1148
1149 return rc;
1150}
static const struct BrowserFunction BrowserFunctions[]
All the NeoMutt functions that the Browser supports.
Definition: functions.c:1088
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:33
@ FR_ERROR
Valid function - error occurred.
Definition: dispatcher.h:38
A NeoMutt function.
Definition: functions.h:44
int op
Op code, e.g. OP_MAIN_LIMIT.
Definition: functions.h:45
browser_function_t function
Function to call.
Definition: functions.h:46
Private state data for the Browser.
Definition: private_data.h:34
struct Menu * menu
Menu.
Definition: private_data.h:43
Definition: lib.h:79
void * mdata
Private data.
Definition: lib.h:147
void * wdata
Private data.
Definition: mutt_window.h:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ OpBrowser

const struct MenuFuncOp OpBrowser[]
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 },
{ NULL, 0 },
}

Functions for the file Browser Menu.

Definition at line 72 of file functions.c.

◆ BrowserDefaultBindings

const struct MenuOpSeq BrowserDefaultBindings[]
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 106 of file functions.c.

◆ BrowserFunctions

const struct BrowserFunction BrowserFunctions[]
static

All the NeoMutt functions that the Browser supports.

Definition at line 1088 of file functions.c.