NeoMutt  2024-10-02-37-gfa9146
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 "mutt/lib.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 57 of file node_text.c.

58{
59 struct ExpandoNode *node = node_new();
60
61 node->type = ENT_TEXT;
62 node->text = mutt_strn_dup(start, end - start);
64
65 return node;
66}
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:41
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
Definition: string.c:380
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: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
const char * text
Node-specific text.
Definition: node.h:73
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:

◆ 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 75 of file node_text.c.

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

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