]> granicus.if.org Git - neomutt/commitdiff
Add color commands for the compose menu headers and security status. (closes #3915).
authorKevin McCarthy <kevin@8t8.us>
Thu, 4 May 2017 01:52:54 +0000 (18:52 -0700)
committerKevin McCarthy <kevin@8t8.us>
Thu, 4 May 2017 01:52:54 +0000 (18:52 -0700)
Add "color compose header" to color the From/To/Subject/etc fields in
the compose menu.

Add "color compose security_encrypt/sign/both/none" to color the
security status of the message.

color.c
compose.c
doc/manual.xml.head
mutt_curses.h

diff --git a/color.c b/color.c
index 073b6166eda02ace5b22407a8ae9876012c50383..df9cd4714b2d6c950878485d21ceb096eda474a9 100644 (file)
--- a/color.c
+++ b/color.c
@@ -106,6 +106,16 @@ static const struct mapping_t Fields[] =
   { NULL,              0 }
 };
 
+static const struct mapping_t ComposeFields[] =
+{
+  { "header",               MT_COLOR_COMPOSE_HEADER },
+  { "security_encrypt",     MT_COLOR_COMPOSE_SECURITY_ENCRYPT },
+  { "security_sign",        MT_COLOR_COMPOSE_SECURITY_SIGN },
+  { "security_both",        MT_COLOR_COMPOSE_SECURITY_BOTH },
+  { "security_none",        MT_COLOR_COMPOSE_SECURITY_NONE },
+  { NULL,                   0 }
+};
+
 #define COLOR_QUOTE_INIT       8
 
 static COLOR_LINE *mutt_new_color_line (void)
@@ -622,6 +632,22 @@ parse_object(BUFFER *buf, BUFFER *s, int *o, int *ql, BUFFER *err)
     
     *o = MT_COLOR_QUOTED;
   }
+  else if (!ascii_strcasecmp(buf->data, "compose"))
+  {
+    if (!MoreArgs(s))
+    {
+      strfcpy(err->data, _("Missing arguments."), err->dsize);
+      return -1;
+    }
+
+    mutt_extract_token(buf, s, 0);
+
+    if ((*o = mutt_getvaluebyname (buf->data, ComposeFields)) == -1)
+    {
+      snprintf (err->data, err->dsize, _("%s: no such object"), buf->data);
+      return (-1);
+    }
+  }
   else if ((*o = mutt_getvaluebyname (buf->data, Fields)) == -1)
   {
     snprintf (err->data, err->dsize, _("%s: no such object"), buf->data);
index 6893ee00405b7405544fe7adcc36ce15b2da9409..386e330040dde9c53682bbb37f712ca53b2077da 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -110,7 +110,9 @@ static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
 
 static void redraw_crypt_lines (HEADER *msg)
 {
+  SETCOLOR (MT_COLOR_COMPOSE_HEADER);
   mutt_window_mvprintw (MuttIndexWindow, HDR_CRYPT, 0, TITLE_FMT, "Security: ");
+  NORMAL_COLOR;
 
   if ((WithCrypto & (APPLICATION_PGP | APPLICATION_SMIME)) == 0)
   {
@@ -119,13 +121,26 @@ static void redraw_crypt_lines (HEADER *msg)
   }
 
   if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN))
+  {
+    SETCOLOR (MT_COLOR_COMPOSE_SECURITY_BOTH);
     addstr (_("Sign, Encrypt"));
+  }
   else if (msg->security & ENCRYPT)
+  {
+    SETCOLOR (MT_COLOR_COMPOSE_SECURITY_ENCRYPT);
     addstr (_("Encrypt"));
+  }
   else if (msg->security & SIGN)
+  {
+    SETCOLOR (MT_COLOR_COMPOSE_SECURITY_SIGN);
     addstr (_("Sign"));
+  }
   else
