NeoMutt  2024-12-12-14-g7b49f7
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 ExpandoRenderCallback *erc, 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 94 of file node_container.c.

95{
96 struct ExpandoNode *node = node_new();
97
98 node->type = ENT_CONTAINER;
100
101 return node;
102}
int node_container_render(const struct ExpandoNode *node, const struct ExpandoRenderCallback *erc, 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 ExpandoRenderCallback *erc, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Definition: node.h:92
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 108 of file node_container.c.

109{
110 if (!ptr || !*ptr)
111 return;
112
113 struct ExpandoNode *node = *ptr;
114
115 if (node->type != ENT_CONTAINER)
116 return;
117
118 struct ExpandoNode *child = NULL;
119 struct ExpandoNode **np = NULL;
120 size_t size = 0;
121 ARRAY_FOREACH(np, &node->children)
122 {
123 if (!np || !*np)
124 continue;
125
126 size++;
127 child = *np;
128 }
129
130 if (size > 1)
131 return;
132
133 if (size == 0)
134 {
135 node_free(ptr);
136 return;
137 }
138
139 ARRAY_FREE(&node->children);
140 node_free(ptr);
141 *ptr = child;
142}
#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 148 of file node_container.c.

149{
150 if (!ptr || !*ptr)
151 return;
152
153 struct ExpandoNode *parent = *ptr;
154
155 struct ExpandoNode **np = NULL;
156 ARRAY_FOREACH(np, &parent->children)
157 {
159 }
160
162}
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: