NeoMutt  2024-10-02-37-gfa9146
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, 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 42 of file node_padding.h.

43{
47};
@ EPT_FILL_EOL
Fill to the end-of-line.
Definition: node_padding.h:44
@ EPT_SOFT_FILL
Soft-fill: right-hand-side will be truncated.
Definition: node_padding.h:46
@ EPT_HARD_FILL
Hard-fill: left-hand-side will be truncated.
Definition: node_padding.h:45

◆ 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 54 of file node_padding.h.

55{
56 ENP_LEFT,
57 ENP_RIGHT,
58};
@ ENP_LEFT
Index of Left-Hand Nodes.
Definition: node_padding.h:56
@ ENP_RIGHT
Index of Right-Hand Nodes.
Definition: node_padding.h:57

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

283{
284 if (!ptr || !*ptr)
285 return;
286
287 struct ExpandoNode *parent = *ptr;
288 struct ExpandoNode **np = NULL;
289 ARRAY_FOREACH(np, &parent->children)
290 {
291 if (!np || !*np)
292 continue;
293
294 // Repad any children, recursively
296
297 struct ExpandoNode *node = *np;
298 if (node->type != ENT_PADDING)
299 continue;
300
301 struct ExpandoNode *node_left = node_container_new();
302 struct ExpandoNode *node_right = node_container_new();
303
304 if (ARRAY_FOREACH_IDX > 0)
305 {
306 for (int i = 0; i < ARRAY_FOREACH_IDX; i++)
307 {
308 node_add_child(node_left, node_get_child(parent, i));
309 }
310 }
311
312 size_t count = ARRAY_SIZE(&parent->children);
313 if ((ARRAY_FOREACH_IDX + 1) < count)
314 {
315 for (int i = ARRAY_FOREACH_IDX + 1; i < count; i++)
316 {
317 node_add_child(node_right, node_get_child(parent, i));
318 }
319 }
320
321 // All the children have been transferred
322 ARRAY_FREE(&parent->children);
323
324 node_add_child(node, node_left);
325 node_add_child(node, node_right);
326
327 node_add_child(parent, node);
328
329 break; // Only repad the first padding node
330 }
331}
#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:282
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: