NeoMutt  2024-11-14-138-ge5ca67
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
expando.c
Go to the documentation of this file.
1
29#include <stdbool.h>
30#include <stdio.h>
31#include "private.h"
32#include "mutt/lib.h"
33#include "expando.h"
34#include "expando/lib.h"
35#include "menu/lib.h"
36#include "attach_data.h"
37#include "globals.h"
38#include "muttlib.h"
39#include "shared_data.h"
40
44static long compose_attach_count_num(const struct ExpandoNode *node, void *data,
45 MuttFormatFlags flags)
46{
47 const struct ComposeSharedData *shared = data;
48 struct ComposeAttachData *adata = shared->adata;
49
50 if (!adata || !adata->menu)
51 return 0;
52
53 return adata->menu->max;
54}
55
59static void compose_attach_size(const struct ExpandoNode *node, void *data,
60 MuttFormatFlags flags, struct Buffer *buf)
61{
62 const struct ComposeSharedData *shared = data;
63
64 char tmp[128] = { 0 };
65
66 mutt_str_pretty_size(tmp, sizeof(tmp), cum_attachs_size(shared->sub, shared->adata));
67 buf_strcpy(buf, tmp);
68}
69
73static long compose_attach_size_num(const struct ExpandoNode *node, void *data,
75{
76 const struct ComposeSharedData *shared = data;
77 return cum_attachs_size(shared->sub, shared->adata);
78}
79
83static void global_hostname(const struct ExpandoNode *node, void *data,
84 MuttFormatFlags flags, struct Buffer *buf)
85{
86 const char *s = ShortHostname;
87 buf_strcpy(buf, s);
88}
89
93static void global_version(const struct ExpandoNode *node, void *data,
94 MuttFormatFlags flags, struct Buffer *buf)
95{
96 const char *s = mutt_make_version();
97 buf_strcpy(buf, s);
98}
99
106 // clang-format off
111 { -1, -1, NULL, NULL },
112 // clang-format on
113};
Compose Attach Data.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
unsigned long cum_attachs_size(struct ConfigSubset *sub, struct ComposeAttachData *adata)
Cumulative Attachments Size.
Definition: attach.c:84
const struct ExpandoRenderCallback ComposeRenderCallbacks[]
Callbacks for Compose Expandos.
Definition: expando.c:105
@ ED_COM_ATTACH_COUNT
ComposeAttachData, num_attachments()
Definition: shared_data.h:54
@ ED_COM_ATTACH_SIZE
ComposeAttachData, cum_attachs_size()
Definition: shared_data.h:55
@ ED_COMPOSE
Compose ED_COM_ ExpandoDataCompose.
Definition: domain.h:39
@ ED_GLOBAL
Global ED_GLO_ ExpandoDataGlobal.
Definition: domain.h:44
Parse Expando string.
char * ShortHostname
Short version of the hostname.
Definition: globals.c:38
static long compose_attach_count_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Compose: Number of attachments - Implements get_number_t -.
Definition: expando.c:44
static long compose_attach_size_num(const struct ExpandoNode *node, void *data, MuttFormatFlags flags)
Compose: Size in bytes - Implements get_number_t -.
Definition: expando.c:73
static void compose_attach_size(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Compose: Size in bytes - Implements get_string_t -.
Definition: expando.c:59
static void global_hostname(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Compose: Hostname - Implements get_string_t -.
Definition: expando.c:83
static void global_version(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Compose: Version - Implements get_string_t -.
Definition: expando.c:93
Data shared between Index, Pager and Sidebar.
GUI present the user with a selectable list.
Convenience wrapper for the library headers.
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:858
void mutt_str_pretty_size(char *buf, size_t buflen, size_t num)
Display an abbreviated size, like 3.4K.
Definition: muttlib.c:1004
Some miscellaneous functions.
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
Definition: render.h:32
Sidebar Expando definitions.
GUI display the mailboxes in a side panel.
String manipulation buffer.
Definition: buffer.h:36
Data to fill the Compose Attach Window.
Definition: attach_data.h:33
struct Menu * menu
Menu displaying the attachments.
Definition: attach_data.h:35
Shared Compose Data.
Definition: shared_data.h:35
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:36
int flags
Flags, e.g. MUTT_COMPOSE_NOFREEHEADER.
Definition: shared_data.h:42
struct ComposeAttachData * adata
Attachments.
Definition: shared_data.h:39
Basic Expando Node.
Definition: node.h:67
int max
Number of entries in the menu.
Definition: lib.h:81
@ ED_GLO_VERSION
NeoMutt version.
Definition: uid.h:42
@ ED_GLO_HOSTNAME
Local hostname.
Definition: uid.h:37