]> granicus.if.org Git - mutt/commitdiff
Add attributes support on color declarations
authorMuh Muhten <muh.muhten@gmail.com>
Tue, 15 Jan 2019 06:17:02 +0000 (01:17 -0500)
committerMuh Muhten <muh.muhten@gmail.com>
Thu, 17 Jan 2019 10:30:09 +0000 (05:30 -0500)
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.

color.c
doc/manual.xml.head
doc/muttrc.man.head

diff --git a/color.c b/color.c
index fafee92943c7633b3d9587f7533f52c80f1fc7aa..992b7c1139c259f902c93d6e110ec28a02c0fbc2 100644 (file)
--- 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))
   {
index 252bdf44d5c89e591ab14310b1eaa79205d22c58..cb22736aa6c0e0907efc9b3a5eb54991ad77b5c7 100644 (file)
@@ -2659,6 +2659,9 @@ silently truncated at the screen width, and are not wrapped.
 <arg choice="plain">
 <replaceable class="parameter">object</replaceable>
 </arg>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
@@ -2675,6 +2678,9 @@ silently truncated at the screen width, and are not wrapped.
 <option>body</option>
 </arg>
 </group>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
@@ -2689,6 +2695,9 @@ silently truncated at the screen width, and are not wrapped.
 <arg choice="plain">
 <option>index</option>
 </arg>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
@@ -2706,6 +2715,9 @@ silently truncated at the screen width, and are not wrapped.
 <arg choice="plain">
 <replaceable class="parameter">composeobject</replaceable>
 </arg>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
@@ -2796,6 +2808,18 @@ When set, color is applied only to the exact text matched by
 <listitem><para>security_none</para></listitem>
 </itemizedlist>
 
+<para>
+<emphasis>attribute</emphasis> can be one of the following:
+</para>
+
+<itemizedlist>
+<listitem><para>none</para></listitem>
+<listitem><para>bold</para></listitem>
+<listitem><para>underline</para></listitem>
+<listitem><para>reverse</para></listitem>
+<listitem><para>standout</para></listitem>
+</itemizedlist>
+
 <para>
 <emphasis>foreground</emphasis> and <emphasis>background</emphasis> can
 be one of the following:
@@ -2948,19 +2972,9 @@ command. Usage:
 </cmdsynopsis>
 
 <para>
-For <emphasis>object</emphasis> and <emphasis>composeobject</emphasis>,
-see the <command>color</command> command. <emphasis>attribute</emphasis>
-can be one of the following:
+For <emphasis>object</emphasis>, <emphasis>composeobject</emphasis>, and
+<emphasis>attribute</emphasis>, see the <command>color</command> command.
 </para>
-
-<itemizedlist>
-<listitem><para>none</para></listitem>
-<listitem><para>bold</para></listitem>
-<listitem><para>underline</para></listitem>
-<listitem><para>reverse</para></listitem>
-<listitem><para>standout</para></listitem>
-</itemizedlist>
-
 </sect1>
 
 <sect1 id="msg-hdr-display">
@@ -9799,6 +9813,9 @@ The following are the commands understood by Mutt:
 <arg choice="plain">
 <replaceable class="parameter">object</replaceable>
 </arg>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
@@ -9815,6 +9832,9 @@ The following are the commands understood by Mutt:
 <option>body</option>
 </arg>
 </group>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
@@ -9829,6 +9849,9 @@ The following are the commands understood by Mutt:
 <arg choice="plain">
 <option>index</option>
 </arg>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
@@ -9846,6 +9869,9 @@ The following are the commands understood by Mutt:
 <arg choice="plain">
 <replaceable class="parameter">composeobject</replaceable>
 </arg>
+<arg choice="opt" rep="repeat">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
 <arg choice="plain">
 <replaceable class="parameter">foreground</replaceable>
 </arg>
index 92b40935ee311c0cbfcd2a8aa4fef48c81a4c449..eb31cd05e1872ef9723c045950bd11a5198cdf9d 100644 (file)
@@ -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