NeoMutt  2024-11-14-34-g5aaf0d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
node_container.c File Reference

Expando Node for a Container. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "node_container.h"
#include "format.h"
#include "helpers.h"
#include "node.h"
#include "render.h"
+ Include dependency graph for node_container.c:

Go to the source code of this file.

Functions

int node_container_render (const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
 Callback for a Container Node - Implements ExpandoNode::render() -.
 
struct ExpandoNodenode_container_new (void)
 Create a new Container ExpandoNode.
 
void node_container_collapse (struct ExpandoNode **ptr)
 Remove an unnecessary Container.
 
void node_container_collapse_all (struct ExpandoNode **ptr)
 Remove unnecessary Containers.
 

Detailed Description

Expando Node for a Container.

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_container.c.

Function Documentation

◆ node_container_new()

struct ExpandoNode * node_container_new ( void  )

Create a new Container ExpandoNode.

Return values
ptrNew Container ExpandoNode

Definition at line 95 of file node_container.c.

96{
97 struct ExpandoNode *node = node_new();
98
99 node->type = ENT_CONTAINER;
101
102 return node;
103}
int node_container_render(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Callback for a Container Node - Implements ExpandoNode::render() -.
struct ExpandoNode * node_new(void)
Create a new empty ExpandoNode.
Definition: node.c:39
@ ENT_CONTAINER
Container for other nodes.
Definition: node.h:44
Basic Expando Node.
Definition: node.h:67
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Definition: node.h:91
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
Definition: node.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ node_container_collapse()

void node_container_collapse ( struct ExpandoNode **  ptr)

Remove an unnecessary Container.

Parameters
ptrPointer to a Container

Definition at line 109 of file node_container.c.

110{
111 if (!ptr || !*ptr)
112 return;
113
114 struct ExpandoNode *node = *ptr;
115
116 if (node->type != ENT_CONTAINER)
117 return;
118
119 struct ExpandoNode *child = NULL;
120 struct ExpandoNode **np = NULL;
121 size_t size = 0;
122 ARRAY_FOREACH(np, &node->children)
123 {
124 if (!np || !*np)
125 continue;
126
127 size++;
128 child = *np;
129 }
130
131 if (size > 1)
132 return;
133
134 if (size == 0)
135 {
136 node_free(ptr);
137 return;
138 }
139
140 ARRAY_FREE(&node->children);
141 node_free(ptr);
142 *ptr = child;
143}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
void node_free(struct ExpandoNode **ptr)
Free an ExpandoNode and its private data.
Definition: node.c:48
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:

◆ node_container_collapse_all()

void node_container_collapse_all ( struct ExpandoNode **  ptr)

Remove unnecessary Containers.

Parameters
ptrPointer to the parent node

Definition at line 149 of file node_container.c.

150{
151 if (!ptr || !*ptr)
152 return;
153
154 struct ExpandoNode *parent = *ptr;
155
156 struct ExpandoNode **np = NULL;
157 ARRAY_FOREACH(np, &parent->children)
158 {
160 }
161
163}
void node_container_collapse_all(struct ExpandoNode **ptr)
Remove unnecessary Containers.
void node_container_collapse(struct ExpandoNode **ptr)
Remove an unnecessary Container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function: