]> granicus.if.org Git - neomutt/commitdiff
Add attributes support on color declarations
authorMuh Muhten <muh.muhten@gmail.com>
Tue, 15 Jan 2019 06:17:02 +0000 (01:17 -0500)
committerRichard Russon <rich@flatcap.org>
Wed, 20 Feb 2019 00:55:01 +0000 (00:55 +0000)
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.

Co-authored-by: Richard Russon <rich@flatcap.org>
color.c
doc/manual.xml.head
doc/neomuttrc.man.head

diff --git a/color.c b/color.c
index 89fc61d1ec496551f49c1b6f611142aea0c6cc67..6aa863880c24805bc9b397d982d8f072b3d27b6b 100644 (file)
--- a/color.c
+++ b/color.c
@@ -903,16 +903,35 @@ typedef int (*parser_callback_t)(struct Buffer *buf, struct Buffer *s, int *fg,
 static int parse_color_pair(struct Buffer *buf, struct Buffer *s, int *fg,
                             int *bg, int *attr, struct Buffer *err)
 {
-  if (!MoreArgs(s))
+  while (true)
   {
-    mutt_buffer_printf(err, _("%s: too few arguments"), "color");
-    return -1;
-  }
+    if (!MoreArgs(s))
+    {
+      mutt_buffer_printf(err, _("%s: too few arguments"), "color");
+      return -1;
+    }
 
-  mutt_extract_token(buf, s, 0);
+    mutt_extract_token(buf, s, 0);
 
-  if (parse_color_name(buf->data, fg, attr, true, err) != 0)
-    return -1;
+    if (mutt_str_strcasecmp("bold", buf->data) == 0)
+      *attr |= A_BOLD;
+    else if (mutt_str_strcasecmp("underline", buf->data) == 0)
+      *attr |= A_UNDERLINE;
+    else if (mutt_str_strcasecmp("none", buf->data) == 0)
+      *attr = A_NORMAL;
+    else if (mutt_str_strcasecmp("reverse", buf->data) == 0)
+      *attr |= A_REVERSE;
+    else if (mutt_str_strcasecmp("standout", buf->data) == 0)
+      *attr |= A_STANDOUT;
+    else if (mutt_str_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, true, err) != 0)
+        return -1;
+      break;
+    }
+  }
 
   if (!MoreArgs(s))
   {
index e84a09251ccb1bf76991c02a73ba4c17835c1e62..2a7ee428f485a4b23edf6f65066430c9d6811b8f 100644 (file)
@@ -4349,6 +4349,9 @@ folder-hook work "set sort=threads"
         <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>
@@ -4364,6 +4367,9 @@ folder-hook work "set sort=threads"
             <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>
@@ -4377,6 +4383,9 @@ folder-hook work "set sort=threads"
         <arg choice="plain">
           <option>index-object</option>
         </arg>
+        <arg choice="opt" rep="repeat">
+          <replaceable class="parameter">attribute</replaceable>
+        </arg>
         <arg choice="plain">
           <replaceable class="parameter">foreground</replaceable>
         </arg>
@@ -4393,6 +4402,9 @@ folder-hook work "set sort=threads"
         <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>
@@ -4681,6 +4693,26 @@ folder-hook work "set sort=threads"
           </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:
@@ -4852,36 +4884,9 @@ export COLORFGBG
         </group>
       </cmdsynopsis>
       <para>
-        For <emphasis>object</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">
@@ -17645,6 +17650,9 @@ neomutt mailto:some@one.org?subject=test&amp;cc=other@one.org
             <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>
@@ -17662,6 +17670,9 @@ neomutt mailto:some@one.org?subject=test&amp;cc=other@one.org
                 <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>
@@ -17677,6 +17688,9 @@ neomutt mailto:some@one.org?subject=test&amp;cc=other@one.org
             <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>
index f360bf46e63e8f55a5d6364cde8146b00e754f67..17fa1db91f300d04415467cd7f8dff14a12d94d7 100644 (file)
@@ -232,10 +232,10 @@ configuration file.
 .
 .PP
 .nf
-\fBcolor\fP \fIobject\fP \fIforeground\fP \fIbackground\fP
-\fBcolor\fP { header | body } \fIforeground\fP \fIbackground\fP \fIregex\fP
-\fBcolor\fP index-object \fIforeground\fP \fIbackground\fP \fIpattern\fP
-\fBcolor\fP compose \fIcomposeobject\fP \fIforeground\fP \fIbackground\fP
+\fBcolor\fP \fIobject\fP [ \fIattribute\fP ... ] \fIforeground\fP \fIbackground\fP
+\fBcolor\fP { header | body } [ \fIattribute\fP ... ] \fIforeground\fP \fIbackground\fP \fIregex\fP
+\fBcolor\fP index-object [ \fIattribute\fP ... ] \fIforeground\fP \fIbackground\fP \fIpattern\fP
+\fBcolor\fP compose \fIcomposeobject\fP [ \fIattribute\fP ... ] \fIforeground\fP \fIbackground\fP
 \fBuncolor\fP { index-object | header | body } { \fB*\fP | \fIpattern\fP ... }
 .fi
 .IP
@@ -305,6 +305,10 @@ Valid colors include:
 .BR white ", "
 .BR color\fIN\fP "."
 .IP
+Valid attributes include:
+.BR none ", " bold ", " underline ", "
+.BR reverse ", and " standout .
+IP
 The \fBuncolor\fP command can be applied to the index, header and body objects
 only. It removes entries from the list. You must specify the same \fIpattern\fP
 specified in the \fBcolor\fP command for it to be removed. The pattern
@@ -565,9 +569,8 @@ a global \fIneomuttrc\fP.
 \fBunmono\fP { index-object | header | body } { \fB*\fP | \fIpattern\fP ... }
 .fi
 .IP
-For terminals which don't support color, you can still assign \fIattribute\fPs
-to objects (see \fBcolor\fP command above). Valid attributes include:
-.BR none ", " bold ", " underline ", " reverse ", and " standout "."
+For terminals which don't support color, you can still assign
+attributes to objects.
 .
 .PP
 .nf