NeoMutt  2025-12-11-435-g4ac674
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 "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 261 of file dlg_compose.c.

262{
263 const int max_depth = 20;
264
265 for (; b; b = b->next)
266 {
267 struct AttachPtr *ap = mutt_aptr_new();
268 mutt_actx_add_attach(actx, ap);
269 ap->body = b;
270 b->aptr = ap;
272 ap->level = level;
273 if ((level < max_depth) && (b->type == TYPE_MULTIPART) && b->parts &&
275 {
276 gen_attach_list(actx, b->parts, b->type, level + 1);
277 }
278 }
279}
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:98
#define WithCrypto
Definition lib.h:124
An email to which things will be attached.
Definition attach.h:35
struct Body * body
Attachment.
Definition attach.h:36
int level
Nesting depth of attachment.
Definition attach.h:40
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition attach.h:38
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 287 of file dlg_compose.c.

288{
289 if (init)
290 {
291 gen_attach_list(actx, actx->email->body, -1, 0);
292 mutt_attach_init(actx);
293
294 struct ComposeAttachData *adata = menu->mdata;
295 adata->actx = actx;
296 }
297
299
300 menu->max = actx->vcount;
301 if (menu->max)
302 {
303 int index = menu_get_index(menu);
304 if (index >= menu->max)
306 }
307 else
308 {
310 }
311
313}
#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:188
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:164
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:178
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:72
struct Email * email
Used by recvattach for updating.
Definition attach.h:64
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:149
int max
Number of entries in the menu.
Definition lib.h:82
+ 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 322 of file dlg_compose.c.

324{
326 shared->sub = sub;
327 shared->email = e;
328
332 dlg->wdata = shared;
334 dlg->recalc = compose_recalc;
335
336 struct MuttWindow *win_env = env_window_new(e, fcc, sub);
337 struct MuttWindow *win_attach = attach_new(dlg, shared);
338 struct MuttWindow *win_cbar = cbar_new(shared);
339 struct MuttWindow *win_abar = sbar_new();
340 sbar_set_title(win_abar, _("-- Attachments"));
341 struct MuttWindow *win_preview_bar = sbar_new();
342 sbar_set_title(win_preview_bar, _("-- Preview"));
343 struct MuttWindow *win_preview = preview_window_new(e, win_preview_bar);
344
345 const bool c_preview_above_attachments = cs_subset_bool(shared->sub, "compose_preview_above_attachments");
346 const bool c_status_on_top = cs_subset_bool(sub, "status_on_top");
347 if (c_status_on_top)
348 {
349 mutt_window_add_child(dlg, win_cbar);
350 mutt_window_add_child(dlg, win_env);
351 if (c_preview_above_attachments)
352 {
353 mutt_window_add_child(dlg, win_preview_bar);
354 mutt_window_add_child(dlg, win_preview);
355 mutt_window_add_child(dlg, win_abar);
356 mutt_window_add_child(dlg, win_attach);
357 }
358 else
359 {
360 mutt_window_add_child(dlg, win_abar);
361 mutt_window_add_child(dlg, win_attach);
362 mutt_window_add_child(dlg, win_preview_bar);
363 mutt_window_add_child(dlg, win_preview);
364 }
365 }
366 else
367 {
368 mutt_window_add_child(dlg, win_env);
369 if (c_preview_above_attachments)
370 {
371 mutt_window_add_child(dlg, win_preview_bar);
372 mutt_window_add_child(dlg, win_preview);
373 mutt_window_add_child(dlg, win_abar);
374 mutt_window_add_child(dlg, win_attach);
375 }
376 else
377 {
378 mutt_window_add_child(dlg, win_abar);
379 mutt_window_add_child(dlg, win_attach);
380 mutt_window_add_child(dlg, win_preview_bar);
381 mutt_window_add_child(dlg, win_preview);
382 }
383 mutt_window_add_child(dlg, win_cbar);
384 }
385
386 shared->win_preview_bar = win_preview_bar;
387 shared->win_preview = win_preview;
388 shared->win_attach_bar = win_abar;
389
390 dlg->help_data = ComposeHelp;
391 dlg->help_md = MdCompose;
392
393 return dlg;
394}
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:270
struct MenuDefinition * MdCompose
Compose Menu Definition.
Definition functions.c:74
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:93
struct MuttWindow * env_window_new(struct Email *e, struct Buffer *fcc, struct ConfigSubset *sub)
Create the Envelope Window.
Definition window.c:946
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
#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
struct MuttWindow * preview_window_new(struct Email *e, struct MuttWindow *bar)
Create the preview window.
Definition preview.c:346
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
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)
+ 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_ATTACHMENT_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACHMENT_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}
#define N_(a)
Definition message.h:32

Help Bar for the Compose dialog.

Definition at line 93 of file dlg_compose.c.

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

◆ 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_ATTACHMENT_ATTACH_FILE },
{ N_("Descrip"), OP_ATTACHMENT_EDIT_DESCRIPTION },
{ N_("Help"), OP_HELP },
{ NULL, 0 },
}

Help Bar for the News Compose dialog.

Definition at line 111 of file dlg_compose.c.

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