NeoMutt  2025-09-05-43-g177ed6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
merged.h File Reference

Merged colours. More...

#include "config.h"
+ Include dependency graph for merged.h:
+ 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 107 of file merged.c.

109{
110 if (!attr_color_is_set(over))
111 return base;
112 if (!attr_color_is_set(base))
113 return over;
114
115 struct CursesColor *cc_base = base->curses_color;
116 struct CursesColor *cc_over = over->curses_color;
117
120
121 if (cc_over)
122 {
123 fg = cc_over->fg;
124 bg = cc_over->bg;
125 }
126
127 if (cc_base)
128 {
129 if (fg == COLOR_DEFAULT)
130 fg = cc_base->fg;
131 if (bg == COLOR_DEFAULT)
132 bg = cc_base->bg;
133 }
134
135 int attrs = base->attrs | over->attrs;
136
137 struct AttrColor *ac = merged_colors_find(fg, bg, attrs);
138 if (ac)
139 return ac;
140
141 ac = attr_color_new();
143 ac->attrs = attrs;
144 ac->fg = (base->fg.color == COLOR_DEFAULT) ? over->fg : base->fg;
145 ac->bg = (base->bg.color == COLOR_DEFAULT) ? over->bg : base->bg;
146 TAILQ_INSERT_TAIL(&MergedColors, ac, entries);
147
148 return ac;
149}
struct AttrColor * attr_color_new(void)
Create a new AttrColor.
Definition attr.c:90
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition attr.c:179
#define COLOR_DEFAULT
Definition color.h:103
int32_t color_t
Type for 24-bit colour value.
Definition curses2.h:31
struct CursesColor * curses_color_new(color_t fg, color_t bg)
Create a new CursesColor.
Definition curses.c:151
struct AttrColorList MergedColors
Array of user colours.
Definition merged.c:39
static struct AttrColor * merged_colors_find(color_t fg, color_t bg, int attrs)
Find a Merged colour.
Definition merged.c:72
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition queue.h:866
A curses colour and its attributes.
Definition attr.h:66
struct ColorElement bg
Background colour.
Definition attr.h:68
struct ColorElement fg
Foreground colour.
Definition attr.h:67
int attrs
Text attributes, e.g. A_BOLD.
Definition attr.h:69
struct CursesColor * curses_color
Underlying Curses colour.
Definition attr.h:70
color_t color
Colour.
Definition attr.h:57
Colour in the ncurses palette.
Definition curses2.h:41
color_t fg
Foreground colour.
Definition curses2.h:42
color_t bg
Background colour.
Definition curses2.h:43
+ 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 52 of file merged.c.

53{
54 struct AttrColor *ac = NULL;
55 struct AttrColor *tmp = NULL;
56
57 TAILQ_FOREACH_SAFE(ac, &MergedColors, entries, tmp)
58 {
59 TAILQ_REMOVE(&MergedColors, ac, entries);
61 FREE(&ac);
62 }
63}
void curses_color_free(struct CursesColor **ptr)
Free a CursesColor.
Definition curses.c:120
#define FREE(x)
Definition memory.h:62
#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}
#define TAILQ_INIT(head)
Definition queue.h:822
+ Here is the caller graph for this function: