78 const int pad_len = node->
end - node->
start;
82 while (pad_cols <= max_cols)
87 total_cols += pad_cols;
90 for (; (max_cols > 0); buf++, max_cols--)
110 total_cols +=
pad_string(node, buf, max_cols - total_cols);
133 cols_used +=
node_tree_render(left, rdata, buf_left, max_cols - cols_used, data, flags);
137 cols_used +=
node_tree_render(right, rdata, buf_right, max_cols - cols_used, data, flags);
139 if (max_cols > cols_used)
140 cols_used +=
pad_string(node, buf_pad, max_cols - cols_used);
171 cols_used +=
node_tree_render(right, rdata, buf_right, max_cols - cols_used, data, flags);
175 cols_used +=
node_tree_render(left, rdata, buf_left, max_cols - cols_used, data, flags);
177 if (max_cols > cols_used)
178 cols_used +=
pad_string(node, buf_pad, max_cols - cols_used);
241 _(
"Padding cannot be used as a condition"));
251 else if (*str ==
'>')
255 else if (*str ==
'*')
267 *parsed_until = str + consumed;
277 if (!parent || !*parent)
282 for (; node; prev = node, node = node->
next)
#define ARRAY_SET(head, idx, elem)
Set an element in the array.
#define ARRAY_GET(head, idx)
Return the element at index.
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_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
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, const char **parsed_until, int did, int uid, ExpandoParserFlags flags, struct ExpandoParseError *error)
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.
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.
@ ENT_CONDITION
True/False condition.
@ ENT_PADDING
Padding: soft, hard, EOL.
Expando Node for a Condition.
@ ENC_FALSE
Index of False Node.
@ ENC_TRUE
Index of True Node.
void node_padding_repad(struct ExpandoNode **parent)
Rearrange Padding in a tree of ExpandoNodes.
void node_padding_private_free(void **ptr)
Free Padding private data - Implements ExpandoNode::ndata_free()
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_tree_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.
const char * end
End of string data.
struct ExpandoNode * next
Linked list.
int did
Domain ID, e.g. ED_EMAIL.
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
const char * start
Start of string data.
void(* ndata_free)(void **ptr)
Function to free the private node data.
struct ExpandoNodeArray children
Children nodes.
Buffer for parsing errors.
char message[128]
Error message.
const char * position
Position of error in original string.
Private data for a Padding Node.
enum ExpandoPadType pad_type
Padding type.