summaryrefslogtreecommitdiffstats
path: root/color.c
diff options
context:
space:
mode:
authorMuh Muhten <muh.muhten@gmail.com>2019-01-15 01:17:02 -0500
committerMuh Muhten <muh.muhten@gmail.com>2019-01-17 05:30:09 -0500
commit8117a33e0ff12ed8456c55b49fb7fcf2afc4fbf4 (patch)
treecfaef2a75711f594bac0e31b10fa07b2f803616b /color.c
parent42e2d07a1ca6393080b816c59788645b817ecfb0 (diff)
Add attributes support on color declarations
color now accepts zero or more attributes words before the foreground. Also more or less resolves the issue that setting the color of an object which defaults to underline/reverse is irreversible.
Diffstat (limited to 'color.c')
-rw-r--r--color.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/color.c b/color.c
index fafee929..992b7c11 100644
--- a/color.c
+++ b/color.c
@@ -688,16 +688,35 @@ typedef int (*parser_callback_t)(BUFFER *, BUFFER *, int *, int *, int *, BUFFER
static int
parse_color_pair(BUFFER *buf, BUFFER *s, int *fg, int *bg, int *attr, BUFFER *err)
{
- if (! MoreArgs (s))
+ FOREVER
{
- strfcpy (err->data, _("color: too few arguments"), err->dsize);
- return (-1);
- }
+ if (! MoreArgs (s))
+ {
+ strfcpy (err->data, _("color: too few arguments"), err->dsize);
+ return (-1);
+ }
- mutt_extract_token (buf, s, 0);
+ mutt_extract_token (buf, s, 0);
- if (parse_color_name (buf->data, fg, attr, 1, err) != 0)
- return (-1);
+ if (ascii_strcasecmp ("bold", buf->data) == 0)
+ *attr |= A_BOLD;
+ else if (ascii_strcasecmp ("underline", buf->data) == 0)
+ *attr |= A_UNDERLINE;
+ else if (ascii_strcasecmp ("none", buf->data) == 0)
+ *attr = A_NORMAL;
+ else if (ascii_strcasecmp ("reverse", buf->data) == 0)
+ *attr |= A_REVERSE;
+ else if (ascii_strcasecmp ("standout", buf->data) == 0)
+ *attr |= A_STANDOUT;
+ else if (ascii_strcasecmp ("normal", buf->data) == 0)
+ *attr = A_NORMAL; /* needs use = instead of |= to clear other bits */
+ else
+ {
+ if (parse_color_name (buf->data, fg, attr, 1, err) != 0)
+ return (-1);
+ break;
+ }
+ }
if (! MoreArgs (s))
{