NeoMutt
2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
mutt_curses.c
Go to the documentation of this file.
1
22
28
29
#include "config.h"
30
#include <stddef.h>
31
#include "
mutt_curses.h
"
32
#include "
color/lib.h
"
33
38
void
mutt_curses_set_color
(
const
struct
AttrColor
*ac)
39
{
40
if
(!ac)
41
return
;
42
43
int
index = ac->
curses_color
? ac->
curses_color
->
index
: 0;
44
45
#if defined(HAVE_SETCCHAR) && defined(HAVE_BKGRNDSET)
46
cchar_t cch = { 0 };
47
setcchar(&cch, L
" "
, ac->
attrs
, index, NULL);
48
bkgrndset(&cch);
49
#elif defined(HAVE_BKGDSET)
50
bkgdset(COLOR_PAIR(index) | ac->
attrs
|
' '
);
51
#else
52
attrset(COLOR_PAIR(index) | ac->
attrs
);
53
#endif
54
}
55
63
const
struct
AttrColor
*
mutt_curses_set_normal_backed_color_by_id
(
enum
ColorId
cid)
64
{
65
const
struct
AttrColor
*ac_normal =
simple_color_get
(
MT_COLOR_NORMAL
);
66
const
struct
AttrColor
*ac_color =
simple_color_get
(cid);
67
68
const
struct
AttrColor
*ac_merge =
merged_color_overlay
(ac_normal, ac_color);
69
70
mutt_curses_set_color
(ac_merge);
71
return
ac_merge;
72
}
73
79
const
struct
AttrColor
*
mutt_curses_set_color_by_id
(
enum
ColorId
cid)
80
{
81
struct
AttrColor
*ac =
simple_color_get
(cid);
82
if
(!
attr_color_is_set
(ac))
83
ac =
simple_color_get
(
MT_COLOR_NORMAL
);
84
85
mutt_curses_set_color
(ac);
86
return
ac;
87
}
88
94
enum
MuttCursorState
mutt_curses_set_cursor
(
enum
MuttCursorState
state)
95
{
96
static
enum
MuttCursorState
SavedCursor =
MUTT_CURSOR_VISIBLE
;
97
98
enum
MuttCursorState
OldCursor = SavedCursor;
99
SavedCursor = state;
100
101
if
(curs_set(state) == ERR)
102
{
103
if
(state ==
MUTT_CURSOR_VISIBLE
)
104
curs_set(
MUTT_CURSOR_VERY_VISIBLE
);
105
}
106
107
return
OldCursor;
108
}
attr_color_is_set
bool attr_color_is_set(const struct AttrColor *ac)
Is the object coloured?
Definition
attr.c:178
lib.h
Color and attribute parsing.
simple_color_get
struct AttrColor * simple_color_get(enum ColorId cid)
Get the colour of an object by its ID.
Definition
simple.c:98
ColorId
ColorId
List of all coloured objects.
Definition
color.h:35
MT_COLOR_NORMAL
@ MT_COLOR_NORMAL
Plain text.
Definition
color.h:53
merged_color_overlay
const struct AttrColor * merged_color_overlay(const struct AttrColor *base, const struct AttrColor *over)
Combine two colours.
Definition
merged.c:110
mutt_curses_set_normal_backed_color_by_id
const struct AttrColor * mutt_curses_set_normal_backed_color_by_id(enum ColorId cid)
Set the colour and attributes by the Colour ID.
Definition
mutt_curses.c:63
mutt_curses_set_cursor
enum MuttCursorState mutt_curses_set_cursor(enum MuttCursorState state)
Set the cursor state.
Definition
mutt_curses.c:94
mutt_curses_set_color_by_id
const struct AttrColor * mutt_curses_set_color_by_id(enum ColorId cid)
Set the colour and attributes by the Colour ID.
Definition
mutt_curses.c:79
mutt_curses_set_color
void mutt_curses_set_color(const struct AttrColor *ac)
Set the colour and attributes for text.
Definition
mutt_curses.c:38
mutt_curses.h
Define wrapper functions around Curses.
MuttCursorState
MuttCursorState
Cursor states for mutt_curses_set_cursor().
Definition
mutt_curses.h:64
MUTT_CURSOR_VISIBLE
@ MUTT_CURSOR_VISIBLE
Display a normal cursor.
Definition
mutt_curses.h:66
MUTT_CURSOR_VERY_VISIBLE
@ MUTT_CURSOR_VERY_VISIBLE
Display a very visible cursor.
Definition
mutt_curses.h:67
AttrColor
A curses colour and its attributes.
Definition
attr.h:65
AttrColor::attrs
int attrs
Text attributes, e.g. A_BOLD.
Definition
attr.h:68
AttrColor::curses_color
struct CursesColor * curses_color
Underlying Curses colour.
Definition
attr.h:69
CursesColor::index
short index
Index number.
Definition
curses2.h:43