NeoMutt  2024-11-14-34-g5aaf0d
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.
Definition: node_padding.h:45
@ EPT_SOFT_FILL
Soft-fill: right-hand-side will be truncated.
Definition: node_padding.h:47
@ EPT_HARD_FILL
Hard-fill: left-hand-side will be truncated.
Definition: node_padding.h:46

◆ 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.
Definition: node_padding.h:57
@ ENP_RIGHT
Index of Right-Hand Nodes.
Definition: node_padding.h:58

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 291 of file node_padding.c.

292{
293 if (!ptr || !*ptr)
294 return;
295
296 struct ExpandoNode *parent = *ptr;
297 struct ExpandoNode **np = NULL;
298 ARRAY_FOREACH(np, &parent->children)
299 {
300 if (!np || !*np)
301 continue;
302
303 // Repad any children, recursively
305
306 struct ExpandoNode *node = *np;
307 if (node->type != ENT_PADDING)
308 continue;
309
310 struct ExpandoNode *node_left = node_container_new();
311 struct ExpandoNode *node_right = node_container_new();
312
313 if (ARRAY_FOREACH_IDX > 0)
314 {
315 for (int i = 0; i < ARRAY_FOREACH_IDX; i++)
316 {
317 node_add_child(node_left, node_get_child(parent, i));
318 }
319 }
320
321 size_t count = ARRAY_SIZE(&parent->children);
322 if ((ARRAY_FOREACH_IDX + 1) < count)
323 {
324 for (int i = ARRAY_FOREACH_IDX + 1; i < count; i++)
325 {
326 node_add_child(node_right, node_get_child(parent, i));
327 }
328 }
329
330 // All the children have been transferred
331 ARRAY_FREE(&parent->children);
332
333 node_add_child(node, node_left);
334 node_add_child(node, node_right);
335
336 node_add_child(parent, node);
337
338 break; // Only repad the first padding node
339 }
340}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#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.
Definition: node_padding.c:291
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: