From: Muh Muhten Date: Tue, 15 Jan 2019 06:17:02 +0000 (-0500) Subject: Add attributes support on color declarations X-Git-Tag: mutt-1-12-rel~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8117a33e0ff12ed8456c55b49fb7fcf2afc4fbf4;p=mutt 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. --- 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)) { diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 252bdf44..cb22736a 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -2659,6 +2659,9 @@ silently truncated at the screen width, and are not wrapped. object + +attribute + foreground @@ -2675,6 +2678,9 @@ silently truncated at the screen width, and are not wrapped. + +attribute + foreground @@ -2689,6 +2695,9 @@ silently truncated at the screen width, and are not wrapped. + +attribute + foreground @@ -2706,6 +2715,9 @@ silently truncated at the screen width, and are not wrapped. composeobject + +attribute + foreground @@ -2796,6 +2808,18 @@ When set, color is applied only to the exact text matched by security_none + +attribute can be one of the following: + + + +none +bold +underline +reverse +standout + + foreground and background can be one of the following: @@ -2948,19 +2972,9 @@ command. Usage: -For object and composeobject, -see the color command. attribute -can be one of the following: +For object, composeobject, and +attribute, see the color command. - - -none -bold -underline -reverse -standout - - @@ -9799,6 +9813,9 @@ The following are the commands understood by Mutt: object + +attribute + foreground @@ -9815,6 +9832,9 @@ The following are the commands understood by Mutt: + +attribute + foreground @@ -9829,6 +9849,9 @@ The following are the commands understood by Mutt: + +attribute + foreground @@ -9846,6 +9869,9 @@ The following are the commands understood by Mutt: composeobject + +attribute + foreground diff --git a/doc/muttrc.man.head b/doc/muttrc.man.head index 92b40935..eb31cd05 100644 --- a/doc/muttrc.man.head +++ b/doc/muttrc.man.head @@ -221,8 +221,8 @@ This command binds the given \fIsequence\fP of keys to the given specify multiple maps, put only a comma between the maps. .PP .nf -\fBcolor\fP \fIobject\fP \fIforeground\fP \fIbackground\fP [ \fIregexp\fP ] -\fBcolor\fP index \fIforeground\fP \fIbackground\fP [ \fIpattern\fP ] +\fBcolor\fP \fIobject\fP [ \fIattribute\fP ... ] \fIforeground\fP \fIbackground\fP [ \fIregexp\fP ] +\fBcolor\fP index [ \fIattribute\fP ... ] \fIforeground\fP \fIbackground\fP [ \fIpattern\fP ] \fBuncolor\fP index \fIpattern\fP [ \fIpattern\fP ... ] .fi .IP @@ -246,6 +246,10 @@ messages by pattern. Valid colors include: .BR white ", " black ", " green ", " magenta ", " blue ", " .BR cyan ", " yellow ", " red ", " default ", " color\fIN\fP . +.IP +Valid attributes include: +.BR none ", " bold ", " underline ", " +.BR reverse ", and " standout . .PP .nf \fBmono\fP \fIobject\fP \fIattribute\fP [ \fIregexp\fP ] @@ -253,9 +257,7 @@ Valid colors include: .fi .IP For terminals which don't support color, you can still assign -attributes to objects. Valid attributes include: -.BR none ", " bold ", " underline ", " -.BR reverse ", and " standout . +attributes to objects. .TP [\fBun\fP]\fBignore\fP \fIpattern\fP [ \fIpattern\fP ... ] The \fBignore\fP command permits you to specify header fields which