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

Merged colours. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

const struct AttrColormerged_color_overlay (const struct AttrColor *base, const struct AttrColor *over)
 Combine two colours.
 
void merged_colors_cleanup (void)
 Free the list of Merged colours.
 
void merged_colors_init (void)
 Initialise the Merged colours.
 

Detailed Description

Merged colours.

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 merged.h.

Function Documentation

◆ merged_color_overlay()

const struct AttrColor * merged_color_overlay ( const struct AttrColor * base,
const struct AttrColor * over )

Combine two colours.

Parameters
baseBase colour
overOverlay colour
Return values
ptrMerged colour

If either the foreground or background of the overlay is 'default', then the base colour will show through. The attributes of both base and overlay will be OR'd together.

Definition at line 110 of file merged.c.

112{
113 if (!attr_color_is_set(over))
114 return base;
115 if (!attr_color_is_set(base))
116 return over;
117
119 struct CursesColor *cc_base = base->curses_color;
120 struct CursesColor *cc_over = over->curses_color;
121
124
125 if (cc_over)
126 {
127 fg = cc_over->fg;
128 bg = cc_over->bg;
129 }
130
131 if (cc_base)
132 {
133 if (fg == COLOR_DEFAULT)
134 fg = cc_base->fg;
135 if (bg == COLOR_DEFAULT)
136 bg = cc_base->bg;
137 }
138
139 int attrs = base->attrs | over->attrs;
140
141 struct AttrColor *ac = merged_colors_find(fg, bg, attrs);
142 if (ac)
143 return ac;
144
145 ac = attr_color_new();
147 ac->attrs = attrs;
148 ac->fg = (base->fg.color == COLOR_DEFAULT) ? over->fg : base->fg;
149 ac->bg = (base->bg.color == COLOR_DEFAULT) ? over->bg : base->bg;
150 TAILQ_INSERT_TAIL(&mod_data->merged_colors, ac, entries);
151
152 return ac;
153}
struct AttrColor * attr_color_new(void)
Create a new AttrColor.
Definition attr.c:89
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition attr.c:178
#define COLOR_DEFAULT
Definition color.h:102
int32_t color_t
Type for 24-bit colour value.
Definition curses2.h:30
struct CursesColor * curses_color_new(color_t fg, color_t bg)
Create a new CursesColor.
Definition curses.c:154
static struct AttrColor * merged_colors_find(color_t fg, color_t bg, int attrs)
Find a Merged colour.
Definition merged.c:74
@ MODULE_ID_COLOR
ModuleColor, Color
Definition module_api.h:53
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:665
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition queue.h:866
A curses colour and its attributes.
Definition attr.h:65
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
struct CursesColor * curses_color
Underlying Curses colour.
Definition attr.h:69
color_t color
Colour.
Definition attr.h:56
Color private Module data.
Definition module_data.h:35
struct AttrColorList merged_colors
Array of user colours.
Definition module_data.h:39
Colour in the ncurses palette.
Definition curses2.h:40
color_t fg
Foreground colour.
Definition curses2.h:41
color_t bg
Background colour.
Definition curses2.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:

◆ merged_colors_cleanup()

void merged_colors_cleanup ( void )

Free the list of Merged colours.

Definition at line 53 of file merged.c.

54{
56 struct AttrColor *ac = NULL;
57 struct AttrColor *tmp = NULL;
58
59 TAILQ_FOREACH_SAFE(ac, &mod_data->merged_colors, entries, tmp)
60 {
61 TAILQ_REMOVE(&mod_data->merged_colors, ac, entries);
63 FREE(&ac);
64 }
65}
void curses_color_free(struct CursesColor **ptr)
Free a CursesColor.
Definition curses.c:122
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition queue.h:792
#define TAILQ_REMOVE(head, elm, field)
Definition queue.h:901
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ merged_colors_init()

void merged_colors_init ( void )

Initialise the Merged colours.

Definition at line 44 of file merged.c.

45{
47 TAILQ_INIT(&mod_data->merged_colors);
48}
#define TAILQ_INIT(head)
Definition queue.h:822
+ Here is the call graph for this function:
+ Here is the caller graph for this function: