NeoMutt
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 <stddef.h>
32#include <stdbool.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 "curses2.h"
39#include "debug.h"
40#include "notify2.h"
41#include "simple2.h"
42
44
49{
50 // Set some defaults
51 color_debug(LL_DEBUG5, "init indicator, markers, etc\n");
55#ifdef USE_SIDEBAR
57#endif
60}
61
66{
67 color_debug(LL_DEBUG5, "clean up defs\n");
68 for (size_t i = 0; i < MT_COLOR_MAX; i++)
69 {
71 }
72}
73
82{
83 if (cid >= MT_COLOR_MAX)
84 {
85 mutt_error("colour overflow %d", cid);
86 return NULL;
87 }
88 if (cid <= MT_COLOR_NONE)
89 {
90 mutt_error("colour underflow %d", cid);
91 return NULL;
92 }
93
94 return &SimpleColors[cid];
95}
96
103{
105}
106
113{
114 return (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_HDRDEFAULT);
115}
116
125struct AttrColor *simple_color_set(enum ColorId cid, int fg, int bg, int attrs)
126{
127 struct AttrColor *ac = simple_color_get(cid);
128 if (!ac)
129 return NULL;
130
131 struct CursesColor *cc = curses_color_new(fg, bg);
133 ac->curses_color = cc;
134 ac->attrs = attrs;
135
136 struct Buffer *buf = buf_pool_get();
137 get_colorid_name(cid, buf);
138 color_debug(LL_DEBUG5, "NT_COLOR_SET: %s\n", buf->data);
139 buf_pool_release(&buf);
140
141 struct EventColor ev_c = { cid, NULL };
143
144 return ac;
145}
146
152{
153 struct AttrColor *ac = simple_color_get(cid);
154 if (!ac)
155 return;
156
157 struct Buffer *buf = buf_pool_get();
158 get_colorid_name(cid, buf);
159 color_debug(LL_DEBUG5, "NT_COLOR_RESET: %s\n", buf->data);
160 buf_pool_release(&buf);
161
163
164 struct EventColor ev_c = { cid, ac };
166}
void attr_color_clear(struct AttrColor *ac)
Free the contents of an AttrColor.
Definition: attr.c:44
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition: attr.c:160
Colour and attributes.
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a color id.
Definition: command.c:677
struct Notify * ColorsNotify
Notifications: ColorId, EventColor.
Definition: notify.c:35
void simple_colors_init(void)
Initialise the simple colour definitions.
Definition: simple.c:48
void simple_colors_cleanup(void)
Reset the simple colour definitions.
Definition: simple.c:65
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
bool simple_color_is_header(enum ColorId cid)
Colour is for an Email header.
Definition: simple.c:112
void simple_color_reset(enum ColorId cid)
Clear the colour of a simple object.
Definition: simple.c:151
bool simple_color_is_set(enum ColorId cid)
Is the object coloured?
Definition: simple.c:102
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition: simple.c:81
struct AttrColor SimpleColors[MT_COLOR_MAX]
Array of Simple colours.
Definition: simple.c:43
Color and attribute parsing.
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:94
@ 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_STRIPE_EVEN
Stripes: even lines of the Help Page.
Definition: color.h:76
@ 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
Parse colour commands.
Curses Colour.
void curses_color_free(struct CursesColor **ptr)
Free a CursesColor.
Definition: curses.c:121
struct CursesColor * curses_color_new(int fg, int bg)
Create a new CursesColor.
Definition: curses.c:151
int color_debug(enum LogLevel level, const char *format,...)
Write to the log file.
Definition: debug.c:51
Colour Debugging.
#define mutt_error(...)
Definition: logging2.h:92
Convenience wrapper for the gui headers.
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
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
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: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