NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
color.h
Go to the documentation of this file.
1 
23 #ifndef MUTT_COLOR_H
24 #define MUTT_COLOR_H
25 
26 #include "config.h"
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include "mutt/lib.h"
30 #include "mutt_commands.h"
31 
35 struct ColorLine
36 {
37  regex_t regex;
38  int match;
39  char *pattern;
40  struct PatternList *color_pattern;
41  uint32_t fg;
42  uint32_t bg;
43  int pair;
44 
45  bool stop_matching : 1;
46 
47  STAILQ_ENTRY(ColorLine) entries;
48 };
49 STAILQ_HEAD(ColorLineList, ColorLine);
50 
58 enum ColorId
59 {
83 #ifdef USE_SIDEBAR
92 #endif
99  /* please no non-MT_COLOR_INDEX objects after this point */
105  /* below here - only index coloring stuff that doesn't have a pattern */
113 };
114 
118 struct ColorList
119 {
120  /* TrueColor uses 24bit. Use fixed-width integer type to make sure it fits.
121  * Use the upper 8 bits to store flags. */
122  uint32_t fg;
123  uint32_t bg;
124  short index;
125  short count;
126  struct ColorList *next;
127 };
128 
129 struct Colors
130 {
131  int *defs;
132 
133  struct ColorLineList attach_list;
134  struct ColorLineList body_list;
135  struct ColorLineList hdr_list;
136  struct ColorLineList index_author_list;
137  struct ColorLineList index_flags_list;
138  struct ColorLineList index_list;
139  struct ColorLineList index_subject_list;
140  struct ColorLineList index_tag_list;
141  struct ColorLineList status_list;
142 
143  int *quotes;
145 
148 
149  struct Notify *notify;
150 };
151 
160 {
162 };
163 
170 {
173 };
174 
175 int mutt_color_alloc (struct Colors *c, uint32_t fg, uint32_t bg);
176 int mutt_color_combine(struct Colors *c, uint32_t fg_attr, uint32_t bg_attr);
177 void mutt_color_free (struct Colors *c, uint32_t fg, uint32_t bg);
178 
179 struct Colors *mutt_colors_new(void);
180 void mutt_colors_free(struct Colors **ptr);
181 
182 enum CommandResult mutt_parse_color (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
183 enum CommandResult mutt_parse_mono (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
184 enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
185 enum CommandResult mutt_parse_unmono (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err);
186 
187 #endif /* MUTT_COLOR_H */
MT_COLOR_UNDERLINE
@ MT_COLOR_UNDERLINE
Underlined text.
Definition: color.h:97
NotifyColor
NotifyColor
Types of Color Event.
Definition: color.h:169
MT_COLOR_COMPOSE_HEADER
@ MT_COLOR_COMPOSE_HEADER
Header labels, e.g. From:
Definition: color.h:65
mutt_parse_color
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: color.c:1346
MT_COLOR_SIDEBAR_HIGHLIGHT
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
Definition: color.h:86
Colors::index_author_list
struct ColorLineList index_author_list
List of colours applied to the author in the index.
Definition: color.h:136
MT_COLOR_INDEX_DATE
@ MT_COLOR_INDEX_DATE
Index: date field.
Definition: color.h:107
mutt_parse_uncolor
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: color.c:921
ColorLine::regex
regex_t regex
Compiled regex.
Definition: color.h:37
NT_COLOR_RESET
@ NT_COLOR_RESET
Color has been reset/removed.
Definition: color.h:172
ColorLine::bg
uint32_t bg
Background colour.
Definition: color.h:42
ColorLine::stop_matching
bool stop_matching
Used by the pager for body patterns, to prevent the color from being retried once it fails.
Definition: color.h:45
mutt_colors_new
struct Colors * mutt_colors_new(void)
Create new colours.
Definition: color.c:374
MT_COLOR_INDEX_LABEL
@ MT_COLOR_INDEX_LABEL
Index: label field.
Definition: color.h:108
MT_COLOR_ERROR
@ MT_COLOR_ERROR
Error message.
Definition: color.h:70
MT_COLOR_STATUS
@ MT_COLOR_STATUS
Status bar (takes a pattern)
Definition: color.h:94
Buffer
String manipulation buffer.
Definition: buffer.h:33
MT_COLOR_INDEX_AUTHOR
@ MT_COLOR_INDEX_AUTHOR
Index: author field (takes a pattern)
Definition: color.h:101
ColorList::fg
uint32_t fg
Definition: color.h:122
STAILQ_HEAD
STAILQ_HEAD(ColorLineList, ColorLine)
MT_COLOR_HDRDEFAULT
@ MT_COLOR_HDRDEFAULT
Header default colour.
Definition: color.h:71
MT_COLOR_WARNING
@ MT_COLOR_WARNING
Warning messages.
Definition: color.h:98
Colors::num_user_colors
int num_user_colors
Definition: color.h:147
Colors::body_list
struct ColorLineList body_list
List of colours applied to the email body.
Definition: color.h:134
MT_COLOR_QUOTED
@ MT_COLOR_QUOTED
Pager: quoted text.
Definition: color.h:81
MT_COLOR_BOLD
@ MT_COLOR_BOLD
Bold text.
Definition: color.h:64
MT_COLOR_INDICATOR
@ MT_COLOR_INDICATOR
Selected item in list.
Definition: color.h:73
mutt_color_free
void mutt_color_free(struct Colors *c, uint32_t fg, uint32_t bg)
Free a colour.
Definition: color.c:252
Colors::user_colors
struct ColorList * user_colors
Definition: color.h:146
mutt_color_alloc
int mutt_color_alloc(struct Colors *c, uint32_t fg, uint32_t bg)
Allocate a colour pair.
Definition: color.c:472
MT_COLOR_INDEX_NUMBER
@ MT_COLOR_INDEX_NUMBER
Index: index number.
Definition: color.h:109
ColorId
ColorId
List of all colored objects.
Definition: color.h:58
NT_COLOR_SET
@ NT_COLOR_SET
A new Color has been set.
Definition: color.h:171
ColorList::count
short count
Definition: color.h:125
MT_COLOR_BODY
@ MT_COLOR_BODY
Pager: highlight body of message (takes a pattern)
Definition: color.h:63
MT_COLOR_NORMAL
@ MT_COLOR_NORMAL
Plain text.
Definition: color.h:77
MT_COLOR_INDEX_TAGS
@ MT_COLOR_INDEX_TAGS
Index: tags field (g, J)
Definition: color.h:111
Colors::hdr_list
struct ColorLineList hdr_list
List of colours applied to the email headers.
Definition: color.h:135
MT_COLOR_NONE
@ MT_COLOR_NONE
Definition: color.h:60
MT_COLOR_SEARCH
@ MT_COLOR_SEARCH
Pager: search matches.
Definition: color.h:82
MT_COLOR_SIGNATURE
@ MT_COLOR_SIGNATURE
Pager: signature lines.
Definition: color.h:93
Colors::quotes_used
int quotes_used
Number of colours for quoted email text.
Definition: color.h:144
MT_COLOR_MESSAGE
@ MT_COLOR_MESSAGE
Informational message.
Definition: color.h:75
MT_COLOR_COMPOSE_SECURITY_NONE
@ MT_COLOR_COMPOSE_SECURITY_NONE
Mail will not be encrypted or signed.
Definition: color.h:68
MT_COLOR_ATTACH_HEADERS
@ MT_COLOR_ATTACH_HEADERS
MIME attachment test (takes a pattern)
Definition: color.h:62
MT_COLOR_COMPOSE_SECURITY_SIGN
@ MT_COLOR_COMPOSE_SECURITY_SIGN
Mail will be signed.
Definition: color.h:69
lib.h
MT_COLOR_ATTACHMENT
@ MT_COLOR_ATTACHMENT
MIME attachments text (entire line)
Definition: color.h:61
MT_COLOR_SIDEBAR_ORDINARY
@ MT_COLOR_SIDEBAR_ORDINARY
Mailbox with no new or flagged messages.
Definition: color.h:89
Colors::index_flags_list
struct ColorLineList index_flags_list
List of colours applied to the flags in the index.
Definition: color.h:137
ColorLine::STAILQ_ENTRY
STAILQ_ENTRY(ColorLine) entries
Linked list.
MT_COLOR_OPTIONS
@ MT_COLOR_OPTIONS
Options in prompt.
Definition: color.h:78
MT_COLOR_MAX
@ MT_COLOR_MAX
Definition: color.h:112
Colors::attach_list
struct ColorLineList attach_list
List of colours applied to the attachment headers.
Definition: color.h:133
Colors
Definition: color.h:129
ColorLine::pair
int pair
Colour pair index.
Definition: color.h:43
MT_COLOR_MESSAGE_LOG
@ MT_COLOR_MESSAGE_LOG
Menu showing log messages.
Definition: color.h:76
MT_COLOR_INDEX_COLLAPSED
@ MT_COLOR_INDEX_COLLAPSED
Index: number of messages in collapsed thread.
Definition: color.h:106
MT_COLOR_PROMPT
@ MT_COLOR_PROMPT
Question/user input.
Definition: color.h:80
EventColor
An Event that happened to a Colour.
Definition: color.h:159
mutt_parse_unmono
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: color.c:931
Colors::notify
struct Notify * notify
Notifications system.
Definition: color.h:149
MT_COLOR_TILDE
@ MT_COLOR_TILDE
Pager: empty lines after message.
Definition: color.h:95
MT_COLOR_INDEX_SIZE
@ MT_COLOR_INDEX_SIZE
Index: size field.
Definition: color.h:110
MT_COLOR_TREE
@ MT_COLOR_TREE
Index: tree-drawing characters.
Definition: color.h:96
MT_COLOR_INDEX_TAG
@ MT_COLOR_INDEX_TAG
Index: tag field (g, takes a pattern)
Definition: color.h:104
MT_COLOR_PROGRESS
@ MT_COLOR_PROGRESS
Progress bar.
Definition: color.h:79
CommandResult
CommandResult
Error codes for command_t parse functions.
Definition: mutt_commands.h:34
Colors::quotes
int * quotes
Array of colours for quoted email text.
Definition: color.h:143
Notify
Notification API.
Definition: notify.c:39
MT_COLOR_SIDEBAR_FLAGGED
@ MT_COLOR_SIDEBAR_FLAGGED
Mailbox with flagged messages.
Definition: color.h:85
MT_COLOR_COMPOSE_SECURITY_ENCRYPT
@ MT_COLOR_COMPOSE_SECURITY_ENCRYPT
Mail will be encrypted.
Definition: color.h:67
mutt_parse_mono
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: color.c:1361
Colors::index_list
struct ColorLineList index_list
List of default colours applied to the index.
Definition: color.h:138
ColorList::bg
uint32_t bg
Definition: color.h:123
MT_COLOR_MARKERS
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
Definition: color.h:74
MT_COLOR_INDEX
@ MT_COLOR_INDEX
Index: default colour (takes a pattern)
Definition: color.h:100
Colors::index_tag_list
struct ColorLineList index_tag_list
List of colours applied to tags in the index.
Definition: color.h:140
MT_COLOR_HEADER
@ MT_COLOR_HEADER
Message headers (takes a pattern)
Definition: color.h:72
MT_COLOR_SIDEBAR_NEW
@ MT_COLOR_SIDEBAR_NEW
Mailbox with new mail.
Definition: color.h:88
ColorList::next
struct ColorList * next
Definition: color.h:126
ColorList
A set of colors.
Definition: color.h:118
EventColor::color
enum ColorId color
Definition: color.h:161
MT_COLOR_INDEX_FLAGS
@ MT_COLOR_INDEX_FLAGS
Index: flags field (takes a pattern)
Definition: color.h:102
ColorLine::match
int match
Substring to match, 0 for old behaviour.
Definition: color.h:38
ColorLine
A regular expression and a color to highlight a line.
Definition: color.h:35
MT_COLOR_INDEX_SUBJECT
@ MT_COLOR_INDEX_SUBJECT
Index: subject field (takes a pattern)
Definition: color.h:103
ColorLine::color_pattern
struct PatternList * color_pattern
Compiled pattern to speed up index color calculation.
Definition: color.h:40
ColorLine::pattern
char * pattern
Pattern to match.
Definition: color.h:39
MT_COLOR_SIDEBAR_DIVIDER
@ MT_COLOR_SIDEBAR_DIVIDER
Line dividing sidebar from the index/pager.
Definition: color.h:84
MT_COLOR_SIDEBAR_SPOOLFILE
@ MT_COLOR_SIDEBAR_SPOOLFILE
$spool_file (Spool mailbox)
Definition: color.h:90
mutt_commands.h
Colors::defs
int * defs
Array of all fixed colours, see enum ColorId.
Definition: color.h:131
ColorLine::fg
uint32_t fg
Foreground colour.
Definition: color.h:41
Colors::index_subject_list
struct ColorLineList index_subject_list
List of colours applied to the subject in the index.
Definition: color.h:139
MT_COLOR_COMPOSE_SECURITY_BOTH
@ MT_COLOR_COMPOSE_SECURITY_BOTH
Mail will be encrypted and signed.
Definition: color.h:66
Colors::status_list
struct ColorLineList status_list
List of colours applied to the status bar.
Definition: color.h:141
ColorList::index
short index
Definition: color.h:124
mutt_color_combine
int mutt_color_combine(struct Colors *c, uint32_t fg_attr, uint32_t bg_attr)
Combine two colours.
Definition: color.c:577
MT_COLOR_SIDEBAR_INDICATOR
@ MT_COLOR_SIDEBAR_INDICATOR
Current open mailbox.
Definition: color.h:87
MT_COLOR_SIDEBAR_UNREAD
@ MT_COLOR_SIDEBAR_UNREAD
Mailbox with unread mail.
Definition: color.h:91
mutt_colors_free
void mutt_colors_free(struct Colors **ptr)
Free all the colours.
Definition: color.c:356