1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/**
* @file
* Regex Colour
*
* @authors
* Copyright (C) 2021 Richard Russon <rich@flatcap.org>
*
* @copyright
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MUTT_COLOR_REGEX4_H
#define MUTT_COLOR_REGEX4_H
#include "config.h"
#include <stdbool.h>
#include "mutt/lib.h"
#include "attr.h"
#include "color.h"
#include "curses2.h"
/**
* struct RegexColor - A regular expression and a color to highlight a line
*/
struct RegexColor
{
struct AttrColor attr_color; ///< Colour and attributes to apply
char *pattern; ///< Pattern to match
regex_t regex; ///< Compiled regex
int match; ///< Substring to match, 0 for old behaviour
struct PatternList *color_pattern; ///< Compiled pattern to speed up index color calculation
bool stop_matching : 1; ///< Used by the pager for body patterns, to prevent the color from being retried once it fails
STAILQ_ENTRY(RegexColor) entries; ///< Linked list
};
STAILQ_HEAD(RegexColorList, RegexColor);
void regex_color_clear(struct RegexColor *rcol);
void regex_color_free(struct RegexColorList *list, struct RegexColor **ptr);
struct RegexColor * regex_color_new (void);
void regex_colors_cleanup(void);
struct RegexColorList *regex_colors_get_list(enum ColorId cid);
void regex_colors_init(void);
void regex_color_list_clear(struct RegexColorList *rcl);
bool regex_colors_parse_color_list (enum ColorId cid, const char *pat, color_t fg, color_t bg, int attrs, int *rc, struct Buffer *err);
int regex_colors_parse_status_list(enum ColorId cid, const char *pat, color_t fg, color_t bg, int attrs, int match, struct Buffer *err);
bool regex_colors_parse_uncolor (enum ColorId cid, const char *pat, bool uncolor);
#endif /* MUTT_COLOR_REGEX4_H */
|