NeoMutt  2023-03-22-27-g3cb248
Teaching an old dog new tricks
DOXYGEN
simple.c
Go to the documentation of this file.
1
30#include "config.h"
31#include <stddef.h>
32#include <stdbool.h>
33#include "mutt/lib.h"
34#include "gui/lib.h"
35#include "lib.h"
36
38
43{
44 // Set some defaults
45 color_debug(LL_DEBUG5, "init indicator, markers, etc\n");
49#ifdef USE_SIDEBAR
51#endif
53}
54
59{
60 color_debug(LL_DEBUG5, "clean up defs\n");
61 for (size_t i = 0; i < MT_COLOR_MAX; i++)
62 {
64 }
65}
66
75{
76 if (cid >= MT_COLOR_MAX)
77 {
78 mutt_error("colour overflow %d", cid);
79 return NULL;
80 }
81 if (cid <= MT_COLOR_NONE)
82 {
83 mutt_error("colour underflow %d", cid);
84 return NULL;
85 }
86
87 return &SimpleColors[cid];
88}
89
96{
98}
99
106{
107 return (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_HDRDEFAULT);
108}
109
118struct AttrColor *simple_color_set(enum ColorId cid, int fg, int bg, int attrs)
119{
120 struct AttrColor *ac = simple_color_get(cid);
121 if (!ac)
122 return NULL;
123
124 struct CursesColor *cc = curses_color_new(fg, bg);
126 ac->curses_color = cc;
127 ac->attrs = attrs;
128
129 struct Buffer *buf = mutt_buffer_pool_get();
130 get_colorid_name(cid, buf);
131 color_debug(LL_DEBUG5, "NT_COLOR_SET: %s\n", buf->data);
133
134 struct EventColor ev_c = { cid, NULL };
136
137 return ac;
138}
139
145{
146 struct AttrColor *ac = simple_color_get(cid);
147 if (!ac)
148 return;
149
150 struct Buffer *buf = mutt_buffer_pool_get();
151 get_colorid_name(cid, buf);
152 color_debug(LL_DEBUG5, "NT_COLOR_RESET: %s\n", buf->data);
154
156
157 struct EventColor ev_c = { cid, ac };
159}
void attr_color_clear(struct AttrColor *ac)
Free the contents of an AttrColor.
Definition: attr.c:44
bool attr_color_is_set(struct AttrColor *ac)
Is the object coloured?
Definition: attr.c:160
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
Definition: command.c:336
struct Notify * ColorsNotify
Notifications: ColorId, EventColor.
Definition: notify.c:34
void simple_colors_init(void)
Initialise the simple colour definitions.
Definition: simple.c:42
struct AttrColor * simple_color_set(enum ColorId cid, int fg, int bg, int attrs)
Set the colour of a simple object.
Definition: simple.c:118
bool simple_color_is_header(enum ColorId cid)
Colour is for an Email header.
Definition: simple.c:105
void simple_colors_clear(void)
Reset the simple colour definitions.
Definition: simple.c:58
void simple_color_reset(enum ColorId cid)
Clear the colour of a simple object.
Definition: simple.c:144
bool simple_color_is_set(enum ColorId cid)
Is the object coloured?
Definition: simple.c:95
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:74
struct AttrColor SimpleColors[MT_COLOR_MAX]
Array of Simple colours.
Definition: simple.c:37
ColorId
List of all colored objects.
Definition: color.h:38
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
Definition: color.h:54
@ MT_COLOR_MAX
Definition: color.h:92
@ 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_INDICATOR
Selected item in list.
Definition: color.h:52
@ MT_COLOR_NONE
Definition: color.h:39
@ MT_COLOR_HDRDEFAULT
Header default colour.
Definition: color.h:50
@ MT_COLOR_SEARCH
Pager: search matches.
Definition: color.h:62
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
Definition: color.h:67
void curses_color_free(struct CursesColor **ptr)
Free a CursesColor.
Definition: curses.c:116
struct CursesColor * curses_color_new(int fg, int bg)
Create a new CursesColor.
Definition: curses.c:148
int color_debug(enum LogLevel level, const char *format,...)
Write to the log file.
Definition: debug.c:44
#define mutt_error(...)
Definition: logging.h:87
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
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:171
@ 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
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
Key value store.
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 * 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