NeoMutt  2025-09-05-43-g177ed6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Colour Parsing API

Prototype for a function to parse color config. More...

Functions

enum CommandResult parse_color_pair (struct Buffer *buf, struct Buffer *s, struct AttrColor *ac, struct Buffer *err)
 Parse a pair of colours - Implements parser_callback_t -.
 
enum CommandResult parse_attr_spec (struct Buffer *buf, struct Buffer *s, struct AttrColor *ac, struct Buffer *err)
 Parse an attribute description - Implements parser_callback_t -.
 

Detailed Description

Prototype for a function to parse color config.

Parameters
[in]bufTemporary Buffer space
[in]sBuffer containing string to be parsed
[out]acColour
[out]errBuffer for error messages
Return values
0Success
-1Error

Function Documentation

◆ parse_color_pair()

enum CommandResult parse_color_pair ( struct Buffer * buf,
struct Buffer * s,
struct AttrColor * ac,
struct Buffer * err )

Parse a pair of colours - Implements parser_callback_t -.

Parse a pair of colours, e.g. "red default"

Definition at line 283 of file parse_color.c.

285{
286 while (true)
287 {
288 if (!MoreArgsF(s, TOKEN_COMMENT))
289 {
290 buf_printf(err, _("%s: too few arguments"), "color");
291 return MUTT_CMD_WARNING;
292 }
293
295 if (buf_is_empty(buf))
296 continue;
297
299 if (attr == -1)
300 {
301 enum CommandResult rc = parse_color_name(buf_string(buf), &ac->fg, err);
302 if (rc != MUTT_CMD_SUCCESS)
303 return rc;
304 break;
305 }
306
307 if (attr == A_NORMAL)
308 ac->attrs = attr; // Clear all attributes
309 else
310 ac->attrs |= attr; // Merge with other attributes
311 }
312
313 if (!MoreArgsF(s, TOKEN_COMMENT))
314 {
315 buf_printf(err, _("%s: too few arguments"), "color");
316 return MUTT_CMD_WARNING;
317 }
318
320
321 return parse_color_name(buf_string(buf), &ac->bg, err);
322}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
CommandResult
Error codes for command_t parse functions.
Definition command.h:35
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition command.h:38
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition command.h:37
int parse_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition extract.c:48
#define MoreArgsF(buf, flags)
Definition extract.h:33
#define TOKEN_COMMENT
Don't reap comments.
Definition extract.h:50
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
Definition mapping.c:85
#define _(a)
Definition message.h:28
static struct Mapping AttributeNames[]
Mapping of attribute names to their IDs.
Definition parse_color.c:61
enum CommandResult parse_color_name(const char *s, struct ColorElement *elem, struct Buffer *err)
Parse a colour name.
struct ColorElement bg
Background colour.
Definition attr.h:68
struct ColorElement fg
Foreground colour.
Definition attr.h:67
int attrs
Text attributes, e.g. A_BOLD.
Definition attr.h:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_attr_spec()

enum CommandResult parse_attr_spec ( struct Buffer * buf,
struct Buffer * s,
struct AttrColor * ac,
struct Buffer * err )

Parse an attribute description - Implements parser_callback_t -.

Definition at line 327 of file parse_color.c.

329{
330 if (!buf || !s || !ac)
331 return MUTT_CMD_ERROR;
332
333 if (!MoreArgs(s))
334 {
335 buf_printf(err, _("%s: too few arguments"), "mono");
336 return MUTT_CMD_WARNING;
337 }
338
340
342 if (attr == -1)
343 {
344 buf_printf(err, _("%s: no such attribute"), buf_string(buf));
345 return MUTT_CMD_WARNING;
346 }
347
348 if (attr == A_NORMAL)
349 ac->attrs = attr; // Clear all attributes
350 else
351 ac->attrs |= attr; // Merge with other attributes
352
353 return MUTT_CMD_SUCCESS;
354}
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition command.h:36
#define MoreArgs(buf)
Definition extract.h:30
#define TOKEN_NO_FLAGS
No flags are set.
Definition extract.h:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function: