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

Compose Private Data. More...

#include <stdbool.h>
+ Include dependency graph for private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct MuttWindowattach_new (struct MuttWindow *parent, struct ComposeSharedData *shared)
 Create the Attachments Menu.
 
unsigned long cum_attachs_size (struct ConfigSubset *sub, struct ComposeAttachData *adata)
 Cumulative Attachments Size.
 
void update_menu (struct AttachCtx *actx, struct Menu *menu, bool init)
 Redraw the compose window.
 
void attachment_size_fixed (struct MuttWindow *win)
 Make the Attachment Window fixed-size.
 
void attachment_size_max (struct MuttWindow *win)
 Make the Attachment Window maximised.
 
struct MuttWindowpreview_window_new (struct Email *e, struct MuttWindow *bar)
 Create the preview window.
 
int preview_function_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform a preview function - Implements function_dispatcher_t -.
 

Detailed Description

Compose Private Data.

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

Function Documentation

◆ attach_new()

struct MuttWindow * attach_new ( struct MuttWindow * parent,
struct ComposeSharedData * shared )

Create the Attachments Menu.

Parameters
parentParent Window
sharedShared compose data

Definition at line 269 of file attach.c.

270{
272 ASSERT(mod_data);
273
274 struct MuttWindow *win_attach = menu_window_new(mod_data->md_compose, NeoMutt->sub);
275
276 struct ComposeAttachData *adata = attach_data_new(shared->email);
277
278 shared->adata = adata;
279
280 // NT_COLOR is handled by the Menu Window
284
285 struct Menu *menu = win_attach->wdata;
286 menu->page_len = win_attach->state.rows;
287 menu->win = win_attach;
288
290 menu->tag = compose_attach_tag;
291 menu->mdata = adata;
293 adata->menu = menu;
294
295 return win_attach;
296}
struct ComposeAttachData * attach_data_new(struct Email *e)
Create new Compose Attach Data.
Definition attach_data.c:54
static int compose_make_entry(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Format an Attachment for the Menu - Implements Menu::make_entry() -.
Definition attach.c:219
void attach_data_free(struct Menu *menu, void **ptr)
Free the Compose Attach Data - Implements Menu::mdata_free() -.
Definition attach_data.c:37
static int compose_attach_tag(struct Menu *menu, int sel, int act)
Tag an attachment - Implements Menu::tag() -.
Definition attach.c:203
static int attach_email_observer(struct NotifyCallback *nc)
Notification that the Email has changed - Implements observer_t -.
Definition attach.c:128
static int attach_config_observer(struct NotifyCallback *nc)
Notification that a Config Variable has changed - Implements observer_t -.
Definition dlg_attach.c:108
static int attach_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition dlg_attach.c:173
struct MuttWindow * menu_window_new(const struct MenuDefinition *md, struct ConfigSubset *sub)
Create a new Menu Window.
Definition window.c:140
@ MODULE_ID_COMPOSE
ModuleCompose, Compose an Email
Definition module_api.h:57
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
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
@ NT_WINDOW
MuttWindow has changed, NotifyWindow, EventWindow.
Definition notify_type.h:58
@ NT_CONFIG
Config has changed, NotifyConfig, EventConfig.
Definition notify_type.h:43
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition notify_type.h:44
#define ASSERT(COND)
Definition signal2.h:59
Data to fill the Compose Attach Window.
Definition attach_data.h:33
struct Menu * menu
Menu displaying the attachments.
Definition attach_data.h:35
Compose private Module data.
Definition module_data.h:30
struct MenuDefinition * md_compose
Compose Menu Definition.
Definition module_data.h:32
struct ComposeAttachData * adata
Attachments.
Definition shared_data.h:39
struct Email * email
Email being composed.
Definition shared_data.h:38
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
struct Notify * notify
Notifications: NotifyEmail, EventEmail.
Definition email.h:73
Definition lib.h:86
struct MuttWindow * win
Window holding the Menu.
Definition lib.h:94
void(* mdata_free)(struct Menu *menu, void **ptr)
Definition lib.h:169
int(* tag)(struct Menu *menu, int sel, int act)
Definition lib.h:139
int(* make_entry)(struct Menu *menu, int line, int max_cols, struct Buffer *buf)
Definition lib.h:114
void * mdata
Private data.
Definition lib.h:155
int page_len
Number of entries per screen.
Definition lib.h:91
struct WindowState state
Current state of the Window.
void * wdata
Private data.
struct Notify * notify
Notifications: NotifyWindow, EventWindow.
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
short rows
Number of rows, can be MUTT_WIN_SIZE_UNLIMITED.
Definition mutt_window.h:61
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cum_attachs_size()

unsigned long cum_attachs_size ( struct ConfigSubset * sub,
struct ComposeAttachData * adata )

Cumulative Attachments Size.

Parameters
subConfig Subset
adataAttachment data
Return values
numBytes in attachments

Returns the total number of bytes used by the attachments in the attachment list after content-transfer-encodings have been applied.

Definition at line 86 of file attach.c.

87{
88 if (!adata || !adata->actx)
89 return 0;
90
91 size_t s = 0;
92 struct Content *info = NULL;
93 struct Body *b = NULL;
94 struct AttachCtx *actx = adata->actx;
95 struct AttachPtr **idx = actx->idx;
96
97 for (unsigned short i = 0; i < actx->idxlen; i++)
98 {
99 b = idx[i]->body;
100
101 if (!b->content)
102 b->content = mutt_get_content_info(b->filename, b, sub);
103
104 info = b->content;
105 if (info)
106 {
107 switch (b->encoding)
108 {
110 s += 3 * (info->lobin + info->hibin) + info->ascii + info->crlf;
111 break;
112 case ENC_BASE64:
113 s += (4 * (info->lobin + info->hibin + info->ascii + info->crlf)) / 3;
114 break;
115 default:
116 s += info->lobin + info->hibin + info->ascii + info->crlf;
117 break;
118 }
119 }
120 }
121
122 return s;
123}
struct Content * mutt_get_content_info(const char *fname, struct Body *b, struct ConfigSubset *sub)
Analyze file to determine MIME encoding to use.
@ ENC_BASE64
Base-64 encoded text.
Definition mime.h:52
@ ENC_QUOTED_PRINTABLE
Quoted-printable text.
Definition mime.h:51
A set of attachments.
Definition attach.h:65
struct AttachPtr ** idx
Array of attachments.
Definition attach.h:69
short idxlen
Number of attachmentes.
Definition attach.h:70
An email to which things will be attached.
Definition attach.h:36
struct Body * body
Attachment.
Definition attach.h:37
The body of an email.
Definition body.h:36
struct Content * content
Detailed info about the content of the attachment.
Definition body.h:70
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition body.h:41
char * filename
When sending a message, this is the file to which this structure refers.
Definition body.h:59
struct AttachCtx * actx
Set of attachments.
Definition attach_data.h:34
Info about an attachment.
Definition content.h:35
long crlf
\r and \n characters
Definition content.h:39
long hibin
8-bit characters
Definition content.h:36
long ascii
Number of ascii chars.
Definition content.h:40
long lobin
Unprintable 7-bit chars (eg., control chars)
Definition content.h:37
+ 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}
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 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
struct Body * body
List of MIME parts.
Definition email.h:69
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:

◆ attachment_size_fixed()

void attachment_size_fixed ( struct MuttWindow * win)

Make the Attachment Window fixed-size.

Parameters
winAttachment Window

Definition at line 302 of file attach.c.

303{
304 if (!win || (win->size == MUTT_WIN_SIZE_FIXED))
305 return;
306
308 win->recalc = attach_recalc;
309}
static int attach_recalc(struct MuttWindow *win)
Recalculate the Window data - Implements MuttWindow::recalc() -.
Definition attach.c:244
@ MUTT_WIN_SIZE_FIXED
Window has a fixed size.
Definition mutt_window.h:47
int(* recalc)(struct MuttWindow *win)
enum MuttWindowSize size
Type of Window, e.g. MUTT_WIN_SIZE_FIXED.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attachment_size_max()

void attachment_size_max ( struct MuttWindow * win)

Make the Attachment Window maximised.

Parameters
winAttachment Window

Definition at line 315 of file attach.c.

316{
317 if (!win || (win->size == MUTT_WIN_SIZE_MAXIMISE))
318 return;
319
321 win->recalc = NULL;
322}
@ MUTT_WIN_SIZE_MAXIMISE
Window wants as much space as possible.
Definition mutt_window.h:48
+ Here is the caller graph for this function:

◆ preview_window_new()

struct MuttWindow * preview_window_new ( struct Email * e,
struct MuttWindow * bar )

Create the preview window.

Parameters
eEmail
barPreview Bar

Definition at line 359 of file preview.c.

360{
364
368
369 struct PreviewWindowData *wdata = preview_wdata_new();
370 wdata->email = e;
371 wdata->scroll_offset = 0;
372 wdata->win = win;
373 wdata->bar = bar;
374
375 win->wdata = wdata;
379
380 return win;
381}
void mutt_color_observer_add(observer_t callback, void *global_data)
Add an observer.
Definition notify.c:62
static int preview_email_observer(struct NotifyCallback *nc)
Notification that the Email has changed - Implements observer_t -.
Definition preview.c:282
static int preview_window_observer(struct NotifyCallback *nc)
Notification that a Window has changed - Implements observer_t -.
Definition preview.c:299
static int preview_color_observer(struct NotifyCallback *nc)
Notification that a Color has changed - Implements observer_t -.
Definition preview.c:251
static int preview_recalc(struct MuttWindow *win)
Recalculate the Window data - Implements MuttWindow::recalc() -.
Definition preview.c:344
static int preview_repaint(struct MuttWindow *win)
Repaint the Window - Implements MuttWindow::repaint() -.
Definition preview.c:332
static void preview_wdata_free(struct MuttWindow *win, void **ptr)
Free the Preview Data - Implements MuttWindow::wdata_free() -.
Definition preview.c:115
struct MuttWindow * mutt_window_new(enum WindowType type, enum MuttWindowOrientation orient, enum MuttWindowSize size, int cols, int rows)
Create a new Window.
@ WT_CUSTOM
Window with a custom drawing function.
Definition mutt_window.h:95
@ 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
@ NT_ALL
Register for all notifications.
Definition notify_type.h:35
static struct PreviewWindowData * preview_wdata_new(void)
Create new Preview Data.
Definition preview.c:127
int(* repaint)(struct MuttWindow *win)
void(* wdata_free)(struct MuttWindow *win, void **ptr)
Data to fill the Preview Window.
Definition preview.c:78
struct MuttWindow * win
Window holding the message preview.
Definition preview.c:81
struct MuttWindow * bar
Status bar above the preview window.
Definition preview.c:82
int scroll_offset
Scroll offset.
Definition preview.c:80
struct Email * email
Email being composed.
Definition preview.c:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function: