NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
simple.c
Go to the documentation of this file.
1
30#include "config.h"
31#include <stdbool.h>
32#include <stddef.h>
33#include "mutt/lib.h"
34#include "gui/lib.h"
35#include "attr.h"
36#include "color.h"
37#include "command2.h"
38#include "debug.h"
39#include "notify2.h"
40#include "simple2.h"
41
43
48{
49 for (int i = 0; i < MT_COLOR_MAX; i++)
50 {
53 }
54
55 // Set some defaults
56 color_debug(LL_DEBUG5, "init indicator, markers, etc\n");
66}
67
72{
73 color_debug(LL_DEBUG5, "clean up defs\n");
74 for (size_t i = 0; i < MT_COLOR_MAX; i++)
75 {
77 }
79}
80
89{
90 if (cid >= MT_COLOR_MAX)
91 {
92 mutt_debug(LL_DEBUG1, "color overflow %d/%d", cid, MT_COLOR_MAX);
93 return NULL;
94 }
95 if (cid <= MT_COLOR_NONE)
96 {
97 mutt_debug(LL_DEBUG1, "color underflow %d/%d", cid, MT_COLOR_NONE);
98 return NULL;
99 }
100
101 return &SimpleColors[cid];
102}
103
110{
112}
113
120{
121 return (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_HDRDEFAULT);
122}
123
130struct AttrColor *simple_color_set(enum ColorId cid, struct AttrColor *ac_val)
131{
132 struct AttrColor *ac = simple_color_get(cid);
133 if (!ac)
134 return NULL;
135
136 attr_color_overwrite(ac, ac_val);
137
138 struct Buffer *buf = buf_pool_get();
139 get_colorid_name(cid, buf);
140 color_debug(LL_DEBUG5, "NT_COLOR_SET: %s\n", buf->data);
141 buf_pool_release(&buf);
142
143 struct EventColor ev_c = { cid, NULL };
145
146 return ac;
147}
148
154{
155 struct AttrColor *ac = simple_color_get(cid);
156 if (!ac)
157 return;
158
159 struct Buffer *buf = buf_pool_get();
160 get_colorid_name(cid, buf);
161 color_debug(LL_DEBUG5, "NT_COLOR_RESET: %s\n", buf->data);
162 buf_pool_release(&buf);
163
165
166 struct EventColor ev_c = { cid, ac };
168}
void attr_color_overwrite(struct AttrColor *ac_old, struct AttrColor *ac_new)
Update an AttrColor in-place.
Definition: attr.c:395
void attr_color_clear(struct AttrColor *ac)
Free the contents of an AttrColor.
Definition: attr.c:48
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition: attr.c:179
Colour and attributes.
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
Definition: command.c:127
struct Notify * ColorsNotify
Notifications: ColorId, EventColor.
Definition: notify.c:35
void simple_colors_init(void)
Initialise the simple colour definitions.
Definition: simple.c:47
struct AttrColor * simple_color_set(enum ColorId cid, struct AttrColor *ac_val)
Set the colour of a simple object.
Definition: simple.c:130
void simple_colors_cleanup(void)
Reset the simple colour definitions.
Definition: simple.c:71
bool simple_color_is_header(enum ColorId cid)
Colour is for an Email header.
Definition: simple.c:119
void simple_color_reset(enum ColorId cid)
Clear the colour of a simple object.
Definition: simple.c:153
bool simple_color_is_set(enum ColorId cid)
Is the object coloured?
Definition: simple.c:109
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:88
struct AttrColor SimpleColors[MT_COLOR_MAX]
Array of Simple colours.
Definition: simple.c:42
Color and attribute parsing.
#define COLOR_DEFAULT
Definition: color.h:100
ColorId
List of all colored objects.
Definition: color.h:40
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
Definition: color.h:56
@ MT_COLOR_MAX
Definition: color.h:94
@ MT_COLOR_HEADER
Message headers (takes a pattern)
Definition: color.h:53
@ MT_COLOR_STATUS
Status bar (takes a pattern)
Definition: color.h:75
@ MT_COLOR_INDICATOR
Selected item in list.
Definition: color.h:54
@ MT_COLOR_STRIPE_EVEN
Stripes: even lines of the Help Page.
Definition: color.h:76
@ MT_COLOR_NONE
Definition: color.h:41
@ MT_COLOR_BOLD
Bold text.
Definition: color.h:45
@ MT_COLOR_HDRDEFAULT
Header default colour.
Definition: color.h:52
@ MT_COLOR_SEARCH
Pager: search matches.
Definition: color.h:64
@ MT_COLOR_ITALIC
Italic text.
Definition: color.h:55
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
Definition: color.h:68
@ MT_COLOR_UNDERLINE
Underlined text.
Definition: color.h:80
Parse colour commands.
Colour Debugging.
static int color_debug(enum LogLevel level, const char *format,...)
Definition: debug.h:52
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
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.
Definition: notify.c:173
#define A_ITALIC
Definition: mutt_curses.h:49
Colour notifications.
@ 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:41
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
Simple colour.
A curses colour and its attributes.
Definition: attr.h:66
struct ColorElement bg
Background colour.
Definition: attr.h:68
struct ColorElement fg
Foreground colour.
Definition: attr.h:67
int attrs
Text attributes, e.g. A_BOLD.
Definition: attr.h:69
String manipulation buffer.
Definition: buffer.h:36
char * data
Pointer to data.
Definition: buffer.h:37
color_t color
Colour.
Definition: attr.h:57
An Event that happened to a Colour.
Definition: notify2.h:53
enum ColorId cid
Colour ID that has changed.
Definition: notify2.h:54