NeoMutt  2021-10-29-220-g2b1eec
Teaching an old dog new tricks
DOXYGEN
command.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <stddef.h>
31 #include <stdbool.h>
32 #include <stdint.h>
33 #include <stdlib.h>
34 #include "mutt/lib.h"
35 #include "core/lib.h"
36 #include "gui/lib.h"
37 #include "mutt.h"
38 #include "init.h"
39 #include "options.h"
40 
44 const struct Mapping ColorFields[] = {
45  // clang-format off
46  { "attachment", MT_COLOR_ATTACHMENT },
47  { "attach_headers", MT_COLOR_ATTACH_HEADERS },
48  { "body", MT_COLOR_BODY },
49  { "bold", MT_COLOR_BOLD },
50  { "error", MT_COLOR_ERROR },
51  { "hdrdefault", MT_COLOR_HDRDEFAULT },
52  { "header", MT_COLOR_HEADER },
53  { "index", MT_COLOR_INDEX },
54  { "index_author", MT_COLOR_INDEX_AUTHOR },
55  { "index_collapsed", MT_COLOR_INDEX_COLLAPSED },
56  { "index_date", MT_COLOR_INDEX_DATE },
57  { "index_flags", MT_COLOR_INDEX_FLAGS },
58  { "index_label", MT_COLOR_INDEX_LABEL },
59  { "index_number", MT_COLOR_INDEX_NUMBER },
60  { "index_size", MT_COLOR_INDEX_SIZE },
61  { "index_subject", MT_COLOR_INDEX_SUBJECT },
62  { "index_tag", MT_COLOR_INDEX_TAG },
63  { "index_tags", MT_COLOR_INDEX_TAGS },
64  { "indicator", MT_COLOR_INDICATOR },
65  { "markers", MT_COLOR_MARKERS },
66  { "message", MT_COLOR_MESSAGE },
67  { "normal", MT_COLOR_NORMAL },
68  { "options", MT_COLOR_OPTIONS },
69  { "progress", MT_COLOR_PROGRESS },
70  { "prompt", MT_COLOR_PROMPT },
71  { "quoted", MT_COLOR_QUOTED },
72  { "search", MT_COLOR_SEARCH },
73 #ifdef USE_SIDEBAR
74  { "sidebar_divider", MT_COLOR_SIDEBAR_DIVIDER },
75  { "sidebar_flagged", MT_COLOR_SIDEBAR_FLAGGED },
76  { "sidebar_highlight", MT_COLOR_SIDEBAR_HIGHLIGHT },
77  { "sidebar_indicator", MT_COLOR_SIDEBAR_INDICATOR },
78  { "sidebar_new", MT_COLOR_SIDEBAR_NEW },
79  { "sidebar_ordinary", MT_COLOR_SIDEBAR_ORDINARY },
80  { "sidebar_spool_file", MT_COLOR_SIDEBAR_SPOOLFILE },
81  { "sidebar_spoolfile", MT_COLOR_SIDEBAR_SPOOLFILE }, // This will be deprecated
82  { "sidebar_unread", MT_COLOR_SIDEBAR_UNREAD },
83 #endif
84  { "signature", MT_COLOR_SIGNATURE },
85  { "status", MT_COLOR_STATUS },
86  { "tilde", MT_COLOR_TILDE },
87  { "tree", MT_COLOR_TREE },
88  { "underline", MT_COLOR_UNDERLINE },
89  { "warning", MT_COLOR_WARNING },
90  { NULL, 0 },
91  // clang-format on
92 };
93 
97 const struct Mapping ComposeColorFields[] = {
98  // clang-format off
99  { "header", MT_COLOR_COMPOSE_HEADER },
100  { "security_encrypt", MT_COLOR_COMPOSE_SECURITY_ENCRYPT },
101  { "security_sign", MT_COLOR_COMPOSE_SECURITY_SIGN },
102  { "security_both", MT_COLOR_COMPOSE_SECURITY_BOTH },
103  { "security_none", MT_COLOR_COMPOSE_SECURITY_NONE },
104  { NULL, 0 }
105  // clang-format on
106 };
107 
119 static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *attrs,
120  bool is_fg, struct Buffer *err)
121 {
122  char *eptr = NULL;
123  bool is_alert = false, is_bright = false, is_light = false;
124  int clen;
125 
126  if ((clen = mutt_istr_startswith(s, "bright")))
127  {
128  is_bright = true;
129  s += clen;
130  }
131  else if ((clen = mutt_istr_startswith(s, "alert")))
132  {
133  is_alert = true;
134  is_bright = true;
135  s += clen;
136  }
137  else if ((clen = mutt_istr_startswith(s, "light")))
138  {
139  is_light = true;
140  s += clen;
141  }
142 
143  /* allow aliases for xterm color resources */
144  if ((clen = mutt_istr_startswith(s, "color")))
145  {
146  s += clen;
147  *col = strtoul(s, &eptr, 10);
148  if ((*s == '\0') || (*eptr != '\0') ||
149  ((*col >= COLORS) && !OptNoCurses && has_colors()))
150  {
151  mutt_buffer_printf(err, _("%s: color not supported by term"), s);
152  return MUTT_CMD_ERROR;
153  }
154  }
155  else if ((*col = mutt_map_get_value(s, ColorNames)) == -1)
156  {
157  mutt_buffer_printf(err, _("%s: no such color"), s);
158  return MUTT_CMD_WARNING;
159  }
160 
161  if (is_bright || is_light)
162  {
163  if (is_alert)
164  {
165  *attrs |= A_BOLD;
166  *attrs |= A_BLINK;
167  }
168  else if (is_fg)
169  {
170  if ((COLORS >= 16) && is_light)
171  {
172  if (*col <= 7)
173  {
174  /* Advance the color 0-7 by 8 to get the light version */
175  *col += 8;
176  }
177  }
178  else
179  {
180  *attrs |= A_BOLD;
181  }
182  }
183  else if (!(*col & RGB24))
184  {
185  if (COLORS >= 16)
186  {
187  if (*col <= 7)
188  {
189  /* Advance the color 0-7 by 8 to get the light version */
190  *col += 8;
191  }
192  }
193  }
194  }
195 
196  return MUTT_CMD_SUCCESS;
197 }
198 
202 static enum CommandResult parse_attr_spec(struct Buffer *buf, struct Buffer *s,
203  uint32_t *fg, uint32_t *bg,
204  int *attrs, struct Buffer *err)
205 {
206  if (fg)
207  *fg = COLOR_UNSET;
208  if (bg)
209  *bg = COLOR_UNSET;
210 
211  if (!MoreArgs(s))
212  {
213  mutt_buffer_printf(err, _("%s: too few arguments"), "mono");
214  return MUTT_CMD_WARNING;
215  }
216 
218 
219  if (mutt_istr_equal("bold", buf->data))
220  *attrs |= A_BOLD;
221  else if (mutt_istr_equal("none", buf->data))
222  *attrs = A_NORMAL; // Use '=' to clear other bits
223  else if (mutt_istr_equal("normal", buf->data))
224  *attrs = A_NORMAL; // Use '=' to clear other bits
225  else if (mutt_istr_equal("reverse", buf->data))
226  *attrs |= A_REVERSE;
227  else if (mutt_istr_equal("standout", buf->data))
228  *attrs |= A_STANDOUT;
229  else if (mutt_istr_equal("underline", buf->data))
230  *attrs |= A_UNDERLINE;
231  else
232  {
233  mutt_buffer_printf(err, _("%s: no such attribute"), buf->data);
234  return MUTT_CMD_WARNING;
235  }
236 
237  return MUTT_CMD_SUCCESS;
238 }
239 
245 static enum CommandResult parse_color_pair(struct Buffer *buf, struct Buffer *s,
246  uint32_t *fg, uint32_t *bg,
247  int *attrs, struct Buffer *err)
248 {
249  while (true)
250  {
251  if (!MoreArgs(s))
252  {
253  mutt_buffer_printf(err, _("%s: too few arguments"), "color");
254  return MUTT_CMD_WARNING;
255  }
256 
258 
259  if (mutt_istr_equal("bold", buf->data))
260  {
261  *attrs |= A_BOLD;
262  }
263  else if (mutt_istr_equal("none", buf->data))
264  {
265  *attrs = A_NORMAL; // Use '=' to clear other bits
266  }
267  else if (mutt_istr_equal("normal", buf->data))
268  {
269  *attrs = A_NORMAL; // Use '=' to clear other bits
270  }
271  else if (mutt_istr_equal("reverse", buf->data))
272  {
273  *attrs |= A_REVERSE;
274  }
275  else if (mutt_istr_equal("standout", buf->data))
276  {
277  *attrs |= A_STANDOUT;
278  }
279  else if (mutt_istr_equal("underline", buf->data))
280  {
281  *attrs |= A_UNDERLINE;
282  }
283  else
284  {
285  enum CommandResult rc = parse_color_name(buf->data, fg, attrs, true, err);
286  if (rc != MUTT_CMD_SUCCESS)
287  return rc;
288  break;
289  }
290  }
291 
292  if (!MoreArgs(s))
293  {
294  mutt_buffer_printf(err, _("%s: too few arguments"), "color");
295  return MUTT_CMD_WARNING;
296  }
297 
299 
300  return parse_color_name(buf->data, bg, attrs, false, err);
301 }
302 
308 void get_colorid_name(unsigned int cid, struct Buffer *buf)
309 {
310  const char *name = NULL;
311 
313  {
315  if (name)
316  {
317  mutt_buffer_printf(buf, "compose %s", name);
318  return;
319  }
320  }
321 
323  if (name)
324  mutt_buffer_printf(buf, "%s", name);
325  else
326  mutt_buffer_printf(buf, "UNKNOWN %d", cid);
327 }
328 
340 static enum CommandResult parse_object(struct Buffer *buf, struct Buffer *s,
341  enum ColorId *cid, int *ql, struct Buffer *err)
342 {
343  int rc;
344 
345  if (mutt_str_startswith(buf->data, "quoted") != 0)
346  {
347  int val = 0;
348  if (buf->data[6] != '\0')
349  {
350  if (!mutt_str_atoi_full(buf->data + 6, &val) || (val > COLOR_QUOTES_MAX))
351  {
352  mutt_buffer_printf(err, _("%s: no such object"), buf->data);
353  return MUTT_CMD_WARNING;
354  }
355  }
356 
357  *ql = val;
358  *cid = MT_COLOR_QUOTED;
359  return MUTT_CMD_SUCCESS;
360  }
361 
362  if (mutt_istr_equal(buf->data, "compose"))
363  {
364  if (!MoreArgs(s))
365  {
366  mutt_buffer_printf(err, _("%s: too few arguments"), "color");
367  return MUTT_CMD_WARNING;
368  }
369 
371 
373  if (rc == -1)
374  {
375  mutt_buffer_printf(err, _("%s: no such object"), buf->data);
376  return MUTT_CMD_WARNING;
377  }
378 
379  *cid = rc;
380  return MUTT_CMD_SUCCESS;
381  }
382 
383  rc = mutt_map_get_value(buf->data, ColorFields);
384  if (rc == -1)
385  {
386  mutt_buffer_printf(err, _("%s: no such object"), buf->data);
387  return MUTT_CMD_WARNING;
388  }
389 
390  *cid = rc;
391  return MUTT_CMD_SUCCESS;
392 }
393 
402 static bool do_uncolor(struct Buffer *buf, struct Buffer *s,
403  struct RegexColorList *cl, bool uncolor)
404 {
405  struct RegexColor *np = NULL, *prev = NULL;
406  bool rc = false;
407 
408  do
409  {
411  if (mutt_str_equal("*", buf->data))
412  {
413  rc = STAILQ_FIRST(cl);
415  return rc;
416  }
417 
418  prev = NULL;
419  STAILQ_FOREACH(np, cl, entries)
420  {
421  if (mutt_str_equal(buf->data, np->pattern))
422  {
423  rc = true;
424 
425  mutt_debug(LL_DEBUG1, "Freeing pattern \"%s\" from user_colors\n", buf->data);
426  if (prev)
427  STAILQ_REMOVE_AFTER(cl, prev, entries);
428  else
429  STAILQ_REMOVE_HEAD(cl, entries);
430  regex_color_free(&np, uncolor);
431  break;
432  }
433  prev = np;
434  }
435  } while (MoreArgs(s));
436 
437  return rc;
438 }
439 
452 static enum CommandResult parse_uncolor(struct Buffer *buf, struct Buffer *s,
453  struct Buffer *err, bool uncolor)
454 {
456 
457  if (mutt_str_equal(buf->data, "*"))
458  {
459  mutt_debug(LL_NOTIFY, "NT_COLOR_RESET: [ALL]\n");
460  colors_clear();
461  struct EventColor ev_c = { MT_COLOR_MAX };
463  return MUTT_CMD_SUCCESS;
464  }
465 
466  unsigned int cid = MT_COLOR_NONE;
467  int ql = 0;
468  enum CommandResult rc = parse_object(buf, s, &cid, &ql, err);
469  if (rc != MUTT_CMD_SUCCESS)
470  return rc;
471 
472  if (cid == -1)
473  {
474  mutt_buffer_printf(err, _("%s: no such object"), buf->data);
475  return MUTT_CMD_ERROR;
476  }
477 
478  if (cid == MT_COLOR_QUOTED)
479  {
480  QuotedColors[ql] = A_NORMAL;
481  /* fallthrough to simple case */
482  }
483 
484  if ((cid != MT_COLOR_ATTACH_HEADERS) && (cid != MT_COLOR_BODY) &&
488  {
489  // Simple colours
490  SimpleColors[cid] = A_NORMAL;
491 
492  get_colorid_name(cid, buf);
493  mutt_debug(LL_NOTIFY, "NT_COLOR_RESET: %s\n", buf->data);
494  struct EventColor ev_c = { cid };
496  return MUTT_CMD_SUCCESS;
497  }
498 
499  if (!MoreArgs(s))
500  {
501  mutt_buffer_printf(err, _("%s: too few arguments"), uncolor ? "uncolor" : "unmono");
502  return MUTT_CMD_WARNING;
503  }
504 
505  if (OptNoCurses || // running without curses
506  (uncolor && !has_colors()) || // parsing an uncolor command, and have no colors
507  (!uncolor && has_colors())) // parsing an unmono command, and have colors
508  {
509  do
510  {
511  /* just eat the command, but don't do anything real about it */
513  } while (MoreArgs(s));
514 
515  return MUTT_CMD_SUCCESS;
516  }
517 
518  bool changed = false;
520  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_ATTACH_HEADERS), uncolor);
521  else if (cid == MT_COLOR_BODY)
522  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_BODY), uncolor);
523  else if (cid == MT_COLOR_HEADER)
524  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_HEADER), uncolor);
525  else if (cid == MT_COLOR_INDEX)
526  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_INDEX), uncolor);
527  else if (cid == MT_COLOR_INDEX_AUTHOR)
528  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_INDEX_AUTHOR), uncolor);
529  else if (cid == MT_COLOR_INDEX_FLAGS)
530  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_INDEX_FLAGS), uncolor);
531  else if (cid == MT_COLOR_INDEX_SUBJECT)
532  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_INDEX_SUBJECT), uncolor);
533  else if (cid == MT_COLOR_INDEX_TAG)
534  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_INDEX_TAG), uncolor);
535  else if (cid == MT_COLOR_STATUS)
536  changed |= do_uncolor(buf, s, regex_colors_get_list(MT_COLOR_STATUS), uncolor);
537 
538  if (changed)
539  {
540  get_colorid_name(cid, buf);
541  mutt_debug(LL_NOTIFY, "NT_COLOR_RESET: %s\n", buf->data);
542  struct EventColor ev_c = { cid };
544  }
545 
546  return MUTT_CMD_SUCCESS;
547 }
548 
556 int fgbgattr_to_color(int fg, int bg, int attrs)
557 {
558  if ((fg != COLOR_UNSET) && (bg != COLOR_UNSET))
559  return attrs | mutt_color_alloc(fg, bg);
560  return attrs;
561 }
562 
577 static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s,
578  struct Buffer *err, parser_callback_t callback,
579  bool dry_run, bool color)
580 {
581  int attrs = 0, q_level = 0;
582  uint32_t fg = 0, bg = 0, match = 0;
583  enum ColorId cid = MT_COLOR_NONE;
584  enum CommandResult rc;
585 
586  if (!MoreArgs(s))
587  {
588  mutt_buffer_printf(err, _("%s: too few arguments"), "color");
589  return MUTT_CMD_WARNING;
590  }
591 
593 
594  rc = parse_object(buf, s, &cid, &q_level, err);
595  if (rc != MUTT_CMD_SUCCESS)
596  return rc;
597 
598  rc = callback(buf, s, &fg, &bg, &attrs, err);
599  if (rc != MUTT_CMD_SUCCESS)
600  return rc;
601 
602  /* extract a regular expression if needed */
603 
604  if ((cid == MT_COLOR_ATTACH_HEADERS) || (cid == MT_COLOR_BODY) ||
605  (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_INDEX) ||
608  {
609  if (!MoreArgs(s))
610  {
611  mutt_buffer_printf(err, _("%s: too few arguments"), color ? "color" : "mono");
612  return MUTT_CMD_WARNING;
613  }
614 
616  }
617 
618  if (MoreArgs(s) && (cid != MT_COLOR_STATUS))
619  {
620  mutt_buffer_printf(err, _("%s: too many arguments"), color ? "color" : "mono");
621  return MUTT_CMD_WARNING;
622  }
623 
624  if (dry_run)
625  {
626  *s->dptr = '\0'; /* fake that we're done parsing */
627  return MUTT_CMD_SUCCESS;
628  }
629 
630  if (!OptNoCurses &&
631  has_colors()
632  /* delay use_default_colors() until needed, since it initializes things */
633  && ((fg == COLOR_DEFAULT) || (bg == COLOR_DEFAULT) || (cid == MT_COLOR_TREE)) &&
634  (use_default_colors() != OK))
635  /* the case of the tree cid is special, because a non-default fg color of
636  * the tree element may be combined dynamically with the default bg color of
637  * an index line, not necessarily defined in a rc file. */
638  {
639  mutt_buffer_strcpy(err, _("default colors not supported"));
640  return MUTT_CMD_ERROR;
641  }
642 
643  if (regex_colors_parse_color_list(cid, buf->data, fg, bg, attrs, &rc, err))
644  {
645  // do nothing
646  }
647  else if (quoted_colors_parse_color(cid, fg, bg, attrs, q_level, &rc, err))
648  {
649  // do nothing
650  }
651  else if ((cid == MT_COLOR_STATUS) && MoreArgs(s))
652  {
653  /* 'color status fg bg' can have up to 2 arguments:
654  * 0 arguments: sets the default status color (handled below by else part)
655  * 1 argument : colorize pattern on match
656  * 2 arguments: colorize nth submatch of pattern */
658 
659  if (MoreArgs(s))
660  {
661  struct Buffer tmp = mutt_buffer_make(0);
663  if (!mutt_str_atoui_full(tmp.data, &match))
664  {
665  mutt_buffer_printf(err, _("%s: invalid number: %s"),
666  color ? "color" : "mono", tmp.data);
667  mutt_buffer_dealloc(&tmp);
668  return MUTT_CMD_WARNING;
669  }
670  mutt_buffer_dealloc(&tmp);
671  }
672 
673  if (MoreArgs(s))
674  {
675  mutt_buffer_printf(err, _("%s: too many arguments"), color ? "color" : "mono");
676  return MUTT_CMD_WARNING;
677  }
678 
679  rc = regex_colors_parse_status_list(cid, buf->data, fg, bg, attrs, match, err);
680  }
681  else // Remaining simple colours
682  {
683  SimpleColors[cid] = fgbgattr_to_color(fg, bg, attrs);
684  rc = MUTT_CMD_SUCCESS;
685  }
686 
687  if (rc == MUTT_CMD_SUCCESS)
688  {
689  get_colorid_name(cid, buf);
690  mutt_debug(LL_NOTIFY, "NT_COLOR_SET: %s\n", buf->data);
691  struct EventColor ev_c = { cid };
693  }
694 
695  return rc;
696 }
697 
701 enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s,
702  intptr_t data, struct Buffer *err)
703 {
704  if (OptNoCurses || !has_colors())
705  {
706  *s->dptr = '\0'; /* fake that we're done parsing */
707  return MUTT_CMD_SUCCESS;
708  }
709  return parse_uncolor(buf, s, err, true);
710 }
711 
715 enum CommandResult mutt_parse_unmono(struct Buffer *buf, struct Buffer *s,
716  intptr_t data, struct Buffer *err)
717 {
718  if (OptNoCurses || !has_colors())
719  {
720  *s->dptr = '\0'; /* fake that we're done parsing */
721  return MUTT_CMD_SUCCESS;
722  }
723  return parse_uncolor(buf, s, err, false);
724 }
725 
729 enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s,
730  intptr_t data, struct Buffer *err)
731 {
732  bool dry_run = false;
733 
734  if (OptNoCurses || !has_colors())
735  dry_run = true;
736 
737  return parse_color(buf, s, err, parse_color_pair, dry_run, true);
738 }
739 
743 enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s,
744  intptr_t data, struct Buffer *err)
745 {
746  bool dry_run = false;
747 
748  if (OptNoCurses || has_colors())
749  dry_run = true;
750 
751  return parse_color(buf, s, err, parse_attr_spec, dry_run, false);
752 }
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
#define MoreArgs(buf)
Definition: buffer.h:40
int fgbgattr_to_color(int fg, int bg, int attrs)
Convert a foreground, background, attribute triplet into a colour.
Definition: command.c:556
const struct Mapping ComposeColorFields[]
Mapping of compose colour names to their IDs.
Definition: command.c:97
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
Definition: command.c:308
const struct Mapping ColorFields[]
Mapping of colour names to their IDs.
Definition: command.c:44
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.
Definition: command.c:577
static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *attrs, bool is_fg, struct Buffer *err)
Parse a colour name.
Definition: command.c:119
static enum CommandResult parse_object(struct Buffer *buf, struct Buffer *s, enum ColorId *cid, int *ql, struct Buffer *err)
Identify a colour object.
Definition: command.c:340
static enum CommandResult parse_uncolor(struct Buffer *buf, struct Buffer *s, struct Buffer *err, bool uncolor)
Parse an 'uncolor' command.
Definition: command.c:452
static bool do_uncolor(struct Buffer *buf, struct Buffer *s, struct RegexColorList *cl, bool uncolor)
Parse the 'uncolor' or 'unmono' command.
Definition: command.c:402
struct Notify * ColorsNotify
Notifications: ColorId, EventColor.
Definition: notify.c:33
struct RegexColorList * regex_colors_get_list(enum ColorId cid)
Return the RegexColorList for a colour id.
Definition: regex.c:130
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.
Definition: regex.c:290
void regex_color_free(struct RegexColor **ptr, bool free_colors)
Free a RegexColor.
Definition: regex.c:63
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.
Definition: regex.c:338
void regex_color_list_clear(struct RegexColorList *rcl)
Clear a list of colours.
Definition: regex.c:83
int SimpleColors[MT_COLOR_MAX]
Array of all fixed colours, see enum ColorId.
Definition: simple.c:36
const struct Mapping ColorNames[]
Definition: color.c:66
int mutt_color_alloc(uint32_t fg, uint32_t bg)
Allocate a colour pair.
Definition: color.c:188
void colors_clear(void)
Reset all the colours.
Definition: color.c:151
#define COLOR_DEFAULT
Definition: color.h:103
#define RGB24
Definition: color.h:101
#define COLOR_UNSET
Definition: color.h:104
ColorId
List of all colored objects.
Definition: color.h:35
@ MT_COLOR_SIDEBAR_DIVIDER
Line dividing sidebar from the index/pager.
Definition: color.h:60
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
Definition: color.h:50
@ MT_COLOR_COMPOSE_SECURITY_ENCRYPT
Mail will be encrypted.
Definition: color.h:43
@ MT_COLOR_MESSAGE
Informational message.
Definition: color.h:51
@ MT_COLOR_QUOTED
Pager: quoted text.
Definition: color.h:57
@ MT_COLOR_INDEX_AUTHOR
Index: author field (takes a pattern)
Definition: color.h:77
@ MT_COLOR_MAX
Definition: color.h:88
@ MT_COLOR_SIDEBAR_NEW
Mailbox with new mail.
Definition: color.h:64
@ MT_COLOR_HEADER
Message headers (takes a pattern)
Definition: color.h:48
@ MT_COLOR_STATUS
Status bar (takes a pattern)
Definition: color.h:70
@ MT_COLOR_SIDEBAR_UNREAD
Mailbox with unread mail.
Definition: color.h:67
@ MT_COLOR_INDEX_SIZE
Index: size field.
Definition: color.h:86
@ MT_COLOR_INDICATOR
Selected item in list.
Definition: color.h:49
@ MT_COLOR_SIDEBAR_SPOOLFILE
$spool_file (Spool mailbox)
Definition: color.h:66
@ MT_COLOR_ERROR
Error message.
Definition: color.h:46
@ MT_COLOR_NONE
Definition: color.h:36
@ MT_COLOR_COMPOSE_SECURITY_NONE
Mail will not be encrypted or signed.
Definition: color.h:44
@ MT_COLOR_SIDEBAR_ORDINARY
Mailbox with no new or flagged messages.
Definition: color.h:65
@ MT_COLOR_INDEX_TAGS
Index: tags field (g, J)
Definition: color.h:87
@ MT_COLOR_BOLD
Bold text.
Definition: color.h:40
@ MT_COLOR_INDEX_SUBJECT
Index: subject field (takes a pattern)
Definition: color.h:79
@ MT_COLOR_BODY
Pager: highlight body of message (takes a pattern)
Definition: color.h:39
@ MT_COLOR_INDEX_DATE
Index: date field.
Definition: color.h:83
@ MT_COLOR_PROGRESS
Progress bar.
Definition: color.h:55
@ MT_COLOR_COMPOSE_SECURITY_BOTH
Mail will be encrypted and signed.
Definition: color.h:42
@ MT_COLOR_INDEX_TAG
Index: tag field (g, takes a pattern)
Definition: color.h:80
@ MT_COLOR_HDRDEFAULT
Header default colour.
Definition: color.h:47
@ MT_COLOR_OPTIONS
Options in prompt.
Definition: color.h:54
@ MT_COLOR_TREE
Index: tree-drawing characters.
Definition: color.h:72
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:53
@ MT_COLOR_ATTACH_HEADERS
MIME attachment test (takes a pattern)
Definition: color.h:38
@ MT_COLOR_SEARCH
Pager: search matches.
Definition: color.h:58
@ MT_COLOR_COMPOSE_SECURITY_SIGN
Mail will be signed.
Definition: color.h:45
@ MT_COLOR_INDEX_LABEL
Index: label field.
Definition: color.h:84
@ MT_COLOR_PROMPT
Question/user input.
Definition: color.h:56
@ MT_COLOR_COMPOSE_HEADER
Header labels, e.g. From:
Definition: color.h:41
@ MT_COLOR_INDEX
Index: default colour (takes a pattern)
Definition: color.h:76
@ MT_COLOR_ATTACHMENT
MIME attachments text (entire line)
Definition: color.h:37
@ MT_COLOR_SIDEBAR_INDICATOR
Current open mailbox.
Definition: color.h:63
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
Definition: color.h:62
@ MT_COLOR_WARNING
Warning messages.
Definition: color.h:74
@ MT_COLOR_UNDERLINE
Underlined text.
Definition: color.h:73
@ MT_COLOR_INDEX_NUMBER
Index: index number.
Definition: color.h:85
@ MT_COLOR_SIGNATURE
Pager: signature lines.
Definition: color.h:69
@ MT_COLOR_INDEX_FLAGS
Index: flags field (takes a pattern)
Definition: color.h:78
@ MT_COLOR_SIDEBAR_FLAGGED
Mailbox with flagged messages.
Definition: color.h:61
@ MT_COLOR_TILDE
Pager: empty lines after message.
Definition: color.h:71
@ MT_COLOR_INDEX_COLLAPSED
Index: number of messages in collapsed thread.
Definition: color.h:82
int(* parser_callback_t)(struct Buffer *buf, struct Buffer *s, uint32_t *fg, uint32_t *bg, int *attrs, struct Buffer *err)
Definition: command2.h:46
CommandResult
Error codes for command_t parse functions.
Definition: command.h:34
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition: command.h:37
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition: command.h:35
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition: command.h:36
Convenience wrapper for the core headers.
enum CommandResult mutt_parse_unmono(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'unmono' command - Implements Command::parse() -.
Definition: command.c:715
enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'mono' command - Implements Command::parse() -.
Definition: command.c:743
enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'color' command - Implements Command::parse() -.
Definition: command.c:729
enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
Parse the 'uncolor' command - Implements Command::parse() -.
Definition: command.c:701
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
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 -.
Definition: command.c:245
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 -.
Definition: command.c:202
Convenience wrapper for the gui headers.
int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: init.c:399
Config/command parsing.
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
@ LL_NOTIFY
Log of notifications.
Definition: logging.h:45
int mutt_map_get_value(const char *name, const struct Mapping *map)
Lookup the constant for a string.
Definition: mapping.c:85
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition: mapping.c:42
Convenience wrapper for the library headers.
#define _(a)
Definition: message.h:28
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:171
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:727
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:715
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:158
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:170
Many unsorted constants and some structs.
#define MUTT_TOKEN_NO_FLAGS
No flags are set.
Definition: mutt.h:66
@ NT_COLOR_RESET
Color has been reset/removed.
Definition: notify2.h:42
@ NT_COLOR_SET
Color has been set.
Definition: notify2.h:41
@ NT_COLOR
Colour has changed, NotifyColor, EventColor.
Definition: notify_type.h:39
Handling of global boolean variables.
bool OptNoCurses
(pseudo) when sending in batch mode
Definition: options.h:53
#define STAILQ_REMOVE_HEAD(head, field)
Definition: queue.h:422
#define STAILQ_FIRST(head)
Definition: queue.h:350
#define STAILQ_REMOVE_AFTER(head, elm, field)
Definition: queue.h:416
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
int QuotedColors[COLOR_QUOTES_MAX]
Array of colours for quoted email text.
Definition: quoted.c:38
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.
Definition: quoted.c:92
#define COLOR_QUOTES_MAX
Ten colours, quoted0..quoted9 (quoted and quoted0 are equivalent)
Definition: quoted.h:35
String manipulation buffer.
Definition: buffer.h:34
char * dptr
Current read/write position.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:35
An Event that happened to a Colour.
Definition: notify2.h:53
enum ColorId cid
Colour ID that has changed.
Definition: notify2.h:54
Mapping between user-readable string and a constant.
Definition: mapping.h:32
const char * name
String value.
Definition: mapping.h:33
A regular expression and a color to highlight a line.
Definition: regex4.h:36
char * pattern
Pattern to match.
Definition: regex4.h:37