NeoMutt  2024-04-25-76-g20fe7b
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
node_text.c File Reference

Expando Node for Text. More...

#include "config.h"
#include <stdbool.h>
#include "node_text.h"
#include "format.h"
#include "node.h"
#include "render.h"
+ Include dependency graph for node_text.c:

Go to the source code of this file.

Functions

static int node_text_render (const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
 Render a Text Node - Implements ExpandoNode::render() -.
 
struct ExpandoNodenode_text_new (const char *start, const char *end)
 Create a new Text ExpandoNode.
 
static const char * skip_until_ch_or_end (const char *start, char terminator, const char *end)
 Search for a terminator character.
 
struct ExpandoNodenode_text_parse (const char *str, const char *end, const char **parsed_until)
 Extract a block of text.
 

Detailed Description

Expando Node for Text.

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

Function Documentation

◆ node_text_new()

struct ExpandoNode * node_text_new ( const char *  start,
const char *  end 
)

Create a new Text ExpandoNode.

Parameters
startStart of text to store
endEnd of text to store
Return values
ptrNew Text ExpandoNode

Definition at line 58 of file node_text.c.

59{
60 struct ExpandoNode *node = node_new();
61
62 node->type = ENT_TEXT;
63 node->start = start;
64 node->end = end;
66
67 return node;
68}
static int node_text_render(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Render a Text Node - Implements ExpandoNode::render() -.
Definition: node_text.c:42
struct ExpandoNode * node_new(void)
Create a new empty ExpandoNode.
Definition: node.c:39
@ ENT_TEXT
Plain text.
Definition: node.h:38
Basic Expando Node.
Definition: node.h:69
int(* render)(const struct ExpandoNode *node, const struct ExpandoRenderData *rdata, struct Buffer *buf, int max_cols, void *data, MuttFormatFlags flags)
Definition: node.h:96
const char * end
End of string data.
Definition: node.h:80
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
Definition: node.h:70
const char * start
Start of string data.
Definition: node.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ skip_until_ch_or_end()

static const char * skip_until_ch_or_end ( const char *  start,
char  terminator,
const char *  end 
)
static

Search for a terminator character.

Parameters
startStart of string
terminatorTerminating character
endEnd of string
Return values
ptrPosition of terminator character, or end-of-string

Definition at line 77 of file node_text.c.

78{
79 while (*start)
80 {
81 if (*start == terminator)
82 {
83 break;
84 }
85
86 if (end && (start > (end - 1)))
87 {
88 break;
89 }
90
91 start++;
92 }
93
94 return start;
95}
+ Here is the caller graph for this function:

◆ node_text_parse()

struct ExpandoNode * node_text_parse ( const char *  str,
const char *  end,
const char **  parsed_until 
)

Extract a block of text.

Parameters
strString to parse
endEnd of string
parsed_untilFirst character after parsed text
Return values
ptrNew Text ExpandoNode

Definition at line 104 of file node_text.c.

105{
106 const char *text_end = skip_until_ch_or_end(str, '%', end);
107 *parsed_until = text_end;
108 return node_text_new(str, text_end);
109}
struct ExpandoNode * node_text_new(const char *start, const char *end)
Create a new Text ExpandoNode.
Definition: node_text.c:58
static const char * skip_until_ch_or_end(const char *start, char terminator, const char *end)
Search for a terminator character.
Definition: node_text.c:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function: