NeoMutt  2023-03-22-27-g3cb248
Teaching an old dog new tricks
DOXYGEN
simple.c File Reference

Simple colour. More...

#include "config.h"
#include <stddef.h>
#include <stdbool.h>
#include "mutt/lib.h"
#include "gui/lib.h"
#include "lib.h"
+ Include dependency graph for simple.c:

Go to the source code of this file.

Functions

void simple_colors_init (void)
 Initialise the simple colour definitions. More...
 
void simple_colors_clear (void)
 Reset the simple colour definitions. More...
 
struct AttrColorsimple_color_get (enum ColorId cid)
 Get the colour of an object by its ID. More...
 
bool simple_color_is_set (enum ColorId cid)
 Is the object coloured? More...
 
bool simple_color_is_header (enum ColorId cid)
 Colour is for an Email header. More...
 
struct AttrColorsimple_color_set (enum ColorId cid, int fg, int bg, int attrs)
 Set the colour of a simple object. More...
 
void simple_color_reset (enum ColorId cid)
 Clear the colour of a simple object. More...
 

Variables

struct AttrColor SimpleColors [MT_COLOR_MAX]
 Array of Simple colours. More...
 

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 simple.c.

Function Documentation

◆ simple_colors_init()

void simple_colors_init ( void  )

Initialise the simple colour definitions.

Definition at line 42 of file simple.c.

43{
44 // Set some defaults
45 color_debug(LL_DEBUG5, "init indicator, markers, etc\n");
49#ifdef USE_SIDEBAR
51#endif
53}
struct AttrColor SimpleColors[MT_COLOR_MAX]
Array of Simple colours.
Definition: simple.c:37
@ MT_COLOR_MARKERS
Pager: markers, line continuation.
Definition: color.h:54
@ 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_SEARCH
Pager: search matches.
Definition: color.h:62
@ MT_COLOR_SIDEBAR_HIGHLIGHT
Select cursor.
Definition: color.h:67
int color_debug(enum LogLevel level, const char *format,...)
Write to the log file.
Definition: debug.c:44
@ LL_DEBUG5
Log at debug level 5.
Definition: logging.h:44
int attrs
Text attributes, e.g. A_BOLD.
Definition: attr.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simple_colors_clear()

void simple_colors_clear ( void  )

Reset the simple colour definitions.

Definition at line 58 of file simple.c.

59{
60 color_debug(LL_DEBUG5, "clean up defs\n");
61 for (size_t i = 0; i < MT_COLOR_MAX; i++)
62 {
64 }
65}
void attr_color_clear(struct AttrColor *ac)
Free the contents of an AttrColor.
Definition: attr.c:44
@ MT_COLOR_MAX
Definition: color.h:92
+ 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 74 of file simple.c.

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}
@ MT_COLOR_NONE
Definition: color.h:39
#define mutt_error(...)
Definition: logging.h:87
+ 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 95 of file simple.c.

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

◆ simple_color_is_header()

bool simple_color_is_header ( enum ColorId  cid)

Colour is for an Email header.

Parameters
cidColour Id, e.g. MT_COLOR_HEADER
Return values
trueColour is for an Email header

Definition at line 105 of file simple.c.

106{
107 return (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_HDRDEFAULT);
108}
@ MT_COLOR_HEADER
Message headers (takes a pattern)
Definition: color.h:51
@ MT_COLOR_HDRDEFAULT
Header default colour.
Definition: color.h:50
+ Here is the caller graph for this function:

◆ simple_color_set()

struct AttrColor * simple_color_set ( enum ColorId  cid,
int  fg,
int  bg,
int  attrs 
)

Set the colour of a simple object.

Parameters
cidColour Id, e.g. MT_COLOR_SEARCH
fgForeground colour
bgBackground colour
attrsAttributes, e.g. A_UNDERLINE
Return values
ptrColour

Definition at line 118 of file simple.c.

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}
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 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
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_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
A curses colour and its attributes.
Definition: attr.h:35
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
+ 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 144 of file simple.c.

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}
@ NT_COLOR_RESET
Color has been reset/removed.
Definition: notify2.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ SimpleColors

struct AttrColor SimpleColors[MT_COLOR_MAX]

Array of Simple colours.

Definition at line 37 of file simple.c.