diff options
author | Richard Russon <rich@flatcap.org> | 2023-10-09 17:24:22 +0100 |
---|---|---|
committer | Richard Russon <rich@flatcap.org> | 2023-10-18 14:14:48 +0100 |
commit | 0c0deef9a4170b7dc8f22de73e5834969c9e082e (patch) | |
tree | b5dbc639b5677835d7aaaaa1c6400a0fc2852394 | |
parent | b717d5e7eadc889de776c31c4f43c6fcf0ac40fd (diff) |
color: define a type for colours
Be specific about the type of a Colour.
It needs to be larger than 24-bits and signed (to allow -1 for "default").
-rw-r--r-- | color/ansi.c | 14 | ||||
-rw-r--r-- | color/ansi.h | 5 | ||||
-rw-r--r-- | color/attr.c | 5 | ||||
-rw-r--r-- | color/attr.h | 4 | ||||
-rw-r--r-- | color/color.h | 5 | ||||
-rw-r--r-- | color/command.c | 55 | ||||
-rw-r--r-- | color/command2.h | 9 | ||||
-rw-r--r-- | color/curses.c | 6 | ||||
-rw-r--r-- | color/curses2.h | 13 | ||||
-rw-r--r-- | color/debug.c | 20 | ||||
-rw-r--r-- | color/debug.h | 6 | ||||
-rw-r--r-- | color/merged.c | 7 | ||||
-rw-r--r-- | color/quoted.c | 3 | ||||
-rw-r--r-- | color/quoted.h | 4 | ||||
-rw-r--r-- | color/regex.c | 10 | ||||
-rw-r--r-- | color/regex4.h | 8 | ||||
-rw-r--r-- | color/simple.c | 2 | ||||
-rw-r--r-- | color/simple2.h | 3 |
18 files changed, 92 insertions, 87 deletions
diff --git a/color/ansi.c b/color/ansi.c index 6442885f8..676c7b790 100644 --- a/color/ansi.c +++ b/color/ansi.c @@ -146,7 +146,7 @@ static int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool } else if (buf[pos] == '3') { - // 30-37 basic fg + // 30-37 basic foreground if ((buf[pos + 1] >= '0') && (buf[pos + 1] < '8') && ansi_is_end_char(buf[pos + 2])) { ansi->fg = buf[pos + 1] - '0'; @@ -156,7 +156,7 @@ static int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool { if (mutt_str_startswith(buf + pos, "38;5;") && isdigit(buf[pos + 5])) { - // 38;5;n palette fg + // 38;5;n palette foreground char *end = NULL; int value = strtoul(buf + pos + 5, &end, 10); if ((value >= 0) && (value < 256) && end && ansi_is_end_char(end[0])) @@ -171,7 +171,7 @@ static int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool } else if (mutt_str_startswith(buf + pos, "38;2;") && isdigit(buf[pos + 5])) { - // 38;2;R;G;B true colour fg + // 38;2;R;G;B true colour foreground pos += ansi_skip_sequence(buf + pos + 5); pos += ansi_skip_sequence(buf + pos); pos += ansi_skip_sequence(buf + pos); @@ -199,7 +199,7 @@ static int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool } else if (buf[pos] == '4') { - // 40-47 basic bg + // 40-47 basic background if ((buf[pos + 1] >= '0') && (buf[pos + 1] < '8')) { ansi->bg = buf[pos + 1] - '0'; @@ -209,7 +209,7 @@ static int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool { if (mutt_str_startswith(buf + pos, "48;5;") && isdigit(buf[pos + 5])) { - // 48;5;n palette bg + // 48;5;n palette background char *end = NULL; int value = strtoul(buf + pos + 5, &end, 10); if ((value >= 0) && (value < 256) && end && ansi_is_end_char(end[0])) @@ -224,7 +224,7 @@ static int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool } else if (mutt_str_startswith(buf + pos, "48;2;") && isdigit(buf[pos + 5])) { - // 48;2;R;G;B true colour bg + // 48;2;R;G;B true colour background pos += ansi_skip_sequence(buf + pos + 5); pos += ansi_skip_sequence(buf + pos); pos += ansi_skip_sequence(buf + pos); @@ -236,7 +236,7 @@ static int ansi_color_parse_single(const char *buf, struct AnsiColor *ansi, bool } else if ((buf[pos + 1] == '9') && ansi_is_end_char(buf[pos + 2])) { - // default bg + // default background ansi->bg = COLOR_DEFAULT; pos += 2; } diff --git a/color/ansi.h b/color/ansi.h index ccd189f28..b78b4427d 100644 --- a/color/ansi.h +++ b/color/ansi.h @@ -24,6 +24,7 @@ #define MUTT_COLOR_ANSI_H #include <stdbool.h> +#include "curses2.h" struct AttrColorList; @@ -34,8 +35,8 @@ struct AnsiColor { const struct AttrColor *attr_color; ///< Curses colour of text int attrs; ///< Attributes, e.g. A_BOLD - int fg; ///< Foreground colour - int bg; ///< Background colour + color_t fg; ///< Foreground colour + color_t bg; ///< Background colour }; int ansi_color_parse (const char *str, struct AnsiColor *ansi, struct AttrColorList *acl, bool dry_run); diff --git a/color/attr.c b/color/attr.c index b4db66545..e616871d7 100644 --- a/color/attr.c +++ b/color/attr.c @@ -29,7 +29,6 @@ #include "config.h" #include <stddef.h> -#include <stdint.h> #include "mutt/lib.h" #include "attr.h" #include "curses2.h" @@ -116,8 +115,8 @@ void attr_color_list_clear(struct AttrColorList *acl) * @param attrs Attributes, e.g. A_UNDERLINE * @retval ptr Matching AttrColor */ -struct AttrColor *attr_color_list_find(struct AttrColorList *acl, uint32_t fg, - uint32_t bg, int attrs) +struct AttrColor *attr_color_list_find(struct AttrColorList *acl, color_t fg, + color_t bg, int attrs) { if (!acl) return NULL; diff --git a/color/attr.h b/color/attr.h index 0a3f5aec2..1657c2efd 100644 --- a/color/attr.h +++ b/color/attr.h @@ -25,8 +25,8 @@ #include "config.h" #include <stdbool.h> -#include <stdint.h> #include "mutt/lib.h" +#include "curses2.h" /** * struct AttrColor - A curses colour and its attributes @@ -48,6 +48,6 @@ bool attr_color_match (struct AttrColor *ac1, struct AttrColor *ac2 struct AttrColor *attr_color_new (void); void attr_color_list_clear(struct AttrColorList *acl); -struct AttrColor *attr_color_list_find (struct AttrColorList *acl, uint32_t fg, uint32_t bg, int attrs); +struct AttrColor *attr_color_list_find (struct AttrColorList *acl, color_t fg, color_t bg, int attrs); #endif /* MUTT_COLOR_ATTR_H */ diff --git a/color/color.h b/color/color.h index c2405cd4d..b280889a5 100644 --- a/color/color.h +++ b/color/color.h @@ -25,7 +25,9 @@ #define MUTT_COLOR_COLOR_H #include "config.h" +#include "mutt/lib.h" #include <stdbool.h> +#include <stdint.h> /** * enum ColorId - List of all colored objects @@ -94,9 +96,6 @@ enum ColorId MT_COLOR_MAX, }; -#include <stdint.h> -#include "mutt/lib.h" - extern const struct Mapping ColorNames[]; extern const struct Mapping ColorFields[]; extern const struct Mapping ComposeColorFields[]; diff --git a/color/command.c b/color/command.c index 7eef8ee59..c02b50520 100644 --- a/color/command.c +++ b/color/command.c @@ -40,6 +40,7 @@ #include "parse/lib.h" #include "color.h" #include "command2.h" +#include "curses2.h" #include "debug.h" #include "globals.h" #include "notify2.h" @@ -200,9 +201,9 @@ enum ColorPrefix * | 240 | `#585858` | 241 | `#606060` | 242 | `#666666` | 243 | `#767676` | 244 | `#808080` | 245 | `#8a8a8a` | 246 | `#949494` | 247 | `#9e9e9e` | * | 248 | `#a8a8a8` | 249 | `#b2b2b2` | 250 | `#bcbcbc` | 251 | `#c6c6c6` | 252 | `#d0d0d0` | 253 | `#dadada` | 254 | `#e4e4e4` | 255 | `#eeeeee` | */ -static uint32_t color_xterm256_to_24bit(const uint32_t color) +static color_t color_xterm256_to_24bit(const color_t color) { - static const uint32_t basic[] = { + static const color_t basic[] = { 0x000000, 0x800000, 0x008000, 0x808000, 0x000080, 0x800080, 0x008080, 0xc0c0c0, 0x808080, 0xff0000, 0x00ff00, 0xffff00, 0x0000ff, 0xff00ff, 0x00ffff, 0xffffff, @@ -210,6 +211,9 @@ static uint32_t color_xterm256_to_24bit(const uint32_t color) assert(color < 256); + if (color < 0) + return color; + if (color < 16) { color_debug(LL_DEBUG5, "Converted color 0-15: %d\n", color); @@ -236,26 +240,26 @@ static uint32_t color_xterm256_to_24bit(const uint32_t color) * value for red, green, and blue, respectively. */ - uint32_t normalised_color = color - 16; - uint32_t vr = (normalised_color % 216) / 36; /* 216 = 6*6*6 */ - uint32_t vg = (normalised_color % 36) / 6; - uint32_t vb = (normalised_color % 6) / 1; + color_t normalised_color = color - 16; + color_t vr = (normalised_color % 216) / 36; /* 216 = 6*6*6 */ + color_t vg = (normalised_color % 36) / 6; + color_t vb = (normalised_color % 6) / 1; /* First step is wider than the other ones, so add the difference if needed */ - uint32_t r = vr * 0x28 + ((vr > 0) ? (0x5f - 0x40) : 0); - uint32_t g = vg * 0x28 + ((vg > 0) ? (0x5f - 0x40) : 0); - uint32_t b = vb * 0x28 + ((vb > 0) ? (0x5f - 0x40) : 0); + color_t r = vr * 0x28 + ((vr > 0) ? (0x5f - 0x40) : 0); + color_t g = vg * 0x28 + ((vg > 0) ? (0x5f - 0x40) : 0); + color_t b = vb * 0x28 + ((vb > 0) ? (0x5f - 0x40) : 0); - uint32_t rgb = (r << 16) + (g << 8) + (b << 0); + color_t rgb = (r << 16) + (g << 8) + (b << 0); color_debug(LL_DEBUG5, "Converted xterm color %d to RGB #%x:\n", color, rgb); return rgb; } /* Grey scale starts at 0x08 and adds 0xa = 10 in very step ending in 0xee. * There are a total of 6*4 = 24 grey colors in total. */ - uint32_t steps = color - 232; - uint32_t grey = (steps * 0x0a) + 0x08; - uint32_t rgb = (grey << 16) + (grey << 8) + (grey << 0); + color_t steps = color - 232; + color_t grey = (steps * 0x0a) + 0x08; + color_t rgb = (grey << 16) + (grey << 8) + (grey << 0); color_debug(LL_DEBUG5, "Converted xterm color %d to RGB #%x:\n", color, rgb); return rgb; } @@ -269,7 +273,7 @@ static uint32_t color_xterm256_to_24bit(const uint32_t color) * @param[in,out] attrs attributes to modify */ static void modify_color_by_prefix(enum ColorPrefix prefix, bool is_fg, - uint32_t *col, int *attrs) + color_t *col, int *attrs) { if (prefix == COLOR_PREFIX_NONE) return; // nothing to do here @@ -353,7 +357,7 @@ static int parse_color_prefix(const char *s, enum ColorPrefix *prefix) * @retval #MUTT_CMD_SUCCESS Colour parsed successfully * @retval #MUTT_CMD_WARNING Unknown colour, try other parsers */ -static enum CommandResult parse_color_namedcolor(const char *s, uint32_t *col, int *attrs, +static enum CommandResult parse_color_namedcolor(const char *s, color_t *col, int *attrs, bool is_fg, struct Buffer *err) { enum ColorPrefix prefix = COLOR_PREFIX_NONE; @@ -400,7 +404,7 @@ static enum CommandResult parse_color_namedcolor(const char *s, uint32_t *col, i * * On #MUTT_CMD_ERROR, an error message will be written to err. */ -static enum CommandResult parse_color_colornnn(const char *s, uint32_t *col, int *attrs, +static enum CommandResult parse_color_colornnn(const char *s, color_t *col, int *attrs, bool is_fg, struct Buffer *err) { /* prefixes bright, alert, light are only allowed for named colours and @@ -458,7 +462,7 @@ static enum CommandResult parse_color_colornnn(const char *s, uint32_t *col, int * * On #MUTT_CMD_ERROR, an error message will be written to err. */ -static enum CommandResult parse_color_rrggbb(const char *s, uint32_t *col, int *attrs, +static enum CommandResult parse_color_rrggbb(const char *s, color_t *col, int *attrs, bool is_fg, struct Buffer *err) { /* parse #RRGGBB colours */ @@ -504,7 +508,7 @@ static enum CommandResult parse_color_rrggbb(const char *s, uint32_t *col, int * * * Parse a colour name, such as "red", "brightgreen", "color123", "#12FE45" */ -static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *attrs, +static enum CommandResult parse_color_name(const char *s, color_t *col, int *attrs, bool is_fg, struct Buffer *err) { mutt_debug(LL_DEBUG5, "Parsing color name: %s\n", s); @@ -534,8 +538,8 @@ static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *at * parse_attr_spec - Parse an attribute description - Implements ::parser_callback_t - @ingroup parser_callback_api */ static enum CommandResult parse_attr_spec(struct Buffer *buf, struct Buffer *s, - uint32_t *fg, uint32_t *bg, - int *attrs, struct Buffer *err) + color_t *fg, color_t *bg, int *attrs, + struct Buffer *err) { if (fg) *fg = COLOR_UNSET; @@ -593,8 +597,8 @@ static enum CommandResult parse_attr_spec(struct Buffer *buf, struct Buffer *s, * Parse a pair of colours, e.g. "red default" */ static enum CommandResult parse_color_pair(struct Buffer *buf, struct Buffer *s, - uint32_t *fg, uint32_t *bg, - int *attrs, struct Buffer *err) + color_t *fg, color_t *bg, int *attrs, + struct Buffer *err) { while (true) { @@ -873,7 +877,8 @@ static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s, bool dry_run, bool color) { int attrs = 0, q_level = 0; - uint32_t fg = 0, bg = 0, match = 0; + color_t fg = 0, bg = 0; + unsigned int match = 0; enum ColorId cid = MT_COLOR_NONE; enum CommandResult rc; @@ -902,7 +907,7 @@ static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s, /* extract a regular expression if needed */ - if (mutt_color_has_pattern(cid) && cid != MT_COLOR_STATUS) + if (mutt_color_has_pattern(cid) && (cid != MT_COLOR_STATUS)) { color_debug(LL_DEBUG5, "regex needed\n"); if (MoreArgs(s)) @@ -1049,5 +1054,5 @@ enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s, enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err) { - return parse_color(buf, s, err, parse_attr_spec, true, false); + return parse_color(buf, s, err, parse_attr_spec, false, false); } diff --git a/color/command2.h b/color/command2.h index 87c754e82..f3ff74e4e 100644 --- a/color/command2.h +++ b/color/command2.h @@ -26,6 +26,7 @@ #include "config.h" #include <stdint.h> #include "core/lib.h" +#include "curses2.h" struct Buffer; @@ -36,15 +37,15 @@ struct Buffer; * * @param[in] buf Temporary Buffer space * @param[in] s Buffer containing string to be parsed - * @param[out] fg Foreground colour (set to -1) - * @param[out] bg Background colour (set to -1) + * @param[out] fg Foreground colour + * @param[out] bg Background colour * @param[out] attrs Attributes, e.g. A_UNDERLINE * @param[out] err Buffer for error messages * @retval 0 Success * @retval -1 Error */ -typedef int (*parser_callback_t)(struct Buffer *buf, struct Buffer *s, uint32_t *fg, - uint32_t *bg, int *attrs, struct Buffer *err); +typedef int (*parser_callback_t)(struct Buffer *buf, struct Buffer *s, color_t *fg, + color_t *bg, int *attrs, struct Buffer *err); enum CommandResult mutt_parse_color (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err); enum CommandResult mutt_parse_mono (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err); diff --git a/color/curses.c b/color/curses.c index 96c18a102..a3bed5338 100644 --- a/color/curses.c +++ b/color/curses.c @@ -54,7 +54,7 @@ void curses_colors_init(void) * @param bg Background colour * @retval ptr Curses colour */ -struct CursesColor *curses_colors_find(int fg, int bg) +struct CursesColor *curses_colors_find(color_t fg, color_t bg) { struct CursesColor *cc = NULL; TAILQ_FOREACH(cc, &CursesColors, entries) @@ -74,7 +74,7 @@ struct CursesColor *curses_colors_find(int fg, int bg) * @param bg Background colour * @retval num Index of Curses colour */ -static int curses_color_init(int fg, int bg) +static int curses_color_init(color_t fg, color_t bg) { color_debug(LL_DEBUG5, "find lowest index\n"); int index = 16; @@ -148,7 +148,7 @@ void curses_color_free(struct CursesColor **ptr) * If the colour already exists, this function will return a pointer to the * object (and increase its ref-count). */ -struct CursesColor *curses_color_new(int fg, int bg) +struct CursesColor *curses_color_new(color_t fg, color_t bg) { color_debug(LL_DEBUG5, "fg %d, bg %d\n", fg, bg); if (((fg == COLOR_UNSET) && (bg == COLOR_UNSET)) || diff --git a/color/curses2.h b/color/curses2.h index 100fb20e0..8b033689c 100644 --- a/color/curses2.h +++ b/color/curses2.h @@ -27,6 +27,9 @@ #include <stdint.h> #include "mutt/lib.h" +/// Type for 24-bit colour value +typedef int32_t color_t; + /** * struct CursesColor - Colour in the ncurses palette * @@ -36,10 +39,8 @@ */ struct CursesColor { - /* TrueColor uses 24bit. Use fixed-width integer type to make sure it fits. - * Use the upper 8 bits to store flags. */ - uint32_t fg; ///< Foreground colour - uint32_t bg; ///< Background colour + color_t fg; ///< Foreground colour + color_t bg; ///< Background colour short index; ///< Index number short ref_count; ///< Number of users TAILQ_ENTRY(CursesColor) entries; ///< Linked list @@ -47,9 +48,9 @@ struct CursesColor TAILQ_HEAD(CursesColorList, CursesColor); void curses_color_free(struct CursesColor **ptr); -struct CursesColor *curses_color_new (int fg, int bg); +struct CursesColor *curses_color_new (color_t fg, color_t bg); void curses_colors_init(void); -struct CursesColor *curses_colors_find (int fg, int bg); +struct CursesColor *curses_colors_find(color_t fg, color_t bg); #endif /* MUTT_COLOR_CURSES2_H */ diff --git a/color/debug.c b/color/debug.c index dba6970c4..a592a76cf 100644 --- a/color/debug.c +++ b/color/debug.c @@ -93,7 +93,7 @@ int color_debug(enum LogLevel level, const char *format, ...) * * @note Do not free the returned string */ -void color_debug_log_color_attrs(int fg, int bg, int attrs, struct Buffer *swatch) +void color_debug_log_color_attrs(color_t fg, color_t bg, int attrs, struct Buffer *swatch) { buf_reset(swatch); @@ -126,7 +126,7 @@ void color_debug_log_color_attrs(int fg, int bg, int attrs, struct Buffer *swatc * * @note Do not free the returned string */ -const char *color_debug_log_color(int fg, int bg) +const char *color_debug_log_color(color_t fg, color_t bg) { static char text[64]; snprintf(text, sizeof(text), "\033[38;5;%dm\033[48;5;%dmXXXXXX\033[0m", fg, bg); @@ -229,8 +229,8 @@ void attr_color_dump(struct AttrColor *ac, const char *prefix) int index = ac->curses_color ? ac->curses_color->index : -1; - int fg = COLOR_DEFAULT; - int bg = COLOR_DEFAULT; + color_t fg = COLOR_DEFAULT; + color_t bg = COLOR_DEFAULT; struct CursesColor *cc = ac->curses_color; if (cc) { @@ -318,8 +318,8 @@ void quoted_color_dump(struct AttrColor *ac, int q_level, const char *prefix) int index = ac->curses_color ? ac->curses_color->index : -1; - int fg = COLOR_DEFAULT; - int bg = COLOR_DEFAULT; + color_t fg = COLOR_DEFAULT; + color_t bg = COLOR_DEFAULT; struct CursesColor *cc = ac->curses_color; if (cc) { @@ -358,8 +358,8 @@ void regex_color_dump(struct RegexColor *rcol, const char *prefix) struct AttrColor *ac = &rcol->attr_color; int index = ac->curses_color ? ac->curses_color->index : -1; - int fg = COLOR_DEFAULT; - int bg = COLOR_DEFAULT; + color_t fg = COLOR_DEFAULT; + color_t bg = COLOR_DEFAULT; struct CursesColor *cc = ac->curses_color; if (cc) { @@ -444,8 +444,8 @@ void simple_color_dump(enum ColorId cid, const char *prefix) } } - int fg = COLOR_DEFAULT; - int bg = COLOR_DEFAULT; + color_t fg = COLOR_DEFAULT; + color_t bg = COLOR_DEFAULT; struct CursesColor *cc = ac->curses_color; if (cc) { diff --git a/color/debug.h b/color/debug.h index 1f076644c..96c4f6d54 100644 --- a/color/debug.h +++ b/color/debug.h @@ -27,10 +27,10 @@ #include <stdbool.h> #include "mutt/lib.h" #include "color.h" +#include "curses2.h" struct AttrColor; struct AttrColorList; -struct CursesColor; struct RegexColor; struct RegexColorList; @@ -39,7 +39,7 @@ struct RegexColorList; void color_dump(void); const char *color_debug_log_attrs(int attrs); -const char *color_debug_log_color(int fg, int bg); +const char *color_debug_log_color(color_t fg, color_t bg); void attr_color_dump (struct AttrColor *ac, const char *prefix); void attr_color_list_dump (struct AttrColorList *acl, const char *title); @@ -67,7 +67,7 @@ int color_debug(enum LogLevel level, const char *format, ...) static inline void color_dump(void) {} static inline const char *color_debug_log_attrs(int attrs) { return ""; } -static inline const char *color_debug_log_color(int fg, int bg) { return ""; } +static inline const char *color_debug_log_color(color_t fg, color_t bg) { return ""; } static inline void attr_color_dump (struct AttrColor *ac, const char *prefix) {} static inline void attr_color_list_dump (struct AttrColorList *acl, const char *title) {} diff --git a/color/merged.c b/color/merged.c index da4f41708..3cb8573f2 100644 --- a/color/merged.c +++ b/color/merged.c @@ -31,7 +31,6 @@ #include "config.h" #include <stddef.h> #include <stdbool.h> -#include <stdint.h> #include "mutt/lib.h" #include "attr.h" #include "color.h" @@ -71,7 +70,7 @@ void merged_colors_cleanup(void) * @param attrs Attributes, e.g. A_UNDERLINE * @retval ptr Matching Merged colour */ -static struct AttrColor *merged_colors_find(int fg, int bg, int attrs) +static struct AttrColor *merged_colors_find(color_t fg, color_t bg, int attrs) { struct AttrColor *ac = NULL; TAILQ_FOREACH(ac, &MergedColors, entries) @@ -117,8 +116,8 @@ const struct AttrColor *merged_color_overlay(const struct AttrColor *base, struct CursesColor *cc_base = base->curses_color; struct CursesColor *cc_over = over->curses_color; - uint32_t fg = COLOR_DEFAULT; - uint32_t bg = COLOR_DEFAULT; + color_t fg = COLOR_DEFAULT; + color_t bg = COLOR_DEFAULT; if (cc_over) { diff --git a/color/quoted.c b/color/quoted.c index aeebd5441..135e28f8d 100644 --- a/color/quoted.c +++ b/color/quoted.c @@ -29,7 +29,6 @@ #include "config.h" #include <stddef.h> #include <stdbool.h> -#include <stdint.h> #include "mutt/lib.h" #include "core/lib.h" #include "quoted.h" @@ -103,7 +102,7 @@ int quoted_colors_num_used(void) * @param err Buffer for error messages * @retval true Colour was parsed */ -bool quoted_colors_parse_color(enum ColorId cid, uint32_t fg, uint32_t bg, +bool quoted_colors_parse_color(enum ColorId cid, color_t fg, color_t bg, int attrs, int q_level, int *rc, struct Buffer *err) { if (cid != MT_COLOR_QUOTED) diff --git a/color/quoted.h b/color/quoted.h index 611071d12..ccca2c4cb 100644 --- a/color/quoted.h +++ b/color/quoted.h @@ -26,10 +26,10 @@ #include "config.h" #include <stddef.h> #include <stdbool.h> -#include <stdint.h> #include "core/lib.h" #include "attr.h" #include "color.h" +#include "curses2.h" struct Buffer; @@ -78,7 +78,7 @@ void quoted_colors_cleanup(void); struct AttrColor * quoted_colors_get(int q); int quoted_colors_num_used(void); -bool quoted_colors_parse_color (enum ColorId cid, uint32_t fg, uint32_t bg, int attrs, int q_level, int *rc, struct Buffer *err); +bool quoted_colors_parse_color (enum ColorId cid, color_t fg, color_t bg, int attrs, int q_level, int *rc, struct Buffer *err); enum CommandResult quoted_colors_parse_uncolor(enum ColorId cid, int q_level, struct Buffer *err); struct QuoteStyle *qstyle_classify (struct QuoteStyle **quote_list, const char *qptr, size_t length, bool *force_redraw, int *q_level); diff --git a/color/regex.c b/color/regex.c index c8a1f5978..28775e6ae 100644 --- a/color/regex.c +++ b/color/regex.c @@ -237,7 +237,7 @@ struct RegexColorList *regex_colors_get_list(enum ColorId cid) * called from mutt_parse_color() */ static enum CommandResult add_pattern(struct RegexColorList *rcl, const char *s, - bool sensitive, uint32_t fg, uint32_t bg, int attrs, + bool sensitive, color_t fg, color_t bg, int attrs, struct Buffer *err, bool is_index, int match) { struct RegexColor *rcol = NULL; @@ -337,8 +337,8 @@ static enum CommandResult add_pattern(struct RegexColorList *rcl, const char *s, * * Parse a Regex 'color' command, e.g. "color index green default pattern" */ -bool regex_colors_parse_color_list(enum ColorId cid, const char *pat, uint32_t fg, - uint32_t bg, int attrs, int *rc, struct Buffer *err) +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) { if (cid == MT_COLOR_STATUS) @@ -407,8 +407,8 @@ bool regex_colors_parse_color_list(enum ColorId cid, const char *pat, uint32_t f * @param err Buffer for error messages * @retval #CommandResult Result e.g. #MUTT_CMD_SUCCESS */ -int regex_colors_parse_status_list(enum ColorId cid, const char *pat, uint32_t fg, - uint32_t bg, int attrs, int match, 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) { if (cid != MT_COLOR_STATUS) return MUTT_CMD_ERROR; diff --git a/color/regex4.h b/color/regex4.h index d948ed9cc..dea7fc50d 100644 --- a/color/regex4.h +++ b/color/regex4.h @@ -25,10 +25,10 @@ #include "config.h" #include <stdbool.h> -#include <stdint.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 @@ -43,7 +43,7 @@ struct RegexColor 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_ENTRY(RegexColor) entries; ///< Linked list }; STAILQ_HEAD(RegexColorList, RegexColor); @@ -57,8 +57,8 @@ 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, uint32_t fg, uint32_t bg, int attrs, int *rc, struct Buffer *err); -int regex_colors_parse_status_list(enum ColorId cid, const char *pat, uint32_t fg, uint32_t bg, int attrs, int match, struct Buffer *err); +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 */ diff --git a/color/simple.c b/color/simple.c index bb1aec3c9..cdf57db7a 100644 --- a/color/simple.c +++ b/color/simple.c @@ -122,7 +122,7 @@ bool simple_color_is_header(enum ColorId cid) * @param attrs Attributes, e.g. A_UNDERLINE * @retval ptr Colour */ -struct AttrColor *simple_color_set(enum ColorId cid, int fg, int bg, int attrs) +struct AttrColor *simple_color_set(enum ColorId cid, color_t fg, color_t bg, int attrs) { struct AttrColor *ac = simple_color_get(cid); if (!ac) diff --git a/color/simple2.h b/color/simple2.h index b250eca45..62fcab464 100644 --- a/color/simple2.h +++ b/color/simple2.h @@ -27,6 +27,7 @@ #include <stdbool.h> #include "attr.h" #include "color.h" +#include "curses2.h" extern struct AttrColor SimpleColors[]; @@ -34,7 +35,7 @@ struct AttrColor *simple_color_get (enum ColorId cid); bool simple_color_is_header(enum ColorId cid); bool simple_color_is_set (enum ColorId cid); void simple_color_reset (enum ColorId cid); -struct AttrColor *simple_color_set (enum ColorId cid, int fg, int bg, int attrs); +struct AttrColor *simple_color_set (enum ColorId cid, color_t fg, color_t bg, int attrs); void simple_colors_cleanup(void); void simple_colors_init(void); |