NeoMutt
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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 "attr.h"
#include "color.h"
#include "command2.h"
#include "curses2.h"
#include "debug.h"
#include "notify2.h"
#include "simple2.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.
 
void simple_colors_cleanup (void)
 Reset 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?
 
bool simple_color_is_header (enum ColorId cid)
 Colour is for an Email header.
 
struct AttrColorsimple_color_set (enum ColorId cid, int fg, int bg, int attrs)
 Set the colour of a simple object.
 
void simple_color_reset (enum ColorId cid)
 Clear the colour of a simple object.
 

Variables

struct AttrColor SimpleColors [MT_COLOR_MAX]
 Array of Simple colours.
 

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 48 of file simple.c.

49{
50 // Set some defaults
51 color_debug(LL_DEBUG5, "init indicator, markers, etc\n");
55#ifdef USE_SIDEBAR
57#endif
60}
struct AttrColor SimpleColors[MT_COLOR_MAX]
Array of Simple colours.
Definition: simple.c:43
@ 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_STRIPE_EVEN
Stripes: even lines of the Help Page.
Definition: color.h:76
@ 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:51
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
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_cleanup()

void simple_colors_cleanup ( void  )

Reset the simple colour definitions.

Definition at line 65 of file simple.c.

66{
67 color_debug(LL_DEBUG5, "clean up defs\n");
68 for (size_t i = 0; i < MT_COLOR_MAX; i++)
69 {
71 }
72}
void attr_color_clear(struct AttrColor *ac)
Free the contents of an AttrColor.
Definition: attr.c:44
@ MT_COLOR_MAX
Definition: color.h:94
+ 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 81 of file simple.c.

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

103{
105}
bool attr_color_is_set(const 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:81
+ 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 112 of file simple.c.

113{
114 return (cid == MT_COLOR_HEADER) || (cid == MT_COLOR_HDRDEFAULT);
115}
@ 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 125 of file simple.c.

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}
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 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
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_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
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 151 of file simple.c.

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}
@ 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 43 of file simple.c.