NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dlg_compose.c File Reference

Compose Email Dialog. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "lib.h"
#include "attach/lib.h"
#include "envelope/lib.h"
#include "hooks/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "attach_data.h"
#include "cbar.h"
#include "functions.h"
#include "globals.h"
#include "module_data.h"
#include "mutt_logging.h"
#include "shared_data.h"
+ Include dependency graph for dlg_compose.c:

Go to the source code of this file.

Functions

static int compose_recalc (struct MuttWindow *dlg)
 Recalculate the Window data - Implements MuttWindow::recalc() -.
 
static int compose_config_observer (struct NotifyCallback *nc)
 Notification that a Config Variable has changed - Implements observer_t -.
 
static int compose_email_observer (struct NotifyCallback *nc)
 Notification that an Email has changed - Implements observer_t -.
 
static int compose_window_observer (struct NotifyCallback *nc)
 Notification that a Window has changed - Implements observer_t -.
 
static void gen_attach_list (struct AttachCtx *actx, struct Body *b, int parent_type, int level)
 Generate the attachment list for the compose screen.
 
void update_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Redraw the compose window.
 
static struct MuttWindowcompose_dlg_init (struct ConfigSubset *sub, struct Email *e, struct Buffer *fcc)
 Allocate the Windows for Compose.
 
int dlg_compose (struct Email *e, struct Buffer *fcc, uint8_t flags, struct ConfigSubset *sub)
 Allow the user to edit the message envelope -.
 

Variables

static const struct Mapping ComposeHelp []
 Help Bar for the Compose dialog.
 
static const struct Mapping ComposeNewsHelp []
 Help Bar for the News Compose dialog.
 

Detailed Description

Compose Email Dialog.

Authors
  • Richard Russon
  • Pietro Cerutti
  • 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 dlg_compose.c.

Function Documentation

◆ gen_attach_list()

static void gen_attach_list ( struct AttachCtx * actx,
struct Body * b,
int parent_type,
int level )
static

Generate the attachment list for the compose screen.

Parameters
actxAttachment context
bAttachment
parent_typeAttachment type, e.g TYPE_MULTIPART
levelNesting depth of attachment
Note
Recursion is limited to 20 levels to prevent stack overflow from deeply nested MIME structures.

Definition at line 262 of file dlg_compose.c.

