NeoMutt
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
command.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stddef.h>
31#include <assert.h>
32#include <stdbool.h>
33#include <stdint.h>
34#include <stdlib.h>
35#include "mutt/lib.h"
36#include "config/lib.h"
37#include "core/lib.h"
38#include "gui/lib.h"
39#include "parse/lib.h"
40#include "color.h"
41#include "command2.h"
42#include "debug.h"
43#include "globals.h"
44#include "notify2.h"
45#include "quoted.h"
46#include "regex4.h"
47#include "simple2.h"
48#ifdef USE_DEBUG_COLOR
49#include <stdio.h>
50#include "mutt.h"
51#include "pager/lib.h"
52#include "attr.h"
53#include "curses2.h"
54#include "merged.h"
55#include "pager/private_data.h" // IWYU pragma: keep
56#endif
57
61const struct Mapping ColorFields[] = {
62 // clang-format off
63 { "attachment", MT_COLOR_ATTACHMENT },
64 { "attach_headers", MT_COLOR_ATTACH_HEADERS },
65 { "body", MT_COLOR_BODY },
66 { "bold", MT_COLOR_BOLD },
67 { "error", MT_COLOR_ERROR },
68 { "hdrdefault", MT_COLOR_HDRDEFAULT },
69 { "header", MT_COLOR_HEADER },
70 { "index", MT_COLOR_INDEX },
71 { "index_author", MT_COLOR_INDEX_AUTHOR },
72 { "index_collapsed", MT_COLOR_INDEX_COLLAPSED },
73 { "index_date", MT_COLOR_INDEX_DATE },
74 { "index_flags", MT_COLOR_INDEX_FLAGS },
75 { "index_label", MT_COLOR_INDEX_LABEL },
76 { "index_number", MT_COLOR_INDEX_NUMBER },
77 { "index_size", MT_COLOR_INDEX_SIZE },
78 { "index_subject", MT_COLOR_INDEX_SUBJECT },
79 { "index_tag", MT_COLOR_INDEX_TAG },
80 { "index_tags", MT_COLOR_INDEX_TAGS },
81 { "indicator", MT_COLOR_INDICATOR },
82 { "italic", MT_COLOR_ITALIC },
83 { "markers", MT_COLOR_MARKERS },
84 { "message", MT_COLOR_MESSAGE },
85 { "normal", MT_COLOR_NORMAL },
86 { "options", MT_COLOR_OPTIONS },
87 { "progress", MT_COLOR_PROGRESS },
88 { "prompt", MT_COLOR_PROMPT },
89 { "quoted", MT_COLOR_QUOTED },
90 { "search", MT_COLOR_SEARCH },
91#ifdef USE_SIDEBAR
92 { "sidebar_background", MT_COLOR_SIDEBAR_BACKGROUND },
93 { "sidebar_divider", MT_COLOR_SIDEBAR_DIVIDER },
94 { "sidebar_flagged", MT_COLOR_SIDEBAR_FLAGGED },
95 { "sidebar_highlight", MT_COLOR_SIDEBAR_HIGHLIGHT },
96 { "sidebar_indicator", MT_COLOR_SIDEBAR_INDICATOR },
97 { "sidebar_new", MT_COLOR_SIDEBAR_NEW },
98 { "sidebar_ordinary", MT_COLOR_SIDEBAR_ORDINARY },
99 { "sidebar_spool_file", MT_COLOR_SIDEBAR_SPOOLFILE },
100 { "sidebar_spoolfile", MT_COLOR_SIDEBAR_SPOOLFILE }, // This will be deprecated
101 { "sidebar_unread", MT_COLOR_SIDEBAR_UNREAD },
102#endif
103 { "signature", MT_COLOR_SIGNATURE },
104 { "status", MT_COLOR_STATUS },
105 { "stripe_even", MT_COLOR_STRIPE_EVEN},
106 { "stripe_odd", MT_COLOR_STRIPE_ODD},
107 { "tilde", MT_COLOR_TILDE },
108 { "tree", MT_COLOR_TREE },
109 { "underline", MT_COLOR_UNDERLINE },
110 { "warning", MT_COLOR_WARNING },
111 { NULL, 0 },
112 // clang-format on
113};
114
118const struct Mapping ComposeColorFields[] = {
119 // clang-format off
120 { "header", MT_COLOR_COMPOSE_HEADER },
121 { "security_encrypt", MT_COLOR_COMPOSE_SECURITY_ENCRYPT },
122 { "security_sign", MT_COLOR_COMPOSE_SECURITY_SIGN },
123 { "security_both", MT_COLOR_COMPOSE_SECURITY_BOTH },
124 { "security_none", MT_COLOR_COMPOSE_SECURITY_NONE },
125 { NULL, 0 }
126 // clang-format on
127};
128
133{
138};
139
140#ifdef NEOMUTT_DIRECT_COLORS
211static uint32_t color_xterm256_to_24bit(const uint32_t color)
212{
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,
217 };
218
219 assert(color < 256);
220
221 if (color < 16)
222 {
223 color_debug(LL_DEBUG5, "Converted color 0-15: %d\n", color);
224 /* The first 16 colours are the "usual" terminal colours */
225 return basic[color];
226 }
227
228 if (color < 232)
229 {
230 /* The Color palette is divided in 6x6x6 colours, i.e. each R, G, B channel
231 * has six values:
232 *
233 * value: 1 2 3 4 5 6
234 * color: 0x00 0x5f 0x87 0xaf 0xd7 0xff
235 *
236 * The steps between the values is 0x28 = 40, the EXCEPT for the first one
237 * where it is 0x5f = 95.
238 *
239 * If we express the xterm color number minus 16 to base 6, i.e.
240 *
241 * color - 16 = (vr * 36) + (vg * 6) + (vb * 1)
242 *
243 * with vr, vg, vb integers between 0 and 5, then vr, vg, vb is the channel
244 * value for red, green, and blue, respectively.
245 */
246
247 uint32_t normalised_color = color - 16;
248 uint32_t vr = (normalised_color % 216) / 36; /* 216 = 6*6*6 */
249 uint32_t vg = (normalised_color % 36) / 6;
250 uint32_t vb = (normalised_color % 6) / 1;
251
252 /* First step is wider than the other ones, so add the difference if needed */
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);
256
257 uint32_t rgb = (r << 16) + (g << 8) + (b << 0);
258 color_debug(LL_DEBUG5, "Converted xterm color %d to RGB #%x:\n", color, rgb);
259 return rgb;
260 }
261
262 /* Grey scale starts at 0x08 and adds 0xa = 10 in very step ending in 0xee.
263 * There are a total of 6*4 = 24 grey colors in total. */
264 uint32_t steps = color - 232;
265 uint32_t grey = (steps * 0x0a) + 0x08;
266 uint32_t rgb = (grey << 16) + (grey << 8) + (grey << 0);
267 color_debug(LL_DEBUG5, "Converted xterm color %d to RGB #%x:\n", color, rgb);
268 return rgb;
269}
270#endif
271
279static void modify_color_by_prefix(enum ColorPrefix prefix, bool is_fg,
280 uint32_t *col, int *attrs)
281{
282 if (prefix == COLOR_PREFIX_NONE)
283 return; // nothing to do here
284
285 if (prefix == COLOR_PREFIX_ALERT)
286 {
287 *attrs |= A_BOLD;
288 *attrs |= A_BLINK;
289 }
290 else if (is_fg)
291 {
292 if ((COLORS >= 16) && (prefix == COLOR_PREFIX_LIGHT))
293 {
294 if (*col <= 7)
295 {
296 /* Advance the color 0-7 by 8 to get the light version */
297 *col += 8;
298 }
299 }
300 else
301 {
302 *attrs |= A_BOLD;
303 }
304 }
305 else
306 {
307 if (COLORS >= 16)
308 {
309 if (*col <= 7)
310 {
311 /* Advance the color 0-7 by 8 to get the light version */
312 *col += 8;
313 }
314 }
315 }
316}
317
328static int parse_color_prefix(const char *s, enum ColorPrefix *prefix)
329{
330 int clen = 0;
331
332 if ((clen = mutt_istr_startswith(s, "bright")))
333 {
334 color_debug(LL_DEBUG5, "bright\n");
335 if (prefix)
336 *prefix = COLOR_PREFIX_BRIGHT;
337 }
338 else if ((clen = mutt_istr_startswith(s, "alert")))
339 {
340 color_debug(LL_DEBUG5, "alert\n");
341 if (prefix)
342 *prefix = COLOR_PREFIX_ALERT;
343 }
344 else if ((clen = mutt_istr_startswith(s, "light")))
345 {
346 color_debug(LL_DEBUG5, "light\n");
347 if (prefix)
348 *prefix = COLOR_PREFIX_LIGHT;
349 }
350
351 return clen;
352}
353
364static enum CommandResult parse_color_namedcolor(const char *s, uint32_t *col, int *attrs,
365 bool is_fg, struct Buffer *err)
366{
367 enum ColorPrefix prefix = COLOR_PREFIX_NONE;
368 s += parse_color_prefix(s, &prefix);
369
370 if ((*col = mutt_map_get_value(s, ColorNames)) == -1)
371 return MUTT_CMD_WARNING;
372
373 const char *name = mutt_map_get_name(*col, ColorNames);
374 if (name)
375 color_debug(LL_DEBUG5, "color: %s\n", name);
376
377 modify_color_by_prefix(prefix, is_fg, col, attrs);
378
379#ifdef NEOMUTT_DIRECT_COLORS
380 /* If we are running in direct color mode, we must convert the color
381 * number 0-15 to an RGB value.
382 * The first 16 colours of the xterm palette correspond to the terminal
383 * colours. Note that this replace the colour with a predefined RGB value
384 * and not the RGB value the terminal configured to use.
385 *
386 * Note that some colors are "special" e.g. "default" and do not fall in
387 * the range from 0 to 15. These must not be converted.
388 */
389 const bool c_color_directcolor = cs_subset_bool(NeoMutt->sub, "color_directcolor");
390 if (c_color_directcolor && (*col < 16))
391 {
392 *col = color_xterm256_to_24bit(*col);
393 }
394#endif
395 return MUTT_CMD_SUCCESS;
396}
397
411static enum CommandResult parse_color_colornnn(const char *s, uint32_t *col, int *attrs,
412 bool is_fg, struct Buffer *err)
413{
414 /* prefixes bright, alert, light are only allowed for named colours and
415 * colorNNN for backwards compatibility. */
416 enum ColorPrefix prefix = COLOR_PREFIX_NONE;
417 s += parse_color_prefix(s, &prefix);
418
419 int clen = 0;
420 /* allow aliases for xterm color resources */
421 if ((clen = mutt_istr_startswith(s, "color")) == 0)
422 return MUTT_CMD_WARNING;
423
424 s += clen;
425 char *eptr = NULL;
426 *col = strtoul(s, &eptr, 10);
427 /* There are only 256 xterm colors. Do not confuse with COLORS which is
428 * the number of colours the terminal supports (usually one of 16, 256,
429 * 16777216 (=24bit)). */
430 if ((*s == '\0') || (*eptr != '\0') || (*col >= 256) || ((*col >= COLORS) && !OptNoCurses))
431 {
432 buf_printf(err, _("%s: color not supported by term"), s);
433 return MUTT_CMD_ERROR;
434 }
435
436 modify_color_by_prefix(prefix, is_fg, col, attrs);
437
438#ifdef NEOMUTT_DIRECT_COLORS
439 const bool c_color_directcolor = cs_subset_bool(NeoMutt->sub, "color_directcolor");
440 if (c_color_directcolor)
441 {
442 /* If we are running in direct color mode, we must convert the xterm
443 * color numbers 0-255 to an RGB value. */
444 *col = color_xterm256_to_24bit(*col);
445 /* FIXME: The color values 0 to 7 (both inclusive) are still occupied by
446 * the default terminal colours. As a workaround we round them up to
447 * #000008 which is the blackest black we can produce. */
448 if (*col < 8)
449 *col = 8;
450 }
451#endif
452 color_debug(LL_DEBUG5, "colorNNN %d\n", *col);
453 return MUTT_CMD_SUCCESS;
454}
455
469static enum CommandResult parse_color_rrggbb(const char *s, uint32_t *col, int *attrs,
470 bool is_fg, struct Buffer *err)
471{
472 /* parse #RRGGBB colours */
473 if (s[0] != '#')
474 return MUTT_CMD_WARNING;
475
476#ifndef NEOMUTT_DIRECT_COLORS
477 buf_printf(err, _("Direct colors support not compiled in: %s"), s);
478 return MUTT_CMD_ERROR;
479#endif
480 const bool c_color_directcolor = cs_subset_bool(NeoMutt->sub, "color_directcolor");
481 if (!c_color_directcolor)
482 {
483 buf_printf(err, _("Direct colors support disabled: %s"), s);
484 return MUTT_CMD_ERROR;
485 }
486 s++;
487 char *eptr = NULL;
488 *col = strtoul(s, &eptr, 16);
489 if ((*s == '\0') || (*eptr != '\0') || ((*col >= COLORS) && !OptNoCurses))
490 {
491 buf_printf(err, _("%s: color not supported by term"), s);
492 return MUTT_CMD_ERROR;
493 }
494 /* FIXME: The color values 0 to 7 (both inclusive) are still occupied by
495 * the default terminal colours. As a workaround we round them up to
496 * #000008 which is the blackest black we can produce. */
497 if (*col < 8)
498 *col = 8;
499
500 color_debug(LL_DEBUG5, "#RRGGBB: %d\n", *col);
501 return MUTT_CMD_SUCCESS;
502}
503
515static enum CommandResult parse_color_name(const char *s, uint32_t *col, int *attrs,
516 bool is_fg, struct Buffer *err)
517{
518 mutt_debug(LL_DEBUG5, "Parsing color name: %s\n", s);
519
520 /* Try the different colour syntaxes. A return value of MUTT_CMD_WARNING
521 * means, we should try the next syntax. */
522 enum CommandResult cr;
523
524 /* #RRGGBB */
525 cr = parse_color_rrggbb(s, col, attrs, is_fg, err);
526 if (cr != MUTT_CMD_WARNING)
527 return cr;
528 /* color123 */
529 cr = parse_color_colornnn(s, col, attrs, is_fg, err);
530 if (cr != MUTT_CMD_WARNING)
531 return cr;
532 /* named color, e.g. "brightred" */
533 cr = parse_color_namedcolor(s, col, attrs, is_fg, err);
534 if (cr != MUTT_CMD_WARNING)
535 return cr;
536
537 buf_printf(err, _("%s: no such color"), s);
538 return MUTT_CMD_WARNING;
539}
540
544static enum CommandResult parse_attr_spec(struct Buffer *buf, struct Buffer *s,
545 uint32_t *fg, uint32_t *bg,
546 int *attrs, struct Buffer *err)
547{
548 if (fg)
549 *fg = COLOR_UNSET;
550 if (bg)
551 *bg = COLOR_UNSET;
552
553 if (!MoreArgs(s))
554 {
555 buf_printf(err, _("%s: too few arguments"), "mono");
556 return MUTT_CMD_WARNING;
557 }
558
560
561 if (mutt_istr_equal("bold", buf->data))
562 {
563 *attrs |= A_BOLD;
564 }
565 else if (mutt_istr_equal("italic", buf->data))
566 {
567 *attrs |= A_ITALIC;
568 }
569 else if (mutt_istr_equal("none", buf->data))
570 {
571 *attrs = A_NORMAL; // Use '=' to clear other bits
572 }
573 else if (mutt_istr_equal("normal", buf->data))
574 {
575 *attrs = A_NORMAL; // Use '=' to clear other bits
576 }
577 else if (mutt_istr_equal("reverse", buf->data))
578 {
579 *attrs |= A_REVERSE;
580 }
581 else if (mutt_istr_equal("standout", buf->data))
582 {
583 *attrs |= A_STANDOUT;
584 }
585 else if (mutt_istr_equal("underline", buf->data))
586 {
587 *attrs |= A_UNDERLINE;
588 }
589 else
590 {
591 buf_printf(err, _("%s: no such attribute"), buf->data);
592 return MUTT_CMD_WARNING;
593 }
594
595 return MUTT_CMD_SUCCESS;
596}
597
603static enum CommandResult parse_color_pair(struct Buffer *buf, struct Buffer *s,
604 uint32_t *fg, uint32_t *bg,
605 int *attrs, struct Buffer *err)
606{
607 while (true)
608 {
609 if (!MoreArgsF(s, TOKEN_COMMENT))
610 {
611 buf_printf(err, _("%s: too few arguments"), "color");
612 return MUTT_CMD_WARNING;
613 }
614
616
617 if (mutt_istr_equal("bold", buf->data))
618 {
619 *attrs |= A_BOLD;
620 color_debug(LL_DEBUG5, "bold\n");
621 }
622 else if (mutt_istr_equal("italic", buf->data))
623 {
624 *attrs |= A_ITALIC;
625 color_debug(LL_DEBUG5, "italic\n");
626 }
627 else if (mutt_istr_equal("none", buf->data))
628 {
629 *attrs = A_NORMAL; // Use '=' to clear other bits
630 color_debug(LL_DEBUG5, "none\n");
631 }
632 else if (mutt_istr_equal("normal", buf->data))
633 {
634 *attrs = A_NORMAL; // Use '=' to clear other bits
635 color_debug(LL_DEBUG5, "normal\n");
636 }
637 else if (mutt_istr_equal("reverse", buf->data))
638 {
639 *attrs |= A_REVERSE;
640 color_debug(LL_DEBUG5, "reverse\n");
641 }
642 else if (mutt_istr_equal("standout", buf->data))
643 {
644 *attrs |= A_STANDOUT;
645 color_debug(LL_DEBUG5, "standout\n");
646 }
647 else if (mutt_istr_equal("underline", buf->data))
648 {
649 *attrs |= A_UNDERLINE;
650 color_debug(LL_DEBUG5, "underline\n");
651 }
652 else
653 {
654 enum CommandResult rc = parse_color_name(buf->data, fg, attrs, true, err);
655 if (rc != MUTT_CMD_SUCCESS)
656 return rc;
657 break;
658 }
659 }
660
661 if (!MoreArgsF(s, TOKEN_COMMENT))
662 {
663 buf_printf(err, _("%s: too few arguments"), "color");
664 return MUTT_CMD_WARNING;
665 }
666
668
669 return parse_color_name(buf->data, bg, attrs, false, err);
670}
671
677void get_colorid_name(unsigned int cid, struct Buffer *buf)
678{
679 const char *name = NULL;
680
682 {
684 if (name)
685 {
686 buf_printf(buf, "compose %s", name);
687 return;
688 }
689 }
690
692 if (name)
693 buf_addstr(buf, name);
694 else
695 buf_printf(buf, "UNKNOWN %d", cid);
696}
697
709static enum CommandResult parse_object(struct Buffer *buf, struct Buffer *s,
710 enum ColorId *cid, int *ql, struct Buffer *err)
711{
712 int rc;
713
714 if (mutt_str_startswith(buf->data, "quoted") != 0)
715 {
716 int val = 0;
717 if (buf->data[6] != '\0')
718 {
719 if (!mutt_str_atoi_full(buf->data + 6, &val) || (val > COLOR_QUOTES_MAX))
720 {
721 buf_printf(err, _("%s: no such object"), buf->data);
722 return MUTT_CMD_WARNING;
723 }
724 }
725
726 *ql = val;
727 *cid = MT_COLOR_QUOTED;
728 return MUTT_CMD_SUCCESS;
729 }
730
731 if (mutt_istr_equal(buf->data, "compose"))
732 {
733 if (!MoreArgs(s))
734 {
735 buf_printf(err, _("%s: too few arguments"), "color");
736 return MUTT_CMD_WARNING;
737 }
738
740
742 if (rc == -1)
743 {
744 buf_printf(err, _("%s: no such object"), buf->data);
745 return MUTT_CMD_WARNING;
746 }
747
748 *cid = rc;
749 return MUTT_CMD_SUCCESS;
750 }
751
753 if (rc == -1)
754 {
755 buf_printf(err, _("%s: no such object"), buf->data);
756 return MUTT_CMD_WARNING;
757 }
758 else
759 {
760 color_debug(LL_DEBUG5, "object: %s\n", mutt_map_get_name(rc, ColorFields));
761 }
762
763 *cid = rc;
764 return MUTT_CMD_SUCCESS;
765}
766
779static enum CommandResult parse_uncolor(struct Buffer *buf, struct Buffer *s,
780 struct Buffer *err, bool uncolor)
781{
783
784 if (mutt_str_equal(buf->data, "*"))
785 {
787 return MUTT_CMD_SUCCESS;
788 }
789
790 unsigned int cid = MT_COLOR_NONE;
791 int ql = 0;
792 color_debug(LL_DEBUG5, "uncolor: %s\n", buf_string(buf));
793 enum CommandResult rc = parse_object(buf, s, &cid, &ql, err);
794 if (rc != MUTT_CMD_SUCCESS)
795 return rc;
796
797 if (cid == -1)
798 {
799 buf_printf(err, _("%s: no such object"), buf->data);
800 return MUTT_CMD_ERROR;
801 }
802
803 if (cid == MT_COLOR_QUOTED)
804 {
805 color_debug(LL_DEBUG5, "quoted\n");
806 return quoted_colors_parse_uncolor(cid, ql, err);
807 }
808
809 if ((cid == MT_COLOR_STATUS) && !MoreArgs(s))
810 {
811 color_debug(LL_DEBUG5, "simple\n");
812 simple_color_reset(cid); // default colour for the status bar
813 return MUTT_CMD_SUCCESS;
814 }
815
816 if (!mutt_color_has_pattern(cid))
817 {
818 color_debug(LL_DEBUG5, "simple\n");
820 return MUTT_CMD_SUCCESS;
821 }
822
823 if (OptNoCurses)
824 {
825 do
826 {
827 color_debug(LL_DEBUG5, "do nothing\n");
828 /* just eat the command, but don't do anything real about it */
830 } while (MoreArgs(s));
831
832 return MUTT_CMD_SUCCESS;
833 }
834
835 bool changes = false;
836 if (!MoreArgs(s))
837 {
838 if (regex_colors_parse_uncolor(cid, NULL, uncolor))
839 return MUTT_CMD_SUCCESS;
840 else
841 return MUTT_CMD_ERROR;
842 }
843
844 do
845 {
847 if (mutt_str_equal("*", buf->data))
848 {
849 if (regex_colors_parse_uncolor(cid, NULL, uncolor))
850 return MUTT_CMD_SUCCESS;
851 else
852 return MUTT_CMD_ERROR;
853 }
854
855 changes |= regex_colors_parse_uncolor(cid, buf->data, uncolor);
856
857 } while (MoreArgs(s));
858
859 if (changes)
861
862 return MUTT_CMD_SUCCESS;
863}
864
865#ifdef USE_DEBUG_COLOR
869static enum CommandResult color_dump(struct Buffer *buf, struct Buffer *s,
870 intptr_t data, struct Buffer *err)
871{
872 if (MoreArgs(s))
873 return MUTT_CMD_ERROR;
874
875 FILE *fp_out = NULL;
876 struct Buffer *tempfile = buf_pool_get();
877 struct Buffer filebuf = buf_make(4096);
878 char color_fg[32] = { 0 };
879 char color_bg[32] = { 0 };
880
881 buf_mktemp(tempfile);
882 fp_out = mutt_file_fopen(buf_string(tempfile), "w");
883 if (!fp_out)
884 {
885 // L10N: '%s' is the file name of the temporary file
886 buf_printf(err, _("Could not create temporary file %s"), buf_string(tempfile));
887 buf_dealloc(&filebuf);
888 buf_pool_release(&tempfile);
889 return MUTT_CMD_ERROR;
890 }
891
892 buf_addstr(&filebuf, "# All Colours\n\n");
893 buf_addstr(&filebuf, "# Simple Colours\n");
894 for (enum ColorId cid = MT_COLOR_NONE + 1; cid < MT_COLOR_MAX; cid++)
895 {
896 struct AttrColor *ac = simple_color_get(cid);
897 if (!ac)
898 continue;
899
900 struct CursesColor *cc = ac->curses_color;
901 if (!cc)
902 continue;
903
904 const char *name = mutt_map_get_name(cid, ColorFields);
905 if (!name)
906 continue;
907
908 const char *swatch = color_debug_log_color_attrs(cc->fg, cc->bg, ac->attrs);
909 buf_add_printf(&filebuf, "color %-18s %-30s %-8s %-8s # %s\n", name,
911 color_debug_log_name(color_fg, sizeof(color_fg), cc->fg),
912 color_debug_log_name(color_bg, sizeof(color_bg), cc->bg), swatch);
913 }
914
915 if (NumQuotedColors > 0)
916 {
917 buf_addstr(&filebuf, "\n# Quoted Colours\n");
918 for (int i = 0; i < NumQuotedColors; i++)
919 {
920 struct AttrColor *ac = quoted_colors_get(i);
921 if (!ac)
922 continue;
923
924 struct CursesColor *cc = ac->curses_color;
925 if (!cc)
926 continue;
927
928 const char *swatch = color_debug_log_color_attrs(cc->fg, cc->bg, ac->attrs);
929 buf_add_printf(&filebuf, "color quoted%d %-30s %-8s %-8s # %s\n", i,
931 color_debug_log_name(color_fg, sizeof(color_fg), cc->fg),
932 color_debug_log_name(color_bg, sizeof(color_bg), cc->bg), swatch);
933 }
934 }
935
936 int rl_count = 0;
937 for (enum ColorId id = MT_COLOR_NONE; id != MT_COLOR_MAX; ++id)
938 {
939 if (!mutt_color_has_pattern(id))
940 {
941 continue;
942 }
943
944 struct RegexColorList *rcl = regex_colors_get_list(id);
945 if (!STAILQ_EMPTY(rcl))
946 rl_count++;
947 }
948
949 if (rl_count > 0)
950 {
951 for (enum ColorId id = MT_COLOR_NONE; id != MT_COLOR_MAX; ++id)
952 {
953 if (!mutt_color_has_pattern(id))
954 {
955 continue;
956 }
957
958 struct RegexColorList *rcl = regex_colors_get_list(id);
959 if (STAILQ_EMPTY(rcl))
960 continue;
961
962 const char *name = mutt_map_get_name(id, ColorFields);
963 if (!name)
964 continue;
965
966 buf_add_printf(&filebuf, "\n# Regex Colour %s\n", name);
967
968 struct RegexColor *rc = NULL;
969 STAILQ_FOREACH(rc, rcl, entries)
970 {
971 struct AttrColor *ac = &rc->attr_color;
972 struct CursesColor *cc = ac->curses_color;
973 if (!cc)
974 continue;
975
976 const char *swatch = color_debug_log_color_attrs(cc->fg, cc->bg, ac->attrs);
977 buf_add_printf(&filebuf, "color %-14s %-30s %-8s %-8s %-30s # %s\n",
979 color_debug_log_name(color_fg, sizeof(color_fg), cc->fg),
980 color_debug_log_name(color_bg, sizeof(color_bg), cc->bg),
981 rc->pattern, swatch);
982 }
983 }
984 }
985
986#ifdef USE_DEBUG_COLOR
988 {
989 buf_addstr(&filebuf, "\n# Merged Colours\n");
990 struct AttrColor *ac = NULL;
991 TAILQ_FOREACH(ac, &MergedColors, entries)
992 {
993 struct CursesColor *cc = ac->curses_color;
994 if (!cc)
995 continue;
996
997 const char *swatch = color_debug_log_color_attrs(cc->fg, cc->bg, ac->attrs);
998 buf_add_printf(&filebuf, "# %-30s %-8s %-8s # %s\n",
1000 color_debug_log_name(color_fg, sizeof(color_fg), cc->fg),
1001 color_debug_log_name(color_bg, sizeof(color_bg), cc->bg), swatch);
1002 }
1003 }
1004
1005 struct MuttWindow *win = window_get_focus();
1006 if (win && (win->type == WT_CUSTOM) && win->parent && (win->parent->type == WT_PAGER))
1007 {
1008 struct PagerPrivateData *priv = win->parent->wdata;
1009 if (priv && !TAILQ_EMPTY(&priv->ansi_list))
1010 {
1011 buf_addstr(&filebuf, "\n# Ansi Colours\n");
1012 struct AttrColor *ac = NULL;
1013 TAILQ_FOREACH(ac, &priv->ansi_list, entries)
1014 {
1015 struct CursesColor *cc = ac->curses_color;
1016 if (!cc)
1017 continue;
1018
1019 const char *swatch = color_debug_log_color_attrs(cc->fg, cc->bg, ac->attrs);
1020 buf_add_printf(&filebuf, "# %-30s %-8s %-8s # %s\n",
1022 color_debug_log_name(color_fg, sizeof(color_fg), cc->fg),
1023 color_debug_log_name(color_bg, sizeof(color_bg), cc->bg), swatch);
1024 }
1025 }
1026 }
1027#endif
1028
1029 fputs(filebuf.data, fp_out);
1030
1031 mutt_file_fclose(&fp_out);
1032 buf_dealloc(&filebuf);
1033
1034 struct PagerData pdata = { 0 };
1035 struct PagerView pview = { &pdata };
1036
1037 pdata.fname = buf_string(tempfile);
1038
1039 pview.banner = "color";
1040 pview.flags = MUTT_SHOWCOLOR;
1041 pview.mode = PAGER_MODE_OTHER;
1042
1043 mutt_do_pager(&pview, NULL);
1044 buf_pool_release(&tempfile);
1045
1046 return MUTT_CMD_SUCCESS;
1047}
1048#endif
1049
1064static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s,
1065 struct Buffer *err, parser_callback_t callback,
1066 bool dry_run, bool color)
1067{
1068 int attrs = 0, q_level = 0;
1069 uint32_t fg = 0, bg = 0, match = 0;
1070 enum ColorId cid = MT_COLOR_NONE;
1071 enum CommandResult rc;
1072
1073 if (!MoreArgs(s))
1074 {
1075#ifdef USE_DEBUG_COLOR
1076 if (StartupComplete)
1077 return color_dump(buf, s, 0, err);
1078#endif
1079
1080 buf_printf(err, _("%s: too few arguments"), "color");
1081 return MUTT_CMD_WARNING;
1082 }
1083
1085 color_debug(LL_DEBUG5, "color: %s\n", buf_string(buf));
1086
1087 rc = parse_object(buf, s, &cid, &q_level, err);
1088 if (rc != MUTT_CMD_SUCCESS)
1089 return rc;
1090
1091 rc = callback(buf, s, &fg, &bg, &attrs, err);
1092 if (rc != MUTT_CMD_SUCCESS)
1093 return rc;
1094
1095 /* extract a regular expression if needed */
1096
1097 if (mutt_color_has_pattern(cid) && cid != MT_COLOR_STATUS)
1098 {
1099 color_debug(LL_DEBUG5, "regex needed\n");
1100 if (MoreArgs(s))
1101 {
1103 }
1104 else
1105 {
1106 buf_strcpy(buf, ".*");
1107 }
1108 }
1109
1110 if (MoreArgs(s) && (cid != MT_COLOR_STATUS))
1111 {
1112 buf_printf(err, _("%s: too many arguments"), color ? "color" : "mono");
1113 return MUTT_CMD_WARNING;
1114 }
1115
1116 if (dry_run)
1117 {
1118 color_debug(LL_DEBUG5, "dry_run bailout\n");
1119 *s->dptr = '\0'; /* fake that we're done parsing */
1120 return MUTT_CMD_SUCCESS;
1121 }
1122
1123 /* The case of the tree object is special, because a non-default fg color of
1124 * the tree element may be combined dynamically with the default bg color of
1125 * an index line, not necessarily defined in a rc file. */
1126 if (!OptNoCurses &&
1127 ((fg == COLOR_DEFAULT) || (bg == COLOR_DEFAULT) || (cid == MT_COLOR_TREE)) &&
1128 (use_default_colors() != OK))
1129 {
1130 buf_strcpy(err, _("default colors not supported"));
1131 return MUTT_CMD_ERROR;
1132 }
1133
1134 if (regex_colors_parse_color_list(cid, buf->data, fg, bg, attrs, &rc, err))
1135 {
1136 color_debug(LL_DEBUG5, "regex_colors_parse_color_list done\n");
1137 return rc;
1138 // do nothing
1139 }
1140 else if (quoted_colors_parse_color(cid, fg, bg, attrs, q_level, &rc, err))
1141 {
1142 color_debug(LL_DEBUG5, "quoted_colors_parse_color done\n");
1143 return rc;
1144 // do nothing
1145 }
1146 else if ((cid == MT_COLOR_STATUS) && MoreArgs(s))
1147 {
1148 color_debug(LL_DEBUG5, "status\n");
1149 /* 'color status fg bg' can have up to 2 arguments:
1150 * 0 arguments: sets the default status color (handled below by else part)
1151 * 1 argument : colorize pattern on match
1152 * 2 arguments: colorize nth submatch of pattern */
1154
1155 if (MoreArgs(s))
1156 {
1157 struct Buffer tmp = buf_make(0);
1159 if (!mutt_str_atoui_full(tmp.data, &match))
1160 {
1161 buf_printf(err, _("%s: invalid number: %s"), color ? "color" : "mono", tmp.data);
1162 buf_dealloc(&tmp);
1163 return MUTT_CMD_WARNING;
1164 }
1165 buf_dealloc(&tmp);
1166 }
1167
1168 if (MoreArgs(s))
1169 {
1170 buf_printf(err, _("%s: too many arguments"), color ? "color" : "mono");
1171 return MUTT_CMD_WARNING;
1172 }
1173
1174 rc = regex_colors_parse_status_list(cid, buf->data, fg, bg, attrs, match, err);
1175 return rc;
1176 }
1177 else // Remaining simple colours
1178 {
1179 color_debug(LL_DEBUG5, "simple\n");
1180 if (simple_color_set(cid, fg, bg, attrs))
1181 rc = MUTT_CMD_SUCCESS;
1182 else
1183 rc = MUTT_CMD_ERROR;
1184 }
1185
1186 if (rc == MUTT_CMD_SUCCESS)
1187 {
1188 get_colorid_name(cid, buf);
1189 color_debug(LL_DEBUG5, "NT_COLOR_SET: %s\n", buf->data);
1190 struct EventColor ev_c = { cid, NULL };
1192 }
1193
1194 return rc;
1195}
1196
1200enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s,
1201 intptr_t data, struct Buffer *err)
1202{
1203 if (OptNoCurses)
1204 {
1205 *s->dptr = '\0'; /* fake that we're done parsing */
1206 return MUTT_CMD_SUCCESS;
1207 }
1208 color_debug(LL_DEBUG5, "parse: %s\n", buf_string(buf));
1209 enum CommandResult rc = parse_uncolor(buf, s, err, true);
1211 return rc;
1212}
1213
1217enum CommandResult mutt_parse_unmono(struct Buffer *buf, struct Buffer *s,
1218 intptr_t data, struct Buffer *err)
1219{
1220 *s->dptr = '\0'; /* fake that we're done parsing */
1221 return MUTT_CMD_SUCCESS;
1222}
1223
1227enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s,
1228 intptr_t data, struct Buffer *err)
1229{
1230 bool dry_run = OptNoCurses;
1231
1232 color_debug(LL_DEBUG5, "parse: %s\n", buf_string(buf));
1233 enum CommandResult rc = parse_color(buf, s, err, parse_color_pair, dry_run, true);
1235 return rc;
1236}
1237
1241enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s,
1242 intptr_t data, struct Buffer *err)
1243{
1244 return parse_color(buf, s, err, parse_attr_spec, true, false);
1245}
Colour and attributes.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:173
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:216
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:389
struct Buffer buf_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:70
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:238
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:407
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:93
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.
Definition: command.c:411
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.
Definition: command.c:469
static int parse_color_prefix(const char *s, enum ColorPrefix *prefix)
Parse a colour prefix, e.g.
Definition: command.c:328
static uint32_t color_xterm256_to_24bit(const uint32_t color)
Convert a xterm color to its RGB value.
Definition: command.c:211
const struct Mapping ComposeColorFields[]
Mapping of compose colour names to their IDs.
Definition: command.c:118
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
Definition: command.c:677
const struct Mapping ColorFields[]
Mapping of colour names to their IDs.
Definition: command.c:61
ColorPrefix
Constants for colour prefixes of named colours.
Definition: command.c:133
@ COLOR_PREFIX_NONE
no prefix
Definition: command.c:134
@ COLOR_PREFIX_ALERT
"alert" colour prefix
Definition: command.c:135
@ COLOR_PREFIX_LIGHT
"light" colour prefix
Definition: command.c:137
@ COLOR_PREFIX_BRIGHT
"bright" colour prefix
Definition: command.c:136
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:1064
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:515
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:709
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.
Definition: command.c:364
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.
Definition: command.c:279
static enum CommandResult parse_uncolor(struct Buffer *buf, struct Buffer *s, struct Buffer *err, bool uncolor)
Parse an 'uncolor' command.
Definition: command.c:779
struct Notify * ColorsNotify
Notifications: ColorId, EventColor.
Definition: notify.c:35
struct RegexColorList * regex_colors_get_list(enum ColorId cid)
Return the RegexColorList for a colour id.
Definition: regex.c:184
bool regex_colors_parse_uncolor(enum ColorId cid, const char *pat, bool uncolor)
Parse a Regex 'uncolor' command.
Definition: regex.c:439
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:340
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:410
struct AttrColor * simple_color_set(enum ColorId cid, int fg, int bg, int attrs)
Set the colour of a simple object.
Definition: simple.c:125
void simple_color_reset(enum ColorId cid)
Clear the colour of a simple object.
Definition: simple.c:151
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:81
const struct Mapping ColorNames[]
Mapping between a colour name and an ncurses colour.
Definition: color.c:46
void colors_cleanup(void)
Reset all the simple, quoted and regex colours.
Definition: color.c:64
bool mutt_color_has_pattern(enum ColorId cid)
Check if a color object supports a regex pattern.
Definition: color.c:110
Color and attribute parsing.
#define COLOR_DEFAULT
Definition: color.h:104
#define COLOR_UNSET
Definition: color.h:105
ColorId
List of all colored objects.
Definition: color.h:38
@ MT_COLOR_SIDEBAR_DIVIDER
Line dividing sidebar from the index/pager.
Definition: color.h:65
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
Definition: color.h:54
@ MT_COLOR_COMPOSE_SECURITY_ENCRYPT
Mail will be encrypted.
Definition: color.h:46
@ MT_COLOR_MESSAGE
Informational message.
Definition: color.h:55
@ MT_COLOR_QUOTED
Pager: quoted text.
Definition: color.h:61
@ MT_COLOR_INDEX_AUTHOR
Index: author field.
Definition: color.h:84
@ MT_COLOR_MAX
Definition: color.h:94
@ MT_COLOR_SIDEBAR_NEW
Mailbox with new mail.
Definition: color.h:69
@ MT_COLOR_HEADER
Message headers (takes a pattern)
Definition: color.h:51
@ MT_COLOR_STATUS
Status bar (takes a pattern)
Definition: color.h:75
@ MT_COLOR_SIDEBAR_UNREAD
Mailbox with unread mail.
Definition: color.h:72
@ MT_COLOR_INDEX_SIZE
Index: size field.
Definition: color.h:90
@ MT_COLOR_INDICATOR
Selected item in list.
Definition: color.h:52
@ MT_COLOR_STRIPE_EVEN
Stripes: even lines of the Help Page.
Definition: color.h:76
@ MT_COLOR_SIDEBAR_SPOOLFILE
$spool_file (Spool mailbox)
Definition: color.h:71
@ MT_COLOR_ERROR
Error message.
Definition: color.h:49
@ MT_COLOR_NONE
Definition: color.h:39
@ MT_COLOR_COMPOSE_SECURITY_NONE
Mail will not be encrypted or signed.
Definition: color.h:47
@ MT_COLOR_SIDEBAR_ORDINARY
Mailbox with no new or flagged messages.
Definition: color.h:70
@ MT_COLOR_INDEX_TAGS
Index: tags field (g, J)
Definition: color.h:93
@ MT_COLOR_BOLD
Bold text.
Definition: color.h:43
@ MT_COLOR_INDEX_SUBJECT
Index: subject field.
Definition: color.h:91
@ MT_COLOR_BODY
Pager: highlight body of message (takes a pattern)
Definition: color.h:42
@ MT_COLOR_INDEX_DATE
Index: date field.
Definition: color.h:86
@ MT_COLOR_PROGRESS
Progress bar.
Definition: color.h:59
@ MT_COLOR_COMPOSE_SECURITY_BOTH
Mail will be encrypted and signed.
Definition: color.h:45
@ MT_COLOR_SIDEBAR_BACKGROUND
Background colour for the Sidebar.
Definition: color.h:64
@ MT_COLOR_INDEX_TAG
Index: tag field (G)
Definition: color.h:92
@ MT_COLOR_HDRDEFAULT
Header default colour.
Definition: color.h:50
@ MT_COLOR_OPTIONS
Options in prompt.
Definition: color.h:58
@ MT_COLOR_TREE
Index: tree-drawing characters.
Definition: color.h:79
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:57
@ MT_COLOR_ATTACH_HEADERS
MIME attachment test (takes a pattern)
Definition: color.h:41
@ MT_COLOR_SEARCH
Pager: search matches.
Definition: color.h:62
@ MT_COLOR_COMPOSE_SECURITY_SIGN
Mail will be signed.
Definition: color.h:48
@ MT_COLOR_INDEX_LABEL
Index: label field.
Definition: color.h:88
@ MT_COLOR_ITALIC
Italic text.
Definition: color.h:53
@ MT_COLOR_STRIPE_ODD
Stripes: odd lines of the Help Page.
Definition: color.h:77
@ MT_COLOR_PROMPT
Question/user input.
Definition: color.h:60
@ MT_COLOR_COMPOSE_HEADER
Header labels, e.g. From:
Definition: color.h:44
@ MT_COLOR_INDEX
Index: default colour.
Definition: color.h:83
@ MT_COLOR_ATTACHMENT
MIME attachments text (entire line)
Definition: color.h:40
@ MT_COLOR_SIDEBAR_INDICATOR
Current open mailbox.
Definition: color.h:68
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
Definition: color.h:67
@ MT_COLOR_WARNING
Warning messages.
Definition: color.h:81
@ MT_COLOR_UNDERLINE
Underlined text.
Definition: color.h:80
@ MT_COLOR_INDEX_NUMBER
Index: index number.
Definition: color.h:89
@ MT_COLOR_SIGNATURE
Pager: signature lines.
Definition: color.h:74
@ MT_COLOR_INDEX_FLAGS
Index: flags field.
Definition: color.h:87
@ MT_COLOR_SIDEBAR_FLAGGED
Mailbox with flagged messages.
Definition: color.h:66
@ MT_COLOR_TILDE
Pager: empty lines after message.
Definition: color.h:78
@ MT_COLOR_INDEX_COLLAPSED
Index: number of messages in collapsed thread.
Definition: color.h:85
Parse colour commands.
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:36
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition: command.h:39
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition: command.h:37
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition: command.h:38
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:48
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
Curses Colour.
void regex_colors_dump_all(void)
Dump all the Regex colours to the log.
Definition: debug.c:387
int color_debug(enum LogLevel level, const char *format,...)
Write to the log file.
Definition: debug.c:51
const char * color_debug_log_attrs_list(int attrs)
Get a string to represent some attributes in the log.
Definition: debug.c:157
const char * color_debug_log_name(char *buf, int buflen, int color)
Get a string to represent a colour name.
Definition: debug.c:188
const char * color_debug_log_color_attrs(int fg, int bg, int attrs)
Get a colourful string to represent a colour in the log.
Definition: debug.c:74
void curses_colors_dump(void)
Log all the Curses colours.
Definition: debug.c:274
Colour Debugging.
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition: do_pager.c:123
int parse_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: extract.c:48
#define MoreArgsF(buf, flags)
Definition: extract.h:34
#define MoreArgs(buf)
Definition: extract.h:31
#define TOKEN_COMMENT
Don't reap comments.
Definition: extract.h:51
#define TOKEN_NO_FLAGS
No flags are set.
Definition: extract.h:45
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:636
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
bool OptNoCurses
(pseudo) when sending in batch mode
Definition: globals.c:79
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:1217
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:1241
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:1227
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:1200
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
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:603
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:544
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
bool StartupComplete
When the config has been read.
Definition: main.c:194
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
struct AttrColorList MergedColors
Array of user colours.
Definition: merged.c:41
Merged colours.
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:173
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:810
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:228
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition: string.c:240
Many unsorted constants and some structs.
struct MuttWindow * window_get_focus(void)
Get the currently focused Window.
Definition: mutt_window.c:668
@ WT_CUSTOM
Window with a custom drawing function.
Definition: mutt_window.h:95
@ WT_PAGER
A panel containing the Pager Window.
Definition: mutt_window.h:100
Colour notifications.
@ NT_COLOR_SET
Color has been set.
Definition: notify2.h:41
@ NT_COLOR
Colour has changed, NotifyColor, EventColor.
Definition: notify_type.h:41
GUI display a file/email/help in a viewport with paging.
#define MUTT_SHOWCOLOR
Show characters in color otherwise don't show characters.
Definition: lib.h:61
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:141
Private state data for the Pager.
Text parsing functions.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define STAILQ_EMPTY(head)
Definition: queue.h:348
#define TAILQ_EMPTY(head)
Definition: queue.h:721
enum CommandResult quoted_colors_parse_uncolor(enum ColorId cid, int q_level, struct Buffer *err)
Parse the 'uncolor quoted' command.
Definition: quoted.c:170
struct AttrColor * quoted_colors_get(int q)
Return the color of a quote, cycling through the used quotes.
Definition: quoted.c:79
int NumQuotedColors
Number of colours for quoted email text.
Definition: quoted.c:45
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:106
Quoted-Email colours.
#define COLOR_QUOTES_MAX
Ten colours, quoted0..quoted9 (quoted and quoted0 are equivalent)
Definition: quoted.h:37
Regex Colour.
Simple colour.
A curses colour and its attributes.
Definition: attr.h:35
int attrs
Text attributes, e.g. A_BOLD.
Definition: attr.h:37
struct CursesColor * curses_color
Underlying Curses colour.
Definition: attr.h:36
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
Colour in the ncurses palette.
Definition: curses2.h:38
uint32_t fg
Foreground colour.
Definition: curses2.h:41
uint32_t bg
Background colour.
Definition: curses2.h:42
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
void * wdata
Private data.
Definition: mutt_window.h:145
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
enum WindowType type
Window type, e.g. WT_SIDEBAR.
Definition: mutt_window.h:144
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
Data to be displayed by PagerView.
Definition: lib.h:160
const char * fname
Name of the file to read.
Definition: lib.h:164
Private state data for the Pager.
Definition: private_data.h:41
struct AttrColorList ansi_list
List of ANSI colours used in the Pager.
Definition: private_data.h:70
Paged view into some data.
Definition: lib.h:171
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:172
enum PagerMode mode
Pager mode.
Definition: lib.h:173
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:174
const char * banner
Title to display in status bar.
Definition: lib.h:175
A regular expression and a color to highlight a line.
Definition: regex4.h:37
struct AttrColor attr_color
Colour and attributes to apply.
Definition: regex4.h:38
char * pattern
Pattern to match.
Definition: regex4.h:39
#define buf_mktemp(buf)
Definition: tmp.h:33