Projects STRLCPY neomutt Commits 7e5fd3ba
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    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_FLAGS) ||
     107 + (cid == MT_COLOR_INDEX_SUBJECT) || (cid == MT_COLOR_INDEX_TAG) ||
     108 + (cid == MT_COLOR_INDEX_COLLAPSED) || (cid == MT_COLOR_INDEX_DATE) ||
     109 + (cid == MT_COLOR_INDEX_LABEL) || (cid == MT_COLOR_INDEX_NUMBER) ||
     110 + (cid == MT_COLOR_INDEX_SIZE) || (cid == MT_COLOR_INDEX_TAGS) ||
     111 + (cid == MT_COLOR_STATUS);
     112 +}
     113 + 
  • ■ ■ ■ ■ ■
    color/color.h
    skipped 100 lines
    101 101   
    102 102  void mutt_colors_init(void);
    103 103  void mutt_colors_cleanup(void);
     104 +bool mutt_color_has_pattern(enum ColorId cid);
    104 105   
    105 106  void colors_clear(void);
    106 107   
    skipped 2 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  -/**
    438 420   * parse_uncolor - Parse an 'uncolor' command
    439 421   * @param buf Temporary Buffer space
    440 422   * @param s Buffer containing string to be parsed
    skipped 42 lines
    483 465   return MUTT_CMD_SUCCESS;
    484 466   }
    485 467   
    486  - if (is_simple(cid))
     468 + if (!mutt_color_has_pattern(cid))
    487 469   {
    488 470   color_debug(LL_DEBUG5, "simple\n");
    489 471   simple_color_reset(cid);
    skipped 84 lines
    574 556   
    575 557   /* extract a regular expression if needed */
    576 558   
    577  - if (!is_simple(cid))
     559 + if (mutt_color_has_pattern(cid))
    578 560   {
    579 561   color_debug(LL_DEBUG5, "regex needed\n");
    580 562   if (MoreArgs(s))
    skipped 149 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, 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  - };
    398  - 
    399 391   int rl_count = 0;
    400  - for (int i = 0; i < mutt_array_size(regex_lists); 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; i < mutt_array_size(regex_lists); 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
Please wait...
Page is in error, reload to recover