NeoMutt  2024-04-25-1-g3de005
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 <assert.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 59 of file node_text.c.

60{
61 struct ExpandoNode *node = node_new();
62
63 node->type = ENT_TEXT;
64 node->start = start;
65 node->end = end;
67
68 return node;
69}
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:43
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 78 of file node_text.c.

79{
80 while (*start)
81 {
82 if (*start == terminator)
83 {
84 break;
85 }
86
87 if (end && (start > (end - 1)))
88 {
89 break;
90 }
91
92 start++;
93 }
94
95 return start;
96}
+ 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 105 of file node_text.c.

106{
107 const char *text_end = skip_until_ch_or_end(str, '%', end);
108 *parsed_until = text_end;
109 return node_text_new(str, text_end);
110}
struct ExpandoNode * node_text_new(const char *start, const char *end)
Create a new Text ExpandoNode.
Definition: node_text.c:59
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:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function: