Projects STRLCPY neomutt Commits 8459f6d0
🤬
  • merge: Extend color objects to support patterns

    * Extend color objects to support pattterns
     * Expose mutt_color_has_pattern
     * sort things alphabetically
     * Fix enum doc
     * Update docs
     * Add index_tag to feature page
     * docs: update index pattern refs
  • Loading...
  • Richard Russon committed 2 years ago
    8459f6d0
  • ■ ■ ■ ■ ■ ■
    color/color.c
    skipped 92 lines
    93 93   notify_set_parent(ColorsNotify, NeoMutt->notify);
    94 94  }
    95 95   
     96 +/**
     97 + * mutt_color_has_pattern - Check if a color object supports a regex pattern
     98 + *
     99 + * @param cid Object type, e.g. #MT_COLOR_TILDE
     100 + * @retval true The color object supports patterns
     101 + */
     102 +bool mutt_color_has_pattern(enum ColorId cid)
     103 +{
     104 + return (cid == MT_COLOR_ATTACH_HEADERS) || (cid == MT_COLOR_BODY) ||
     105 + (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_INDEX) ||
     106 + (cid == MT_COLOR_INDEX_AUTHOR) || (cid == MT_COLOR_INDEX_COLLAPSED) ||
     107 + (cid == MT_COLOR_INDEX_DATE) || (cid == MT_COLOR_INDEX_FLAGS) ||
     108 + (cid == MT_COLOR_INDEX_LABEL) || (cid == MT_COLOR_INDEX_NUMBER) ||
     109 + (cid == MT_COLOR_INDEX_SIZE) || (cid == MT_COLOR_INDEX_SUBJECT) ||
     110 + (cid == MT_COLOR_INDEX_TAG) || (cid == MT_COLOR_INDEX_TAGS) ||
     111 + (cid == MT_COLOR_STATUS);
     112 +}
     113 + 
  • ■ ■ ■ ■ ■ ■
    color/color.h
    skipped 72 lines
    73 73   MT_COLOR_TREE, ///< Index: tree-drawing characters
    74 74   MT_COLOR_UNDERLINE, ///< Underlined text
    75 75   MT_COLOR_WARNING, ///< Warning messages
    76  - /* please no non-MT_COLOR_INDEX objects after this point */
    77  - MT_COLOR_INDEX, ///< Index: default colour (takes a pattern)
    78  - MT_COLOR_INDEX_AUTHOR, ///< Index: author field (takes a pattern)
    79  - MT_COLOR_INDEX_FLAGS, ///< Index: flags field (takes a pattern)
    80  - MT_COLOR_INDEX_SUBJECT, ///< Index: subject field (takes a pattern)
    81  - MT_COLOR_INDEX_TAG, ///< Index: tag field (%g, takes a pattern)
    82  - /* below here - only index coloring stuff that doesn't have a pattern */
     76 + // Index colours which all take a pattern
     77 + MT_COLOR_INDEX, ///< Index: default colour
     78 + MT_COLOR_INDEX_AUTHOR, ///< Index: author field
    83 79   MT_COLOR_INDEX_COLLAPSED, ///< Index: number of messages in collapsed thread
    84 80   MT_COLOR_INDEX_DATE, ///< Index: date field
     81 + MT_COLOR_INDEX_FLAGS, ///< Index: flags field
    85 82   MT_COLOR_INDEX_LABEL, ///< Index: label field
    86 83   MT_COLOR_INDEX_NUMBER, ///< Index: index number
    87 84   MT_COLOR_INDEX_SIZE, ///< Index: size field
     85 + MT_COLOR_INDEX_SUBJECT, ///< Index: subject field
     86 + MT_COLOR_INDEX_TAG, ///< Index: tag field (%G)
    88 87   MT_COLOR_INDEX_TAGS, ///< Index: tags field (%g, %J)
    89 88   MT_COLOR_MAX,
    90 89  };
    skipped 11 lines
    102 101   
    103 102  void mutt_colors_init(void);
    104 103  void mutt_colors_cleanup(void);
     104 +bool mutt_color_has_pattern(enum ColorId cid);
    105 105   
    106 106  void colors_clear(void);
    107 107   
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    color/command.c
    skipped 464 lines
    465 465   return MUTT_CMD_SUCCESS;
    466 466   }
    467 467   
    468  - if ((cid != MT_COLOR_ATTACH_HEADERS) && (cid != MT_COLOR_BODY) &&
    469  - (cid != MT_COLOR_HEADER) && (cid != MT_COLOR_INDEX) && (cid != MT_COLOR_INDEX_AUTHOR) &&
    470  - (cid != MT_COLOR_INDEX_FLAGS) && (cid != MT_COLOR_INDEX_SUBJECT) &&
    471  - (cid != MT_COLOR_INDEX_TAG) && (cid != MT_COLOR_STATUS))
     468 + if (!mutt_color_has_pattern(cid))
    472 469   {
    473 470   color_debug(LL_DEBUG5, "simple\n");
    474 471   simple_color_reset(cid);
    475 472   return MUTT_CMD_SUCCESS;
    476  - }
    477  - 
    478  - if (!MoreArgs(s))
    479  - {
    480  - mutt_buffer_printf(err, _("%s: too few arguments"), uncolor ? "uncolor" : "unmono");
    481  - return MUTT_CMD_WARNING;
    482 473   }
    483 474   
    484 475   if (OptNoCurses)
    skipped 9 lines
    494 485   }
    495 486   
    496 487   bool changes = false;
     488 + if (!MoreArgs(s))
     489 + {
     490 + if (regex_colors_parse_uncolor(cid, NULL, uncolor))
     491 + return MUTT_CMD_SUCCESS;
     492 + else
     493 + return MUTT_CMD_ERROR;
     494 + }
     495 + 
    497 496   do
    498 497   {
    499 498   mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
    skipped 57 lines
    557 556   
    558 557   /* extract a regular expression if needed */
    559 558   
    560  - if ((cid == MT_COLOR_ATTACH_HEADERS) || (cid == MT_COLOR_BODY) ||
    561  - (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_INDEX) ||
    562  - (cid == MT_COLOR_INDEX_AUTHOR) || (cid == MT_COLOR_INDEX_FLAGS) ||
    563  - (cid == MT_COLOR_INDEX_SUBJECT) || (cid == MT_COLOR_INDEX_TAG))
     559 + if (mutt_color_has_pattern(cid))
    564 560   {
    565 561   color_debug(LL_DEBUG5, "regex needed\n");
    566  - if (!MoreArgs(s))
     562 + if (MoreArgs(s))
    567 563   {
    568  - mutt_buffer_printf(err, _("%s: too few arguments"), color ? "color" : "mono");
    569  - return MUTT_CMD_WARNING;
     564 + mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
    570 565   }
    571  - 
    572  - mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
     566 + else
     567 + {
     568 + mutt_buffer_strcpy(buf, ".*");
     569 + }
    573 570   }
    574 571   
    575 572   if (MoreArgs(s) && (cid != MT_COLOR_STATUS))
    skipped 139 lines
  • ■ ■ ■ ■ ■
    color/regex.c
    skipped 44 lines
    45 45  #include "regex4.h"
    46 46   
    47 47  // clang-format off
    48  -struct RegexColorList AttachList; ///< List of colours applied to the attachment headers
    49  -struct RegexColorList BodyList; ///< List of colours applied to the email body
    50  -struct RegexColorList HeaderList; ///< List of colours applied to the email headers
    51  -struct RegexColorList IndexAuthorList; ///< List of colours applied to the author in the index
    52  -struct RegexColorList IndexFlagsList; ///< List of colours applied to the flags in the index
    53  -struct RegexColorList IndexList; ///< List of default colours applied to the index
    54  -struct RegexColorList IndexSubjectList; ///< List of colours applied to the subject in the index
    55  -struct RegexColorList IndexTagList; ///< List of colours applied to tags in the index
    56  -struct RegexColorList StatusList; ///< List of colours applied to the status bar
     48 +struct RegexColorList AttachList; ///< List of colours applied to the attachment headers
     49 +struct RegexColorList BodyList; ///< List of colours applied to the email body
     50 +struct RegexColorList HeaderList; ///< List of colours applied to the email headers
     51 +struct RegexColorList IndexAuthorList; ///< List of colours applied to the author in the index
     52 +struct RegexColorList IndexCollapsedList; ///< List of colours applied to a collapsed thread in the index
     53 +struct RegexColorList IndexDateList; ///< List of colours applied to the date in the index
     54 +struct RegexColorList IndexFlagsList; ///< List of colours applied to the flags in the index
     55 +struct RegexColorList IndexLabelList; ///< List of colours applied to the label in the index
     56 +struct RegexColorList IndexList; ///< List of default colours applied to the index
     57 +struct RegexColorList IndexNumberList; ///< List of colours applied to the message number in the index
     58 +struct RegexColorList IndexSizeList; ///< List of colours applied to the size in the index
     59 +struct RegexColorList IndexSubjectList; ///< List of colours applied to the subject in the index
     60 +struct RegexColorList IndexTagList; ///< List of colours applied to tags in the index
     61 +struct RegexColorList IndexTagsList; ///< List of colours applied to the tags in the index
     62 +struct RegexColorList StatusList; ///< List of colours applied to the status bar
    57 63  // clang-format on
    58 64   
    59 65  /**
    skipped 6 lines
    66 72   STAILQ_INIT(&BodyList);
    67 73   STAILQ_INIT(&HeaderList);
    68 74   STAILQ_INIT(&IndexAuthorList);
     75 + STAILQ_INIT(&IndexCollapsedList);
     76 + STAILQ_INIT(&IndexDateList);
     77 + STAILQ_INIT(&IndexLabelList);
     78 + STAILQ_INIT(&IndexNumberList);
     79 + STAILQ_INIT(&IndexSizeList);
     80 + STAILQ_INIT(&IndexTagsList);
    69 81   STAILQ_INIT(&IndexFlagsList);
    70 82   STAILQ_INIT(&IndexList);
    71 83   STAILQ_INIT(&IndexSubjectList);
    skipped 12 lines
    84 96   regex_color_list_clear(&HeaderList);
    85 97   regex_color_list_clear(&IndexList);
    86 98   regex_color_list_clear(&IndexAuthorList);
     99 + regex_color_list_clear(&IndexCollapsedList);
     100 + regex_color_list_clear(&IndexDateList);
     101 + regex_color_list_clear(&IndexLabelList);
     102 + regex_color_list_clear(&IndexNumberList);
     103 + regex_color_list_clear(&IndexSizeList);
     104 + regex_color_list_clear(&IndexTagsList);
    87 105   regex_color_list_clear(&IndexFlagsList);
    88 106   regex_color_list_clear(&IndexSubjectList);
    89 107   regex_color_list_clear(&IndexTagList);
    skipped 87 lines
    177 195   return &IndexList;
    178 196   case MT_COLOR_INDEX_AUTHOR:
    179 197   return &IndexAuthorList;
     198 + case MT_COLOR_INDEX_COLLAPSED:
     199 + return &IndexCollapsedList;
     200 + case MT_COLOR_INDEX_DATE:
     201 + return &IndexDateList;
    180 202   case MT_COLOR_INDEX_FLAGS:
    181 203   return &IndexFlagsList;
     204 + case MT_COLOR_INDEX_LABEL:
     205 + return &IndexLabelList;
     206 + case MT_COLOR_INDEX_NUMBER:
     207 + return &IndexNumberList;
     208 + case MT_COLOR_INDEX_SIZE:
     209 + return &IndexSizeList;
    182 210   case MT_COLOR_INDEX_SUBJECT:
    183 211   return &IndexSubjectList;
    184 212   case MT_COLOR_INDEX_TAG:
    185 213   return &IndexTagList;
     214 + case MT_COLOR_INDEX_TAGS:
     215 + return &IndexTagsList;
    186 216   case MT_COLOR_STATUS:
    187 217   return &StatusList;
    188 218   default:
    skipped 144 lines
    333 363   break;
    334 364   case MT_COLOR_INDEX:
    335 365   case MT_COLOR_INDEX_AUTHOR:
     366 + case MT_COLOR_INDEX_COLLAPSED:
     367 + case MT_COLOR_INDEX_DATE:
    336 368   case MT_COLOR_INDEX_FLAGS:
     369 + case MT_COLOR_INDEX_LABEL:
     370 + case MT_COLOR_INDEX_NUMBER:
     371 + case MT_COLOR_INDEX_SIZE:
    337 372   case MT_COLOR_INDEX_SUBJECT:
    338 373   case MT_COLOR_INDEX_TAG:
     374 + case MT_COLOR_INDEX_TAGS:
    339 375   sensitive = true;
    340 376   is_index = true;
    341 377   break;
    skipped 108 lines
  • ■ ■ ■ ■ ■ ■
    docs/manual.xml.head
    skipped 5193 lines
    5194 5194  uncolor prompt
    5195 5195  </screen>
    5196 5196   <para>
    5197  - Each of these objects will colour a certain expando in the index.
    5198  - See <link linkend="index-format">$index_format</link> for more details.
    5199  - </para>
    5200  - <table id="color-simple-index">
    5201  - <title>Simple Index Colours</title>
    5202  - <tgroup cols="2">
    5203  - <thead>
    5204  - <row>
    5205  - <entry>Colour Name</entry>
    5206  - <entry>Description</entry>
    5207  - </row>
    5208  - </thead>
    5209  - <tbody>
    5210  - <row>
    5211  - <entry>index_collapsed</entry>
    5212  - <entry>Number of messages in a collapsed thread, <literal>%M</literal></entry>
    5213  - </row>
    5214  - <row>
    5215  - <entry>index_date</entry>
    5216  - <entry>Date field, <literal>%d</literal> <literal>%D</literal> <literal>%{fmt}</literal> <literal>%[fmt]</literal> <literal>%(fmt)</literal></entry>
    5217  - </row>
    5218  - <row>
    5219  - <entry>index_label</entry>
    5220  - <entry>Message label, <literal>%y</literal> <literal>%Y</literal></entry>
    5221  - </row>
    5222  - <row>
    5223  - <entry>index_number</entry>
    5224  - <entry>Message number, <literal>%C</literal></entry>
    5225  - </row>
    5226  - <row>
    5227  - <entry>index_size</entry>
    5228  - <entry>Message size, <literal>%c</literal> <literal>%cr</literal> <literal>%l</literal></entry>
    5229  - </row>
    5230  - <row>
    5231  - <entry>index_tags</entry>
    5232  - <entry>Transformed message tags, <literal>%g</literal> <literal>%J</literal></entry>
    5233  - </row>
    5234  - </tbody>
    5235  - </tgroup>
    5236  - </table>
    5237  -<screen>
    5238  -color index_date green default
    5239  -</screen>
    5240  -<screen>
    5241  -uncolor index_date
    5242  -</screen>
    5243  - <para>
    5244 5197   These are sidebar objects.
    5245 5198   See <link linkend="sidebar-intro">Sidebar Intro</link> for more details.
    5246 5199   </para>
    skipped 238 lines
    5485 5438   <entry>Author in the index, %A %a %F %L %n</entry>
    5486 5439   </row>
    5487 5440   <row>
     5441 + <entry>index_collapsed</entry>
     5442 + <entry>pattern</entry>
     5443 + <entry>Number of messages in a collapsed thread, <literal>%M</literal></entry>
     5444 + </row>
     5445 + <row>
     5446 + <entry>index_date</entry>
     5447 + <entry>pattern</entry>
     5448 + <entry>Date field, <literal>%d</literal> <literal>%D</literal> <literal>%{fmt}</literal> <literal>%[fmt]</literal> <literal>%(fmt)</literal></entry>
     5449 + </row>
     5450 + <row>
    5488 5451   <entry>index_flags</entry>
    5489 5452   <entry>pattern</entry>
    5490 5453   <entry>Flags in the index, %S %Z</entry>
    5491 5454   </row>
    5492 5455   <row>
     5456 + <entry>index_label</entry>
     5457 + <entry>pattern</entry>
     5458 + <entry>Message label, <literal>%y</literal> <literal>%Y</literal></entry>
     5459 + </row>
     5460 + <row>
     5461 + <entry>index_number</entry>
     5462 + <entry>pattern</entry>
     5463 + <entry>Message number, <literal>%C</literal></entry>
     5464 + </row>
     5465 + <row>
     5466 + <entry>index_size</entry>
     5467 + <entry>pattern</entry>
     5468 + <entry>Message size, <literal>%c</literal> <literal>%cr</literal> <literal>%l</literal></entry>
     5469 + </row>
     5470 + <row>
    5493 5471   <entry>index_subject</entry>
    5494 5472   <entry>pattern</entry>
    5495 5473   <entry>Subject in the index, %s</entry>
    skipped 2 lines
    5498 5476   <entry>index_tag</entry>
    5499 5477   <entry>pattern</entry>
    5500 5478   <entry>Tags in the index, %G</entry>
     5479 + </row>
     5480 + <row>
     5481 + <entry>index_tags</entry>
     5482 + <entry>pattern</entry>
     5483 + <entry>Transformed message tags, <literal>%g</literal> <literal>%J</literal></entry>
    5501 5484   </row>
    5502 5485   <row>
    5503 5486   <entry>status</entry>
    skipped 9002 lines
    14506 14489   </para>
    14507 14490   <para>
    14508 14491   The index objects can be themed using the <literal>color</literal>
    14509  - command. Some objects require a pattern.
     14492 + command and an optional pattern. A missing pattern is equivalent to
     14493 + a match-all <literal>.*</literal> pattern.
    14510 14494   </para>
    14511 14495   
    14512 14496  <screen>
    14513  -color index-object foreground background
    14514  -color index-object foreground background pattern
     14497 +color index-object foreground background [pattern]
    14515 14498  </screen>
    14516 14499   
    14517 14500   <table id="table-index-color-colors">
    14518 14501   <title>Index Colors</title>
    14519  - <tgroup cols="3">
     14502 + <tgroup cols="2">
    14520 14503   <thead>
    14521 14504   <row>
    14522 14505   <entry>Object</entry>
    14523  - <entry>Pattern</entry>
    14524 14506   <entry>Highlights</entry>
    14525 14507   </row>
    14526 14508   </thead>
    14527 14509   <tbody>
    14528 14510   <row>
    14529 14511   <entry><literal>index</literal></entry>
    14530  - <entry>yes</entry>
    14531 14512   <entry>Entire index line</entry>
    14532 14513   </row>
    14533 14514   <row>
    14534 14515   <entry><literal>index_author</literal></entry>
    14535  - <entry>yes</entry>
    14536 14516   <entry>Author name, %A %a %F %L %n</entry>
    14537 14517   </row>
    14538 14518   <row>
    14539 14519   <entry><literal>index_collapsed</literal></entry>
    14540  - <entry>no</entry>
    14541 14520   <entry>Number of messages in a collapsed thread, %M</entry>
    14542 14521   </row>
    14543 14522   <row>
    14544 14523   <entry><literal>index_date</literal></entry>
    14545  - <entry>no</entry>
    14546 14524   <entry>Date field</entry>
    14547 14525   </row>
    14548 14526   <row>
    14549 14527   <entry><literal>index_flags</literal></entry>
    14550  - <entry>yes</entry>
    14551 14528   <entry>Message flags, %S %Z</entry>
    14552 14529   </row>
    14553 14530   <row>
    14554 14531   <entry><literal>index_label</literal></entry>
    14555  - <entry>no</entry>
    14556 14532   <entry>Message label, %y %Y</entry>
    14557 14533   </row>
    14558 14534   <row>
    14559 14535   <entry><literal>index_number</literal></entry>
    14560  - <entry>no</entry>
    14561 14536   <entry>Message number, %C</entry>
    14562 14537   </row>
    14563 14538   <row>
    14564 14539   <entry><literal>index_size</literal></entry>
    14565  - <entry>no</entry>
    14566 14540   <entry>Message size, %c %cr %l</entry>
    14567 14541   </row>
    14568 14542   <row>
    14569 14543   <entry><literal>index_subject</literal></entry>
    14570  - <entry>yes</entry>
    14571 14544   <entry>Subject, %s</entry>
     14545 + </row>
     14546 + <row>
     14547 + <entry><literal>index_tag</literal></entry>
     14548 + <entry>Nessage tags, <literal>%G</literal></entry>
     14549 + </row>
     14550 + <row>
     14551 + <entry><literal>index_tags</literal></entry>
     14552 + <entry>Transformed message tags, <literal>%g</literal> <literal>%J</literal></entry>
    14572 14553   </row>
    14573 14554   </tbody>
    14574 14555   </tgroup>
    skipped 1331 lines
    15906 15887   <sect2 id="custom-tags-colors">
    15907 15888   <title>Colors</title>
    15908 15889   <para>
    15909  - Adds these to index-color feature:
     15890 + Adds the objects, below, to index-color feature.
     15891 + The objects can take an optional pattern.
    15910 15892   </para>
    15911 15893   
    15912 15894   <table id="table-custom-tags-colors">
    15913 15895   <title>Index Colors</title>
    15914  - <tgroup cols="3">
     15896 + <tgroup cols="2">
    15915 15897   <thead>
    15916 15898   <row>
    15917 15899   <entry>Object</entry>
    15918  - <entry>Pattern</entry>
    15919 15900   <entry>Highlights</entry>
    15920 15901   </row>
    15921 15902   </thead>
    15922 15903   <tbody>
    15923 15904   <row>
    15924 15905   <entry><literal>index_tag</literal></entry>
    15925  - <entry>yes</entry>
    15926 15906   <entry>an individual message tag, %G, uses tag name</entry>
    15927 15907   </row>
    15928 15908   <row>
    15929 15909   <entry><literal>index_tags</literal></entry>
    15930  - <entry>no</entry>
    15931 15910   <entry>the transformed message tags, %g or %J</entry>
    15932 15911   </row>
    15933 15912   </tbody>
    skipped 57 lines
    15991 15970  <emphasis role="comment"># --------------------------------------------------------------------------</emphasis>
    15992 15971  <emphasis role="comment"># These symbols are added to the index-color feature:</emphasis>
    15993 15972  <emphasis role="comment"># an individual message tag, %G, uses tag name</emphasis>
    15994  -<emphasis role="comment"># this symbol uses a pattern</emphasis>
    15995 15973  color index_tag red white "inbox"
    15996 15974  <emphasis role="comment"># the transformed message tags, %g</emphasis>
    15997  -<emphasis role="comment"># this symbol does not use a pattern</emphasis>
    15998 15975  color index_tags green default
    15999 15976  <emphasis role="comment"># --------------------------------------------------------------------------</emphasis>
    16000 15977   
    skipped 3618 lines
    19619 19596   <arg choice="plain">
    19620 19597   <replaceable class="parameter">background</replaceable>
    19621 19598   </arg>
    19622  - <arg choice="plain">
     19599 + <arg choice="opt">
    19623 19600   <replaceable class="parameter">pattern</replaceable>
    19624 19601   </arg>
    19625 19602   <command>
    skipped 814 lines
  • ■ ■ ■ ■ ■ ■
    icommands.c
    skipped 387 lines
    388 388   }
    389 389   }
    390 390   
    391  - static const int regex_lists[] = {
    392  - MT_COLOR_ATTACH_HEADERS, MT_COLOR_BODY,
    393  - MT_COLOR_HEADER, MT_COLOR_INDEX,
    394  - MT_COLOR_INDEX_AUTHOR, MT_COLOR_INDEX_FLAGS,
    395  - MT_COLOR_INDEX_SUBJECT, MT_COLOR_INDEX_TAG,
    396  - MT_COLOR_STATUS, 0,
    397  - };
    398  - 
    399 391   int rl_count = 0;
    400  - for (int i = 0; regex_lists[i]; i++)
     392 + for (enum ColorId id = MT_COLOR_NONE; id != MT_COLOR_MAX; ++id)
    401 393   {
    402  - struct RegexColorList *rcl = regex_colors_get_list(regex_lists[i]);
     394 + if (!mutt_color_has_pattern(id))
     395 + {
     396 + continue;
     397 + }
     398 + 
     399 + struct RegexColorList *rcl = regex_colors_get_list(id);
    403 400   if (!STAILQ_EMPTY(rcl))
    404 401   rl_count++;
    405 402   }
    406 403   
    407 404   if (rl_count > 0)
    408 405   {
    409  - for (int i = 0; regex_lists[i]; i++)
     406 + for (enum ColorId id = MT_COLOR_NONE; id != MT_COLOR_MAX; ++id)
    410 407   {
    411  - struct RegexColorList *rcl = regex_colors_get_list(regex_lists[i]);
     408 + if (!mutt_color_has_pattern(id))
     409 + {
     410 + continue;
     411 + }
     412 + 
     413 + struct RegexColorList *rcl = regex_colors_get_list(id);
    412 414   if (STAILQ_EMPTY(rcl))
    413 415   continue;
    414 416   
    415  - const char *name = mutt_map_get_name(regex_lists[i], ColorFields);
     417 + const char *name = mutt_map_get_name(id, ColorFields);
    416 418   if (!name)
    417 419   continue;
    418 420   
    skipped 161 lines
  • ■ ■ ■ ■ ■ ■
    index/index.c
    skipped 274 lines
    275 275   const int cid = ev_c->cid;
    276 276   
    277 277   // MT_COLOR_MAX is sent on `uncolor *`
    278  - bool simple = (cid == MT_COLOR_INDEX_COLLAPSED) ||
    279  - (cid == MT_COLOR_INDEX_DATE) || (cid == MT_COLOR_INDEX_LABEL) ||
    280  - (cid == MT_COLOR_INDEX_NUMBER) || (cid == MT_COLOR_INDEX_SIZE) ||
    281  - (cid == MT_COLOR_INDEX_TAGS) || (cid == MT_COLOR_MAX);
    282  - 
    283  - bool lists = (cid == MT_COLOR_INDEX) || (cid == MT_COLOR_INDEX_AUTHOR) ||
    284  - (cid == MT_COLOR_INDEX_FLAGS) || (cid == MT_COLOR_INDEX_SUBJECT) ||
    285  - (cid == MT_COLOR_INDEX_TAG) || (cid == MT_COLOR_TREE) ||
    286  - (cid == MT_COLOR_NORMAL) || (cid == MT_COLOR_MAX);
    287  - 
    288  - // The changes aren't relevant to the index menu
    289  - if (!simple && !lists)
     278 + if (!((cid == MT_COLOR_INDEX) || (cid == MT_COLOR_INDEX_AUTHOR) ||
     279 + (cid == MT_COLOR_INDEX_COLLAPSED) || (cid == MT_COLOR_INDEX_DATE) ||
     280 + (cid == MT_COLOR_INDEX_FLAGS) || (cid == MT_COLOR_INDEX_LABEL) ||
     281 + (cid == MT_COLOR_INDEX_NUMBER) || (cid == MT_COLOR_INDEX_SIZE) ||
     282 + (cid == MT_COLOR_INDEX_SUBJECT) || (cid == MT_COLOR_INDEX_TAG) ||
     283 + (cid == MT_COLOR_INDEX_TAGS) || (cid == MT_COLOR_MAX) ||
     284 + (cid == MT_COLOR_NORMAL) || (cid == MT_COLOR_TREE)))
     285 + {
     286 + // The changes aren't relevant to the index menu
    290 287   return 0;
     288 + }
    291 289   
    292 290   struct MuttWindow *win = nc->global_data;
    293 291   struct MuttWindow *dlg = dialog_find(win);
    skipped 3 lines
    297 295   if (!m)
    298 296   return 0;
    299 297   
    300  - // Colour added/deleted from a list
    301  - if (lists)
     298 + // Force re-caching of index colours
     299 + for (int i = 0; i < m->msg_count; i++)
    302 300   {
    303  - // Force re-caching of index colours
    304  - for (int i = 0; i < m->msg_count; i++)
    305  - {
    306  - struct Email *e = m->emails[i];
    307  - if (!e)
    308  - break;
    309  - e->attr_color = NULL;
    310  - }
     301 + struct Email *e = m->emails[i];
     302 + if (!e)
     303 + break;
     304 + e->attr_color = NULL;
    311 305   }
    312 306   
    313 307   struct MuttWindow *panel_index = window_find_child(dlg, WT_INDEX);
    skipped 356 lines
  • ■ ■ ■ ■ ■ ■
    menu/draw.c
    skipped 53 lines
    54 54   */
    55 55  static struct AttrColor *get_color(int index, unsigned char *s)
    56 56  {
    57  - struct RegexColorList *rcl = NULL;
     57 + const int type = *s;
     58 + struct RegexColorList *rcl = regex_colors_get_list(type);
     59 + if (rcl == NULL)
     60 + {
     61 + return simple_color_get(type);
     62 + }
     63 + 
    58 64   struct RegexColor *np = NULL;
    59 65   struct Mailbox *m_cur = get_current_mailbox();
    60 66   struct Email *e = mutt_get_virt_email(m_cur, index);
    61  - int type = *s;
    62 67   
    63  - switch (type)
     68 + if (type == MT_COLOR_INDEX_TAG)
    64 69   {
    65  - case MT_COLOR_INDEX_AUTHOR:
    66  - rcl = regex_colors_get_list(MT_COLOR_INDEX_AUTHOR);
    67  - break;
    68  - case MT_COLOR_INDEX_FLAGS:
    69  - rcl = regex_colors_get_list(MT_COLOR_INDEX_FLAGS);
    70  - break;
    71  - case MT_COLOR_INDEX_SUBJECT:
    72  - rcl = regex_colors_get_list(MT_COLOR_INDEX_SUBJECT);
    73  - break;
    74  - case MT_COLOR_INDEX_TAG:
     70 + struct AttrColor *ac_merge = NULL;
     71 + STAILQ_FOREACH(np, rcl, entries)
    75 72   {
    76  - struct AttrColor *ac_merge = NULL;
    77  - STAILQ_FOREACH(np, regex_colors_get_list(MT_COLOR_INDEX_TAG), entries)
     73 + if (mutt_strn_equal((const char *) (s + 1), np->pattern, strlen(np->pattern)))
    78 74   {
    79  - if (mutt_strn_equal((const char *) (s + 1), np->pattern, strlen(np->pattern)))
    80  - {
    81  - ac_merge = merged_color_overlay(ac_merge, &np->attr_color);
    82  - continue;
    83  - }
    84  - const char *transform = mutt_hash_find(TagTransforms, np->pattern);
    85  - if (transform && mutt_strn_equal((const char *) (s + 1), transform, strlen(transform)))
    86  - {
    87  - ac_merge = merged_color_overlay(ac_merge, &np->attr_color);
    88  - }
     75 + ac_merge = merged_color_overlay(ac_merge, &np->attr_color);
     76 + continue;
     77 + }
     78 + const char *transform = mutt_hash_find(TagTransforms, np->pattern);
     79 + if (transform && mutt_strn_equal((const char *) (s + 1), transform, strlen(transform)))
     80 + {
     81 + ac_merge = merged_color_overlay(ac_merge, &np->attr_color);
    89 82   }
    90  - return ac_merge;
    91 83   }
    92  - default:
    93  - return simple_color_get(type);
     84 + return ac_merge;
    94 85   }
    95 86   
    96 87   struct AttrColor *ac_merge = NULL;
    skipped 400 lines
Please wait...
Page is in error, reload to recover