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

Expando filtering. More...

#include "render.h"
+ Include dependency graph for filter.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int expando_filter (const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
 Render an Expando and run the result through a filter.
 

Detailed Description

Expando filtering.

Authors
  • 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 filter.h.

Function Documentation

◆ expando_filter()

int expando_filter ( const struct Expando exp,
const struct ExpandoRenderData rdata,
void *  data,
MuttFormatFlags  flags,
int  max_cols,
struct Buffer buf 
)

Render an Expando and run the result through a filter.

Parameters
[in]expExpando containing the expando tree
[in]rdataExpando render data
[in]dataCallback data
[in]flagsCallback flags
[in]max_colsNumber of screen columns (-1 means unlimited)
[out]bufBuffer in which to save string
Return values
objNumber of bytes written to buf and screen columns used

Definition at line 141 of file filter.c.

143{
144 if (!exp || !exp->node)
145 return 0;
146
147 struct ExpandoNode *node = exp->node;
148
149 bool is_pipe = check_for_pipe(node);
150 int old_cols = max_cols;
151 if (is_pipe)
152 max_cols = -1;
153
154 int rc = expando_render(exp, rdata, data, flags, max_cols, buf);
155
156 if (!is_pipe)
157 return rc;
158
159 filter_text(buf);
160
161 // Strictly truncate to size
162 size_t width = 0;
163 size_t bytes = mutt_wstr_trunc(buf_string(buf), buf_len(buf), old_cols, &width);
164 buf->data[bytes] = '\0';
165
166 return width;
167}
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:491
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
size_t mutt_wstr_trunc(const char *src, size_t maxlen, size_t maxwid, size_t *width)
Work out how to truncate a widechar string.
Definition: curs_lib.c:383
bool check_for_pipe(struct ExpandoNode *root)
Should the Expando be piped to an external command?
Definition: filter.c:51
void filter_text(struct Buffer *buf)
Filter the text through an external command.
Definition: filter.c:92
int expando_render(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando + data into a string.
Definition: expando.c:109
char * data
Pointer to data.
Definition: buffer.h:37
Basic Expando Node.
Definition: node.h:69
struct ExpandoNode * node
Parsed tree.
Definition: expando.h:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function: