Projects STRLCPY neomutt Commits 680bdffe
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    color/color.h
    skipped 78 lines
    79 79   MT_COLOR_INDEX_FLAGS, ///< Index: flags field (takes a pattern)
    80 80   MT_COLOR_INDEX_SUBJECT, ///< Index: subject field (takes a pattern)
    81 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 */
    83 82   MT_COLOR_INDEX_COLLAPSED, ///< Index: number of messages in collapsed thread
    84 83   MT_COLOR_INDEX_DATE, ///< Index: date field
    85 84   MT_COLOR_INDEX_LABEL, ///< Index: label field
    skipped 24 lines
  • ■ ■ ■ ■ ■ ■
    color/command.c
    skipped 416 lines
    417 417  }
    418 418   
    419 419  /**
     420 + * is_simple - Check if a color is simple, i.e., doesn't accept a regex pattern
     421 + *
     422 + * @param cid Object type, e.g. #MT_COLOR_TILDE
     423 + * @retval true The color object is simple
     424 + */
     425 +static bool is_simple(enum ColorId cid)
     426 +{
     427 + return (cid != MT_COLOR_ATTACH_HEADERS) && (cid != MT_COLOR_BODY) &&
     428 + (cid != MT_COLOR_HEADER) && (cid != MT_COLOR_INDEX) &&
     429 + (cid != MT_COLOR_INDEX_AUTHOR) && (cid != MT_COLOR_INDEX_FLAGS) &&
     430 + (cid != MT_COLOR_INDEX_SUBJECT) && (cid != MT_COLOR_INDEX_TAG) &&
     431 + (cid != MT_COLOR_INDEX_COLLAPSED) && (cid != MT_COLOR_INDEX_DATE) &&
     432 + (cid != MT_COLOR_INDEX_LABEL) && (cid != MT_COLOR_INDEX_NUMBER) &&
     433 + (cid != MT_COLOR_INDEX_SIZE) && (cid != MT_COLOR_INDEX_TAGS) &&
     434 + (cid != MT_COLOR_STATUS);
     435 +}
     436 + 
     437 +/**
    420 438   * parse_uncolor - Parse an 'uncolor' command
    421 439   * @param buf Temporary Buffer space
    422 440   * @param s Buffer containing string to be parsed
    skipped 42 lines
    465 483   return MUTT_CMD_SUCCESS;
    466 484   }
    467 485   
    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))
     486 + if (is_simple(cid))
    472 487   {
    473 488   color_debug(LL_DEBUG5, "simple\n");
    474 489   simple_color_reset(cid);
    475 490   return MUTT_CMD_SUCCESS;
    476 491   }
    477 492   
    478  - if (!MoreArgs(s))
    479  - {
    480  - mutt_buffer_printf(err, _("%s: too few arguments"), uncolor ? "uncolor" : "unmono");
    481  - return MUTT_CMD_WARNING;
    482  - }
    483  - 
    484 493   if (OptNoCurses)
    485 494   {
    486 495   do
    skipped 7 lines
    494 503   }
    495 504   
    496 505   bool changes = false;
     506 + if (!MoreArgs(s))
     507 + {
     508 + if (regex_colors_parse_uncolor(cid, NULL, uncolor))
     509 + return MUTT_CMD_SUCCESS;
     510 + else
     511 + return MUTT_CMD_ERROR;
     512 + }
     513 + 
    497 514   do
    498 515   {
    499 516   mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
    skipped 57 lines
    557 574   
    558 575   /* extract a regular expression if needed */
    559 576   
    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))
     577 + if (!is_simple(cid))
    564 578   {
    565 579   color_debug(LL_DEBUG5, "regex needed\n");
    566  - if (!MoreArgs(s))
     580 + if (MoreArgs(s))
    567 581   {
    568  - mutt_buffer_printf(err, _("%s: too few arguments"), color ? "color" : "mono");
    569  - return MUTT_CMD_WARNING;
     582 + mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
    570 583   }
    571  - 
    572  - mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
     584 + else
     585 + {
     586 + mutt_buffer_strcpy(buf, ".*");
     587 + }
    573 588   }
    574 589   
    575 590   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 IndexLabelList; ///< List of colours applied to the label in the index
     55 +struct RegexColorList IndexNumberList; ///< List of colours applied to the message number in the index
     56 +struct RegexColorList IndexSizeList; ///< List of colours applied to the size in the index
     57 +struct RegexColorList IndexTagsList; ///< List of colours applied to the tags in the index
     58 +struct RegexColorList IndexFlagsList; ///< List of colours applied to the flags in the index
     59 +struct RegexColorList IndexList; ///< List of default colours applied to the index
     60 +struct RegexColorList IndexSubjectList; ///< List of colours applied to the subject in the index
     61 +struct RegexColorList IndexTagList; ///< List of colours applied to 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 93 lines
    183 201   return &IndexSubjectList;
    184 202   case MT_COLOR_INDEX_TAG:
    185 203   return &IndexTagList;
     204 + case MT_COLOR_INDEX_COLLAPSED:
     205 + return &IndexCollapsedList;
     206 + case MT_COLOR_INDEX_DATE:
     207 + return &IndexDateList;
     208 + case MT_COLOR_INDEX_LABEL:
     209 + return &IndexLabelList;
     210 + case MT_COLOR_INDEX_NUMBER:
     211 + return &IndexNumberList;
     212 + case MT_COLOR_INDEX_SIZE:
     213 + return &IndexSizeList;
     214 + case MT_COLOR_INDEX_TAGS:
     215 + return &IndexTagsList;
    186 216   case MT_COLOR_STATUS:
    187 217   return &StatusList;
    188 218   default:
    skipped 147 lines
    336 366   case MT_COLOR_INDEX_FLAGS:
    337 367   case MT_COLOR_INDEX_SUBJECT:
    338 368   case MT_COLOR_INDEX_TAG:
     369 + case MT_COLOR_INDEX_COLLAPSED:
     370 + case MT_COLOR_INDEX_DATE:
     371 + case MT_COLOR_INDEX_LABEL:
     372 + case MT_COLOR_INDEX_NUMBER:
     373 + case MT_COLOR_INDEX_SIZE:
     374 + case MT_COLOR_INDEX_TAGS:
    339 375   sensitive = true;
    340 376   is_index = true;
    341 377   break;
    skipped 108 lines
  • ■ ■ ■ ■ ■ ■
    icommands.c
    skipped 388 lines
    389 389   }
    390 390   
    391 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,
     392 + MT_COLOR_ATTACH_HEADERS, MT_COLOR_BODY, MT_COLOR_HEADER,
     393 + MT_COLOR_INDEX, MT_COLOR_INDEX_AUTHOR, MT_COLOR_INDEX_FLAGS,
     394 + MT_COLOR_INDEX_SUBJECT, MT_COLOR_INDEX_TAG, MT_COLOR_INDEX_COLLAPSED,
     395 + MT_COLOR_INDEX_DATE, MT_COLOR_INDEX_LABEL, MT_COLOR_INDEX_NUMBER,
     396 + MT_COLOR_INDEX_SIZE, MT_COLOR_INDEX_TAGS, MT_COLOR_STATUS
    397 397   };
    398 398   
    399 399   int rl_count = 0;
    400  - for (int i = 0; regex_lists[i]; i++)
     400 + for (int i = 0; i < mutt_array_size(regex_lists); i++)
    401 401   {
    402 402   struct RegexColorList *rcl = regex_colors_get_list(regex_lists[i]);
    403 403   if (!STAILQ_EMPTY(rcl))
    skipped 2 lines
    406 406   
    407 407   if (rl_count > 0)
    408 408   {
    409  - for (int i = 0; regex_lists[i]; i++)
     409 + for (int i = 0; i < mutt_array_size(regex_lists); i++)
    410 410   {
    411 411   struct RegexColorList *rcl = regex_colors_get_list(regex_lists[i]);
    412 412   if (STAILQ_EMPTY(rcl))
    skipped 167 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_FLAGS) || (cid == MT_COLOR_INDEX_SUBJECT) ||
     280 + (cid == MT_COLOR_INDEX_TAG) || (cid == MT_COLOR_INDEX_COLLAPSED) ||
     281 + (cid == MT_COLOR_INDEX_DATE) || (cid == MT_COLOR_INDEX_LABEL) ||
     282 + (cid == MT_COLOR_INDEX_NUMBER) || (cid == MT_COLOR_INDEX_SIZE) ||
     283 + (cid == MT_COLOR_INDEX_TAGS) || (cid == MT_COLOR_TREE) ||
     284 + (cid == MT_COLOR_NORMAL) || (cid == MT_COLOR_MAX)))
     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