140#ifdef NEOMUTT_DIRECT_COLORS
213 static const uint32_t basic[] = {
214 0x000000, 0x800000, 0x008000, 0x808000, 0x000080, 0x800080,
215 0x008080, 0xc0c0c0, 0x808080, 0xff0000, 0x00ff00, 0xffff00,
216 0x0000ff, 0xff00ff, 0x00ffff, 0xffffff,
247 uint32_t normalised_color = color - 16;
248 uint32_t vr = (normalised_color % 216) / 36;
249 uint32_t vg = (normalised_color % 36) / 6;
250 uint32_t vb = (normalised_color % 6) / 1;
253 uint32_t r = vr * 0x28 + ((vr > 0) ? (0x5f - 0x40) : 0);
254 uint32_t g = vg * 0x28 + ((vg > 0) ? (0x5f - 0x40) : 0);
255 uint32_t b = vb * 0x28 + ((vb > 0) ? (0x5f - 0x40) : 0);
257 uint32_t rgb = (r << 16) + (g << 8) + (b << 0);
264 uint32_t steps = color - 232;
265 uint32_t grey = (steps * 0x0a) + 0x08;
266 uint32_t rgb = (grey << 16) + (grey << 8) + (grey << 0);
280 uint32_t *col,
int *attrs)
365 bool is_fg,
struct Buffer *err)
379#ifdef NEOMUTT_DIRECT_COLORS
390 if (c_color_directcolor && (*col < 16))
412 bool is_fg,
struct Buffer *err)
426 *col = strtoul(s, &eptr, 10);
430 if ((*s ==
'\0') || (*eptr !=
'\0') || (*col >= 256) || ((*col >= COLORS) && !
OptNoCurses))
432 buf_printf(err,
_(
"%s: color not supported by term"), s);
438#ifdef NEOMUTT_DIRECT_COLORS
440 if (c_color_directcolor)
470 bool is_fg,
struct Buffer *err)
476#ifndef NEOMUTT_DIRECT_COLORS
477 buf_printf(err,
_(
"Direct colors support not compiled in: %s"), s);
481 if (!c_color_directcolor)
483 buf_printf(err,
_(
"Direct colors support disabled: %s"), s);
488 *col = strtoul(s, &eptr, 16);
489 if ((*s ==
'\0') || (*eptr !=
'\0') || ((*col >= COLORS) && !
OptNoCurses))
491 buf_printf(err,
_(
"%s: color not supported by term"), s);
516 bool is_fg,
struct Buffer *err)
545 uint32_t *fg, uint32_t *bg,
546 int *attrs,
struct Buffer *err)
555 buf_printf(err,
_(
"%s: too few arguments"),
"mono");
583 *attrs |= A_STANDOUT;
587 *attrs |= A_UNDERLINE;
604 uint32_t *fg, uint32_t *bg,
605 int *attrs,
struct Buffer *err)
611 buf_printf(err,
_(
"%s: too few arguments"),
"color");
644 *attrs |= A_STANDOUT;
649 *attrs |= A_UNDERLINE;
663 buf_printf(err,
_(
"%s: too few arguments"),
"color");
679 const char *
name = NULL;
717 if (buf->
data[6] !=
'\0')
735 buf_printf(err,
_(
"%s: too few arguments"),
"color");
780 struct Buffer *err,
bool uncolor)
835 bool changes =
false;
865#ifdef USE_DEBUG_COLOR
870 intptr_t data,
struct Buffer *err)
878 char color_fg[32] = { 0 };
879 char color_bg[32] = { 0 };
909 buf_add_printf(&filebuf,
"color %-18s %-30s %-8s %-8s # %s\n", name,
929 buf_add_printf(&filebuf,
"color quoted%d %-30s %-8s %-8s # %s\n", i,
977 buf_add_printf(&filebuf,
"color %-14s %-30s %-8s %-8s %-30s # %s\n",
986#ifdef USE_DEBUG_COLOR
1029 fputs(filebuf.
data, fp_out);
1066 bool dry_run,
bool color)
1068 int attrs = 0, q_level = 0;
1069 uint32_t fg = 0, bg = 0, match = 0;
1075#ifdef USE_DEBUG_COLOR
1077 return color_dump(buf, s, 0, err);
1080 buf_printf(err,
_(
"%s: too few arguments"),
"color");
1091 rc = callback(buf, s, &fg, &bg, &attrs, err);
1112 buf_printf(err,
_(
"%s: too many arguments"), color ?
"color" :
"mono");
1128 (use_default_colors() != OK))
1130 buf_strcpy(err,
_(
"default colors not supported"));
1159 if (!mutt_str_atoui_full(tmp.
data, &match))
1161 buf_printf(err,
_(
"%s: invalid number: %s"), color ?
"color" :
"mono", tmp.
data);
1170 buf_printf(err,
_(
"%s: too many arguments"), color ?
"color" :
"mono");
1201 intptr_t data,
struct Buffer *err)
1218 intptr_t data,
struct Buffer *err)
1228 intptr_t data,
struct Buffer *err)
1242 intptr_t data,
struct Buffer *err)
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
struct Buffer buf_make(size_t size)
Make a new buffer on the stack.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
static enum CommandResult parse_color_colornnn(const char *s, uint32_t *col, int *attrs, bool is_fg, struct Buffer *err)
Parse a colorNNN, e.g.
static enum CommandResult parse_color_rrggbb(const char *s, uint32_t *col, int *attrs, bool is_fg, struct Buffer *err)
Parse an RGB colour, e.g.
static int parse_color_prefix(const char *s, enum ColorPrefix *prefix)
Parse a colour prefix, e.g.
static uint32_t color_xterm256_to_24bit(const uint32_t color)
Convert a xterm color to its RGB value.
const struct Mapping ComposeColorFields[]
Mapping of compose colour names to their IDs.
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
const struct Mapping ColorFields[]
Mapping of colour names to their IDs.
ColorPrefix
Constants for colour prefixes of named colours.
@ COLOR_PREFIX_NONE
no prefix
@ COLOR_PREFIX_ALERT
"alert" colour prefix
@ COLOR_PREFIX_LIGHT
"light" colour prefix
@ COLOR_PREFIX_BRIGHT
"bright" colour prefix
static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s, struct Buffer *err, parser_callback_t callback, bool dry_run, bool color)
Parse a 'color' command.
static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *attrs, bool is_fg, struct Buffer *err)
Parse a colour name.
static enum CommandResult parse_object(struct Buffer *buf, struct Buffer *s, enum ColorId *cid, int *ql, struct Buffer *err)
Identify a colour object.
static enum CommandResult parse_color_namedcolor(const char *s, uint32_t *col, int *attrs, bool is_fg, struct Buffer *err)
Parse a named colour, e.g.
static void modify_color_by_prefix(enum ColorPrefix prefix, bool is_fg, uint32_t *col, int *attrs)
Modify a colour/attributes based on a prefix, e.g.
static enum CommandResult parse_uncolor(struct Buffer *buf, struct Buffer *s, struct Buffer *err, bool uncolor)
Parse an 'uncolor' command.
struct Notify * ColorsNotify
Notifications: ColorId, EventColor.
struct RegexColorList * regex_colors_get_list(enum ColorId cid)
Return the RegexColorList for a colour id.
bool regex_colors_parse_uncolor(enum ColorId cid, const char *pat, bool uncolor)
Parse a Regex 'uncolor' command.
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)
Parse a Regex 'color' command.
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)
Parse a Regex 'color status' command.
struct AttrColor * simple_color_set(enum ColorId cid, int fg, int bg, int attrs)
Set the colour of a simple object.
void simple_color_reset(enum ColorId cid)
Clear the colour of a simple object.
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
const struct Mapping ColorNames[]
Mapping between a colour name and an ncurses colour.
void colors_cleanup(void)
Reset all the simple, quoted and regex colours.
bool mutt_color_has_pattern(enum ColorId cid)
Check if a color object supports a regex pattern.
Color and attribute parsing.
ColorId
List of all colored objects.
@ MT_COLOR_SIDEBAR_DIVIDER
Line dividing sidebar from the index/pager.
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
@ MT_COLOR_COMPOSE_SECURITY_ENCRYPT
Mail will be encrypted.
@ MT_COLOR_MESSAGE
Informational message.
@ MT_COLOR_QUOTED
Pager: quoted text.
@ MT_COLOR_INDEX_AUTHOR
Index: author field.
@ MT_COLOR_SIDEBAR_NEW
Mailbox with new mail.
@ MT_COLOR_HEADER
Message headers (takes a pattern)
@ MT_COLOR_STATUS
Status bar (takes a pattern)
@ MT_COLOR_SIDEBAR_UNREAD
Mailbox with unread mail.
@ MT_COLOR_INDEX_SIZE
Index: size field.
@ MT_COLOR_INDICATOR
Selected item in list.
@ MT_COLOR_STRIPE_EVEN
Stripes: even lines of the Help Page.
@ MT_COLOR_SIDEBAR_SPOOLFILE
$spool_file (Spool mailbox)
@ MT_COLOR_ERROR
Error message.
@ MT_COLOR_COMPOSE_SECURITY_NONE
Mail will not be encrypted or signed.
@ MT_COLOR_SIDEBAR_ORDINARY
Mailbox with no new or flagged messages.
@ MT_COLOR_INDEX_TAGS
Index: tags field (g, J)
@ MT_COLOR_BOLD
Bold text.
@ MT_COLOR_INDEX_SUBJECT
Index: subject field.
@ MT_COLOR_BODY
Pager: highlight body of message (takes a pattern)
@ MT_COLOR_INDEX_DATE
Index: date field.
@ MT_COLOR_PROGRESS
Progress bar.
@ MT_COLOR_COMPOSE_SECURITY_BOTH
Mail will be encrypted and signed.
@ MT_COLOR_SIDEBAR_BACKGROUND
Background colour for the Sidebar.
@ MT_COLOR_INDEX_TAG
Index: tag field (G)
@ MT_COLOR_HDRDEFAULT
Header default colour.
@ MT_COLOR_OPTIONS
Options in prompt.
@ MT_COLOR_TREE
Index: tree-drawing characters.
@ MT_COLOR_NORMAL
Plain text.
@ MT_COLOR_ATTACH_HEADERS
MIME attachment test (takes a pattern)
@ MT_COLOR_SEARCH
Pager: search matches.
@ MT_COLOR_COMPOSE_SECURITY_SIGN
Mail will be signed.
@ MT_COLOR_INDEX_LABEL
Index: label field.
@ MT_COLOR_ITALIC
Italic text.
@ MT_COLOR_STRIPE_ODD
Stripes: odd lines of the Help Page.
@ MT_COLOR_PROMPT
Question/user input.
@ MT_COLOR_COMPOSE_HEADER
Header labels, e.g. From:
@ MT_COLOR_INDEX
Index: default colour.
@ MT_COLOR_ATTACHMENT
MIME attachments text (entire line)
@ MT_COLOR_SIDEBAR_INDICATOR
Current open mailbox.
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
@ MT_COLOR_WARNING
Warning messages.
@ MT_COLOR_UNDERLINE
Underlined text.
@ MT_COLOR_INDEX_NUMBER
Index: index number.
@ MT_COLOR_SIGNATURE
Pager: signature lines.
@ MT_COLOR_INDEX_FLAGS
Index: flags field.
@ MT_COLOR_SIDEBAR_FLAGGED
Mailbox with flagged messages.
@ MT_COLOR_TILDE
Pager: empty lines after message.
@ MT_COLOR_INDEX_COLLAPSED
Index: number of messages in collapsed thread.
int(* parser_callback_t)(struct Buffer *buf, struct Buffer *s, uint32_t *fg, uint32_t *bg, int *attrs, struct Buffer *err)
CommandResult
Error codes for command_t parse functions.
@ MUTT_CMD_SUCCESS
Success: Command worked.
@ MUTT_CMD_ERROR
Error: Can't help the user.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
void regex_colors_dump_all(void)
Dump all the Regex colours to the log.
int color_debug(enum LogLevel level, const char *format,...)
Write to the log file.
const char * color_debug_log_attrs_list(int attrs)
Get a string to represent some attributes in the log.
const char * color_debug_log_name(char *buf, int buflen, int color)
Get a string to represent a colour name.
const char * color_debug_log_color_attrs(int fg, int bg, int attrs)
Get a colourful string to represent a colour in the log.
void curses_colors_dump(void)
Log all the Curses colours.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
bool OptNoCurses
(pseudo) when sending in batch mode
enum CommandResult mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'unmono' command - Implements Command::parse() -.
enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'mono' command - Implements Command::parse() -.
enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'color' command - Implements Command::parse() -.
enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'uncolor' command - Implements Command::parse() -.
#define mutt_debug(LEVEL,...)
static enum CommandResult parse_color_pair(struct Buffer *buf, struct Buffer *s, uint32_t *fg, uint32_t *bg, int *attrs, struct Buffer *err)
Parse a pair of colours - Implements parser_callback_t -.
static enum CommandResult parse_attr_spec(struct Buffer *buf, struct Buffer *s, uint32_t *fg, uint32_t *bg, int *attrs, struct Buffer *err)
Parse an attribute description - Implements parser_callback_t -.
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
bool StartupComplete
When the config has been read.
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
struct AttrColorList MergedColors
Array of user colours.
Convenience wrapper for the library headers.
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Many unsorted constants and some structs.
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
@ WT_CUSTOM
Window with a custom drawing function.
@ WT_PAGER
A panel containing the Pager Window.
@ NT_COLOR_SET
Color has been set.
@ NT_COLOR
Colour has changed, NotifyColor, EventColor.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define TAILQ_FOREACH(var, head, field)
#define STAILQ_FOREACH(var, head, field)
#define STAILQ_EMPTY(head)
#define TAILQ_EMPTY(head)
enum CommandResult quoted_colors_parse_uncolor(enum ColorId cid, int q_level, struct Buffer *err)
Parse the 'uncolor quoted' command.
struct AttrColor * quoted_colors_get(int q)
Return the color of a quote, cycling through the used quotes.
int NumQuotedColors
Number of colours for quoted email text.
bool quoted_colors_parse_color(enum ColorId cid, uint32_t fg, uint32_t bg, int attrs, int q_level, int *rc, struct Buffer *err)
Parse the 'color quoted' command.
#define COLOR_QUOTES_MAX
Ten colours, quoted0..quoted9 (quoted and quoted0 are equivalent)
A curses colour and its attributes.
int attrs
Text attributes, e.g. A_BOLD.
struct CursesColor * curses_color
Underlying Curses colour.
String manipulation buffer.
char * dptr
Current read/write position.
char * data
Pointer to data.
Colour in the ncurses palette.
uint32_t fg
Foreground colour.
uint32_t bg
Background colour.
An Event that happened to a Colour.
enum ColorId cid
Colour ID that has changed.
Mapping between user-readable string and a constant.
const char * name
String value.
void * wdata
Private data.
struct MuttWindow * parent
Parent Window.
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
A regular expression and a color to highlight a line.
struct AttrColor attr_color
Colour and attributes to apply.
char * pattern
Pattern to match.