263{
264 const int max_depth = 20;
265
266 for (; b; b = b->next)
267 {
268 struct AttachPtr *ap = mutt_aptr_new();
269 mutt_actx_add_attach(actx, ap);
270 ap->body = b;
271 b->aptr = ap;
273 ap->level = level;
274 if ((level < max_depth) && (b->type == TYPE_MULTIPART) && b->parts &&
276 {
277 gen_attach_list(actx, b->parts, b->type, level + 1);
278 }
279 }
280}
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
Definition attach.c:65
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
Definition attach.c:40
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition crypt.c:443
static void gen_attach_list(struct AttachCtx *actx, struct Body *b, int parent_type, int level)
Generate the attachment list for the compose screen.
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition mime.h:37
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:106
#define WithCrypto
Definition lib.h:132
An email to which things will be attached.
Definition attach.h:36
struct Body * body
Attachment.
Definition attach.h:37
int level
Nesting depth of attachment.
Definition attach.h:41
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition attach.h:39
struct Body * parts
parts of a multipart or message/rfc822
Definition body.h:73
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition body.h:75
struct Body * next
next attachment in the list
Definition body.h:72
unsigned int type
content-type primary type, ContentType
Definition body.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_menu()

void update_menu ( struct AttachCtx * actx,
struct Menu * menu,
bool init )

Redraw the compose window.

Parameters
actxAttachment context
menuCurrent menu
initIf true, initialise the attachment list

Definition at line 288 of file dlg_compose.c.

289{
290 if (init)
291 {
292 gen_attach_list(actx, actx->email->body, -1, 0);
293 mutt_attach_init(actx);
294
295 struct ComposeAttachData *adata = menu->mdata;
296 adata->actx = actx;
297 }
298
300
301 menu->max = actx->vcount;
302 if (menu->max)
303 {
304 int index = menu_get_index(menu);
305 if (index >= menu->max)
307 }
308 else
309 {
311 }
312
314}
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:179
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:155
@ MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:61
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:169
void mutt_attach_init(struct AttachCtx *actx)
Create a new Attachment context.
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition recvattach.c:116
short vcount
The number of virtual attachments.
Definition attach.h:74
struct Email * email
Used by recvattach for updating.
Definition attach.h:66
Data to fill the Compose Attach Window.
Definition attach_data.h:33
struct Menu * menu
Menu displaying the attachments.
Definition attach_data.h:35
struct AttachCtx * actx
Set of attachments.
Definition attach_data.h:34
struct Body * body
List of MIME parts.
Definition email.h:69
void * mdata
Private data.
Definition lib.h:155
int max
Number of entries in the menu.
Definition lib.h:88
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compose_dlg_init()

static struct MuttWindow * compose_dlg_init ( struct ConfigSubset * sub,
struct Email * e,
struct Buffer * fcc )
static

Allocate the Windows for Compose.

Parameters
subConfigSubset
eEmail
fccBuffer to save FCC
Return values
ptrDialog containing nested Windows

Definition at line 323 of file dlg_compose.c.

325{
327 ASSERT(mod_data);
328
330 shared->sub = sub;
331 shared->email = e;
332
336 dlg->wdata = shared;
338 dlg->recalc = compose_recalc;
339
340 struct MuttWindow *win_env = env_window_new(e, fcc, sub);
341 struct MuttWindow *win_attach = attach_new(dlg, shared);
342 struct MuttWindow *win_cbar = cbar_new(shared);
343 struct MuttWindow *win_abar = sbar_new();
344 sbar_set_title(win_abar, _("-- Attachments"));
345 struct MuttWindow *win_preview_bar = sbar_new();
346 sbar_set_title(win_preview_bar, _("-- Preview"));
347 struct MuttWindow *win_preview = preview_window_new(e, win_preview_bar);
348
349 const bool c_preview_above_attachments = cs_subset_bool(shared->sub, "compose_preview_above_attachments");
350 const bool c_status_on_top = cs_subset_bool(sub, "status_on_top");
351 if (c_status_on_top)
352 {
353 mutt_window_add_child(dlg, win_cbar);
354 mutt_window_add_child(dlg, win_env);
355 if (c_preview_above_attachments)
356 {
357 mutt_window_add_child(dlg, win_preview_bar);
358 mutt_window_add_child(dlg, win_preview);
359 mutt_window_add_child(dlg, win_abar);
360 mutt_window_add_child(dlg, win_attach);
361 }
362 else
363 {
364 mutt_window_add_child(dlg, win_abar);
365 mutt_window_add_child(dlg, win_attach);
366 mutt_window_add_child(dlg, win_preview_bar);
367 mutt_window_add_child(dlg, win_preview);
368 }
369 }
370 else
371 {
372 mutt_window_add_child(dlg, win_env);
373 if (c_preview_above_attachments)
374 {
375 mutt_window_add_child(dlg, win_preview_bar);
376 mutt_window_add_child(dlg, win_preview);
377 mutt_window_add_child(dlg, win_abar);
378 mutt_window_add_child(dlg, win_attach);
379 }
380 else
381 {
382 mutt_window_add_child(dlg, win_abar);
383 mutt_window_add_child(dlg, win_attach);
384 mutt_window_add_child(dlg, win_preview_bar);
385 mutt_window_add_child(dlg, win_preview);
386 }
387 mutt_window_add_child(dlg, win_cbar);
388 }
389
390 shared->win_preview_bar = win_preview_bar;
391 shared->win_preview = win_preview;
392 shared->win_attach_bar = win_abar;
393
394 dlg->help_data = ComposeHelp;
395 dlg->help_md = mod_data->md_compose;
396
397 return dlg;
398}
struct MuttWindow * cbar_new(struct ComposeSharedData *shared)
Create the Compose Bar (status)
Definition cbar.c:226
struct MuttWindow * attach_new(struct MuttWindow *parent, struct ComposeSharedData *shared)
Create the Attachments Menu.
Definition attach.c:269
struct ComposeSharedData * compose_shared_data_new(void)
Free the compose shared data.
Definition shared_data.c:48
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
static const struct Mapping ComposeHelp[]
Help Bar for the Compose dialog.
Definition dlg_compose.c:94
struct MuttWindow * env_window_new(struct Email *e, struct Buffer *fcc, struct ConfigSubset *sub)
Create the Envelope Window.
Definition window.c:955
static int compose_recalc(struct MuttWindow *dlg)
Recalculate the Window data - Implements MuttWindow::recalc() -.
void compose_shared_data_free(struct MuttWindow *win, void **ptr)
Free the compose shared data - Implements MuttWindow::wdata_free() -.
Definition shared_data.c:36
@ MODULE_ID_COMPOSE
ModuleCompose, Compose an Email
Definition module_api.h:57
#define _(a)
Definition message.h:28
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.
@ WT_DLG_COMPOSE
Compose Dialog, dlg_compose()
Definition mutt_window.h:82
@ MUTT_WIN_ORIENT_VERTICAL
Window uses all available vertical space.
Definition mutt_window.h:38
#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
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
struct MuttWindow * preview_window_new(struct Email *e, struct MuttWindow *bar)
Create the preview window.
Definition preview.c:359
struct MuttWindow * sbar_new(void)
Add the Simple Bar (status)
Definition sbar.c:203
void sbar_set_title(struct MuttWindow *win, const char *title)
Set the title for the Simple Bar.
Definition sbar.c:227
#define ASSERT(COND)
Definition signal2.h:59
Compose private Module data.
Definition module_data.h:30
struct MenuDefinition * md_compose
Compose Menu Definition.
Definition module_data.h:32
Shared Compose Data.
Definition shared_data.h:35
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:36
struct MuttWindow * win_preview
Message preview window.
Definition shared_data.h:41
struct MuttWindow * win_preview_bar
Status bar divider above preview.
Definition shared_data.h:42
struct Email * email
Email being composed.
Definition shared_data.h:38
struct MuttWindow * win_attach_bar
Status bar divider above attachments.
Definition shared_data.h:40
const struct Mapping * help_data
Data for the Help Bar.
const struct MenuDefinition * help_md
Menu Definition for key bindings.
void * wdata
Private data.
int(* recalc)(struct MuttWindow *win)
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ ComposeHelp

const struct Mapping ComposeHelp[]
static
Initial value:
= {
{ N_("Send"), OP_COMPOSE_SEND_MESSAGE },
{ N_("Abort"), OP_EXIT },
{ N_("To"), OP_ENVELOPE_EDIT_TO },
{ N_("CC"), OP_ENVELOPE_EDIT_CC },
{ N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
{ N_("Attach file"), OP_ATTACH_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACH_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}
#define N_(a)
Definition message.h:32

Help Bar for the Compose dialog.

Definition at line 94 of file dlg_compose.c.

94 {
95 // clang-format off
96 { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
97 { N_("Abort"), OP_EXIT },
98 /* L10N: compose menu help line entry */
99 { N_("To"), OP_ENVELOPE_EDIT_TO },
100 /* L10N: compose menu help line entry */
101 { N_("CC"), OP_ENVELOPE_EDIT_CC },
102 /* L10N: compose menu help line entry */
103 { N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
104 { N_("Attach file"), OP_ATTACH_ATTACH_FILE },
105 { N_("Descrip"), OP_ATTACH_EDIT_DESCRIPTION },
106 { N_("Help"), OP_HELP },
107 { NULL, 0 },
108 // clang-format on
109};

◆ ComposeNewsHelp

const struct Mapping ComposeNewsHelp[]
static
Initial value:
= {
{ N_("Send"), OP_COMPOSE_SEND_MESSAGE },
{ N_("Abort"), OP_EXIT },
{ N_("Newsgroups"), OP_ENVELOPE_EDIT_NEWSGROUPS },
{ N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
{ N_("Attach file"), OP_ATTACH_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACH_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}

Help Bar for the News Compose dialog.

Definition at line 112 of file dlg_compose.c.

112 {
113 // clang-format off
114 { N_("Send"), OP_COMPOSE_SEND_MESSAGE },
115 { N_("Abort"), OP_EXIT },
116 { N_("Newsgroups"), OP_ENVELOPE_EDIT_NEWSGROUPS },
117 { N_("Subj"), OP_ENVELOPE_EDIT_SUBJECT },
118 { N_("Attach file"), OP_ATTACH_ATTACH_FILE },
119 { N_("Descrip"), OP_ATTACH_EDIT_DESCRIPTION },
120 { N_("Help"), OP_HELP },
121 { NULL, 0 },
122 // clang-format on
123};