NeoMutt  2025-12-11-58-g09398d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
node_padding.h File Reference

Expando Node for Padding. More...

#include "definition.h"
+ Include dependency graph for node_padding.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  NodePaddingPrivate
 Private data for a Padding Node -. More...
 

Enumerations

enum  ExpandoPadType { EPT_FILL_EOL , EPT_HARD_FILL , EPT_SOFT_FILL }
 Padding type. More...
 
enum  ENPad { ENP_LEFT , ENP_RIGHT }
 Names for the Padding's children. More...
 

Functions

struct ExpandoNodenode_padding_parse (const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
 Parse a Padding Expando - Implements ExpandoDefinition::parse() -.
 
void node_padding_repad (struct ExpandoNode **parent)
 Rearrange Padding in a tree of ExpandoNodes.
 

Detailed Description

Expando Node for Padding.

Authors
  • Tóth János
  • Richard Russon

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

Enumeration Type Documentation

◆ ExpandoPadType

Padding type.

Padding occurs between two sides, left and right. The type of Padding, soft or hard, refers to how the left-hand-side will react if there's too little space.

Hard padding: The left-hand-side will fixed and the right-hand-side will be truncated. Soft padding: The right-hand-side will be fixed and the left-hand-side will be truncated.

Enumerator
EPT_FILL_EOL 

Fill to the end-of-line.

EPT_HARD_FILL 

Hard-fill: left-hand-side will be truncated.

EPT_SOFT_FILL 

Soft-fill: right-hand-side will be truncated.

Definition at line 43 of file node_padding.h.

44{
48};
@ 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.

◆ ENPad

enum ENPad

Names for the Padding's children.

Padding has two children: Left and Right.

Enumerator
ENP_LEFT 

Index of Left-Hand Nodes.

ENP_RIGHT 

Index of Right-Hand Nodes.

Definition at line 55 of file node_padding.h.

56{
57 ENP_LEFT,
58 ENP_RIGHT,
59};
@ ENP_LEFT
Index of Left-Hand Nodes.
@ ENP_RIGHT
Index of Right-Hand Nodes.

Function Documentation

◆ node_padding_repad()

void node_padding_repad ( struct ExpandoNode ** ptr)

Rearrange Padding in a tree of ExpandoNodes.

Parameters
ptrParent Node

Definition at line 295 of file node_padding.c.

296{
297 if (!ptr || !*ptr)
298 return;
299
300 struct ExpandoNode *parent = *ptr;
301 struct ExpandoNode **np = NULL;
302 ARRAY_FOREACH(np, &parent->children)
303 {
304 if (!np || !*np)
305 continue;
306
307 // Repad any children, recursively
309
310 struct ExpandoNode *node = *np;
311 if (node->type != ENT_PADDING)
312 continue;
313
314 struct ExpandoNode *node_left = node_container_new();
315 struct ExpandoNode *node_right = node_container_new();
316
317 if (ARRAY_FOREACH_IDX_np > 0)
318 {
319 for (int i = 0; i < ARRAY_FOREACH_IDX_np; i++)
320 {
321 node_add_child(node_left, node_get_child(parent, i));
322 }
323 }
324
325 size_t count = ARRAY_SIZE(&parent->children);
326 if ((ARRAY_FOREACH_IDX_np + 1) < count)
327 {
328 for (int i = ARRAY_FOREACH_IDX_np + 1; i < count; i++)
329 {
330 node_add_child(node_right, node_get_child(parent, i));
331 }
332 }
333
334 // All the children have been transferred
335 ARRAY_FREE(&parent->children);
336
337 node_add_child(node, node_left);
338 node_add_child(node, node_right);
339
340 node_add_child(parent, node);
341
342 break; // Only repad the first padding node
343 }
344}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:214
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:204
struct ExpandoNode * node_get_child(const struct ExpandoNode *node, int index)
Get a child of an ExpandoNode.
Definition node.c:91
void node_add_child(struct ExpandoNode *node, struct ExpandoNode *child)
Add a child to an ExpandoNode.
Definition node.c:76
@ ENT_PADDING
Padding: soft, hard, EOL.
Definition node.h:40
struct ExpandoNode * node_container_new(void)
Create a new Container ExpandoNode.
void node_padding_repad(struct ExpandoNode **ptr)
Rearrange Padding in a tree of ExpandoNodes.
Basic Expando Node.
Definition node.h:67
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
Definition node.h:68
struct ExpandoNodeArray children
Children nodes.
Definition node.h:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function: