NeoMutt  2025-12-11-769-g906513
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
simple2.h File Reference

Simple colour. More...

#include <stdbool.h>
#include "color.h"
+ Include dependency graph for simple2.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define COLOR_COMPOSE(cid)
 

Functions

void simple_colors_init (void)
 Initialise the simple colour definitions.
 
void simple_colors_reset (void)
 Reset the simple colour definitions.
 
void simple_colors_cleanup (void)
 Cleanup the simple colour definitions.
 
struct AttrColorsimple_color_get (enum ColorId cid)
 Get the colour of an object by its ID.
 
bool simple_color_is_set (enum ColorId cid)
 Is the object coloured?
 
void simple_color_reset (enum ColorId cid)
 Clear the colour of a simple object.
 
struct AttrColorsimple_color_set (enum ColorId cid, struct AttrColor *ac_val)
 Set the colour of a simple object.
 

Detailed Description

Simple colour.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file simple2.h.

Macro Definition Documentation

◆ COLOR_COMPOSE

#define COLOR_COMPOSE ( cid)
Value:
@ MT_COLOR_COMPOSE_SECURITY_SIGN
Mail will be signed.
Definition color.h:45
@ MT_COLOR_COMPOSE_HEADER
Header labels, e.g. From:
Definition color.h:41

Definition at line 31 of file simple2.h.

Function Documentation

◆ simple_colors_init()

void simple_colors_init ( void )

Initialise the simple colour definitions.

Definition at line 47 of file simple.c.

48{
50 for (int i = 0; i < MT_COLOR_MAX; i++)
51 {
52 mod_data->simple_colors[i].fg.color = COLOR_DEFAULT;
53 mod_data->simple_colors[i].bg.color = COLOR_DEFAULT;
54 }
55
56 // Set some defaults
57 color_debug(LL_DEBUG5, "init indicator, markers, etc\n");
58 mod_data->simple_colors[MT_COLOR_BOLD].attrs = A_BOLD;
59 mod_data->simple_colors[MT_COLOR_INDICATOR].attrs = A_REVERSE;
61 mod_data->simple_colors[MT_COLOR_MARKERS].attrs = A_REVERSE;
62 mod_data->simple_colors[MT_COLOR_SEARCH].attrs = A_REVERSE;
63 mod_data->simple_colors[MT_COLOR_STATUS].attrs = A_REVERSE;
64 mod_data->simple_colors[MT_COLOR_STRIPE_EVEN].attrs = A_BOLD;
65 mod_data->simple_colors[MT_COLOR_UNDERLINE].attrs = A_UNDERLINE;
66}
#define COLOR_DEFAULT
Definition color.h:102
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
Definition color.h:51
@ MT_COLOR_MAX
Definition color.h:97
@ MT_COLOR_STATUS
Status bar (takes a pattern)
Definition color.h:78
@ MT_COLOR_INDICATOR
Selected item in list.
Definition color.h:49
@ MT_COLOR_STRIPE_EVEN
Stripes: even lines of the Help Page.
Definition color.h:79
@ MT_COLOR_BOLD
Bold text.
Definition color.h:40
@ MT_COLOR_SEARCH
Pager: search matches.
Definition color.h:67
@ MT_COLOR_ITALIC
Italic text.
Definition color.h:50
@ MT_COLOR_UNDERLINE
Underlined text.
Definition color.h:83
static int color_debug(enum LogLevel level, const char *format,...)
Definition debug.h:51
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:49
@ MODULE_ID_COLOR
ModuleColor, Color
Definition module_api.h:53
#define A_ITALIC
Definition mutt_curses.h:48
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:665
struct ColorElement bg
Background colour.
Definition attr.h:67
struct ColorElement fg
Foreground colour.
Definition attr.h:66
int attrs
Text attributes, e.g. A_BOLD.
Definition attr.h:68
color_t color
Colour.
Definition attr.h:56
Color private Module data.
Definition module_data.h:35
struct AttrColor simple_colors[MT_COLOR_MAX]
Array of Simple colours.
Definition module_data.h:42
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simple_colors_reset()

void simple_colors_reset ( void )

Reset the simple colour definitions.

Definition at line 71 of file simple.c.

72{
74 color_debug(LL_DEBUG5, "reset defs\n");
75 for (size_t i = 0; i < MT_COLOR_MAX; i++)
76 {
77 attr_color_clear(&mod_data->simple_colors[i]);
78 }
80}
void attr_color_clear(struct AttrColor *ac)
Free the contents of an AttrColor.
Definition attr.c:47
void simple_colors_init(void)
Initialise the simple colour definitions.
Definition simple.c:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simple_colors_cleanup()

void simple_colors_cleanup ( void )

Cleanup the simple colour definitions.

Definition at line 85 of file simple.c.

86{
88}
void simple_colors_reset(void)
Reset the simple colour definitions.
Definition simple.c:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simple_color_get()

struct AttrColor * simple_color_get ( enum ColorId cid)

Get the colour of an object by its ID.

Parameters
cidColour ID, e.g. MT_COLOR_SEARCH
Return values
ptrAttrColor of the object
Note
Do not free the returned object

Definition at line 97 of file simple.c.

98{
99 if (cid >= MT_COLOR_MAX)
100 {
101 mutt_debug(LL_DEBUG1, "color overflow %d/%d\n", cid, MT_COLOR_MAX);
102 return NULL;
103 }
104 if (cid <= MT_COLOR_NONE)
105 {
106 mutt_debug(LL_DEBUG1, "color underflow %d/%d\n", cid, MT_COLOR_NONE);
107 return NULL;
108 }
109
111 return &mod_data->simple_colors[cid];
112}
@ MT_COLOR_NONE
No colour.
Definition color.h:36
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simple_color_is_set()

bool simple_color_is_set ( enum ColorId cid)

Is the object coloured?

Parameters
cidColour ID, e.g. MT_COLOR_SEARCH
Return values
trueYes, a 'color' command has been used on this object

Definition at line 119 of file simple.c.

120{
122}
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition attr.c:178
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition simple.c:97
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simple_color_reset()

void simple_color_reset ( enum ColorId cid)

Clear the colour of a simple object.

Parameters
cidColour ID, e.g. MT_COLOR_SEARCH

Definition at line 154 of file simple.c.

155{
156 struct AttrColor *ac = simple_color_get(cid);
157 if (!ac)
158 return;
159
160 struct Buffer *buf = buf_pool_get();
161 get_colorid_name(cid, buf);
162 color_debug(LL_DEBUG5, "NT_COLOR_RESET: %s\n", buf_string(buf));
163 buf_pool_release(&buf);
164
166
168 struct EventColor ev_c = { cid, ac };
170}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
void get_colorid_name(unsigned int cid, struct Buffer *buf)
Get the name of a Colour ID.
Definition commands.c:128
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
@ NT_COLOR_RESET
Color has been reset/removed.
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:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
A curses colour and its attributes.
Definition attr.h:65
String manipulation buffer.
Definition buffer.h:36
struct Notify * colors_notify
Notifications: ColorId, EventColor.
Definition module_data.h:40
An Event that happened to a Colour.
Definition notify2.h:52
enum ColorId cid
Colour ID that has changed.
Definition notify2.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simple_color_set()

struct AttrColor * simple_color_set ( enum ColorId cid,
struct AttrColor * ac_val )

Set the colour of a simple object.

Parameters
cidColour ID, e.g. MT_COLOR_SEARCH
ac_valColour value to use
Return values
ptrColour

Definition at line 130 of file simple.c.

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_string(buf));
141 buf_pool_release(&buf);
142
144 struct EventColor ev_c = { cid, NULL };
146
147 return ac;
148}
void attr_color_overwrite(struct AttrColor *ac_old, const struct AttrColor *ac_new)
Update an AttrColor in-place.
Definition attr.c:394
@ NT_COLOR_SET
Color has been set.
Definition notify2.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function: