Syntax highlight improvements, patches by Jakub Kicinski (slightly
authorwwp <subscript@free.fr>
Fri, 27 Sep 2019 10:09:22 +0000 (12:09 +0200)
committerwwp <subscript@free.fr>
Fri, 27 Sep 2019 10:09:22 +0000 (12:09 +0200)
adapted to make use of the account_sigsep_matchlist API):
- when '-p' option is used ' @@' can be followed by function name.
- detect git patch in body part.
Added new contributor to authors list.
Fix bug 4130.

src/gtk/authors.h
src/textview.c
src/textview.h

index 310d9fd..6c21c31 100644 (file)
@@ -328,5 +328,6 @@ static char *CONTRIBS_LIST[] = {
 "Gál Zoltán",
 "Marien Zwart",
 "Martin Zwickel",
+"Jakub Kiciński",
 NULL
 };
index d707a87..cdcdd10 100644 (file)
@@ -1036,6 +1036,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
        textview->is_in_signature = FALSE;
        textview->is_diff = FALSE;
        textview->is_attachment = FALSE;;
+       textview->is_in_git_patch = FALSE;
 
        procmime_decode_content(mimeinfo);
 
@@ -1609,7 +1610,7 @@ static void textview_write_line(TextView *textview, const gchar *str,
        }
 
        if (prefs_common.enable_color) {
-               if (textview->is_diff) {
+               if (textview->is_diff || textview->is_in_git_patch) {
                        if (strncmp(buf, "+++ ", 4) == 0)
                                fg_color = "diff-add-file";
                        else if (buf[0] == '+')
@@ -1619,13 +1620,21 @@ static void textview_write_line(TextView *textview, const gchar *str,
                        else if (buf[0] == '-')
                                fg_color = "diff-del";
                        else if (strncmp(buf, "@@ ", 3) == 0 &&
-                                       strcmp(buf+strlen(buf)-4, " @@\n") == 0)
+                                strstr(&buf[3], " @@"))
                                fg_color = "diff-hunk";
-               } else if (account_sigsep_matchlist_str_found(buf,"%s\n")
+
+                       if (account_signatures_matchlist_nchar_found(buf, "%s\n")
+                               textview->is_in_git_patch = FALSE;
+                               textview->is_in_signature = TRUE;
+                               fg_color = "signature";
+                       }
+               } else if (account_sigsep_matchlist_str_found(buf, "%s\n")
                                || account_sigsep_matchlist_str_found(buf, "- %s\n")
                                || textview->is_in_signature) {
                        fg_color = "signature";
                        textview->is_in_signature = TRUE;
+               } else if (strncmp(buf, "diff --git ", 11) == 0) {
+                       textview->is_in_git_patch = TRUE;
                }
        }
 
index 35393a2..71fc914 100644 (file)
@@ -67,7 +67,8 @@ struct _TextView
        gboolean is_in_signature;
        gboolean is_diff;
        gboolean is_attachment;
-       
+       gboolean is_in_git_patch;
+
        GSList *uri_list;
        gint body_pos;