84 while (pad_cols <= max_cols)
89 total_cols += pad_cols;
96 total_cols += max_cols;
111 int total_cols =
node_render(left, rdata, buf, max_cols, data, flags);
113 total_cols +=
pad_string(node, buf, max_cols - total_cols);
136 cols_used +=
node_render(left, rdata, buf_left, max_cols - cols_used, data, flags);
140 cols_used +=
node_render(right, rdata, buf_right, max_cols - cols_used, data, flags);
142 if (max_cols > cols_used)
143 cols_used +=
pad_string(node, buf_pad, max_cols - cols_used);
174 cols_used +=
node_render(right, rdata, buf_right, max_cols - cols_used, data, flags);
178 cols_used +=
node_render(left, rdata, buf_left, max_cols - cols_used, data, flags);
180 if (max_cols > cols_used)
181 cols_used +=
pad_string(node, buf_pad, max_cols - cols_used);
202 const char *start,
const char *end)
243 _(
"Padding cannot be used as a condition"));
253 else if (*str ==
'>')
257 else if (*str ==
'*')
274 *parsed_until = str + consumed;
304 if (ARRAY_FOREACH_IDX > 0)
306 for (
int i = 0; i < ARRAY_FOREACH_IDX; i++)
313 if ((ARRAY_FOREACH_IDX + 1) < count)
315 for (
int i = ARRAY_FOREACH_IDX + 1; i < count; i++)
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
#define ARRAY_SIZE(head)
The number of elements stored.
#define ARRAY_FREE(head)
Release all memory.
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
size_t buf_addstr_n(struct Buffer *buf, const char *s, size_t len)
Add a string to a Buffer, expanding it if necessary.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
size_t mutt_strnwidth(const char *s, size_t n)
Measure a string's width in screen cells.
Define an Expando format string.
uint8_t ExpandoParserFlags
Flags for expando_parse(), e.g. EP_CONDITIONAL.
#define EP_CONDITIONAL
Expando is being used as a condition.
struct ExpandoNode * node_padding_parse(const char *str, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Padding Expando - Implements ExpandoDefinition::parse() -.
int node_padding_render_hard(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render Hard Padding - Implements ExpandoNode::render() -.
int node_padding_render_soft(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render Soft Padding - Implements ExpandoNode::render() -.
int node_padding_render_eol(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render End-of-Line Padding - Implements ExpandoNode::render() -.
Convenience wrapper for the gui headers.
int mutt_mb_charlen(const char *s, int *width)
Count the bytes in a (multibyte) character.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Convenience wrapper for the library headers.
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
struct ExpandoNode * node_new(void)
Create a new empty ExpandoNode.
struct ExpandoNode * node_get_child(const struct ExpandoNode *node, int index)
Get a child of an ExpandoNode.
void node_add_child(struct ExpandoNode *node, struct ExpandoNode *child)
Add a child to an ExpandoNode.
@ ENT_PADDING
Padding: soft, hard, EOL.
struct ExpandoNode * node_container_new(void)
Create a new Container ExpandoNode.
Expando Node for a Container.
void node_padding_private_free(void **ptr)
Free Padding private data - Implements ExpandoNode::ndata_free()
void node_padding_repad(struct ExpandoNode **ptr)
Rearrange Padding in a tree of ExpandoNodes.
int pad_string(const struct ExpandoNode *node, struct Buffer *buf, int max_cols)
Pad a buffer with a character.
struct NodePaddingPrivate * node_padding_private_new(enum ExpandoPadType pad_type)
Create new Padding private data.
struct ExpandoNode * node_padding_new(enum ExpandoPadType pad_type, const char *start, const char *end)
Creata new Padding ExpandoNode.
Expando Node for Padding.
@ ENP_LEFT
Index of Left-Hand Nodes.
@ ENP_RIGHT
Index of Right-Hand Nodes.
ExpandoPadType
Padding type.
@ EPT_FILL_EOL
Fill to the end-of-line.
@ EPT_SOFT_FILL
Soft-fill: right-hand-side will be truncated.
@ EPT_HARD_FILL
Hard-fill: left-hand-side will be truncated.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
int node_render(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render a tree of ExpandoNodes into a string.
Render Expandos using Data.
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
String manipulation buffer.
int uid
Unique ID, e.g. ED_EMA_SIZE.
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
void * ndata
Private node data.
int did
Domain ID, e.g. ED_EMAIL.
const char * text
Node-specific text.
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
void(* ndata_free)(void **ptr)
Function to free the private node data.
struct ExpandoNodeArray children
Children nodes.
Buffer for parsing errors.
const char * position
Position of error in original string.
char message[256]
Error message.
Private data for a Padding Node -.
enum ExpandoPadType pad_type
Padding type.