+  {
+    SETCOLOR (MT_COLOR_COMPOSE_SECURITY_NONE);
     addstr (_("None"));
+  }
+  NORMAL_COLOR;
 
   if ((msg->security & (ENCRYPT | SIGN)))
   {
@@ -150,20 +165,32 @@ static void redraw_crypt_lines (HEADER *msg)
 
   if ((WithCrypto & APPLICATION_PGP)
       && (msg->security & APPLICATION_PGP) && (msg->security & SIGN))
-    printw (TITLE_FMT "%s", _("sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
+  {
+    SETCOLOR (MT_COLOR_COMPOSE_HEADER);
+    printw (TITLE_FMT, _("sign as: "));
+    NORMAL_COLOR;
+    printw ("%s", PgpSignAs ? PgpSignAs : _("<default>"));
+  }
 
   if ((WithCrypto & APPLICATION_SMIME)
-      && (msg->security & APPLICATION_SMIME) && (msg->security & SIGN)) {
-      printw (TITLE_FMT "%s", _("sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
+      && (msg->security & APPLICATION_SMIME) && (msg->security & SIGN))
+  {
+    SETCOLOR (MT_COLOR_COMPOSE_HEADER);
+    printw (TITLE_FMT, _("sign as: "));
+    NORMAL_COLOR;
+    printw ("%s", SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
   }
 
   if ((WithCrypto & APPLICATION_SMIME)
       && (msg->security & APPLICATION_SMIME)
       && (msg->security & ENCRYPT)
       && SmimeCryptAlg
-      && *SmimeCryptAlg) {
-    mutt_window_mvprintw (MuttIndexWindow, HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
-               NONULL(SmimeCryptAlg));
+      && *SmimeCryptAlg)
+  {
+    SETCOLOR (MT_COLOR_COMPOSE_HEADER);
+    mutt_window_mvprintw (MuttIndexWindow, HDR_CRYPTINFO, 40, "%s", _("Encrypt with: "));
+    NORMAL_COLOR;
+    printw ("%s", NONULL(SmimeCryptAlg));
   }
 }
 
@@ -175,8 +202,10 @@ static void redraw_mix_line (LIST *chain)
   int c;
   char *t;
 
+  SETCOLOR (MT_COLOR_COMPOSE_HEADER);
   /* L10N: "Mix" refers to the MixMaster chain for anonymous email */
   mutt_window_mvprintw (MuttIndexWindow, HDR_MIX, 0, TITLE_FMT, _("Mix: "));
+  NORMAL_COLOR;
 
   if (!chain)
   {
@@ -243,7 +272,9 @@ static void draw_envelope_addr (int line, ADDRESS *addr)
 
   buf[0] = 0;
   rfc822_write_address (buf, sizeof (buf), addr, 1);
+  SETCOLOR (MT_COLOR_COMPOSE_HEADER);
   mutt_window_mvprintw (MuttIndexWindow, line, 0, TITLE_FMT, Prompts[line]);
+  NORMAL_COLOR;
   mutt_paddstr (W, buf);
 }
 
@@ -253,10 +284,17 @@ static void draw_envelope (HEADER *msg, char *fcc)
   draw_envelope_addr (HDR_TO, msg->env->to);
   draw_envelope_addr (HDR_CC, msg->env->cc);
   draw_envelope_addr (HDR_BCC, msg->env->bcc);
+
+  SETCOLOR (MT_COLOR_COMPOSE_HEADER);
   mutt_window_mvprintw (MuttIndexWindow, HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT]);
+  NORMAL_COLOR;
   mutt_paddstr (W, NONULL (msg->env->subject));
+
   draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to);
+
+  SETCOLOR (MT_COLOR_COMPOSE_HEADER);
   mutt_window_mvprintw (MuttIndexWindow, HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC]);
+  NORMAL_COLOR;
   mutt_paddstr (W, fcc);
 
   if (WithCrypto)
index 2895481110f8ab304b6835b2ebc6eaea43bb9917..9045d1e5c0a710cdbde808e5957df6f721beacfe 100644 (file)
@@ -2664,6 +2664,20 @@ silently truncated at the screen width, and are not wrapped.
 <replaceable class="parameter">pattern</replaceable>
 </arg>
 
+<command>color</command>
+<arg choice="plain">
+<option>compose</option>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">composeobject</replaceable>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">foreground</replaceable>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">background</replaceable>
+</arg>
+
 <command>uncolor</command>
 <group choice="req">
 <arg choice="plain">
@@ -2727,6 +2741,18 @@ patterns.
 <listitem><para>underline (highlighting underlined patterns in the body of messages)</para></listitem>
 </itemizedlist>
 
+<para>
+<emphasis>composeobject</emphasis> can be one of:
+</para>
+
+<itemizedlist>
+<listitem><para>header</para></listitem>
+<listitem><para>security_encrypt</para></listitem>
+<listitem><para>security_sign</para></listitem>
+<listitem><para>security_both</para></listitem>
+<listitem><para>security_none</para></listitem>
+</itemizedlist>
+
 <para>
 <emphasis>foreground</emphasis> and <emphasis>background</emphasis> can
 be one of the following:
@@ -2841,6 +2867,17 @@ command. Usage:
 <replaceable class="parameter">pattern</replaceable>
 </arg>
 
+<command>mono</command>
+<arg choice="plain">
+<option>compose</option>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">composeobject</replaceable>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
+
 <command>unmono</command>
 <group choice="req">
 <arg choice="plain">
@@ -2864,8 +2901,9 @@ command. Usage:
 </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> and <emphasis>composeobject</emphasis>,
+see the <command>color</command> command. <emphasis>attribute</emphasis>
+can be one of the following:
 </para>
 
 <itemizedlist>
@@ -9502,6 +9540,20 @@ The following are the commands understood by Mutt:
 <replaceable class="parameter">pattern</replaceable>
 </arg>
 
+<command><link linkend="color">color</link></command>
+<arg choice="plain">
+<option>compose</option>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">composeobject</replaceable>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">foreground</replaceable>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">background</replaceable>
+</arg>
+
 <command><link linkend="color">uncolor</link></command>
 <group choice="req">
 <arg choice="plain">
@@ -9845,6 +9897,17 @@ The following are the commands understood by Mutt:
 <replaceable class="parameter">pattern</replaceable>
 </arg>
 
+<command><link linkend="mono">mono</link></command>
+<arg choice="plain">
+<option>compose</option>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">composeobject</replaceable>
+</arg>
+<arg choice="plain">
+<replaceable class="parameter">attribute</replaceable>
+</arg>
+
 <command><link linkend="mono">unmono</link></command>
 <group choice="req">
 <arg choice="plain">
index 01faa1454ca24865056084788c72e677d1d9f63f..7373d542fa2e640533fcdeda6ab0bfbcd46f712f 100644 (file)
@@ -132,6 +132,11 @@ enum
   MT_COLOR_SB_INDICATOR,
   MT_COLOR_SB_SPOOLFILE,
 #endif
+  MT_COLOR_COMPOSE_HEADER,
+  MT_COLOR_COMPOSE_SECURITY_ENCRYPT,
+  MT_COLOR_COMPOSE_SECURITY_SIGN,
+  MT_COLOR_COMPOSE_SECURITY_BOTH,
+  MT_COLOR_COMPOSE_SECURITY_NONE,
   MT_COLOR_MAX
 };