]> granicus.if.org Git - neomutt/commitdiff
Liviu Daia's smiley patch.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 23 Sep 1998 20:01:04 +0000 (20:01 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 23 Sep 1998 20:01:04 +0000 (20:01 +0000)
init.h
mutt_regex.h
pager.c

diff --git a/init.h b/init.h
index 4f360f5dcf1ec729dae355c97ceccc9b699e39c1..ff429bceef43ff48c198909188e507f9791f52da 100644 (file)
--- a/init.h
+++ b/init.h
@@ -245,6 +245,7 @@ struct option_t MuttVars[] = {
   { "signature",       DT_PATH, R_NONE, UL &Signature, UL "~/.signature" },
   { "simple_search",   DT_STR,  R_NONE, UL &SimpleSearch, UL "~f %s | ~s %s" },
   { "smart_wrap",      DT_BOOL, R_PAGER, OPTWRAP, 1 },
+  { "smileys",         DT_RX,   R_PAGER, UL &Smileys, UL "(>From )|(:[-^]?[][)(><}{|/DP])" },
   { "sort",            DT_SORT, R_INDEX|R_RESORT, UL &Sort, SORT_DATE },
   { "sort_alias",      DT_SORT|DT_SORT_ALIAS,  R_NONE, UL &SortAlias, SORT_ALIAS },
   { "sort_aux",                DT_SORT, R_INDEX|R_RESORT_BOTH, UL &SortAux, SORT_DATE },
index 27133becc06cb00d58ecf0439f1d8ccee95977bb..fa02ba3f4e46044cfc4edb9c458e85729dc8763e 100644 (file)
@@ -50,5 +50,6 @@ WHERE REGEXP Alternates;
 WHERE REGEXP Mask;
 WHERE REGEXP QuoteRegexp;
 WHERE REGEXP ReplyRegexp;
+WHERE REGEXP Smileys;
 
 #endif /* MUTT_REGEX_H */
diff --git a/pager.c b/pager.c
index f0fd4b3b36a8a90ee1754562cf0262487dd0a8e0..8e240ebe8d5a8ff471a0482630cca96b5f9e7d71 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -667,12 +667,12 @@ classify_quote (struct q_class_t **QuoteList, const char *qptr,
 }
 
 static void
-resolve_types (const char *buf, struct line_t *lineInfo, int n, int last,
+resolve_types (char *buf, struct line_t *lineInfo, int n, int last,
                struct q_class_t **QuoteList, int *q_level, int *force_redraw,
                int q_classify)
 {
   COLOR_LINE *color_line;
-  regmatch_t pmatch[1];
+  regmatch_t pmatch[1], smatch[1];
   int found, offset, null_rx, i;
 
   if (n == 0 || ISHEADER (lineInfo[n-1].type))
@@ -724,14 +724,43 @@ resolve_types (const char *buf, struct line_t *lineInfo, int n, int last,
   }
   else if (check_sig (buf, lineInfo, n - 1) == 0)
     lineInfo[n].type = MT_COLOR_SIGNATURE;
-  else if (regexec ((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0 &&
-           strncmp (buf, ">From ", 6))
+  else if (regexec ((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0)
   {
-    if (q_classify && lineInfo[n].quote == NULL)
-      lineInfo[n].quote = classify_quote (QuoteList, buf + pmatch[0].rm_so,
-                            pmatch[0].rm_eo - pmatch[0].rm_so,
-                            force_redraw, q_level);
-     lineInfo[n].type = MT_COLOR_QUOTED;
+    if (regexec ((regex_t *) Smileys.rx, buf, 1, smatch, 0) == 0)
+    {
+      if (smatch[0].rm_so > 0)
+      {
+       char c;
+
+       /* hack to avoid making an extra copy of buf */
+       c = buf[smatch[0].rm_so];
+       buf[smatch[0].rm_so] = 0;
+
+       if (regexec ((regex_t *) QuoteRegexp.rx, buf, 1, pmatch, 0) == 0)
+       {
+         if (q_classify && lineInfo[n].quote == NULL)
+           lineInfo[n].quote = classify_quote (QuoteList,
+                                 buf + pmatch[0].rm_so,
+                                 pmatch[0].rm_eo - pmatch[0].rm_so,
+                                 force_redraw, q_level);
+         lineInfo[n].type = MT_COLOR_QUOTED;
+       }
+       else
+         lineInfo[n].type = MT_COLOR_NORMAL;
+
+       buf[smatch[0].rm_so] = c;
+      }
+      else
+       lineInfo[n].type = MT_COLOR_NORMAL;
+    }
+    else
+    {
+      if (q_classify && lineInfo[n].quote == NULL)
+       lineInfo[n].quote = classify_quote (QuoteList, buf + pmatch[0].rm_so,
+                             pmatch[0].rm_eo - pmatch[0].rm_so,
+                             force_redraw, q_level);
+      lineInfo[n].type = MT_COLOR_QUOTED;
+    }
   }
   else
     lineInfo[n].type = MT_COLOR_NORMAL;